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

init()
{
    level.perkfuncs = [];
    level.spawnglowmodel["enemy"] = "emergency_flare_iw6";
    level.spawnglowmodel["friendly"] = "emergency_flare_iw6";
    level.spawnglow["enemy"] = loadfx( "fx/misc/flare_ambient" );
    level.spawnglow["friendly"] = loadfx( "fx/misc/flare_ambient_green" );
    level.spawnfire = loadfx( "fx/props/barrelexp" );
    level._effect["ricochet"] = loadfx( "fx/impacts/large_metalhit_1" );
    level.scriptperks = [];
    level.perksetfuncs = [];
    level.perkunsetfuncs = [];
    level.fauxperks = [];
    level.scriptperks["_specialty_blastshield"] = 1;
    level.scriptperks["_specialty_onemanarmy"] = 1;
    level.scriptperks["_specialty_rearview"] = 1;
    level.scriptperks["specialty_ac130"] = 1;
    level.scriptperks["specialty_akimbo"] = 1;
    level.scriptperks["specialty_anytwo"] = 1;
    level.scriptperks["specialty_armorpiercing"] = 1;
    level.scriptperks["specialty_assists"] = 1;
    level.scriptperks["specialty_autospot"] = 1;
    level.scriptperks["specialty_blackbox"] = 1;
    level.scriptperks["specialty_blastshield"] = 1;
    level.scriptperks["specialty_bloodrush"] = 1;
    level.scriptperks["specialty_boom"] = 1;
    level.scriptperks["specialty_challenger"] = 1;
    level.scriptperks["specialty_combat_speed"] = 1;
    level.scriptperks["specialty_comexp"] = 1;
    level.scriptperks["specialty_concussiongrenade"] = 1;
    level.scriptperks["specialty_dangerclose"] = 1;
    level.scriptperks["specialty_deadeye"] = 1;
    level.scriptperks["specialty_delaymine"] = 1;
    level.scriptperks["specialty_double_load"] = 1;
    level.scriptperks["specialty_endgame"] = 1;
    level.scriptperks["specialty_explosivedamage"] = 1;
    level.scriptperks["specialty_extra_attachment"] = 1;
    level.scriptperks["specialty_extra_deadly"] = 1;
    level.scriptperks["specialty_extra_equipment"] = 1;
    level.scriptperks["specialty_extraspecialduration"] = 1;
    level.scriptperks["specialty_falldamage"] = 1;
    level.scriptperks["specialty_fasterlockon"] = 1;
    level.scriptperks["specialty_feigndeath"] = 1;
    level.scriptperks["specialty_flashgrenade"] = 1;
    level.scriptperks["specialty_gambler"] = 1;
    level.scriptperks["specialty_gunsmith"] = 1;
    level.scriptperks["specialty_hard_shell"] = 1;
    level.scriptperks["specialty_hardjack"] = 1;
    level.scriptperks["specialty_hardline"] = 1;
    level.scriptperks["specialty_helicopter_minigun"] = 1;
    level.scriptperks["specialty_incog"] = 1;
    level.scriptperks["specialty_laststandoffhand"] = 1;
    level.scriptperks["specialty_littlebird_support"] = 1;
    level.scriptperks["specialty_localjammer"] = 1;
    level.scriptperks["specialty_luckycharm"] = 1;
    level.scriptperks["specialty_moreHealth"] = 1;
    level.scriptperks["specialty_omaquickchange"] = 1;
    level.scriptperks["specialty_onemanarmy"] = 1;
    level.scriptperks["specialty_overkillpro"] = 1;
    level.scriptperks["specialty_paint"] = 1;
    level.scriptperks["specialty_paint_pro"] = 1;
    level.scriptperks["specialty_pitcher"] = 1;
    level.scriptperks["specialty_precision_airstrike"] = 1;
    level.scriptperks["specialty_predator_missile"] = 1;
    level.scriptperks["specialty_primarydeath"] = 1;
    level.scriptperks["specialty_rearview"] = 1;
    level.scriptperks["specialty_refill_ammo"] = 1;
    level.scriptperks["specialty_refill_grenades"] = 1;
    level.scriptperks["specialty_regenfaster"] = 1;
    level.scriptperks["specialty_rollover"] = 1;
    level.scriptperks["specialty_saboteur"] = 1;
    level.scriptperks["specialty_secondarybling"] = 1;
    level.scriptperks["specialty_sentry_minigun"] = 1;
    level.scriptperks["specialty_shellshock"] = 1;
    level.scriptperks["specialty_shield"] = 1;
    level.scriptperks["specialty_smokegrenade"] = 1;
    level.scriptperks["specialty_steadyaimpro"] = 1;
    level.scriptperks["specialty_steelnerves"] = 1;
    level.scriptperks["specialty_stun_resistance"] = 1;
    level.scriptperks["specialty_tagger"] = 1;
    level.scriptperks["specialty_tank"] = 1;
    level.scriptperks["specialty_thermal"] = 1;
    level.scriptperks["specialty_triggerhappy"] = 1;
    level.scriptperks["specialty_twoprimaries"] = 1;
    level.scriptperks["specialty_weaponlaser"] = 1;
    level.fauxperks["specialty_shield"] = 1;
    level.scriptperks["specialty_marksman"] = 1;
    level.scriptperks["specialty_sharp_focus"] = 1;
    level.scriptperks["specialty_bling"] = 1;
    level.scriptperks["specialty_moredamage"] = 1;
    level.scriptperks["specialty_rshieldradar"] = 1;
    level.scriptperks["specialty_rshieldscrambler"] = 1;
    level.scriptperks["specialty_combathigh"] = 1;
    level.scriptperks["specialty_finalstand"] = 1;
    level.scriptperks["specialty_c4death"] = 1;
    level.scriptperks["specialty_juiced"] = 1;
    level.scriptperks["specialty_revenge"] = 1;
    level.scriptperks["specialty_light_armor"] = 1;
    level.scriptperks["specialty_carepackage"] = 1;
    level.scriptperks["specialty_stopping_power"] = 1;
    level.scriptperks["specialty_uav"] = 1;
    level.scriptperks["bouncingbetty_mp"] = 1;
    level.scriptperks["c4_mp"] = 1;
    level.scriptperks["claymore_mp"] = 1;
    level.scriptperks["frag_grenade_mp"] = 1;
    level.scriptperks["semtex_mp"] = 1;
    level.scriptperks["throwingknife_mp"] = 1;
    level.scriptperks["throwingknifejugg_mp"] = 1;
    level.scriptperks["thermobaric_grenade_mp"] = 1;
    level.scriptperks["mortar_shell_mp"] = 1;
    level.scriptperks["proximity_explosive_mp"] = 1;
    level.scriptperks["mortar_shelljugg_mp"] = 1;
    level.scriptperks["concussion_grenade_mp"] = 1;
    level.scriptperks["flash_grenade_mp"] = 1;
    level.scriptperks["smoke_grenade_mp"] = 1;
    level.scriptperks["smoke_grenadejugg_mp"] = 1;
    level.scriptperks["emp_grenade_mp"] = 1;
    level.scriptperks["specialty_tacticalinsertion"] = 1;
    level.scriptperks["trophy_mp"] = 1;
    level.scriptperks["motion_sensor_mp"] = 1;
    level.scriptperks["specialty_null"] = 1;
    level.perksetfuncs["specialty_blastshield"] = maps\mp\perks\_perkfunctions::setblastshield;
    level.perkunsetfuncs["specialty_blastshield"] = maps\mp\perks\_perkfunctions::unsetblastshield;
    level.perksetfuncs["specialty_falldamage"] = maps\mp\perks\_perkfunctions::setfreefall;
    level.perkunsetfuncs["specialty_falldamage"] = maps\mp\perks\_perkfunctions::unsetfreefall;
    level.perksetfuncs["specialty_localjammer"] = maps\mp\perks\_perkfunctions::setlocaljammer;
    level.perkunsetfuncs["specialty_localjammer"] = maps\mp\perks\_perkfunctions::unsetlocaljammer;
    level.perksetfuncs["specialty_thermal"] = maps\mp\perks\_perkfunctions::setthermal;
    level.perkunsetfuncs["specialty_thermal"] = maps\mp\perks\_perkfunctions::unsetthermal;
    level.perksetfuncs["specialty_blackbox"] = maps\mp\perks\_perkfunctions::setblackbox;
    level.perkunsetfuncs["specialty_blackbox"] = maps\mp\perks\_perkfunctions::unsetblackbox;
    level.perksetfuncs["specialty_lightweight"] = maps\mp\perks\_perkfunctions::setlightweight;
    level.perkunsetfuncs["specialty_lightweight"] = maps\mp\perks\_perkfunctions::unsetlightweight;
    level.perksetfuncs["specialty_steelnerves"] = maps\mp\perks\_perkfunctions::setsteelnerves;
    level.perkunsetfuncs["specialty_steelnerves"] = maps\mp\perks\_perkfunctions::unsetsteelnerves;
    level.perksetfuncs["specialty_delaymine"] = maps\mp\perks\_perkfunctions::setdelaymine;
    level.perkunsetfuncs["specialty_delaymine"] = maps\mp\perks\_perkfunctions::unsetdelaymine;
    level.perksetfuncs["specialty_challenger"] = maps\mp\perks\_perkfunctions::setchallenger;
    level.perkunsetfuncs["specialty_challenger"] = maps\mp\perks\_perkfunctions::unsetchallenger;
    level.perksetfuncs["specialty_saboteur"] = maps\mp\perks\_perkfunctions::setsaboteur;
    level.perkunsetfuncs["specialty_saboteur"] = maps\mp\perks\_perkfunctions::unsetsaboteur;
    level.perksetfuncs["specialty_endgame"] = maps\mp\perks\_perkfunctions::setendgame;
    level.perkunsetfuncs["specialty_endgame"] = maps\mp\perks\_perkfunctions::unsetendgame;
    level.perksetfuncs["specialty_rearview"] = maps\mp\perks\_perkfunctions::setrearview;
    level.perkunsetfuncs["specialty_rearview"] = maps\mp\perks\_perkfunctions::unsetrearview;
    level.perksetfuncs["specialty_ac130"] = maps\mp\perks\_perkfunctions::setac130;
    level.perkunsetfuncs["specialty_ac130"] = maps\mp\perks\_perkfunctions::unsetac130;
    level.perksetfuncs["specialty_sentry_minigun"] = maps\mp\perks\_perkfunctions::setsentryminigun;
    level.perkunsetfuncs["specialty_sentry_minigun"] = maps\mp\perks\_perkfunctions::unsetsentryminigun;
    level.perksetfuncs["specialty_predator_missile"] = maps\mp\perks\_perkfunctions::setpredatormissile;
    level.perkunsetfuncs["specialty_predator_missile"] = maps\mp\perks\_perkfunctions::unsetpredatormissile;
    level.perksetfuncs["specialty_tank"] = maps\mp\perks\_perkfunctions::settank;
    level.perkunsetfuncs["specialty_tank"] = maps\mp\perks\_perkfunctions::unsettank;
    level.perksetfuncs["specialty_precision_airstrike"] = maps\mp\perks\_perkfunctions::setprecision_airstrike;
    level.perkunsetfuncs["specialty_precision_airstrike"] = maps\mp\perks\_perkfunctions::unsetprecision_airstrike;
    level.perksetfuncs["specialty_helicopter_minigun"] = maps\mp\perks\_perkfunctions::sethelicopterminigun;
    level.perkunsetfuncs["specialty_helicopter_minigun"] = maps\mp\perks\_perkfunctions::unsethelicopterminigun;
    level.perksetfuncs["specialty_onemanarmy"] = maps\mp\perks\_perkfunctions::setonemanarmy;
    level.perkunsetfuncs["specialty_onemanarmy"] = maps\mp\perks\_perkfunctions::unsetonemanarmy;
    level.perksetfuncs["specialty_littlebird_support"] = maps\mp\perks\_perkfunctions::setlittlebirdsupport;
    level.perkunsetfuncs["specialty_littlebird_support"] = maps\mp\perks\_perkfunctions::unsetlittlebirdsupport;
    level.perksetfuncs["specialty_tacticalinsertion"] = maps\mp\perks\_perkfunctions::settacticalinsertion;
    level.perkunsetfuncs["specialty_tacticalinsertion"] = maps\mp\perks\_perkfunctions::unsettacticalinsertion;
    level.perksetfuncs["specialty_weaponlaser"] = maps\mp\perks\_perkfunctions::setweaponlaser;
    level.perkunsetfuncs["specialty_weaponlaser"] = maps\mp\perks\_perkfunctions::unsetweaponlaser;
    level.perksetfuncs["specialty_steadyaimpro"] = maps\mp\perks\_perkfunctions::setsteadyaimpro;
    level.perkunsetfuncs["specialty_steadyaimpro"] = maps\mp\perks\_perkfunctions::unsetsteadyaimpro;
    level.perksetfuncs["specialty_stun_resistance"] = maps\mp\perks\_perkfunctions::setstunresistance;
    level.perkunsetfuncs["specialty_stun_resistance"] = maps\mp\perks\_perkfunctions::unsetstunresistance;
    level.perksetfuncs["specialty_marksman"] = maps\mp\perks\_perkfunctions::setmarksman;
    level.perkunsetfuncs["specialty_marksman"] = maps\mp\perks\_perkfunctions::unsetmarksman;
    level.perksetfuncs["specialty_rshieldradar"] = maps\mp\perks\_perkfunctions::setrshieldradar;
    level.perkunsetfuncs["specialty_rshieldradar"] = maps\mp\perks\_perkfunctions::unsetrshieldradar;
    level.perksetfuncs["specialty_rshieldscrambler"] = maps\mp\perks\_perkfunctions::setrshieldscrambler;
    level.perkunsetfuncs["specialty_rshieldscrambler"] = maps\mp\perks\_perkfunctions::unsetrshieldscrambler;
    level.perksetfuncs["specialty_double_load"] = maps\mp\perks\_perkfunctions::setdoubleload;
    level.perkunsetfuncs["specialty_double_load"] = maps\mp\perks\_perkfunctions::unsetdoubleload;
    level.perksetfuncs["specialty_sharp_focus"] = maps\mp\perks\_perkfunctions::setsharpfocus;
    level.perkunsetfuncs["specialty_sharp_focus"] = maps\mp\perks\_perkfunctions::unsetsharpfocus;
    level.perksetfuncs["specialty_hard_shell"] = maps\mp\perks\_perkfunctions::sethardshell;
    level.perkunsetfuncs["specialty_hard_shell"] = maps\mp\perks\_perkfunctions::unsethardshell;
    level.perksetfuncs["specialty_regenfaster"] = maps\mp\perks\_perkfunctions::setregenfaster;
    level.perkunsetfuncs["specialty_regenfaster"] = maps\mp\perks\_perkfunctions::unsetregenfaster;
    level.perksetfuncs["specialty_autospot"] = maps\mp\perks\_perkfunctions::setautospot;
    level.perkunsetfuncs["specialty_autospot"] = maps\mp\perks\_perkfunctions::unsetautospot;
    level.perksetfuncs["specialty_empimmune"] = maps\mp\perks\_perkfunctions::setempimmune;
    level.perkunsetfuncs["specialty_empimmune"] = maps\mp\perks\_perkfunctions::unsetempimmune;
    level.perksetfuncs["specialty_overkill_pro"] = maps\mp\perks\_perkfunctions::setoverkillpro;
    level.perkunsetfuncs["specialty_overkill_pro"] = maps\mp\perks\_perkfunctions::unsetoverkillpro;
    level.perksetfuncs["specialty_assists"] = maps\mp\perks\_perkfunctions::setassists;
    level.perkunsetfuncs["specialty_assists"] = maps\mp\perks\_perkfunctions::unsetassists;
    level.perksetfuncs["specialty_refill_grenades"] = maps\mp\perks\_perkfunctions::setrefillgrenades;
    level.perkunsetfuncs["specialty_refill_grenades"] = maps\mp\perks\_perkfunctions::unsetrefillgrenades;
    level.perksetfuncs["specialty_refill_ammo"] = maps\mp\perks\_perkfunctions::setrefillammo;
    level.perkunsetfuncs["specialty_refill_ammo"] = maps\mp\perks\_perkfunctions::unsetrefillammo;
    level.perksetfuncs["specialty_combat_speed"] = maps\mp\perks\_perkfunctions::setcombatspeed;
    level.perkunsetfuncs["specialty_combat_speed"] = maps\mp\perks\_perkfunctions::unsetcombatspeed;
    level.perksetfuncs["specialty_gambler"] = maps\mp\perks\_perkfunctions::setgambler;
    level.perkunsetfuncs["specialty_gambler"] = maps\mp\perks\_perkfunctions::unsetgambler;
    level.perksetfuncs["specialty_comexp"] = maps\mp\perks\_perkfunctions::setcomexp;
    level.perkunsetfuncs["specialty_comexp"] = maps\mp\perks\_perkfunctions::unsetcomexp;
    level.perksetfuncs["specialty_gunsmith"] = maps\mp\perks\_perkfunctions::setgunsmith;
    level.perkunsetfuncs["specialty_gunsmith"] = maps\mp\perks\_perkfunctions::unsetgunsmith;
    level.perksetfuncs["specialty_tagger"] = maps\mp\perks\_perkfunctions::settagger;
    level.perkunsetfuncs["specialty_tagger"] = maps\mp\perks\_perkfunctions::unsettagger;
    level.perksetfuncs["specialty_pitcher"] = maps\mp\perks\_perkfunctions::setpitcher;
    level.perkunsetfuncs["specialty_pitcher"] = maps\mp\perks\_perkfunctions::unsetpitcher;
    level.perksetfuncs["specialty_boom"] = maps\mp\perks\_perkfunctions::setboom;
    level.perkunsetfuncs["specialty_boom"] = maps\mp\perks\_perkfunctions::unsetboom;
    level.perksetfuncs["specialty_silentkill"] = maps\mp\perks\_perkfunctions::setsilentkill;
    level.perkunsetfuncs["specialty_silentkill"] = maps\mp\perks\_perkfunctions::unsetsilentkill;
    level.perksetfuncs["specialty_bloodrush"] = maps\mp\perks\_perkfunctions::setbloodrush;
    level.perkunsetfuncs["specialty_bloodrush"] = maps\mp\perks\_perkfunctions::unsetbloodrush;
    level.perksetfuncs["specialty_triggerhappy"] = maps\mp\perks\_perkfunctions::settriggerhappy;
    level.perkunsetfuncs["specialty_triggerhappy"] = maps\mp\perks\_perkfunctions::unsettriggerhappy;
    level.perksetfuncs["specialty_deadeye"] = maps\mp\perks\_perkfunctions::setdeadeye;
    level.perkunsetfuncs["specialty_deadeye"] = maps\mp\perks\_perkfunctions::unsetdeadeye;
    level.perksetfuncs["specialty_incog"] = maps\mp\perks\_perkfunctions::setincog;
    level.perkunsetfuncs["specialty_incog"] = maps\mp\perks\_perkfunctions::unsetincog;
    level.perksetfuncs["specialty_blindeye"] = maps\mp\perks\_perkfunctions::setblindeye;
    level.perkunsetfuncs["specialty_blindeye"] = maps\mp\perks\_perkfunctions::unsetblindeye;
    level.perksetfuncs["specialty_quickswap"] = maps\mp\perks\_perkfunctions::setquickswap;
    level.perkunsetfuncs["specialty_quickswap"] = maps\mp\perks\_perkfunctions::unsetquickswap;
    level.perksetfuncs["specialty_extraammo"] = maps\mp\perks\_perkfunctions::setextraammo;
    level.perkunsetfuncs["specialty_extraammo"] = maps\mp\perks\_perkfunctions::unsetextraammo;
    level.perksetfuncs["specialty_extra_equipment"] = maps\mp\perks\_perkfunctions::setextraequipment;
    level.perkunsetfuncs["specialty_extra_equipment"] = maps\mp\perks\_perkfunctions::unsetextraequipment;
    level.perksetfuncs["specialty_extra_deadly"] = maps\mp\perks\_perkfunctions::setextradeadly;
    level.perkunsetfuncs["specialty_extra_deadly"] = maps\mp\perks\_perkfunctions::unsetextradeadly;
    level.perksetfuncs["specialty_combathigh"] = maps\mp\perks\_perkfunctions::setcombathigh;
    level.perkunsetfuncs["specialty_combathigh"] = maps\mp\perks\_perkfunctions::unsetcombathigh;
    level.perksetfuncs["specialty_light_armor"] = maps\mp\perks\_perkfunctions::setlightarmor;
    level.perkunsetfuncs["specialty_light_armor"] = maps\mp\perks\_perkfunctions::unsetlightarmor;
    level.perksetfuncs["specialty_revenge"] = maps\mp\perks\_perkfunctions::setrevenge;
    level.perkunsetfuncs["specialty_revenge"] = maps\mp\perks\_perkfunctions::unsetrevenge;
    level.perksetfuncs["specialty_c4death"] = maps\mp\perks\_perkfunctions::setc4death;
    level.perkunsetfuncs["specialty_c4death"] = maps\mp\perks\_perkfunctions::unsetc4death;
    level.perksetfuncs["specialty_finalstand"] = maps\mp\perks\_perkfunctions::setfinalstand;
    level.perkunsetfuncs["specialty_finalstand"] = maps\mp\perks\_perkfunctions::unsetfinalstand;
    level.perksetfuncs["specialty_juiced"] = maps\mp\perks\_perkfunctions::setjuiced;
    level.perkunsetfuncs["specialty_juiced"] = maps\mp\perks\_perkfunctions::unsetjuiced;
    level.perksetfuncs["specialty_carepackage"] = maps\mp\perks\_perkfunctions::setcarepackage;
    level.perkunsetfuncs["specialty_carepackage"] = maps\mp\perks\_perkfunctions::unsetcarepackage;
    level.perksetfuncs["specialty_stopping_power"] = maps\mp\perks\_perkfunctions::setstoppingpower;
    level.perkunsetfuncs["specialty_stopping_power"] = maps\mp\perks\_perkfunctions::unsetstoppingpower;
    level.perksetfuncs["specialty_uav"] = maps\mp\perks\_perkfunctions::setuav;
    level.perkunsetfuncs["specialty_uav"] = maps\mp\perks\_perkfunctions::unsetuav;
    initperkdvars();
    level thread onplayerconnect();
}

validateequipment( var_0, var_1, var_2 )
{
    var_2 = common_scripts\utility::ter_op( isdefined( var_2 ), var_2, 1 );
    var_0 = common_scripts\utility::ter_op( var_0 == "none", "specialty_null", var_0 );

    if ( var_1 )
    {
        switch ( var_0 )
        {
            case "proximity_explosive_mp":
            case "semtex_mp":
            case "c4_mp":
            case "throwingknifejugg_mp":
            case "throwingknife_mp":
            case "mortar_shelljugg_mp":
            case "mortar_shell_mp":
            case "frag_grenade_mp":
            case "specialty_null":
                break;
            default:
                var_0 = "specialty_null";
                break;
        }
    }
    else
    {
        switch ( var_0 )
        {
            case "concussion_grenade_mp":
            case "smoke_grenadejugg_mp":
            case "smoke_grenade_mp":
            case "thermobaric_grenade_mp":
            case "motion_sensor_mp":
            case "flash_grenade_mp":
            case "trophy_mp":
            case "specialty_null":
                break;
            default:
                var_0 = "specialty_null";
                break;
        }
    }

    return var_0;
}

validateperk( var_0 )
{
    if ( !maps\mp\_utility::perksenabled() )
        var_0 = "specialty_null";
    else
    {
        switch ( var_0 )
        {
            case "specialty_deadeye":
            case "specialty_explosivedamage":
            case "specialty_comexp":
            case "specialty_gpsjammer":
            case "specialty_quickdraw":
            case "specialty_stalker":
            case "specialty_boom":
            case "specialty_extraammo":
            case "specialty_extra_deadly":
            case "_specialty_blastshield":
            case "specialty_regenfaster":
            case "specialty_selectivehearing":
            case "specialty_detectexplosive":
            case "specialty_scavenger":
            case "specialty_quieter":
            case "specialty_marathon":
            case "specialty_lightweight":
            case "specialty_fastreload":
            case "specialty_gambler":
            case "specialty_extra_equipment":
            case "specialty_falldamage":
            case "specialty_paint":
            case "specialty_silentkill":
            case "specialty_sprintreload":
            case "specialty_pitcher":
            case "specialty_fastsprintrecovery":
            case "specialty_extra_attachment":
            case "specialty_twoprimaries":
            case "specialty_bulletaccuracy":
            case "specialty_quickswap":
            case "specialty_sharp_focus":
            case "specialty_blindeye":
            case "specialty_incog":
            case "specialty_hardline":
            case "specialty_stun_resistance":
            case "specialty_null":
                break;
            default:
                var_0 = "specialty_null";
                break;
        }
    }

    return var_0;
}

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

onplayerspawned()
{
    self endon( "disconnect" );
    self.perks = [];
    self.perksperkname = [];
    self.perksuseslot = [];
    self.weaponlist = [];
    self.omaclasschanged = 0;

    for (;;)
    {
        self waittill( "spawned_player" );
        self.omaclasschanged = 0;
        thread maps\mp\killstreaks\_portableaoegenerator::generatoraoetracker();
    }
}

thermodebuffwatcher()
{
    self endon( "disconnect" );
    level endon( "game_ended" );
    var_0 = gettime() + 5000;
    wait 0.05;
    self.thermodebuffed = 1;

    for (;;)
    {
        if ( self.health == self.maxhealth )
        {
            self.thermodebuffed = 0;
            return;
        }

        if ( gettime() >= var_0 )
        {
            self.thermodebuffed = 0;
            return;
        }

        wait 0.05;
    }
}

cac_modified_damage( var_0, var_1, var_2, var_3, var_4, var_5, var_6, var_7, var_8 )
{
    if ( maps\mp\_utility::matchmakinggame() && self.maxhealth > 100 )
    {
        if ( isdefined( var_4 ) && weaponclass( var_4 ) == "spread" )
            var_2 = var_2 * ( self.maxhealth / 100 );
    }

    var_9 = 0;
    var_10 = 0;

    if ( var_0 maps\mp\_utility::isjuggernaut() )
    {
        var_10 = level.juggernautmod;

        if ( isdefined( self.isjuggernautmaniac ) && self.isjuggernautmaniac )
            var_10 = level.juggernautmaniacmod;
    }

    if ( maps\mp\_utility::isbulletdamage( var_3 ) )
    {
        if ( maps\mp\_utility::isfmjdamage( var_4, var_3, var_1 ) )
            var_10 = var_10 * level.armorpiercingmod;

        if ( isplayer( var_1 ) && var_1 maps\mp\_utility::_hasperk( "specialty_paint_pro" ) && !maps\mp\_utility::iskillstreakweapon( var_4 ) )
        {
            if ( !var_0 maps\mp\perks\_perkfunctions::ispainted() )
                var_1 maps\mp\gametypes\_missions::processchallenge( "ch_bulletpaint" );

            var_0 thread maps\mp\perks\_perkfunctions::setpainted( var_1 );
        }

        if ( isplayer( var_1 ) && ( var_1 maps\mp\_utility::_hasperk( "specialty_bulletdamage" ) && var_0 maps\mp\_utility::_hasperk( "specialty_armorvest" ) ) )
        {

        }
        else if ( isplayer( var_1 ) && ( var_1 maps\mp\_utility::_hasperk( "specialty_bulletdamage" ) || var_1 maps\mp\_utility::_hasperk( "specialty_moredamage" ) ) )
            var_9 = var_9 + var_2 * level.bulletdamagemod;
        else if ( var_0 maps\mp\_utility::_hasperk( "specialty_armorvest" ) )
            var_9 = var_9 - var_2 * level.armorvestmod;

        if ( var_0 maps\mp\_utility::isjuggernaut() )
        {
            if ( level.hardcoremode && isdefined( var_4 ) && weaponclass( var_4 ) == "spread" )
            {
                var_2 = min( var_2, 25 ) * var_10;
                var_9 = min( var_2, 25 ) * var_10;
            }
            else
            {
                var_2 = var_2 * var_10;
                var_9 = var_9 * var_10;
            }
        }
    }
    else if ( isexplosivedamagemod( var_3 ) )
    {
        if ( var_4 == "proximity_explosive_mp" && isdefined( var_8.origin ) )
        {
            if ( var_0 getstance() == "prone" )
                var_2 = var_2 * 0.65;
            else if ( !var_0 isonground() )
                var_2 = var_2 * 0.8;
            else if ( var_0 getstance() == "crouch" )
                var_2 = var_2 * 0.9;
        }

        if ( isplayer( var_1 ) )
        {
            if ( var_1 != var_0 && ( var_1 isitemunlocked( "specialty_paint" ) && var_1 maps\mp\_utility::_hasperk( "specialty_paint" ) ) && !maps\mp\_utility::iskillstreakweapon( var_4 ) )
            {
                if ( !var_0 maps\mp\perks\_perkfunctions::ispainted() )
                    var_1 maps\mp\gametypes\_missions::processchallenge( "ch_paint_pro" );

                var_0 thread maps\mp\perks\_perkfunctions::setpainted( var_1 );
            }
        }

        if ( isdefined( var_0.thermodebuffed ) && var_0.thermodebuffed )
            var_9 = var_9 + int( var_2 * level.thermodebuffmod );

        if ( var_4 == "thermobaric_grenade_mp" )
        {
            if ( level.hardcoremode )
                var_2 = var_2 * 0.3;

            var_0 thread thermodebuffwatcher();
        }

        if ( isplayer( var_1 ) && weaponinheritsperks( var_4 ) && ( var_1 maps\mp\_utility::_hasperk( "specialty_explosivedamage" ) && var_0 maps\mp\_utility::_hasperk( "_specialty_blastshield" ) ) )
        {

        }
        else if ( isplayer( var_1 ) && weaponinheritsperks( var_4 ) && !maps\mp\_utility::iskillstreakweapon( var_4 ) && var_1 maps\mp\_utility::_hasperk( "specialty_explosivedamage" ) )
            var_9 = var_9 + var_2 * level.explosivedamagemod;
        else if ( var_0 maps\mp\_utility::_hasperk( "_specialty_blastshield" ) && !maps\mp\_utility::weaponignoresblastshield( var_4 ) && ( !isdefined( var_8 ) || !isdefined( var_8.stuckenemyentity ) || var_8.stuckenemyentity != var_0 ) )
        {
            var_11 = int( var_2 * level.blastshieldmod );

            if ( maps\mp\gametypes\_weapons::isgrenade( var_4 ) || maps\mp\_utility::isweaponaffectedbyblastshield( var_4 ) )
                var_11 = clamp( var_11, 0, level.blastshieldclamp );

            var_9 = var_9 - ( var_2 - var_11 );
        }

        if ( var_0 maps\mp\_utility::isjuggernaut() )
        {
            var_9 = var_9 * var_10;

            if ( var_2 < 1000 )
                var_2 = var_2 * var_10;
        }

        if ( !maps\mp\_utility::is_aliens() )
        {
            if ( 10 - ( level.graceperiod - level.ingraceperiod ) > 0 )
                var_2 = var_2 * level.graceperiodgrenademod;
        }
    }
    else if ( var_3 == "MOD_FALLING" )
    {
        if ( var_0 maps\mp\_utility::_hasperk( "specialty_falldamage" ) )
        {
            if ( var_2 > 0 )
                var_0 maps\mp\gametypes\_missions::processchallenge( "ch_falldamage" );

            var_9 = 0;
            var_2 = 0;
        }
        else if ( var_0 maps\mp\_utility::isjuggernaut() )
            var_2 = var_2 * var_10;
    }
    else if ( var_3 == "MOD_MELEE" )
    {
        if ( var_0 maps\mp\_utility::isjuggernaut() )
        {
            var_2 = 20;
            var_9 = 0;
        }
        else if ( maps\mp\perks\_perkfunctions::hasheavyarmor( var_0 ) )
            var_2 = 100;
        else if ( isdefined( var_0.custommeleedamagetaken ) && var_0.custommeleedamagetaken >= 0 )
            var_2 = var_0.custommeleedamagetaken;
        else if ( maps\mp\gametypes\_weapons::isriotshield( var_4 ) )
        {
            if ( level.hardcoremode )
                var_2 = int( var_0.maxhealth + 1 );
            else
                var_2 = int( var_0.maxhealth * 0.66 );
        }
        else
            var_2 = var_0.maxhealth + 1;
    }
    else if ( var_3 == "MOD_IMPACT" )
    {
        if ( var_0 maps\mp\_utility::isjuggernaut() )
        {
            switch ( var_4 )
            {
                case "semtexproj_mp":
                case "semtex_mp":
                case "concussion_grenade_mp":
                case "smoke_grenadejugg_mp":
                case "smoke_grenade_mp":
                case "flash_grenade_mp":
                case "mortar_shelljugg_mp":
                case "mortar_shell_mp":
                case "frag_grenade_mp":
                    var_2 = 5;
                    break;
                default:
                    if ( var_2 < 1000 )
                        var_2 = 25;

                    break;
            }

            var_9 = 0;
        }
    }
    else if ( var_3 == "MOD_UNKNOWN" || var_3 == "MOD_MELEE_DOG" )
    {
        if ( isagent( var_1 ) && isdefined( var_1.agent_type ) && var_1.agent_type == "dog" && var_0 maps\mp\_utility::isjuggernaut() )
        {
            var_0 shellshock( "dog_bite", 2 );
            var_2 = var_2 * var_10;
        }
    }

    if ( var_0 maps\mp\_utility::_hasperk( "specialty_combathigh" ) )
    {
        if ( isdefined( self.damageblockedtotal ) && ( !level.teambased || isdefined( var_1 ) && isdefined( var_1.team ) && var_0.team != var_1.team ) )
        {
            var_12 = var_2 + var_9;
            var_13 = var_12 - var_12 / 3;
            self.damageblockedtotal = self.damageblockedtotal + var_13;

            if ( self.damageblockedtotal >= 101 )
            {
                self notify( "combathigh_survived" );
                self.damageblockedtotal = undefined;
            }
        }

        if ( var_4 != "throwingknife_mp" && var_4 != "throwingknifejugg_mp" )
        {
            switch ( var_3 )
            {
                case "MOD_FALLING":
                case "MOD_MELEE":
                    break;
                default:
                    var_2 = int( var_2 / 3 );
                    var_9 = int( var_9 / 3 );
                    break;
            }
        }
    }

    if ( isdefined( var_0.lightarmorhp ) )
    {
        switch ( var_4 )
        {
            case "throwingknifejugg_mp":
            case "throwingknife_mp":
                var_2 = var_0.health;
                var_9 = 0;
                break;
            case "semtexproj_mp":
            case "semtex_mp":
                if ( isdefined( var_8 ) && isdefined( var_8.stuckenemyentity ) && var_8.stuckenemyentity == var_0 )
                {
                    var_2 = var_0.health;
                    var_9 = 0;
                }

                break;
            default:
                if ( var_3 != "MOD_FALLING" && var_3 != "MOD_MELEE" && !maps\mp\_utility::isheadshot( var_4, var_7, var_3, var_1 ) && !maps\mp\_utility::isfmjdamage( var_4, var_3, var_1 ) )
                {
                    var_0.lightarmorhp = var_0.lightarmorhp - ( var_2 + var_9 );
                    var_2 = 0;
                    var_9 = 0;

                    if ( var_0.lightarmorhp <= 0 )
                    {
                        var_2 = abs( var_0.lightarmorhp );
                        var_9 = 0;
                        maps\mp\perks\_perkfunctions::unsetlightarmor();
                    }
                }

                break;
        }
    }

    if ( maps\mp\perks\_perkfunctions::hasheavyarmor( var_0 ) )
    {
        var_0.heavyarmorhp = var_0.heavyarmorhp - ( var_2 + var_9 );
        var_2 = 0;

        if ( var_0.heavyarmorhp < 0 )
            var_2 = abs( var_0.heavyarmorhp );
    }

    if ( !maps\mp\_utility::is_aliens() && var_2 <= 1 )
        var_2 = 1;
    else
        var_2 = int( var_2 + var_9 );

    return var_2;
}

initperkdvars()
{
    level.graceperiodgrenademod = 0.08;
    level.juggernautmod = 0.08;
    level.juggernautmaniacmod = 0.08;
    level.armorpiercingmod = 1.5;
    level.regenfastermod = maps\mp\_utility::getintproperty( "perk_fastRegenWaitMS", 500 ) / 1000;
    level.regenfasterhealthmod = maps\mp\_utility::getintproperty( "perk_fastRegenRate", 2 );
    level.bulletdamagemod = maps\mp\_utility::getintproperty( "perk_bulletDamage", 40 ) / 100;
    level.explosivedamagemod = maps\mp\_utility::getintproperty( "perk_explosiveDamage", 40 ) / 100;
    level.blastshieldmod = maps\mp\_utility::getintproperty( "perk_blastShieldScale", 65 ) / 100;
    level.blastshieldclamp = maps\mp\_utility::getintproperty( "perk_blastShieldClampHP", 80 );
    level.thermodebuffmod = maps\mp\_utility::getintproperty( "weap_thermoDebuffMod", 185 ) / 100;
    level.riotshieldmod = maps\mp\_utility::getintproperty( "perk_riotShield", 100 ) / 100;
    level.armorvestmod = maps\mp\_utility::getintproperty( "perk_armorVest", 75 ) / 100;

    if ( isdefined( level.hardcoremode ) && level.hardcoremode )
    {
        level.blastshieldmod = maps\mp\_utility::getintproperty( "perk_blastShieldScale_HC", 10 ) / 100;
        level.blastshieldclamp = maps\mp\_utility::getintproperty( "perk_blastShieldClampHP_HC", 20 );
    }
}

cac_selector()
{
    var_0 = self.specialty;
}

giveperksafterspawn()
{
    self endon( "death" );
    self endon( "disconnect" );
    var_0 = [];

    if ( !maps\mp\_utility::_hasperk( "specialty_blindeye" ) )
    {
        maps\mp\_utility::giveperk( "specialty_blindeye", 0 );
        var_0[var_0.size] = "specialty_blindeye";
    }

    if ( !maps\mp\_utility::_hasperk( "specialty_gpsjammer" ) )
    {
        maps\mp\_utility::giveperk( "specialty_gpsjammer", 0 );
        var_0[var_0.size] = "specialty_gpsjammer";
    }

    if ( var_0.size > 0 )
    {
        self.spawnperk = 1;

        while ( self.avoidkillstreakonspawntimer > 0 )
        {
            self.avoidkillstreakonspawntimer = self.avoidkillstreakonspawntimer - 0.05;
            wait 0.05;
        }

        foreach ( var_2 in var_0 )
            maps\mp\_utility::_unsetperk( var_2 );

        self.spawnperk = 0;
        self notify( "starting_perks_unset" );
    }
}

getperkicon( var_0 )
{
    return tablelookup( "mp/perkTable.csv", 1, var_0, 3 );
}

getperkname( var_0 )
{
    return tablelookupistring( "mp/perkTable.csv", 1, var_0, 2 );
}

updateactiveperks( var_0, var_1, var_2, var_3, var_4 )
{
    if ( isdefined( var_0 ) && isplayer( var_0 ) && isdefined( var_1 ) && isplayer( var_1 ) && var_1 != var_2 )
    {
        if ( var_1 maps\mp\_utility::_hasperk( "specialty_triggerhappy" ) )
            var_1 thread maps\mp\perks\_perkfunctions::settriggerhappyinternal();

        if ( var_1 maps\mp\_utility::_hasperk( "specialty_boom" ) )
            var_2 thread maps\mp\perks\_perkfunctions::setboominternal( var_1 );

        if ( var_1 maps\mp\_utility::_hasperk( "specialty_bloodrush" ) )
            var_1 thread maps\mp\perks\_perkfunctions::setbloodrushinternal();

        if ( var_1 maps\mp\_utility::_hasperk( "specialty_deadeye" ) )
            var_1.deadeyekillcount++;

        var_5 = var_1.pers["abilityRecharging"];

        if ( isdefined( var_5 ) && var_5 )
            var_1 notify( "abilityFastRecharge" );

        var_6 = var_1.pers["abilityOn"];

        if ( isdefined( var_6 ) && var_6 )
            var_1 notify( "abilityExtraTime" );
    }
}
