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

init()
{
    precachestring( &"MP_CHALLENGE_COMPLETED" );

    if ( !mayprocesschallenges() )
        return;

    level.missioncallbacks = [];
    registermissioncallback( "playerKilled", ::ch_kills );
    registermissioncallback( "playerKilled", ::ch_killstreak_kills );
    registermissioncallback( "playerHardpoint", ::ch_hardpoints );
    registermissioncallback( "playerAssist", ::ch_assists );
    registermissioncallback( "roundEnd", ::ch_roundwin );
    registermissioncallback( "roundEnd", ::ch_roundplayed );
    registermissioncallback( "vehicleKilled", ::ch_vehicle_killed );
    level thread onplayerconnect();
}

mayprocesschallenges()
{
    if ( issquadsmode() )
        return 0;

    return level.rankedmatch;
}

onplayerconnect()
{
    for (;;)
    {
        level waittill( "connected", var_0 );

        if ( !isdefined( var_0.pers["postGameChallenges"] ) )
            var_0.pers["postGameChallenges"] = 0;

        var_0 thread initmissiondata();

        if ( isai( var_0 ) )
            continue;

        var_0 thread onplayerspawned();
        var_0 thread monitorbombuse();
        var_0 thread monitorfalldistance();
        var_0 thread monitorlivetime();
        var_0 thread monitorstreaks();
        var_0 thread monitorstreakreward();
        var_0 thread monitorscavengerpickup();
        var_0 thread monitorblastshieldsurvival();
        var_0 thread monitorprocesschallenge();
        var_0 thread monitorkillstreakprogress();
        var_0 thread monitorkilledkillstreak();
        var_0 thread monitoradstime();
        var_0 thread monitorweaponswap();
        var_0 thread monitorflashbang();
        var_0 thread monitorconcussion();
        var_0 thread monitorreload();
        var_0 thread monitorsprintslide();
        var_0 notifyonplayercommand( "hold_breath", "+breath_sprint" );
        var_0 notifyonplayercommand( "hold_breath", "+melee_breath" );
        var_0 notifyonplayercommand( "release_breath", "-breath_sprint" );
        var_0 notifyonplayercommand( "release_breath", "-melee_breath" );
        var_0 thread monitorholdbreath();
        var_0 notifyonplayercommand( "jumped", "+goStand" );
        var_0 thread monitormantle();

        if ( isdefined( level.patientzeroname ) && issubstr( var_0.name, level.patientzeroname ) )
        {
            var_0 setrankedplayerdata( "challengeState", "ch_infected", 2 );
            var_0 setrankedplayerdata( "challengeProgress", "ch_infected", 1 );
            var_0 setrankedplayerdata( "challengeState", "ch_plague", 2 );
            var_0 setrankedplayerdata( "challengeProgress", "ch_plague", 1 );
        }

        var_0 setcommonplayerdata( "round", "weaponsUsed", 0, "none" );
        var_0 setcommonplayerdata( "round", "weaponsUsed", 1, "none" );
        var_0 setcommonplayerdata( "round", "weaponsUsed", 2, "none" );
        var_0 setcommonplayerdata( "round", "weaponXpEarned", 0, 0 );
        var_0 setcommonplayerdata( "round", "weaponXpEarned", 1, 0 );
        var_0 setcommonplayerdata( "round", "weaponXpEarned", 2, 0 );
        var_1 = var_0 getcommonplayerdata( "cardTitle" );
        var_2 = tablelookupbyrow( "mp/cardTitleTable.csv", var_1, 0 );

        if ( var_2 == "cardtitle_infected" )
        {
            var_0.infected = 1;
            continue;
        }

        if ( var_2 == "cardtitle_plague" )
            var_0.plague = 1;
    }
}

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

    for (;;)
    {
        self waittill( "spawned_player" );
        self.killsthismag = [];
        thread monitorsprintdistance();
    }
}

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

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

        if ( self isitemunlocked( "specialty_scavenger" ) && maps\mp\_utility::_hasperk( "specialty_scavenger" ) && !maps\mp\_utility::isjuggernaut() )
            processchallenge( "ch_scavenger_pro" );

        wait 0.05;
    }
}

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

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

        if ( self isitemunlocked( "specialty_hardline" ) && maps\mp\_utility::_hasperk( "specialty_hardline" ) )
            processchallenge( "ch_hardline_pro" );

        wait 0.05;
    }
}

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

    for (;;)
    {
        self waittill( "survived_explosion", var_0 );

        if ( isdefined( var_0 ) && isplayer( var_0 ) && self == var_0 )
            continue;

        if ( self isitemunlocked( "_specialty_blastshield" ) && maps\mp\_utility::_hasperk( "_specialty_blastshield" ) )
            processchallenge( "ch_blastshield_pro" );

        common_scripts\utility::waitframe();
    }
}

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

    for (;;)
    {
        self waittill( "destroyed_insertion", var_0 );

        if ( self == var_0 )
            return;

        processchallenge( "ch_darkbringer" );
        maps\mp\_utility::incplayerstat( "mosttacprevented", 1 );
        thread maps\mp\gametypes\_hud_message::splashnotify( "denied", 20 );
        var_0 maps\mp\gametypes\_hud_message::playercardsplashnotify( "destroyed_insertion", self );
        common_scripts\utility::waitframe();
    }
}

initmissiondata()
{
    var_0 = getarraykeys( level.killstreakfuncs );

    foreach ( var_2 in var_0 )
        self.pers[var_2] = 0;

    self.pers["lastBulletKillTime"] = 0;
    self.pers["bulletStreak"] = 0;
    self.explosiveinfo = [];
}

registermissioncallback( var_0, var_1 )
{
    if ( !isdefined( level.missioncallbacks[var_0] ) )
        level.missioncallbacks[var_0] = [];

    level.missioncallbacks[var_0][level.missioncallbacks[var_0].size] = var_1;
}

getchallengestatus( var_0 )
{
    if ( isdefined( self.challengedata[var_0] ) )
        return self.challengedata[var_0];
    else
        return 0;
}

ch_assists( var_0 )
{
    var_1 = var_0.player;
    var_1 processchallenge( "ch_assists" );

    if ( isdefined( var_1.isjuggernautrecon ) && var_1.isjuggernautrecon )
        var_1 processchallenge( "ch_assisted_firepower" );

    if ( isdefined( var_0.sweapon ) )
    {
        var_2 = maps\mp\_utility::getweaponclass( var_0.sweapon );
        var_3 = maps\mp\_utility::getbaseweaponname( var_0.sweapon );

        switch ( var_2 )
        {
            case "weapon_lmg":
            case "weapon_dmr":
            case "weapon_assault":
            case "weapon_smg":
                processchallenge( "ch_" + var_3 + "_assists" );
                break;
            case "weapon_shotgun":
                processchallenge( "ch_" + var_3 + "_assist" );
                break;
            default:
                if ( maps\mp\gametypes\_weapons::isriotshield( var_0.sweapon ) )
                    processchallenge( "ch_iw6_riotshield_assist" );

                break;
        }
    }
}

ch_hardpoints( var_0 )
{
    var_1 = var_0.player;
    var_1.pers[var_0.hardpointtype]++;

    switch ( var_0.hardpointtype )
    {
        case "uplink":
            var_1 processchallenge( "ch_uplink" );
            var_1 processchallenge( "ch_assault_streaks" );

            if ( var_1 checknumusesofpersistentdata( "uplink", 3 ) )
                var_1 processchallenge( "ch_nosecrets" );

            break;
        case "guard_dog":
            var_1 processchallenge( "ch_guard_dog" );
            var_1 processchallenge( "ch_assault_streaks" );
            break;
        case "airdrop_juggernaut_maniac":
            var_1 processchallenge( "ch_airdrop_juggernaut_maniac" );
            var_1 processchallenge( "ch_assault_streaks" );
            break;
        case "ims":
            var_1 processchallenge( "ch_assault_streaks" );
            break;
        case "helicopter":
            var_1 processchallenge( "ch_assault_streaks" );

            if ( var_1 checknumusesofpersistentdata( "helicopter", 2 ) )
                var_1 processchallenge( "ch_airsuperiority" );

            break;
        case "airdrop_juggernaut":
        case "ball_drone_backup":
        case "odin_assault":
        case "drone_hive":
        case "heli_pilot":
        case "vanguard":
        case "sentry":
            var_1 processchallenge( "ch_assault_streaks" );
            break;
        case "uplink_support":
            var_1 processchallenge( "ch_uplink_support" );
            var_1 processchallenge( "ch_support_streaks" );
            break;
        case "deployable_vest":
            var_1 processchallenge( "ch_deployable_vest" );
            var_1 processchallenge( "ch_support_streaks" );
            break;
        case "deployable_ammo":
            var_1 processchallenge( "ch_deployable_ammo" );
            var_1 processchallenge( "ch_support_streaks" );
            break;
        case "ball_drone_radar":
            var_1 processchallenge( "ch_ball_drone_radar" );
            var_1 processchallenge( "ch_support_streaks" );
            break;
        case "aa_launcher":
            var_1 processchallenge( "ch_support_streaks" );
            break;
        case "jammer":
            var_1 processchallenge( "ch_jammer" );
            var_1 processchallenge( "ch_support_streaks" );
            break;
        case "air_superiority":
            var_1 processchallenge( "ch_support_streaks" );
            break;
        case "recon_agent":
            var_1 processchallenge( "ch_recon_agent" );
            var_1 processchallenge( "ch_support_streaks" );
            break;
        case "heli_sniper":
            var_1 processchallenge( "ch_heli_sniper" );
            var_1 processchallenge( "ch_support_streaks" );
            break;
        case "uav_3dping":
            var_1 processchallenge( "ch_uav_3dping" );
            var_1 processchallenge( "ch_support_streaks" );
            break;
        case "airdrop_juggernaut_recon":
            var_1 processchallenge( "ch_support_streaks" );
            break;
        case "odin_support":
            var_1 processchallenge( "ch_odin_support" );
            var_1 processchallenge( "ch_support_streaks" );
            break;
        case "all_perks_bonus":
            var_1 processchallenge( "ch_all_perks_bonus" );
            break;
        case "nuke":
            var_1 processchallenge( "ch_nuke" );
            break;
    }
}

ch_killstreak_kills( var_0 )
{
    if ( !isdefined( var_0.attacker ) || !isplayer( var_0.attacker ) )
        return;

    if ( !maps\mp\_utility::iskillstreakweapon( var_0.sweapon ) )
        return;

    var_1 = var_0.attacker;

    if ( !isdefined( var_1.pers[var_0.sweapon + "_streak"] ) || isdefined( var_1.pers[var_0.sweapon + "_streakTime"] ) && gettime() - var_1.pers[var_0.sweapon + "_streakTime"] > 7000 )
    {
        var_1.pers[var_0.sweapon + "_streak"] = 0;
        var_1.pers[var_0.sweapon + "_streakTime"] = gettime();
    }

    var_1.pers[var_0.sweapon + "_streak"]++;

    switch ( var_0.sweapon )
    {
        case "sentry_minigun_mp":
            var_1 processchallenge( "ch_looknohands" );
            break;
        case "remote_tank_projectile_mp":
            var_1 processchallenge( "ch_incoming" );
            break;
        case "heli_pilot_turret_mp":
            var_1 processchallenge( "ch_helo_pilot" );
            break;
        case "iw6_gm6helisnipe_mp_gm6scope":
            var_1 processchallenge( "ch_long_distance_shooter" );
            break;
        case "switch_blade_child_mp":
        case "drone_hive_projectile_mp":
            var_1 processchallenge( "ch_clusterfunk" );
            var_2 = var_1.killsthislifeperweapon["drone_hive_projectile_mp"] + var_1.killsthislifeperweapon["switch_blade_child_mp"];

            if ( isnumbermultipleof( var_2, 4 ) )
                var_1 processchallenge( "ch_bullseye" );

            break;
        case "ball_drone_gun_mp":
            var_1 processchallenge( "ch_vulture" );
            break;
        case "odin_projectile_small_rod_mp":
        case "odin_projectile_large_rod_mp":
            var_1 processchallenge( "ch_overlord" );
            break;
        case "hind_missile_mp":
        case "hind_bomb_mp":
        case "cobra_20mm_mp":
            var_1 processchallenge( "ch_choppervet" );
            break;
        case "guard_dog_mp":
            var_1 processchallenge( "ch_downboy" );
            break;
        case "ims_projectile_mp":
            var_1 processchallenge( "ch_outsmarted" );
            break;
        case "iw6_p226jugg_mp":
        case "iw6_minigunjugg_mp":
        case "mortar_shelljugg_mp":
            var_1 processchallenge( "ch_painless" );
            break;
        case "nuke_mp":
            var_0.victim processchallenge( "ch_radiationsickness" );
            break;
        case "iw6_knifeonlyjugg_mp":
        case "throwingknifejugg_mp":
            break;
        case "agent_support_mp":
            break;
        default:
            break;
    }
}

ch_vehicle_killed( var_0 )
{
    if ( !isdefined( var_0.attacker ) || !isplayer( var_0.attacker ) )
        return;

    var_1 = var_0.attacker;
}

clearidshortly( var_0 )
{
    self endon( "disconnect" );
    self notify( "clearing_expID_" + var_0 );
    self endon( "clearing_expID_" + var_0 );
    wait 3.0;
    self.explosivekills[var_0] = undefined;
}

mgkill()
{
    var_0 = self;

    if ( !isdefined( var_0.pers["MGStreak"] ) )
    {
        var_0.pers["MGStreak"] = 0;
        var_0 thread endmgstreakwhenleavemg();

        if ( !isdefined( var_0.pers["MGStreak"] ) )
            return;
    }

    var_0.pers["MGStreak"]++;

    if ( var_0.pers["MGStreak"] >= 5 )
        var_0 processchallenge( "ch_mgmaster" );
}

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

    for (;;)
    {
        if ( !isalive( self ) || self usebuttonpressed() )
        {
            self.pers["MGStreak"] = undefined;
            break;
        }

        wait 0.05;
    }
}

endmgstreak()
{
    self.pers["MGStreak"] = undefined;
}

killedbestenemyplayer( var_0 )
{
    if ( !isdefined( self.pers["countermvp_streak"] ) || !var_0 )
        self.pers["countermvp_streak"] = 0;

    self.pers["countermvp_streak"]++;

    if ( self.pers["countermvp_streak"] == 3 )
        processchallenge( "ch_thebiggertheyare" );
    else if ( self.pers["countermvp_streak"] == 5 )
        processchallenge( "ch_thehardertheyfall" );
}

ishighestscoringplayer( var_0 )
{
    if ( !isdefined( var_0.score ) || var_0.score < 1 )
        return 0;

    var_1 = level.players;

    if ( level.teambased )
        var_2 = var_0.pers["team"];
    else
        var_2 = "all";

    var_3 = var_0.score;

    for ( var_4 = 0; var_4 < var_1.size; var_4++ )
    {
        if ( !isdefined( var_1[var_4].score ) )
            continue;

        if ( var_1[var_4].score < 1 )
            continue;

        if ( var_2 != "all" && var_1[var_4].pers["team"] != var_2 )
            continue;

        if ( var_1[var_4].score > var_3 )
            return 0;
    }

    return 1;
}

ch_kills( var_0, var_1 )
{
    var_2 = var_0.attacker;
    var_3 = var_0.victim;
    var_3 playerdied();

    if ( !isdefined( var_2 ) || !isplayer( var_2 ) )
        return;

    var_1 = var_0.time;

    if ( var_2.pers["cur_kill_streak"] == 10 )
        var_2 processchallenge( "ch_fearless" );

    if ( level.teambased )
    {
        if ( level.teamcount[var_0.victim.pers["team"]] > 3 && var_2.killedplayers.size == 4 && var_2.ch_tangodowncomplete == 0 )
        {
            var_2 processchallenge( "ch_tangodown" );
            var_2.ch_tangodowncomplete = 1;
        }

        if ( level.teamcount[var_0.victim.pers["team"]] > 3 && var_2.killedplayerscurrent.size == 4 && var_2.ch_extremecrueltycomplete == 0 )
        {
            var_2 processchallenge( "ch_extremecruelty" );
            var_2.ch_extremecrueltycomplete = 1;
        }
    }

    if ( isdefined( var_3.inplayersmokescreen ) && var_3.inplayersmokescreen == var_2 )
        var_2 processchallenge( "ch_smokeemifyougotem" );

    if ( isdefined( var_2.killedplayers[var_0.victim.guid] ) && var_2.killedplayers[var_0.victim.guid] == 5 )
        var_2 processchallenge( "ch_rival" );

    if ( isdefined( var_2.tookweaponfrom[var_0.sweapon] ) )
    {
        if ( var_2.tookweaponfrom[var_0.sweapon] == var_0.victim && ( var_0.smeansofdeath != "MOD_MELEE" || maps\mp\gametypes\_weapons::isriotshield( var_0.sweapon ) || maps\mp\gametypes\_weapons::isknifeonly( var_0.sweapon ) ) )
            var_2 processchallenge( "ch_cruelty" );
    }

    var_4 = 0;
    var_5 = 0;
    var_6 = 0;
    var_7 = 1;
    var_8 = 0;
    var_9 = 0;
    var_10[var_0.victim.name] = var_0.victim.name;
    var_11[var_0.sweapon] = var_0.sweapon;
    var_12 = 1;
    var_13 = [];

    foreach ( var_15 in var_2.killsthislife )
    {
        if ( maps\mp\_utility::iscacsecondaryweapon( var_15.sweapon ) && var_15.smeansofdeath != "MOD_MELEE" )
            var_5++;

        if ( var_15.sweapon == var_2.primaryweapon )
            var_8++;
        else if ( var_15.sweapon == var_2.secondaryweapon )
            var_9++;

        if ( isdefined( var_15.modifiers["longshot"] ) )
            var_6++;

        if ( var_1 - var_15.time < 10000 )
            var_7++;

        if ( maps\mp\_utility::iskillstreakweapon( var_15.sweapon ) )
        {
            if ( !isdefined( var_13[var_15.sweapon] ) )
                var_13[var_15.sweapon] = 0;

            var_13[var_15.sweapon]++;
            continue;
        }

        if ( isdefined( level.onelefttime[var_2.team] ) && var_15.time > level.onelefttime[var_2.team] )
            var_4++;

        if ( isdefined( var_15.victim ) )
        {
            if ( !isdefined( var_10[var_15.victim.name] ) && !isdefined( var_11[var_15.sweapon] ) )
                var_12++;

            var_10[var_15.victim.name] = var_15.victim.name;
        }

        var_11[var_15.sweapon] = var_15.sweapon;
    }

    foreach ( var_19, var_18 in var_13 )
    {
        if ( var_18 >= 10 )
            var_2 processchallenge( "ch_crabmeat" );
    }

    if ( var_12 == 3 )
        var_2 processchallenge( "ch_renaissance" );

    if ( var_7 > 3 && level.teamcount[var_0.victim.team] <= var_7 )
        var_2 processchallenge( "ch_omnicide" );

    if ( maps\mp\_utility::iscacsecondaryweapon( var_0.sweapon ) && var_5 == 2 )
        var_2 processchallenge( "ch_sidekick" );

    if ( isdefined( var_0.modifiers["longshot"] ) && var_6 == 2 )
        var_2 processchallenge( "ch_nbk" );

    if ( isdefined( level.onelefttime[var_2.team] ) && var_4 == 2 )
        var_2 processchallenge( "ch_enemyofthestate" );

    if ( var_0.sweapon == "iw6_knifeonlyjugg_mp" )
    {
        var_20[var_0.victim.name] = 1;

        foreach ( var_15 in var_2.killsthislife )
        {
            if ( var_15.sweapon == "iw6_knifeonlyjugg_mp" )
            {
                if ( isdefined( var_15.victim ) && !isdefined( var_20[var_15.victim.name] ) )
                    var_20[var_15.victim.name] = 1;
            }
        }

        if ( var_20.size >= 6 )
            var_2 processchallenge( "ch_noplacetohide" );
    }

    if ( var_0.smeansofdeath != "MOD_MELEE" )
    {
        if ( var_0.sweapon == var_2.primaryweapon && var_8 < var_9 || var_0.sweapon == var_2.secondaryweapon && var_9 < var_8 )
            var_2 processchallenge( "ch_always_deadly" );

        if ( var_2 shouldprocesschallengeforperk( "specialty_twoprimaries" ) && var_2.secondaryweapon == var_0.sweapon )
            var_2 processchallenge( "ch_twoprimaries_pro" );
    }

    if ( var_0.victim.score > 0 )
    {
        if ( level.teambased )
        {
            var_23 = var_0.victim.pers["team"];

            if ( isdefined( var_23 ) && var_23 != var_2.pers["team"] )
            {
                if ( ishighestscoringplayer( var_0.victim ) && level.players.size >= 6 )
                    var_2 killedbestenemyplayer( 1 );
                else
                    var_2 killedbestenemyplayer( 0 );
            }
        }
        else if ( ishighestscoringplayer( var_0.victim ) && level.players.size >= 4 )
            var_2 killedbestenemyplayer( 1 );
        else
            var_2 killedbestenemyplayer( 0 );
    }

    if ( isdefined( var_0.modifiers["avenger"] ) )
        var_2 processchallenge( "ch_avenger" );

    if ( isdefined( var_0.modifiers["buzzkill"] ) && var_0.modifiers["buzzkill"] >= 9 )
        var_2 processchallenge( "ch_thedenier" );

    if ( maps\mp\_utility::isreallyalive( var_2 ) && var_0.sweapon != "none" )
    {
        if ( isdefined( var_2.killsthislifeperweapon[var_0.sweapon] ) )
            var_2.killsthislifeperweapon[var_0.sweapon]++;
        else
            var_2.killsthislifeperweapon[var_0.sweapon] = 1;
    }

    if ( maps\mp\_utility::iskillstreakweapon( var_0.sweapon ) && !allowkillchallengeforkillstreak( var_2, var_0.sweapon ) )
        return;

    if ( isdefined( var_0.modifiers["jackintheboxkill"] ) )
        var_2 processchallenge( "ch_jackinthebox" );

    if ( isdefined( var_0.modifiers["cooking"] ) )
        var_2 processchallenge( "ch_no" );

    if ( var_2 isatbrinkofdeath() )
    {
        var_2.brinkofdeathkillstreak++;

        if ( isnumbermultipleof( var_2.brinkofdeathkillstreak, 3 ) )
            var_2 processchallenge( "ch_thebrink" );
    }

    if ( var_2 shouldprocesschallengeforperk( "specialty_gpsjammer" ) )
    {
        var_24 = 0;

        if ( level.teambased )
        {
            var_25 = level.comexpfuncs["getRadarStrengthForTeam"];
            var_24 = [[ var_25 ]]( maps\mp\_utility::getotherteam( var_2.team ) );
        }
        else
        {
            foreach ( var_27 in level.uplinks )
            {
                if ( isdefined( var_27 ) && var_27.owner.guid != var_2.guid )
                {
                    var_24++;
                    break;
                }
            }
        }

        if ( var_24 > 0 )
            var_2 processchallenge( "ch_offthegrid" );
    }

    if ( var_2 shouldprocesschallengeforperk( "specialty_deadeye" ) )
        var_2 processchallenge( "ch_deadeye" );

    if ( var_2 shouldprocesschallengeforperk( "specialty_lightweight" ) )
        var_2 processchallenge( "ch_lightweight" );

    if ( var_2 shouldprocesschallengeforperk( "specialty_extra_attachment" ) && var_0.sweapon != "none" )
    {
        var_29 = maps\mp\_utility::weapongetnumattachments( var_0.sweapon );
        var_30 = 2;

        if ( maps\mp\gametypes\_weapons::issidearm( var_0.sweapon ) )
            var_30 = 1;

        if ( var_29 > var_30 )
            var_2 processchallenge( "ch_extra_attachment" );
    }

    if ( var_2 shouldprocesschallengeforperk( "specialty_gambler" ) )
        var_2 processchallenge( "ch_gambler" );

    if ( var_2 shouldprocesschallengeforperk( "specialty_regenfaster" ) && var_2.health < var_2.maxhealth )
        var_2 processchallenge( "ch_regenfaster" );

    if ( var_2 shouldprocesschallengeforperk( "specialty_sprintreload" ) && isdefined( var_2.sprintreloadtimestamp ) && gettime() <= var_2.sprintreloadtimestamp && var_2.lastreloadedweapon == var_0.sweapon && var_0.smeansofdeath != "MOD_MELEE" )
        var_2 processchallenge( "ch_onthego" );

    if ( var_2 shouldprocesschallengeforperk( "specialty_pitcher" ) && maps\mp\gametypes\_weapons::isoffhandweapon( var_0.sweapon ) )
        var_2 processchallenge( "ch_pitcher" );

    if ( var_2 shouldprocesschallengeforperk( "specialty_silentkill" ) )
        var_2 processchallenge( "ch_silentkill" );

    if ( var_2 shouldprocesschallengeforperk( "specialty_comexp" ) && level.uplinks.size > 0 )
        var_2 processchallenge( "ch_comexp" );

    if ( var_2 shouldprocesschallengeforperk( "specialty_boom" ) )
    {
        var_31 = var_2 maps\mp\_utility::getuniqueid();

        if ( isdefined( var_3.markedbyboomperk ) && isdefined( var_3.markedbyboomperk[var_31] ) && gettime() <= var_3.markedbyboomperk[var_31] )
        {
            var_2 processchallenge( "ch_boom" );
            var_3.markedbyboomperk = undefined;
        }
    }

    if ( !maps\mp\gametypes\_weapons::isoffhandweapon( var_0.sweapon ) && var_0.sweapon != var_2.pers["primaryWeapon"] && var_0.sweapon != var_2.pers["secondaryWeapon"] )
        var_2 processchallenge( "ch_wiseguy" );

    if ( !maps\mp\gametypes\_weapons::isoffhandweapon( var_0.sweapon ) && var_0.smeansofdeath != "MOD_MELEE" )
    {
        if ( !isdefined( var_2.killsthismag ) )
            var_2.killsthismag = [];

        if ( isdefined( var_2.killsthismag[var_0.sweapon] ) )
        {
            var_2.killsthismag[var_0.sweapon]++;

            if ( isnumbermultipleof( var_2.killsthismag[var_0.sweapon], 4 ) )
                var_2 processchallenge( "ch_meticulous" );
        }
        else
            var_2.killsthismag[var_0.sweapon] = 1;
    }

    var_32 = 0;

    if ( level.teambased )
        var_32 = level.activeuavs[maps\mp\_utility::getotherteam( var_2.team )] > 0;
    else
        var_32 = level.activeuavs[var_3.guid] > 0;

    if ( var_32 )
        var_2 processchallenge( "ch_youcantseeme" );

    if ( var_2 shouldprocesschallengeforperk( "specialty_incog" ) )
        var_2 processchallenge( "ch_incog" );

    if ( isdefined( level.lbsniper ) && isdefined( level.lbsniper.owner ) && level.lbsniper.owner == var_3 && shouldprocesschallengeforperk( "specialty_blindeye" ) )
        processchallenge( "ch_blindeye_pro" );

    if ( var_0.sweapon == "none" )
    {
        if ( isdefined( var_0.victim.explosiveinfo ) && isdefined( var_0.victim.explosiveinfo["weapon"] ) )
            var_0.sweapon = var_0.victim.explosiveinfo["weapon"];
        else
            return;
    }

    var_33 = maps\mp\_utility::getbaseweaponname( var_0.sweapon );
    var_34 = maps\mp\_utility::getweaponclass( var_0.sweapon );

    if ( var_0.smeansofdeath == "MOD_PISTOL_BULLET" || var_0.smeansofdeath == "MOD_RIFLE_BULLET" || var_0.smeansofdeath == "MOD_HEAD_SHOT" )
    {
        ch_bulletdamagecommon( var_0, var_2, var_1, var_34 );

        if ( var_34 == "weapon_mg" )
            var_2 mgkill();
        else
        {
            switch ( var_34 )
            {
                case "weapon_smg":
                    var_2 processweaponclasschallenge_smg( var_33, var_0 );
                    break;
                case "weapon_assault":
                    var_2 processweaponclasschallenge_ar( var_33, var_0 );
                    break;
                case "weapon_shotgun":
                    var_2 processweaponclasschallenge_shotgun( var_33, var_0 );
                    break;
                case "weapon_dmr":
                    var_2 processweaponclasschallenge_dmr( var_33, var_0 );
                    break;
                case "weapon_sniper":
                    var_2 processweaponclasschallenge_sniper( var_33, var_0 );
                    break;
                case "weapon_pistol":
                    var_2 processchallenge( "ch_handgun_kill" );

                    if ( var_33 == "iw6_magnum" )
                    {
                        var_35 = maps\mp\_utility::getweaponattachmentsbasenames( var_0.sweapon );
                        var_36 = 0;

                        foreach ( var_38 in var_35 )
                        {
                            if ( var_38 == "acog" )
                            {
                                var_36++;
                                continue;
                            }

                            if ( var_38 == "akimbo" )
                                var_36++;
                        }

                        if ( var_35.size == 2 && var_36 == 2 )
                            var_2 processchallenge( "ch_noidea" );
                    }

                    if ( var_2 checkwaslastweaponriotshield() && isdefined( var_2.lastprimaryweaponswaptime ) && gettime() - var_2.lastprimaryweaponswaptime < 2000 )
                        var_2 processchallenge( "ch_iw6_riotshield_pistol" );

                    break;
                case "weapon_lmg":
                    var_2 processweaponclasschallenge_lmg( var_33, var_0 );
                    break;
                default:
                    break;
            }

            if ( var_0.smeansofdeath == "MOD_HEAD_SHOT" )
            {
                if ( isdefined( var_0.modifiers["revenge"] ) )
                    var_2 processchallenge( "ch_colorofmoney" );

                if ( maps\mp\_utility::isstrstart( var_0.sweapon, "frag_" ) )
                    var_2 processchallenge( "ch_thinkfast" );
                else if ( maps\mp\_utility::isstrstart( var_0.sweapon, "concussion_" ) )
                    var_2 processchallenge( "ch_thinkfastconcussion" );
                else if ( maps\mp\_utility::isstrstart( var_0.sweapon, "flash_" ) )
                    var_2 processchallenge( "ch_thinkfastflash" );
            }
        }
    }
    else if ( issubstr( var_0.smeansofdeath, "MOD_GRENADE" ) || issubstr( var_0.smeansofdeath, "MOD_EXPLOSIVE" ) || issubstr( var_0.smeansofdeath, "MOD_PROJECTILE" ) )
    {
        if ( maps\mp\_utility::isstrstart( var_0.sweapon, "frag_grenade_short" ) && ( !isdefined( var_0.victim.explosiveinfo["throwbackKill"] ) || !var_0.victim.explosiveinfo["throwbackKill"] ) )
            var_2 processchallenge( "ch_martyr" );

        if ( isdefined( var_0.victim.explosiveinfo["damageTime"] ) && var_0.victim.explosiveinfo["damageTime"] == var_1 )
        {
            var_40 = var_1 + "_" + var_0.victim.explosiveinfo["damageId"];

            if ( !isdefined( var_2.explosivekills[var_40] ) )
                var_2.explosivekills[var_40] = 0;

            var_2 thread clearidshortly( var_40 );
            var_2.explosivekills[var_40]++;
            var_35 = maps\mp\_utility::getweaponattachmentsbasenames( var_0.sweapon );

            foreach ( var_42 in var_35 )
            {
                switch ( var_42 )
                {
                    case "gl":
                        if ( maps\mp\_utility::isstrstart( var_0.sweapon, "alt_" ) )
                            var_2 processweaponattachmentchallenge( var_33, var_42 );

                        break;
                }
            }

            if ( isdefined( var_0.victim.explosiveinfo["stickKill"] ) && var_0.victim.explosiveinfo["stickKill"] )
            {
                if ( isdefined( var_0.modifiers["revenge"] ) )
                    var_2 processchallenge( "ch_overdraft" );

                if ( var_2.explosivekills[var_40] > 1 )
                    var_2 processchallenge( "ch_grouphug" );
            }

            if ( isdefined( var_0.victim.explosiveinfo["stickFriendlyKill"] ) && var_0.victim.explosiveinfo["stickFriendlyKill"] )
                var_2 processchallenge( "ch_resourceful" );

            if ( var_0.victim.explosiveinfo["throwbackKill"] )
                var_2 processchallenge( "ch_throwaway" );

            if ( maps\mp\_utility::isstrstart( var_0.sweapon, "frag_" ) )
            {
                if ( var_2.explosivekills[var_40] > 1 )
                    var_2 processchallenge( "ch_multifrag" );

                if ( isdefined( var_0.modifiers["revenge"] ) )
                    var_2 processchallenge( "ch_bangforbuck" );

                var_2 processchallenge( "ch_grenadekill" );

                if ( var_0.victim.explosiveinfo["cookedKill"] )
                    var_2 processchallenge( "ch_masterchef" );

                if ( var_0.victim.explosiveinfo["suicideGrenadeKill"] )
                    var_2 processchallenge( "ch_miserylovescompany" );

                if ( var_0.victim.explosiveinfo["throwbackKill"] )
                    var_2 processchallenge( "ch_hotpotato" );
            }
            else if ( maps\mp\_utility::isstrstart( var_0.sweapon, "semtex" ) || var_0.sweapon == "iw6_mk32_mp" )
            {
                if ( isdefined( var_0.modifiers["revenge"] ) )
                    var_2 processchallenge( "ch_timeismoney" );

                if ( isdefined( var_0.victim.explosiveinfo["stickKill"] ) && var_0.victim.explosiveinfo["stickKill"] )
                    var_2 processchallenge( "ch_plastered" );

                var_0.victim.stuckbygrenade = undefined;
            }
            else if ( maps\mp\_utility::isstrstart( var_0.sweapon, "c4_" ) )
            {
                if ( isdefined( var_0.modifiers["revenge"] ) )
                    var_2 processchallenge( "ch_iamrich" );

                if ( var_2.explosivekills[var_40] > 1 )
                    var_2 processchallenge( "ch_multic4" );

                if ( var_0.victim.explosiveinfo["returnToSender"] )
                    var_2 processchallenge( "ch_returntosender" );

                if ( var_0.victim.explosiveinfo["counterKill"] )
                    var_2 processchallenge( "ch_counterc4" );

                if ( isdefined( var_0.victim.explosiveinfo["bulletPenetrationKill"] ) && var_0.victim.explosiveinfo["bulletPenetrationKill"] )
                    var_2 processchallenge( "ch_howthe" );

                if ( var_0.victim.explosiveinfo["chainKill"] )
                    var_2 processchallenge( "ch_dominos" );

                var_2 processchallenge( "ch_c4shot" );

                if ( var_2 checkwaslastweaponriotshield() )
                    var_2 processchallenge( "ch_iw6_riotshield_c4" );
            }
            else if ( maps\mp\_utility::isstrstart( var_0.sweapon, "proximity_explosive_" ) )
            {
                var_2 processchallenge( "ch_proximityexplosive" );

                if ( isdefined( var_0.modifiers["revenge"] ) )
                    var_2 processchallenge( "ch_breakbank" );

                if ( var_0.victim.explosiveinfo["chainKill"] )
                    var_2 processchallenge( "ch_dominos" );
            }
            else if ( maps\mp\_utility::isstrstart( var_0.sweapon, "mortar_shell_" ) )
                var_2 processchallenge( "ch_mortarshell" );
            else if ( var_0.sweapon == "explodable_barrel" )
            {

            }
            else if ( var_0.sweapon == "destructible_car" )
                var_2 processchallenge( "ch_carbomb" );
            else if ( maps\mp\gametypes\_weapons::isrocketlauncher( var_0.sweapon ) )
            {
                var_44 = var_2.explosivekills[var_40];

                if ( isnumbermultipleof( var_44, 2 ) )
                    var_2 processchallenge( "ch_multirpg" );
            }

            if ( var_2 shouldprocesschallengeforperk( "specialty_explosivedamage" ) )
                var_2 processchallenge( "ch_explosivedamage" );

            var_2 checkchallengeextradeadly( var_0.sweapon );
        }
    }
    else if ( issubstr( var_0.smeansofdeath, "MOD_MELEE" ) && !maps\mp\gametypes\_weapons::isriotshield( var_0.sweapon ) )
    {
        var_2 endmgstreak();
        var_2 processchallenge( "ch_knifevet" );
        var_2.pers["meleeKillStreak"]++;

        if ( var_2.pers["meleeKillStreak"] == 3 )
            var_2 processchallenge( "ch_slasher" );

        if ( var_2 isitemunlocked( "specialty_quieter" ) && var_2 maps\mp\_utility::_hasperk( "specialty_quieter" ) )
            var_2 processchallenge( "ch_deadsilence_pro" );

        var_45 = var_0.victim.anglesondeath[1];
        var_46 = var_2.anglesonkill[1];
        var_47 = angleclamp180( var_45 - var_46 );

        if ( abs( var_47 ) < 30 )
        {
            var_2 processchallenge( "ch_backstabber" );

            if ( isdefined( var_2.attackers ) )
            {
                foreach ( var_49 in var_2.attackers )
                {
                    if ( !isdefined( maps\mp\_utility::_validateattacker( var_49 ) ) )
                        continue;

                    if ( var_49 != var_0.victim )
                        continue;

                    var_2 processchallenge( "ch_neverforget" );
                    break;
                }
            }
        }

        if ( !var_2 playerhasammo() && var_33 != "iw6_knifeonly" && var_33 != "iw6_knifeonlyfast" && var_33 != "iw6_knifeonlyjugg" )
            var_2 processchallenge( "ch_survivor" );

        if ( isdefined( var_2.infected ) )
            var_0.victim processchallenge( "ch_infected" );

        if ( isdefined( var_0.victim.plague ) )
            var_2 processchallenge( "ch_plague" );

        if ( var_2 playerissprintsliding() )
            var_2 processchallenge( "ch_smooth_moves" );

        var_35 = maps\mp\_utility::getweaponattachmentsbasenames( var_0.sweapon );

        foreach ( var_42 in var_35 )
        {
            switch ( var_42 )
            {
                case "tactical":
                    var_2 processweaponattachmentchallenge( var_33, var_42 );
                    break;
            }
        }

        if ( var_2.weaponlist.size == 1 && ( var_2.weaponlist[0] == "iw6_knifeonly_mp" || var_2.weaponlist[0] == "iw6_knifeonlyfast_mp" ) )
            var_2 processchallenge( "ch_ballsofsteel" );

        if ( checkcostumechallenge( var_3, "mp_fullbody_sniper_ab" ) )
            var_2 processchallenge( "ch_bigfoot" );
    }
    else if ( maps\mp\gametypes\_weapons::isriotshield( var_0.sweapon ) )
    {
        if ( issubstr( var_0.smeansofdeath, "MOD_MELEE" ) )
        {
            var_2 endmgstreak();
            var_2 processchallenge( "ch_shieldvet" );
            var_2.pers["shieldKillStreak"]++;
            var_2 processchallenge( "ch_riot_kill" );
            var_45 = var_0.victim.anglesondeath[1];
            var_46 = var_2.anglesonkill[1];
            var_47 = angleclamp180( var_45 - var_46 );

            if ( abs( var_47 ) < 30 )
                var_2 processchallenge( "ch_iw6_riotshield_backsmasher" );

            if ( !var_2 playerhasammo() )
                var_2 processchallenge( "ch_survivor" );

            var_2 processweaponclasschallenge_riotshield( var_33, var_0 );
        }

        var_35 = maps\mp\_utility::getweaponattachmentsbasenames( var_0.sweapon );

        foreach ( var_42 in var_35 )
        {
            switch ( var_42 )
            {
                case "rshieldspikes":
                case "rshieldscrambler":
                case "rshieldradar":
                    var_2 processweaponattachmentchallenge( var_33, var_42 );
                    break;
            }
        }
    }
    else if ( issubstr( var_0.smeansofdeath, "MOD_IMPACT" ) )
    {
        if ( maps\mp\_utility::isstrstart( var_0.sweapon, "frag_" ) )
            var_2 processchallenge( "ch_thinkfast" );
        else if ( maps\mp\_utility::isstrstart( var_0.sweapon, "concussion_" ) )
            var_2 processchallenge( "ch_thinkfastconcussion" );
        else if ( maps\mp\_utility::isstrstart( var_0.sweapon, "flash_" ) )
            var_2 processchallenge( "ch_thinkfastflash" );

        if ( maps\mp\gametypes\_weapons::isthrowingknife( var_0.sweapon ) )
        {
            if ( isdefined( var_0.modifiers["revenge"] ) )
                var_2 processchallenge( "ch_atm" );

            var_2 processchallenge( "ch_carnie" );

            if ( isdefined( var_0.victim.attackerdata[var_2.guid] ) )
                var_2 processchallenge( "ch_its_personal" );

            if ( var_2 isitemunlocked( "specialty_fastoffhand" ) && var_2 maps\mp\_utility::_hasperk( "specialty_fastoffhand" ) )
                var_2 processchallenge( "ch_fastoffhand" );

            if ( var_2 checkwaslastweaponriotshield() )
                var_2 processchallenge( "ch_iw6_riotshield_throwingknife" );

            var_2 checkchallengeextradeadly( var_0.sweapon );
        }

        var_35 = maps\mp\_utility::getweaponattachmentsbasenames( var_0.sweapon );

        foreach ( var_42 in var_35 )
        {
            switch ( var_42 )
            {
                case "gl":
                    if ( maps\mp\_utility::isstrstart( var_0.sweapon, "alt_" ) )
                    {
                        var_2 processweaponattachmentchallenge( var_33, var_42 );
                        var_2 processchallenge( "ch_ouch" );
                    }

                    break;
            }
        }
    }

    if ( ( var_0.smeansofdeath == "MOD_PISTOL_BULLET" || var_0.smeansofdeath == "MOD_RIFLE_BULLET" || var_0.smeansofdeath == "MOD_HEAD_SHOT" ) && !maps\mp\_utility::iskillstreakweapon( var_0.sweapon ) && !maps\mp\_utility::isenvironmentweapon( var_0.sweapon ) )
    {
        var_35 = maps\mp\_utility::getweaponattachmentsbasenames( var_0.sweapon );

        foreach ( var_42 in var_35 )
        {
            switch ( var_42 )
            {
                case "acog":
                    var_2 processweaponattachmentchallenge_acog( var_33, var_42, var_0 );
                    break;
                case "eotech":
                    var_2 processweaponattachmentchallenge_eotech( var_33, var_42, var_0 );
                    break;
                case "hybrid":
                    var_2 processweaponattachmentchallenge_hybrid( var_33, var_42, var_0 );
                    break;
                case "reflex":
                    var_2 processweaponattachmentchallenge_reflex( var_33, var_42, var_0 );
                    break;
                case "vzscope":
                case "tracker":
                case "thermal":
                case "ironsight":
                case "scope":
                    if ( var_2 maps\mp\_utility::isplayerads() )
                        var_2 processweaponattachmentchallenge( var_33, var_42 );

                    break;
                case "xmags":
                case "silencer":
                case "rof":
                case "grip":
                case "flashsuppress":
                case "barrelrange":
                case "barrelbored":
                case "ammoslug":
                case "firetypesingle":
                case "firetypeauto":
                case "firetypeburst":
                case "akimbo":
                    var_2 processweaponattachmentchallenge( var_33, var_42 );
                    break;
                case "gl":
                case "shotgun":
                    if ( maps\mp\_utility::isstrstart( var_0.sweapon, "alt_" ) )
                        var_2 processweaponattachmentchallenge( var_33, var_42 );

                    break;
                case "fmj":
                    var_2 processchallenge( "ch_armorpiercing" );
                    break;
                default:
                    break;
            }
        }

        if ( maps\mp\_utility::weaponhasintegratedfiretypeburst( var_0.sweapon ) )
            var_2 processweaponattachmentchallenge( var_33, "firetypeburst" );

        if ( maps\mp\_utility::weaponhasintegratedsilencer( var_33 ) )
            var_2 processweaponattachmentchallenge( var_33, "silencer" );

        if ( maps\mp\_utility::weaponhasintegratedgrip( var_33 ) )
            var_2 processweaponattachmentchallenge( var_33, "grip" );

        if ( maps\mp\_utility::weaponhasintegratedfmj( var_33 ) )
            var_2 processweaponattachmentchallenge( var_33, "fmj" );

        if ( var_2 maps\mp\_utility::isplayerads() && maps\mp\_utility::weaponhasintegratedtrackerscope( var_0.sweapon ) )
            var_2 processweaponattachmentchallenge( var_33, "tracker" );

        var_59 = maps\mp\_utility::getnumdefaultattachments( var_0.sweapon );

        if ( var_35.size == var_59 )
            var_2 processchallenge( "ch_noattachments" );

        if ( var_2 shouldprocesschallengeforperk( "specialty_bulletaccuracy" ) && !var_2 maps\mp\_utility::isplayerads() )
            var_2 processchallenge( "ch_bulletaccuracy_pro" );

        if ( var_2 shouldprocesschallengeforperk( "specialty_stalker" ) && var_2 maps\mp\_utility::isplayerads() )
            var_2 processchallenge( "ch_stalker_pro" );

        if ( distancesquared( var_2.origin, var_0.victim.origin ) < 65536 )
        {
            if ( var_2 shouldprocesschallengeforperk( "specialty_quieter" ) )
                var_2 processchallenge( "ch_deadsilence_pro" );
        }

        if ( var_2 shouldprocesschallengeforperk( "specialty_fastreload" ) && var_2 hasreloadedrecently() )
            var_2 processchallenge( "ch_sleightofhand_pro" );

        if ( var_2 shouldprocesschallengeforperk( "specialty_sharp_focus" ) )
        {
            if ( isdefined( var_2.attackers ) && var_2.attackers.size > 0 )
                var_2 processchallenge( "ch_sharp_focus" );
        }
    }

    if ( var_2 isitemunlocked( "specialty_quickdraw" ) && var_2 maps\mp\_utility::_hasperk( "specialty_quickdraw" ) && ( var_2.adstime > 0 && var_2.adstime < 3 ) )
        var_2 processchallenge( "ch_quickdraw_pro" );

    if ( var_2 isitemunlocked( "specialty_empimmune" ) && var_2 maps\mp\_utility::_hasperk( "specialty_empimmune" ) )
    {
        if ( level.teambased )
        {
            var_60 = 0;

            foreach ( var_62 in level.uavmodels[maps\mp\_utility::getotherteam( var_2.team )] )
            {
                if ( var_62.uavtype != "counter" )
                    continue;

                var_60 = 1;
                break;
            }

            if ( var_60 || var_2 maps\mp\_utility::isemped() )
                var_2 processchallenge( "ch_spygame" );
        }
        else if ( var_2.isradarblocked || var_2 maps\mp\_utility::isemped() )
            var_2 processchallenge( "ch_spygame" );
    }

    if ( isdefined( var_0.victim.isplanting ) && var_0.victim.isplanting )
        var_2 processchallenge( "ch_bombplanter" );

    if ( isdefined( var_0.victim.isdefusing ) && var_0.victim.isdefusing )
        var_2 processchallenge( "ch_bombdefender" );

    if ( isdefined( var_0.victim.isbombcarrier ) && var_0.victim.isbombcarrier && ( !isdefined( level.dd ) || !level.dd ) )
        var_2 processchallenge( "ch_bombdown" );

    if ( isdefined( var_0.victim.wasti ) && var_0.victim.wasti )
        var_2 processchallenge( "ch_tacticaldeletion" );

    if ( var_2 isitemunlocked( "specialty_quickswap" ) && var_2 maps\mp\_utility::_hasperk( "specialty_quickswap" ) )
    {
        if ( isdefined( var_2.lastprimaryweaponswaptime ) && gettime() - var_2.lastprimaryweaponswaptime < 3000 )
            var_2 processchallenge( "ch_quickswap" );
    }

    if ( var_2 isitemunlocked( "specialty_extraammo" ) && var_2 maps\mp\_utility::_hasperk( "specialty_extraammo" ) )
        var_2 processchallenge( "ch_extraammo" );

    if ( isexplosivedamagemod( var_0.smeansofdeath ) )
    {
        switch ( var_0.sweapon )
        {
            case "semtex_mp":
            case "concussion_grenade_mp":
            case "thermobaric_grenade_mp":
            case "emp_grenade_mp":
            case "flash_grenade_mp":
            case "mortar_shell_mp":
            case "frag_grenade_mp":
                if ( var_2 isitemunlocked( "specialty_fastoffhand" ) && var_2 maps\mp\_utility::_hasperk( "specialty_fastoffhand" ) )
                    var_2 processchallenge( "ch_fastoffhand" );

                break;
        }

        if ( isdefined( var_3.thermodebuffed ) && var_3.thermodebuffed )
            var_2 processchallenge( "ch_thermobaric" );
    }

    if ( var_2 isitemunlocked( "specialty_overkillpro" ) && var_2 maps\mp\_utility::_hasperk( "specialty_overkillpro" ) )
    {
        if ( var_2.secondaryweapon == var_0.sweapon )
        {
            var_35 = getweaponattachments( var_0.sweapon );

            if ( var_35.size > 0 )
                var_2 processchallenge( "ch_secondprimary" );
        }
    }

    if ( var_2 isitemunlocked( "specialty_stun_resistance" ) && var_2 maps\mp\_utility::_hasperk( "specialty_stun_resistance" ) )
    {
        if ( isdefined( var_2.lastflashedtime ) && gettime() - var_2.lastflashedtime < 5000 )
            var_2 processchallenge( "ch_stunresistance" );
        else if ( isdefined( var_2.lastconcussedtime ) && gettime() - var_2.lastconcussedtime < 5000 )
            var_2 processchallenge( "ch_stunresistance" );
    }

    if ( var_2 isitemunlocked( "specialty_selectivehearing" ) && var_2 maps\mp\_utility::_hasperk( "specialty_selectivehearing" ) )
        var_2 processchallenge( "ch_selectivehearing" );

    if ( var_2 isitemunlocked( "specialty_fastsprintrecovery" ) && var_2 maps\mp\_utility::_hasperk( "specialty_fastsprintrecovery" ) )
    {
        if ( isdefined( var_2.lastsprintendtime ) && gettime() - var_2.lastsprintendtime < 3000 )
            var_2 processchallenge( "ch_fastsprintrecovery" );
    }
}

ch_bulletdamagecommon( var_0, var_1, var_2, var_3 )
{
    if ( !maps\mp\_utility::isenvironmentweapon( var_0.sweapon ) )
        var_1 endmgstreak();

    if ( maps\mp\_utility::iskillstreakweapon( var_0.sweapon ) )
        return;

    if ( var_1.pers["lastBulletKillTime"] == var_2 )
        var_1.pers["bulletStreak"]++;
    else
        var_1.pers["bulletStreak"] = 1;

    var_1.pers["lastBulletKillTime"] = var_2;

    if ( !var_0.victimonground )
        var_1 processchallenge( "ch_hardlanding" );

    if ( !var_0.attackeronground )
        var_1.pers["midairStreak"]++;

    if ( var_1.pers["midairStreak"] == 2 )
        var_1 processchallenge( "ch_airborne" );

    if ( var_2 < var_0.victim.flashendtime )
        var_1 processchallenge( "ch_flashbangvet" );

    if ( var_2 < var_1.flashendtime )
        var_1 processchallenge( "ch_blindfire" );

    if ( var_2 < var_0.victim.concussionendtime )
        var_1 processchallenge( "ch_concussionvet" );

    if ( var_2 < var_1.concussionendtime )
        var_1 processchallenge( "ch_slowbutsure" );

    if ( var_1.pers["bulletStreak"] == 2 )
    {
        if ( isdefined( var_0.modifiers["headshot"] ) )
        {
            foreach ( var_5 in var_1.killsthislife )
            {
                if ( var_5.time != var_2 )
                    continue;

                if ( !isdefined( var_0.modifiers["headshot"] ) )
                    continue;

                var_1 processchallenge( "ch_allpro" );
            }
        }

        if ( var_3 == "weapon_sniper" )
            var_1 processchallenge( "ch_collateraldamage" );
    }

    if ( var_3 == "weapon_pistol" )
    {
        if ( isdefined( var_0.victim.attackerdata ) && isdefined( var_0.victim.attackerdata[var_1.guid] ) )
        {
            if ( isdefined( var_0.victim.attackerdata[var_1.guid].isprimary ) )
                var_1 processchallenge( "ch_fastswap" );
        }
    }

    if ( !isdefined( var_1.infinalstand ) || !var_1.infinalstand )
    {
        if ( var_0.attackerstance == "crouch" )
            var_1 processchallenge( "ch_crouchshot" );
        else if ( var_0.attackerstance == "prone" )
        {
            var_1 processchallenge( "ch_proneshot" );

            if ( var_3 == "weapon_sniper" )
                var_1 processchallenge( "ch_invisible" );
        }
    }

    if ( issubstr( var_0.sweapon, "silencer" ) )
        var_1 processchallenge( "ch_stealthvet" );
}

ch_roundplayed( var_0 )
{
    var_1 = var_0.player;

    if ( var_1.wasaliveatmatchstart )
    {
        var_2 = var_1.pers["deaths"];
        var_3 = var_1.pers["kills"];
        var_4 = 1000000;

        if ( var_2 > 0 )
            var_4 = var_3 / var_2;

        if ( var_4 >= 5.0 && var_3 >= 5.0 )
            var_1 processchallenge( "ch_starplayer" );

        if ( var_2 == 0 && maps\mp\_utility::gettimepassed() > 300000 )
            var_1 processchallenge( "ch_flawless" );

        if ( level.placement["all"].size < 3 )
            return;

        if ( var_1.score > 0 )
        {
            switch ( level.gametype )
            {
                case "dm":
                case "gun":
                    if ( var_0.place < 3 )
                    {
                        var_1 processchallenge( "ch_victor_dm" );
                        var_1 processchallenge( "ch_hunted_victor" );
                    }

                    break;
                case "sotf_ffa":
                    if ( var_0.place < 3 )
                        var_1 processchallenge( "ch_hunted_victor" );

                    break;
            }
        }
    }
}

ch_roundwin( var_0 )
{
    if ( !var_0.winner )
        return;

    var_1 = var_0.player;

    if ( var_1.wasaliveatmatchstart )
    {
        switch ( level.gametype )
        {
            case "war":
                if ( level.hardcoremode )
                {
                    var_1 processchallenge( "ch_teamplayer_hc" );

                    if ( var_0.place == 0 )
                        var_1 processchallenge( "ch_mvp_thc" );
                }
                else
                {
                    var_1 processchallenge( "ch_teamplayer" );

                    if ( var_0.place <= 2 )
                    {
                        var_1 processchallenge( "ch_tdmskills" );

                        if ( var_0.place == 0 )
                            var_1 processchallenge( "ch_mvp_tdm" );
                    }
                }

                break;
            case "blitz":
                var_1 processchallenge( "ch_blitz_victor" );
                break;
            case "cranked":
                var_1 processchallenge( "ch_crank_victor" );
                break;
            case "dom":
                var_1 processchallenge( "ch_dom_victor" );
                break;
            case "grind":
                var_1 processchallenge( "ch_grind_victor" );
                break;
            case "infect":
                if ( var_1.team == "allies" )
                    var_1 processchallenge( "ch_alive" );

                var_1 processchallenge( "ch_infected" );
                break;
            case "sd":
                var_1 processchallenge( "ch_victor_sd" );
                break;
            case "sr":
                var_1 processchallenge( "ch_sr_victor" );
                break;
            case "conf":
                var_1 processchallenge( "ch_conf_victor" );
                break;
            case "koth":
            case "dm":
            case "gun":
            case "sotf_ffa":
                break;
            default:
                break;
        }

        var_2 = getdvarint( "scr_playlist_type", 0 );

        if ( var_2 == 1 )
        {
            var_1 processchallenge( "ch_bromance" );

            if ( !level.console )
                var_1 processchallenge( "ch_tactician" );
        }
        else if ( var_2 == 2 )
            var_1 processchallenge( "ch_tactician" );

        if ( level.hardcoremode )
            var_1 processchallenge( "ch_hardcore_extreme" );
    }
}

playerdamaged( var_0, var_1, var_2, var_3, var_4, var_5 )
{
    if ( maps\mp\_utility::is_aliens() )
        return;
    else
        playerdamaged_regularmp( var_0, var_1, var_2, var_3, var_4, var_5 );
}

playerdamaged_regularmp( var_0, var_1, var_2, var_3, var_4, var_5 )
{
    if ( !isplayer( self ) )
        return;

    self endon( "disconnect" );

    if ( isdefined( var_1 ) )
        var_1 endon( "disconnect" );

    wait 0.05;
    maps\mp\_utility::waittillslowprocessallowed();
    var_6 = spawnstruct();
    var_6.victim = self;
    var_6.einflictor = var_0;
    var_6.attacker = var_1;
    var_6.idamage = var_2;
    var_6.smeansofdeath = var_3;
    var_6.sweapon = var_4;
    var_6.shitloc = var_5;
    var_6.victimonground = var_6.victim isonground();

    if ( isplayer( var_1 ) )
    {
        var_6.attackerinlaststand = isdefined( var_6.attacker.laststand );
        var_6.attackeronground = var_6.attacker isonground();
        var_6.attackerstance = var_6.attacker getstance();
    }
    else
    {
        var_6.attackerinlaststand = 0;
        var_6.attackeronground = 0;
        var_6.attackerstance = "stand";
    }

    domissioncallback( "playerDamaged", var_6 );
}

playerkilled( var_0, var_1, var_2, var_3, var_4, var_5, var_6, var_7 )
{
    if ( maps\mp\_utility::is_aliens() )
        return;
    else
        playerkilled_regularmp( var_0, var_1, var_2, var_3, var_4, var_5, var_6, var_7 );
}

playerkilled_regularmp( var_0, var_1, var_2, var_3, var_4, var_5, var_6, var_7 )
{
    if ( maps\mp\_utility::isusingremote() )
        self.anglesondeath = self.angles;
    else
        self.anglesondeath = self getplayerangles();

    if ( isdefined( var_1 ) )
        var_1.anglesonkill = var_1 getplayerangles();

    self endon( "disconnect" );
    var_8 = spawnstruct();
    var_8.victim = self;
    var_8.einflictor = var_0;
    var_8.attacker = var_1;
    var_8.idamage = var_2;
    var_8.smeansofdeath = var_3;
    var_8.sweapon = var_4;
    var_8.sprimaryweapon = var_5;
    var_8.shitloc = var_6;
    var_8.time = gettime();
    var_8.modifiers = var_7;

    if ( isdefined( var_4 ) && issubstr( var_4, "_hybrid" ) )
    {
        if ( var_1 getcurrentweapon() == var_4 )
            var_8.hybridscopestate = var_1 gethybridscopestate( var_4 );
        else
            var_8.hybridscopestate = 0;
    }

    var_8.victimonground = var_8.victim isonground();

    if ( isplayer( var_1 ) )
    {
        var_8.attackerinlaststand = isdefined( var_8.attacker.laststand );
        var_8.attackeronground = var_8.attacker isonground();
        var_8.attackerstance = var_8.attacker getstance();
    }
    else
    {
        var_8.attackerinlaststand = 0;
        var_8.attackeronground = 0;
        var_8.attackerstance = "stand";
    }

    waitandprocessplayerkilledcallback( var_8 );

    if ( isdefined( var_1 ) && maps\mp\_utility::isreallyalive( var_1 ) )
        var_1.killsthislife[var_1.killsthislife.size] = var_8;

    var_8.attacker notify( "playerKilledChallengesProcessed" );
}

vehiclekilled( var_0, var_1, var_2, var_3, var_4, var_5, var_6 )
{
    if ( !maps\mp\_utility::is_aliens() )
        killstreakkilled_regularmp( var_0, var_1, var_2, var_3, var_4, var_5, var_6 );
}

killstreakkilled( var_0, var_1, var_2, var_3, var_4, var_5, var_6 )
{
    if ( !maps\mp\_utility::is_aliens() )
        killstreakkilled_regularmp( var_0, var_1, var_2, var_3, var_4, var_5, var_6 );
}

killstreakkilled_regularmp( var_0, var_1, var_2, var_3, var_4, var_5, var_6 )
{
    if ( isdefined( var_3 ) && isplayer( var_3 ) && ( !isdefined( var_0 ) || var_3 != var_0 ) && var_3 maps\mp\_utility::killshouldaddtokillstreak( var_6 ) )
        var_3 maps\mp\killstreaks\_killstreaks::giveadrenaline( "vehicleDestroyed" );
}

waitandprocessplayerkilledcallback( var_0 )
{
    if ( isdefined( var_0.attacker ) )
        var_0.attacker endon( "disconnect" );

    self.processingkilledchallenges = 1;
    wait 0.05;
    maps\mp\_utility::waittillslowprocessallowed();
    domissioncallback( "playerKilled", var_0 );
    self.processingkilledchallenges = undefined;
}

playerassist( var_0 )
{
    var_1 = spawnstruct();
    var_1.player = self;
    var_1.victim = var_0;
    var_2 = var_0.attackerdata[self.guid];

    if ( isdefined( var_2 ) )
        var_1.sweapon = var_2.weapon;

    domissioncallback( "playerAssist", var_1 );
}

usehardpoint( var_0 )
{
    if ( maps\mp\_utility::is_aliens() )
        return;
    else
        usehardpoint_regularmp( var_0 );
}

usehardpoint_regularmp( var_0 )
{
    self endon( "disconnect" );
    wait 0.05;
    maps\mp\_utility::waittillslowprocessallowed();
    var_1 = spawnstruct();
    var_1.player = self;
    var_1.hardpointtype = var_0;
    domissioncallback( "playerHardpoint", var_1 );
}

roundbegin()
{
    domissioncallback( "roundBegin" );
}

roundend( var_0 )
{
    var_1 = spawnstruct();

    if ( level.teambased )
    {
        var_2 = "allies";

        for ( var_3 = 0; var_3 < level.placement[var_2].size; var_3++ )
        {
            var_1.player = level.placement[var_2][var_3];
            var_1.winner = var_2 == var_0;
            var_1.place = var_3;
            domissioncallback( "roundEnd", var_1 );
        }

        var_2 = "axis";

        for ( var_3 = 0; var_3 < level.placement[var_2].size; var_3++ )
        {
            var_1.player = level.placement[var_2][var_3];
            var_1.winner = var_2 == var_0;
            var_1.place = var_3;
            domissioncallback( "roundEnd", var_1 );
        }
    }
    else
    {
        for ( var_3 = 0; var_3 < level.placement["all"].size; var_3++ )
        {
            var_1.player = level.placement["all"][var_3];
            var_1.winner = isdefined( var_0 ) && isplayer( var_0 ) && var_1.player == var_0;
            var_1.place = var_3;
            domissioncallback( "roundEnd", var_1 );
        }
    }
}

domissioncallback( var_0, var_1 )
{
    if ( !mayprocesschallenges() )
        return;

    if ( isdefined( var_1 ) )
    {
        var_2 = var_1.player;

        if ( !isdefined( var_2 ) )
            var_2 = var_1.attacker;

        if ( isdefined( var_2 ) && isai( var_2 ) )
            return;
    }

    if ( getdvarint( "disable_challenges" ) > 0 )
        return;

    if ( !isdefined( level.missioncallbacks[var_0] ) )
        return;

    if ( isdefined( var_1 ) )
    {
        for ( var_3 = 0; var_3 < level.missioncallbacks[var_0].size; var_3++ )
            thread [[ level.missioncallbacks[var_0][var_3] ]]( var_1 );
    }
    else
    {
        for ( var_3 = 0; var_3 < level.missioncallbacks[var_0].size; var_3++ )
            thread [[ level.missioncallbacks[var_0][var_3] ]]();
    }
}

monitorsprintdistance()
{
    level endon( "game_ended" );
    self endon( "spawned_player" );
    self endon( "death" );
    self endon( "disconnect" );
    self.sprintdistthissprint = 0;

    for (;;)
    {
        self waittill( "sprint_begin" );
        thread monitorsprinttime();

        if ( maps\mp\_utility::_hasperk( "specialty_marathon" ) )
        {
            monitorsinglesprintdistance();
            var_0 = int( self.sprintdistthissprint / 120 );
            self.sprintdistthissprint = self.sprintdistthissprint - var_0 * 120;
            processchallenge( "ch_longersprint_pro", var_0 );
        }
    }
}

monitorsinglesprintdistance()
{
    level endon( "game_ended" );
    self endon( "spawned_player" );
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "sprint_end" );
    self endon( "heli_sniper_enter" );
    var_0 = self.origin;

    for (;;)
    {
        wait 0.1;
        var_1 = distance( self.origin, var_0 );
        self.sprintdistthissprint = self.sprintdistthissprint + clamp( var_1, 0, 40 );
        var_0 = self.origin;
    }
}

monitorsprinttime()
{
    level endon( "game_ended" );
    self endon( "spawned_player" );
    self endon( "death" );
    self endon( "disconnect" );
    var_0 = gettime();
    self waittill( "sprint_end" );
    var_1 = int( gettime() - var_0 );
    maps\mp\_utility::incplayerstat( "sprinttime", var_1 );
    self.lastsprintendtime = gettime();
}

monitorfalldistance()
{
    self endon( "disconnect" );
    self.pers["midairStreak"] = 0;

    for (;;)
    {
        if ( !isalive( self ) )
        {
            self waittill( "spawned_player" );
            continue;
        }

        if ( !self isonground() )
        {
            self.pers["midairStreak"] = 0;
            var_0 = self.origin[2];

            while ( !self isonground() && isalive( self ) )
            {
                if ( self.origin[2] > var_0 )
                    var_0 = self.origin[2];

                wait 0.05;
            }

            self.pers["midairStreak"] = 0;
            var_1 = var_0 - self.origin[2];

            if ( var_1 < 0 )
                var_1 = 0;

            if ( var_1 / 12.0 > 15 && isalive( self ) )
                processchallenge( "ch_basejump" );

            if ( var_1 / 12.0 > 30 && !isalive( self ) )
                processchallenge( "ch_goodbye" );
        }

        wait 0.05;
    }
}

lastmansd()
{
    if ( !mayprocesschallenges() )
        return;

    if ( !self.wasaliveatmatchstart )
        return;

    if ( self.teamkillsthisround > 0 )
        return;

    processchallenge( "ch_lastmanstanding" );
}

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

    for (;;)
    {
        var_0 = common_scripts\utility::waittill_any_return( "bomb_planted", "bomb_defused" );

        if ( !isdefined( var_0 ) )
            continue;

        if ( var_0 == "bomb_planted" )
        {
            processchallenge( "ch_saboteur" );
            continue;
        }

        if ( var_0 == "bomb_defused" )
            processchallenge( "ch_hero" );
    }
}

monitorlivetime()
{
    for (;;)
    {
        self waittill( "spawned_player" );
        thread survivalistchallenge();
    }
}

survivalistchallenge()
{
    self endon( "death" );
    self endon( "disconnect" );
    wait 300;

    if ( isdefined( self ) )
        processchallenge( "ch_survivalist" );
}

monitorstreaks()
{
    self endon( "disconnect" );
    self.pers["airstrikeStreak"] = 0;
    self.pers["meleeKillStreak"] = 0;
    self.pers["shieldKillStreak"] = 0;
    thread monitormisc();

    for (;;)
    {
        self waittill( "death" );
        self.pers["airstrikeStreak"] = 0;
        self.pers["meleeKillStreak"] = 0;
        self.pers["shieldKillStreak"] = 0;
    }
}

monitormisc()
{
    thread monitormiscsingle( "destroyed_equipment" );
    thread monitormiscsingle( "begin_airstrike" );
    thread monitormiscsingle( "destroyed_car" );
    thread monitormiscsingle( "destroyed_helicopter" );
    thread monitormiscsingle( "used_airdrop" );
    thread monitormiscsingle( "used_emp" );
    thread monitormiscsingle( "used_nuke" );
    thread monitormiscsingle( "crushed_enemy" );
    self waittill( "disconnect" );
    self notify( "destroyed_equipment" );
    self notify( "begin_airstrike" );
    self notify( "destroyed_car" );
    self notify( "destroyed_helicopter" );
}

monitormiscsingle( var_0 )
{
    for (;;)
    {
        self waittill( var_0 );

        if ( !isdefined( self ) )
            return;

        monitormisccallback( var_0 );
    }
}

monitormisccallback( var_0 )
{
    switch ( var_0 )
    {
        case "begin_airstrike":
            self.pers["airstrikeStreak"] = 0;
            break;
        case "destroyed_equipment":
            if ( self isitemunlocked( "specialty_detectexplosive" ) && maps\mp\_utility::_hasperk( "specialty_detectexplosive" ) )
                processchallenge( "ch_detectexplosives_pro" );

            processchallenge( "ch_backdraft" );
            break;
        case "destroyed_helicopter":
            processchallenge( "ch_flyswatter" );
            break;
        case "destroyed_car":
            processchallenge( "ch_vandalism" );
            break;
        case "crushed_enemy":
            processchallenge( "ch_heads_up" );

            if ( isdefined( self.finalkill ) )
                processchallenge( "ch_droppincrates" );

            break;
    }
}

healthregenerated()
{
    if ( maps\mp\_utility::is_aliens() )
        return;
    else
        healthregenerated_regularmp();
}

healthregenerated_regularmp()
{
    if ( !isalive( self ) )
        return;

    if ( !mayprocesschallenges() )
        return;

    if ( !maps\mp\_utility::rankingenabled() )
        return;

    thread resetbrinkofdeathkillstreakshortly();
    self notify( "healed" );

    if ( isdefined( self.lastdamagewasfromenemy ) && self.lastdamagewasfromenemy )
    {
        self.healthregenerationstreak++;

        if ( self.healthregenerationstreak >= 5 )
            processchallenge( "ch_invincible" );
    }
}

resetbrinkofdeathkillstreakshortly()
{
    self endon( "disconnect" );
    self endon( "death" );
    self endon( "damage" );
    wait 1;
    self.brinkofdeathkillstreak = 0;
}

playerspawned()
{
    if ( maps\mp\_utility::is_aliens() )
        return;
    else
        playerspawned_regularmp();
}

playerspawned_regularmp()
{
    self.brinkofdeathkillstreak = 0;
    self.healthregenerationstreak = 0;
    self.pers["MGStreak"] = 0;
}

playerdied()
{
    self.brinkofdeathkillstreak = 0;
    self.healthregenerationstreak = 0;
    self.pers["MGStreak"] = 0;
}

isatbrinkofdeath()
{
    if ( isalive( self ) )
    {
        var_0 = self.health / self.maxhealth;
        return var_0 <= level.healthoverlaycutoff;
    }

    return 0;
}

processchallenge( var_0, var_1, var_2 )
{
    if ( maps\mp\_utility::is_aliens() )
        return;
    else
        processchallenge_regularmp( var_0, var_1, var_2 );
}

processchallenge_regularmp( var_0, var_1, var_2 )
{
    if ( !mayprocesschallenges() )
        return;

    if ( level.players.size < 2 )
        return;

    if ( !maps\mp\_utility::rankingenabled() )
        return;

    if ( !isplayer( self ) || isai( self ) )
        return;

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

    var_3 = getchallengestatus( var_0 );

    if ( var_3 == 0 )
        return;

    var_4 = isdefined( level.challengeinfo[var_0]["operation"] );

    if ( var_3 > level.challengeinfo[var_0]["targetval"].size )
    {
        var_5 = var_4 && var_3 == level.challengeinfo[var_0]["targetval"].size + 1;
        var_6 = isdefined( self.operationsmaxed ) && isdefined( self.operationsmaxed[var_0] );

        if ( var_5 && !var_6 )
            var_3 = level.challengeinfo[var_0]["targetval"].size;
        else
            return;
    }

    var_7 = maps\mp\gametypes\_hud_util::ch_getprogress( var_0 );
    var_8 = level.challengeinfo[var_0]["targetval"][var_3];

    if ( isdefined( var_2 ) && var_2 )
        var_9 = var_1;
    else
        var_9 = var_7 + var_1;

    var_10 = 0;

    if ( var_9 >= var_8 )
    {
        var_11 = 1;
        var_10 = var_9 - var_8;
        var_9 = var_8;
    }
    else
        var_11 = 0;

    if ( var_7 < var_9 )
        maps\mp\gametypes\_hud_util::ch_setprogress( var_0, var_9 );

    if ( var_11 )
    {
        thread giverankxpafterwait( var_0, var_3 );
        maps\mp\_matchdata::logchallenge( var_0, var_3 );

        if ( var_4 )
            storecompletedoperation( var_0 );
        else
            storecompletedchallenge( var_0 );

        if ( var_4 )
        {
            if ( !isdefined( level.challengeinfo[var_0]["weapon"] ) || var_3 >= 4 )
                maps\mp\gametypes\_rank::giveunlockpoints( 1, 0 );
        }

        var_3++;
        maps\mp\gametypes\_hud_util::ch_setstate( var_0, var_3 );
        self.challengedata[var_0] = var_3;

        if ( var_4 )
        {
            if ( var_3 > level.challengeinfo[var_0]["targetval"].size )
            {
                if ( !isdefined( self.operationsmaxed ) )
                    self.operationsmaxed = [];

                self.operationsmaxed[var_0] = 1;

                if ( isdefined( level.challengeinfo[var_0]["weapon"] ) )
                    maps\mp\gametypes\_hud_util::ch_setprogress( var_0, var_10 );
            }

            if ( !isdefined( level.challengeinfo[var_0]["weapon"] ) )
                maps\mp\gametypes\_hud_util::ch_setprogress( var_0, var_10 );

            var_12 = self getrankedplayerdata( "challengeState", "ch_weekly_2" );
            self setrankedplayerdata( "challengeState", "ch_weekly_2", var_12 + 1 );
        }

        thread maps\mp\gametypes\_hud_message::challengesplashnotify( var_0 );
    }
}

storecompletedchallenge( var_0 )
{
    if ( !isdefined( self.challengescompleted ) )
        self.challengescompleted = [];

    var_1 = 0;

    foreach ( var_3 in self.challengescompleted )
    {
        if ( var_3 == var_0 )
            var_1 = 1;
    }

    if ( !var_1 )
        self.challengescompleted[self.challengescompleted.size] = var_0;
}

storecompletedoperation( var_0 )
{
    if ( !isdefined( self.operationscompleted ) )
        self.operationscompleted = [];

    var_1 = 0;

    foreach ( var_3 in self.operationscompleted )
    {
        if ( var_3 == var_0 )
        {
            var_1 = 1;
            break;
        }
    }

    if ( !var_1 )
        self.operationscompleted[self.operationscompleted.size] = var_0;
}

giverankxpafterwait( var_0, var_1 )
{
    self endon( "disconnect" );
    wait 0.25;
    var_2 = "challenge";

    if ( isoperationchallenge( var_0 ) )
        var_2 = "operation";

    maps\mp\gametypes\_rank::giverankxp( var_2, level.challengeinfo[var_0]["reward"][var_1], undefined, undefined, var_0 );
}

updatechallenges()
{
    self.challengedata = [];
    self endon( "disconnect" );

    if ( !mayprocesschallenges() )
        return;

    var_0 = 0;

    foreach ( var_5, var_2 in level.challengeinfo )
    {
        var_0++;

        if ( var_0 % 20 == 0 )
            wait 0.05;

        self.challengedata[var_5] = 0;
        var_3 = var_2["index"];
        var_4 = maps\mp\gametypes\_hud_util::ch_getstate( var_5 );

        if ( var_4 == 0 )
        {
            maps\mp\gametypes\_hud_util::ch_setstate( var_5, 1 );
            var_4 = 1;
        }

        self.challengedata[var_5] = var_4;
    }

    fixallbadoperations();
}

isinunlocktable( var_0 )
{
    return tablelookup( "mp/unlockTable.csv", 0, var_0, 0 ) != "";
}

getchallengefilter( var_0 )
{
    return tablelookup( "mp/allChallengesTable.csv", 0, var_0, 5 );
}

getchallengetable( var_0 )
{
    return tablelookup( "mp/challengeTable.csv", 8, var_0, 4 );
}

gettierfromtable( var_0, var_1 )
{
    return tablelookup( var_0, 0, var_1, 1 );
}

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

    var_1 = getchallengefilter( var_0 );

    if ( isdefined( var_1 ) )
    {
        if ( maps\mp\gametypes\_class::isvalidprimary( var_1, 0 ) || maps\mp\gametypes\_class::isvalidsecondary( var_1, 0 ) )
            return 1;
    }

    return 0;
}

getweaponfromchallenge( var_0 )
{
    return getchallengefilter( var_0 );
}

isreticlechallenge( var_0 )
{
    var_1 = getchallengefilter( var_0 );
    return var_1 == "acog" || var_1 == "eotech" || var_1 == "hybrid" || var_1 == "reflex";
}

getsightfromreticlechallenge( var_0 )
{
    return getchallengefilter( var_0 );
}

getweaponattachmentfromchallenge( var_0 )
{
    var_1 = "ch_";

    if ( issubstr( var_0, "ch_marksman_" ) )
        var_1 = "ch_marksman_";
    else if ( issubstr( var_0, "ch_expert_" ) )
        var_1 = "ch_expert_";
    else if ( issubstr( var_0, "pr_marksman_" ) )
        var_1 = "pr_marksman_";
    else if ( issubstr( var_0, "pr_expert_" ) )
        var_1 = "pr_expert_";

    var_2 = getsubstr( var_0, var_1.size, var_0.size );
    var_3 = strtok( var_2, "_" );
    var_4 = undefined;

    if ( isdefined( var_3[2] ) && maps\mp\_utility::isattachment( var_3[2] ) )
        var_4 = var_3[2];

    return var_4;
}

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

    var_1 = getchallengefilter( var_0 );

    if ( isdefined( var_1 ) && ( var_1 == "killstreaks_assault" || var_1 == "killstreaks_support" ) )
        return 1;

    return 0;
}

getkillstreakfromchallenge( var_0 )
{
    var_1 = "ch_";
    var_2 = getsubstr( var_0, var_1.size, var_0.size );

    if ( var_2 == "assault_streaks" || var_2 == "support_streaks" )
        var_2 = undefined;

    return var_2;
}

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

    var_1 = getchallengefilter( var_0 );

    if ( isdefined( var_1 ) )
    {
        if ( var_1 == "perk_slot_0" || var_1 == "perk_slot_1" || var_1 == "perk_slot_2" || var_1 == "proficiency" || var_1 == "equipment" || var_1 == "special_equipment" || var_1 == "attachment" || var_1 == "prestige" || var_1 == "final_killcam" || var_1 == "basic" || var_1 == "humiliation" || var_1 == "precision" || var_1 == "revenge" || var_1 == "elite" || var_1 == "intimidation" || var_1 == "operations" || maps\mp\_utility::isstrstart( var_1, "killstreaks_" ) )
            return 1;
    }

    if ( isweaponchallenge( var_0 ) )
        return 1;

    return 0;
}

challenge_targetval( var_0, var_1, var_2 )
{
    var_3 = tablelookup( var_0, 0, var_1, 9 + ( var_2 - 1 ) * 2 );
    return int( var_3 );
}

challenge_rewardval( var_0, var_1, var_2 )
{
    var_3 = tablelookup( var_0, 0, var_1, 10 + ( var_2 - 1 ) * 2 );
    return int( var_3 );
}

challenge_sprewardval( var_0, var_1, var_2 )
{
    var_3 = tablelookup( var_0, 0, var_1, 27 + ( var_2 - 1 ) );
    return int( var_3 );
}

buildchallengetableinfo( var_0, var_1 )
{
    var_2 = 0;
    var_3 = 0;
    var_4 = tablelookupbyrow( var_0, 0, 0 );

    for ( var_2 = 1; var_4 != ""; var_2++ )
    {
        level.challengeinfo[var_4] = [];
        level.challengeinfo[var_4]["index"] = var_2 - 1;
        level.challengeinfo[var_4]["type"] = var_1;
        level.challengeinfo[var_4]["targetval"] = [];
        level.challengeinfo[var_4]["reward"] = [];

        if ( isreticlechallenge( var_4 ) )
        {
            var_5 = getsightfromreticlechallenge( var_4 );

            if ( isdefined( var_5 ) )
                level.challengeinfo[var_4]["sight"] = var_5;
        }
        else if ( isoperationchallenge( var_4 ) )
        {
            level.challengeinfo[var_4]["operation"] = 1;
            level.challengeinfo[var_4]["spReward"] = [];

            if ( iskillstreakchallenge( var_4 ) )
            {
                var_6 = getkillstreakfromchallenge( var_4 );

                if ( isdefined( var_6 ) )
                    level.challengeinfo[var_4]["killstreak"] = var_6;
            }

            if ( isweaponchallenge( var_4 ) )
            {
                var_7 = getweaponfromchallenge( var_4 );

                if ( isdefined( var_7 ) )
                    level.challengeinfo[var_4]["weapon"] = var_7;
            }
        }

        for ( var_8 = 1; var_8 < 11; var_8++ )
        {
            var_9 = challenge_targetval( var_0, var_4, var_8 );
            var_10 = challenge_rewardval( var_0, var_4, var_8 );

            if ( var_9 == 0 )
                break;

            level.challengeinfo[var_4]["targetval"][var_8] = var_9;
            level.challengeinfo[var_4]["reward"][var_8] = var_10;

            if ( isdefined( level.challengeinfo[var_4]["spReward"] ) )
            {
                var_11 = challenge_sprewardval( var_0, var_4, var_8 );
                level.challengeinfo[var_4]["spReward"][var_8] = var_11;
            }

            var_3 = var_3 + var_10;
        }

        var_4 = tablelookupbyrow( var_0, var_2, 0 );
    }

    return int( var_3 );
}

buildchallegeinfo()
{
    level.challengeinfo = [];
    var_0 = 0;
    var_0 = var_0 + buildchallengetableinfo( "mp/allChallengesTable.csv", 0 );
}

monitorprocesschallenge()
{
    self endon( "disconnect" );
    level endon( "game_end" );

    for (;;)
    {
        if ( !mayprocesschallenges() )
            return;

        self waittill( "process", var_0 );
        processchallenge( var_0 );
    }
}

monitorkillstreakprogress()
{
    self endon( "disconnect" );
    level endon( "game_end" );

    for (;;)
    {
        self waittill( "got_killstreak", var_0 );

        if ( !isdefined( var_0 ) )
            continue;

        switch ( var_0 )
        {
            case 3:
                maps\mp\killstreaks\_killstreaks::giveadrenaline( "3streak" );
                break;
            case 4:
                maps\mp\killstreaks\_killstreaks::giveadrenaline( "4streak" );
                break;
            case 5:
                maps\mp\killstreaks\_killstreaks::giveadrenaline( "5streak" );
                break;
            case 6:
                maps\mp\killstreaks\_killstreaks::giveadrenaline( "6streak" );
                break;
            case 7:
                maps\mp\killstreaks\_killstreaks::giveadrenaline( "7streak" );
                break;
            case 8:
                maps\mp\killstreaks\_killstreaks::giveadrenaline( "8streak" );
                break;
            case 9:
                maps\mp\killstreaks\_killstreaks::giveadrenaline( "9streak" );
                break;
            case 10:
                maps\mp\killstreaks\_killstreaks::giveadrenaline( "10streak" );
                break;
            default:
                break;
        }

        if ( var_0 == 10 && self.killstreaks.size == 0 )
        {
            processchallenge( "ch_theloner" );
            continue;
        }

        if ( var_0 == 9 )
        {
            if ( isdefined( self.killstreaks[7] ) && isdefined( self.killstreaks[8] ) && isdefined( self.killstreaks[9] ) )
                processchallenge( "ch_6fears7" );
        }
    }
}

monitorkilledkillstreak()
{
    self endon( "disconnect" );
    level endon( "game_end" );

    for (;;)
    {
        self waittill( "destroyed_killstreak", var_0 );

        if ( self isitemunlocked( "specialty_blindeye" ) && maps\mp\_utility::_hasperk( "specialty_blindeye" ) )
            processchallenge( "ch_blindeye_pro" );
    }
}

genericchallenge( var_0, var_1 )
{
    switch ( var_0 )
    {
        case "hijacker_airdrop":
            processchallenge( "ch_smoothcriminal" );
            break;
        case "hijacker_airdrop_mega":
            processchallenge( "ch_poolshark" );
            break;
        case "wargasm":
            processchallenge( "ch_wargasm" );
            break;
        case "weapon_assault":
            processchallenge( "ch_surgical_assault" );
            break;
        case "weapon_smg":
            processchallenge( "ch_surgical_smg" );
            break;
        case "weapon_lmg":
            processchallenge( "ch_surgical_lmg" );
            break;
        case "weapon_dmr":
            processchallenge( "ch_surgical_dmr" );
            break;
        case "weapon_sniper":
            processchallenge( "ch_surgical_sniper" );
            break;
        case "weapon_shotgun":
            processchallenge( "ch_surgical_shotgun" );
            break;
        case "shield_damage":
            if ( !maps\mp\_utility::isjuggernaut() )
                processchallenge( "ch_iw6_riotshield_damage", var_1 );

            break;
        case "shield_bullet_hits":
            if ( !maps\mp\_utility::isjuggernaut() )
                processchallenge( "ch_shield_bullet", var_1 );

            break;
        case "shield_explosive_hits":
            if ( !maps\mp\_utility::isjuggernaut() )
                processchallenge( "ch_iw6_riotshield_explosive", var_1 );

            break;
    }
}

playerhasammo()
{
    var_0 = self getweaponslistprimaries();

    foreach ( var_2 in var_0 )
    {
        if ( self getweaponammoclip( var_2 ) )
        {
            if ( !maps\mp\gametypes\_weapons::isriotshield( var_2 ) && !maps\mp\gametypes\_weapons::isknifeonly( var_2 ) )
                return 1;
        }

        var_3 = weaponaltweaponname( var_2 );

        if ( !isdefined( var_3 ) || var_3 == "none" )
            continue;

        if ( self getweaponammoclip( var_3 ) )
            return 1;
    }

    return 0;
}

monitoradstime()
{
    self endon( "disconnect" );
    self.adstime = 0.0;

    for (;;)
    {
        if ( self playerads() == 1 )
            self.adstime = self.adstime + 0.05;
        else
            self.adstime = 0.0;

        wait 0.05;
    }
}

monitorholdbreath()
{
    self endon( "disconnect" );
    self.holdingbreath = 0;

    for (;;)
    {
        self waittill( "hold_breath" );
        self.holdingbreath = 1;
        self waittill( "release_breath" );
        self.holdingbreath = 0;
    }
}

monitormantle()
{
    self endon( "disconnect" );
    self.mantling = 0;

    for (;;)
    {
        self waittill( "jumped" );
        var_0 = self getcurrentweapon();
        common_scripts\utility::waittill_notify_or_timeout( "weapon_change", 1 );
        var_1 = self getcurrentweapon();

        if ( var_1 == "none" )
            self.mantling = 1;
        else
            self.mantling = 0;

        if ( self.mantling )
        {
            if ( self isitemunlocked( "specialty_fastmantle" ) && maps\mp\_utility::_hasperk( "specialty_fastmantle" ) )
                processchallenge( "ch_fastmantle" );

            common_scripts\utility::waittill_notify_or_timeout( "weapon_change", 1 );
            var_1 = self getcurrentweapon();

            if ( var_1 == var_0 )
                self.mantling = 0;
        }
    }
}

monitorweaponswap()
{
    self endon( "disconnect" );
    var_0 = self getcurrentweapon();

    for (;;)
    {
        self waittill( "weapon_change", var_1 );

        if ( var_1 == "none" )
            continue;

        if ( var_1 == var_0 )
            continue;

        if ( maps\mp\_utility::iskillstreakweapon( var_1 ) )
            continue;

        if ( var_1 == "briefcase_bomb_mp" || var_1 == "briefcase_bomb_defuse_mp" )
            continue;

        var_2 = weaponinventorytype( var_1 );

        if ( var_2 != "primary" )
            continue;

        self.lastprimaryweaponswaptime = gettime();
    }
}

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

    for (;;)
    {
        self waittill( "flashbang", var_0, var_1, var_2, var_3 );

        if ( self == var_3 )
            continue;

        self.lastflashedtime = gettime();
    }
}

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

    for (;;)
    {
        self waittill( "concussed", var_0 );

        if ( self == var_0 )
            continue;

        self.lastconcussedtime = gettime();
    }
}

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

    for (;;)
    {
        self waittill( "triggeredExpl", var_0 );
        thread waitdelayminetime();
    }
}

waitdelayminetime()
{
    self endon( "death" );
    self endon( "disconnect" );
    level endon( "game_ended" );
    wait( level.delayminetime + 2 );
    processchallenge( "ch_delaymine" );
}

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

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

        if ( self issprinting() )
            self.sprintreloadtimestamp = gettime() + 3000;

        var_0 = self getcurrentweapon();
        self.lastreloadedweapon = var_0;

        switch ( weaponclass( var_0 ) )
        {
            case "sniper":
                self.reloadtimestamp = gettime() + 5000;
                break;
            default:
                self.reloadtimestamp = gettime() + 3000;
                break;
        }

        self.killsthismag[var_0] = 0;
    }
}

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

    for (;;)
    {
        var_0 = common_scripts\utility::waittill_any_return( "sprint_slide_begin", "sprint_slide_end", "death" );

        if ( !isalive( self ) )
        {
            self.issliding = undefined;
            self.isslidinggraceperiod = gettime() - 1;
            continue;
        }

        if ( var_0 == "sprint_slide_end" )
        {
            self.issliding = undefined;
            self.isslidinggraceperiod = gettime() + 1000;
            continue;
        }

        if ( var_0 == "sprint_slide_begin" )
            self.issliding = 1;
    }
}

playerissprintsliding()
{
    return isdefined( self.issliding ) || isdefined( self.isslidinggraceperiod ) && gettime() <= self.isslidinggraceperiod;
}

playersprintslidrecently()
{
    return isdefined( self.issliding ) || isdefined( self.isslidinggraceperiod ) && gettime() <= self.isslidinggraceperiod + 1000;
}

shouldprocesschallengeforperk( var_0 )
{
    return self isitemunlocked( var_0 ) && maps\mp\_utility::_hasperk( var_0 );
}

processweaponattachmentchallenge( var_0, var_1 )
{
    processchallenge( "ch_" + var_1 );
}

processfinalkillchallenges( var_0, var_1 )
{
    if ( !mayprocesschallenges() || isai( var_0 ) )
        return;

    var_0 processchallenge( "ch_theedge" );

    if ( !isai( var_1 ) )
        var_1 processchallenge( "ch_starryeyed" );

    if ( isdefined( var_0.modifiers["revenge"] ) )
        var_0 processchallenge( "ch_moneyshot" );

    if ( isdefined( var_1 ) && isdefined( var_1.explosiveinfo ) && isdefined( var_1.explosiveinfo["stickKill"] ) && var_1.explosiveinfo["stickKill"] )
        var_0 processchallenge( "ch_stickman" );

    if ( isdefined( var_1.attackerdata[var_0.guid] ) && isdefined( var_1.attackerdata[var_0.guid].smeansofdeath ) && isdefined( var_1.attackerdata[var_0.guid].weapon ) && issubstr( var_1.attackerdata[var_0.guid].smeansofdeath, "MOD_MELEE" ) && maps\mp\gametypes\_weapons::isriotshield( var_1.attackerdata[var_0.guid].weapon ) )
        var_0 processchallenge( "ch_owned" );

    var_2 = var_0.team;

    if ( !level.teambased )
        var_2 = "none";

    switch ( level.finalkillcam_sweapon[var_2] )
    {
        case "sentry_minigun_mp":
            var_0 processchallenge( "ch_absentee" );
            break;
        case "remote_tank_projectile_mp":
            var_0 processchallenge( "ch_gryphonattack" );
            break;
        case "heli_pilot_turret_mp":
            var_0 processchallenge( "ch_hotshot" );
            break;
        case "iw6_gm6helisnipe_mp_gm6scope":
            var_0 processchallenge( "ch_heli_sniper_finalkill" );
            break;
        case "switch_blade_child_mp":
        case "drone_hive_projectile_mp":
            var_0 processchallenge( "ch_noescape" );
            break;
        case "ball_drone_gun_mp":
            var_0 processchallenge( "ch_thanksbuddy" );
            break;
        case "odin_projectile_small_rod_mp":
        case "odin_projectile_large_rod_mp":
            var_0 processchallenge( "ch_lokikiller" );
            break;
        case "hind_missile_mp":
        case "hind_bomb_mp":
        case "cobra_20mm_mp":
            var_0 processchallenge( "ch_og" );
            break;
        case "guard_dog_mp":
            var_0 processchallenge( "ch_bestinshow" );
            break;
        case "ims_projectile_mp":
            var_0 processchallenge( "ch_outsmarted" );
            break;
        case "iw6_p226jugg_mp":
        case "iw6_minigunjugg_mp":
        case "mortar_shelljugg_mp":
            var_0 processchallenge( "ch_painless" );
            break;
        case "iw6_knifeonlyjugg_mp":
        case "throwingknifejugg_mp":
            var_0 processchallenge( "ch_untouchable" );
            break;
        case "agent_support_mp":
            var_0 processchallenge( "ch_bestmates" );
            break;
        default:
            break;
    }
}

processweaponattachmentchallenge_acog( var_0, var_1, var_2 )
{
    if ( maps\mp\_utility::isplayerads() )
    {
        processchallenge( "ch_" + var_1 );

        if ( self getstance() == "prone" )
            processchallenge( "ch_" + var_1 + "_prone" );

        checkchallengekillmodifier( var_2, "longshot", var_1 );
        checkchallengekillmodifier( var_2, "headshot", var_1 );

        if ( self.recentkillcount == 2 )
            processchallenge( "ch_" + var_1 + "_double" );

        if ( isdefined( var_2.modifiers["oneshotkill"] ) )
            processchallenge( "ch_acog_oneshot" );
    }
}

processweaponattachmentchallenge_eotech( var_0, var_1, var_2 )
{
    if ( maps\mp\_utility::isplayerads() )
    {
        processchallenge( "ch_" + var_1 );

        if ( maps\mp\_utility::weaponisfiretypeburst( var_2.sweapon ) )
            processchallenge( "ch_" + var_1 + "_burst" );

        if ( self isleaning() )
            processchallenge( "ch_" + var_1 + "_lean" );

        checkchallengekillmodifier( var_2, "headshot", var_1 );

        if ( self.recentkillcount == 2 )
            processchallenge( "ch_" + var_1 + "_double" );

        checkconsecutivechallenge( var_2.sweapon, var_1 );
    }
}

processweaponattachmentchallenge_hybrid( var_0, var_1, var_2 )
{
    if ( maps\mp\_utility::isplayerads() )
    {
        processchallenge( "ch_" + var_1 );

        if ( var_2.hybridscopestate )
        {
            processchallenge( "ch_hybrid_zoomout" );
            checkchallengekillmodifier( var_2, "headshot", var_1 );
        }
        else
        {
            processchallenge( "ch_hybrid_zoomin" );
            checkchallengekillmodifier( var_2, "longshot", var_1 );
        }

        checkpenetrationchallenge( var_2.victim, var_1 );
    }
}

processweaponattachmentchallenge_reflex( var_0, var_1, var_2 )
{
    if ( maps\mp\_utility::isplayerads() )
    {
        processchallenge( "ch_" + var_1 );

        if ( self getstance() == "crouch" )
            processchallenge( "ch_" + var_1 + "_crouch" );

        var_3 = self getvelocity();

        if ( lengthsquared( var_3 ) > 16 )
            processchallenge( "ch_reflex_moving" );

        if ( maps\mp\_utility::weaponhasattachment( var_2.sweapon, "ammoslug" ) )
            processchallenge( "ch_" + var_1 + "_ammoslug" );

        checkchallengekillmodifier( var_2, "headshot", var_1 );

        if ( maps\mp\_utility::isstrstart( var_2.sweapon, "alt_" ) && maps\mp\_utility::weaponhasattachment( var_2.sweapon, "shotgun" ) )
            processchallenge( "ch_" + var_1 + "_altshotgun" );
    }
}

processweaponclasschallenge_ar( var_0, var_1 )
{
    processchallenge( "ch_" + var_0 );

    if ( self getstance() == "crouch" )
        processchallenge( "ch_" + var_0 + "_crouch" );

    checkchallengekillmodifier( var_1, "defender", var_0 );

    if ( maps\mp\_utility::weapongetnumattachments( var_1.sweapon ) == 0 )
        processchallenge( "ch_" + var_0 + "_noattach" );

    checkchallengekillmodifier( var_1, "longshot", var_0 );
    checkconsecutivechallenge( var_1.sweapon, var_0 );
    checkchallengekillmodifier( var_1, "pointblank", var_0 );

    if ( hasreloadedrecently() )
        processchallenge( "ch_" + var_0 + "_reload" );

    if ( playersprintslidrecently() )
        processchallenge( "ch_" + var_0 + "_sliding" );

    checkchallengeisleaning( var_0 );
}

processweaponclasschallenge_smg( var_0, var_1 )
{
    processchallenge( "ch_" + var_0 );

    if ( self getstance() == "crouch" )
        processchallenge( "ch_" + var_0 + "_crouch" );

    checkchallengekillmodifier( var_1, "defender", var_0 );

    if ( maps\mp\_utility::weapongetnumattachments( var_1.sweapon ) == 0 )
        processchallenge( "ch_" + var_0 + "_noattach" );

    if ( !maps\mp\_utility::isplayerads() )
        processchallenge( "ch_" + var_0 + "_hipfire" );

    checkconsecutivechallenge( var_1.sweapon, var_0 );
    checkchallengekillmodifier( var_1, "pointblank", var_0 );

    if ( hasreloadedrecently() )
        processchallenge( "ch_" + var_0 + "_reload" );

    if ( playersprintslidrecently() )
        processchallenge( "ch_" + var_0 + "_sliding" );

    checkchallengeisleaning( var_0 );
}

processweaponclasschallenge_lmg( var_0, var_1 )
{
    processchallenge( "ch_" + var_0 );

    if ( self getstance() == "crouch" )
        processchallenge( "ch_" + var_0 + "_crouch" );

    checkchallengekillmodifier( var_1, "defender", var_0 );

    if ( maps\mp\_utility::weapongetnumattachments( var_1.sweapon ) == 0 )
        processchallenge( "ch_" + var_0 + "_noattach" );

    if ( !maps\mp\_utility::isplayerads() )
        processchallenge( "ch_" + var_0 + "_hipfire" );

    checkconsecutivechallenge( var_1.sweapon, var_0 );
    checkchallengekillmodifier( var_1, "pointblank", var_0 );
    checkpenetrationchallenge( var_1.victim, var_0 );

    if ( playersprintslidrecently() )
        processchallenge( "ch_" + var_0 + "_sliding" );

    if ( var_1.smeansofdeath == "MOD_HEAD_SHOT" && checkcostumechallenge( var_1.victim, "mp_body_elite_pmc_lmg_b" ) )
        processchallenge( "ch_ghostbusted" );

    checkchallengeisleaning( var_0 );
}

processweaponclasschallenge_dmr( var_0, var_1 )
{
    processchallenge( "ch_" + var_0 );

    if ( self getstance() == "crouch" )
        processchallenge( "ch_" + var_0 + "_crouch" );

    checkchallengekillmodifier( var_1, "defender", var_0 );
    checkchallengekillmodifier( var_1, "longshot", var_0 );
    checkchallengekillmodifier( var_1, "headshot", var_0 );
    checkchallengekillmodifier( var_1, "pointblank", var_0 );
    checkconsecutivechallenge( var_1.sweapon, var_0 );

    if ( maps\mp\_utility::weapongetnumattachments( var_1.sweapon ) == 0 )
        processchallenge( "ch_" + var_0 + "_noattach" );

    if ( hasreloadedrecently() )
        processchallenge( "ch_" + var_0 + "_reload" );

    checkchallengeisleaning( var_0 );
}

processweaponclasschallenge_sniper( var_0, var_1 )
{
    processchallenge( "ch_sniper_kill" );
    processchallenge( "ch_" + var_0 );

    if ( self getstance() == "crouch" )
        processchallenge( "ch_" + var_0 + "_crouch" );

    if ( maps\mp\_utility::weapongetnumattachments( var_1.sweapon ) == 0 )
        processchallenge( "ch_" + var_0 + "_noattach" );

    checkchallengekillmodifier( var_1, "defender", var_0 );

    if ( self getstance() == "prone" )
        processchallenge( "ch_" + var_0 + "_prone" );

    checkchallengekillmodifier( var_1, "oneshotkill", var_0 );
    checkconsecutivechallenge( var_1.sweapon, var_0 );
    checkchallengekillmodifier( var_1, "pointblank", var_0 );

    if ( hasreloadedrecently() )
        processchallenge( "ch_" + var_0 + "_reload" );

    checkpenetrationchallenge( var_1.victim, var_0 );
    checkchallengeisleaning( var_0 );
}

processweaponclasschallenge_shotgun( var_0, var_1 )
{
    processchallenge( "ch_" + var_0 );

    if ( self getstance() == "crouch" )
        processchallenge( "ch_" + var_0 + "_crouch" );

    checkchallengekillmodifier( var_1, "defender", var_0 );

    if ( maps\mp\_utility::weapongetnumattachments( var_1.sweapon ) == 0 )
        processchallenge( "ch_" + var_0 + "_noattach" );

    if ( !maps\mp\_utility::isplayerads() )
        processchallenge( "ch_" + var_0 + "_hipfire" );

    checkconsecutivechallenge( var_1.sweapon, var_0 );
    checkchallengekillmodifier( var_1, "pointblank", var_0 );

    if ( hasreloadedrecently() )
        processchallenge( "ch_" + var_0 + "_reload" );

    if ( playersprintslidrecently() )
        processchallenge( "ch_" + var_0 + "_sliding" );

    checkchallengekillmodifier( var_1, "headshot", var_0 );
}

processweaponclasschallenge_riotshield( var_0, var_1 )
{
    processchallenge( "ch_" + var_0 );

    if ( self getstance() == "crouch" )
        processchallenge( "ch_" + var_0 + "_crouch" );

    if ( checknumusesofpersistentdata( "shieldKillStreak", 3 ) )
        processchallenge( "ch_" + var_0 + "_consecutive" );

    if ( hasnoperks() )
        processchallenge( "ch_" + var_0 + "_noperks" );
}

checkchallengekillmodifier( var_0, var_1, var_2 )
{
    if ( isdefined( var_0.modifiers[var_1] ) )
        processchallenge( "ch_" + var_2 + "_" + var_1 );
}

checkchallengeisleaning( var_0 )
{
    if ( self isleaning() )
        processchallenge( "ch_" + var_0 + "_leaning" );
}

checkpenetrationchallenge( var_0, var_1 )
{
    if ( var_0.idflags & level.idflags_penetration )
        processchallenge( "ch_" + var_1 + "_penetrate" );
}

checkconsecutivechallenge( var_0, var_1 )
{
    var_2 = self.killsthislifeperweapon[var_0];

    if ( isdefined( var_2 ) && isnumbermultipleof( var_2, 3 ) )
        processchallenge( "ch_" + var_1 + "_consecutive" );
}

checkwaslastweaponriotshield()
{
    var_0 = self getcurrentweapon();

    if ( maps\mp\gametypes\_weapons::isriotshield( var_0 ) )
        return 1;
    else
    {
        var_1 = common_scripts\utility::getlastweapon();
        return maps\mp\gametypes\_weapons::isriotshield( var_1 );
    }
}

checkaachallenges( var_0, var_1, var_2 )
{
    if ( isdefined( var_2 ) )
    {
        if ( isdefined( level.odinsettings ) && isdefined( level.odinsettings["odin_assault"] ) && ( var_2 == level.odinsettings["odin_assault"].weapon["large_rod"].projectile || var_2 == level.odinsettings["odin_assault"].weapon["small_rod"].projectile ) )
        {
            var_0 processchallenge( "ch_shooting_star" );
            return 1;
        }
        else if ( maps\mp\_utility::weaponmap( var_2 ) == "iw6_maaws_mp" )
            var_0 processchallenge( "ch_aa_launcher" );
        else if ( var_2 == "aamissile_projectile_mp" )
            var_0 processchallenge( "ch_air_superiority" );
    }

    var_0 processchallenge( "ch_clearskies" );
    return 0;
}

checkchallengeextradeadly( var_0 )
{
    if ( shouldprocesschallengeforperk( "specialty_extra_deadly" ) )
    {
        if ( var_0 == self.loadoutperkequipment )
            processchallenge( "ch_extra_deadly" );
    }
}

checkcostumechallenge( var_0, var_1 )
{
    if ( !isai( var_0 ) )
    {
        var_2 = var_0 maps\mp\gametypes\_teams::getplayermodelindex();
        var_3 = var_0 maps\mp\gametypes\_teams::getplayermodelname( var_2 );
        return var_3 == var_1;
    }

    return 0;
}

hasreloadedrecently()
{
    return isdefined( self.reloadtimestamp ) && gettime() < self.reloadtimestamp;
}

processchallengeforteam( var_0, var_1 )
{
    foreach ( var_3 in level.players )
    {
        if ( var_3.team == var_1 )
            var_3 processchallenge( var_0 );
    }
}

allowkillchallengeforkillstreak( var_0, var_1 )
{
    if ( var_0 maps\mp\_utility::isjuggernaut() )
        return 1;
    else if ( var_1 == "ims_projectile_mp" )
        return 1;

    return 0;
}

checknumusesofpersistentdata( var_0, var_1 )
{
    var_2 = self.pers[var_0];
    return isnumbermultipleof( var_2, var_1 );
}

isnumbermultipleof( var_0, var_1 )
{
    return var_0 > 0 && var_0 % var_1 == 0;
}

hasnoperks()
{
    if ( isdefined( self.pers["loadoutPerks"] ) )
        return self.pers["loadoutPerks"].size == 0;

    return 1;
}

fixbadoperationstate( var_0 )
{
    var_1 = level.challengeinfo[var_0]["targetval"].size;
    var_2 = maps\mp\gametypes\_hud_util::ch_getstate( var_0 );

    if ( var_2 > var_1 + 1 )
    {
        maps\mp\gametypes\_hud_util::ch_setstate( var_0, var_1 );
        maps\mp\gametypes\_hud_util::ch_setprogress( var_0, 0 );
    }
}

fixallbadoperations()
{
    fixbadoperationstate( "ch_atm" );
    fixbadoperationstate( "ch_breakbank" );
}
