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

setoverkillpro()
{

}

unsetoverkillpro()
{

}

setempimmune()
{

}

unsetempimmune()
{

}

setautospot()
{
    if ( !isplayer( self ) )
        return;

    autospotadswatcher();
    autospotdeathwatcher();
}

autospotdeathwatcher()
{
    self waittill( "death" );
    self endon( "disconnect" );
    self endon( "endAutoSpotAdsWatcher" );
    level endon( "game_ended" );
    self autospotoverlayoff();
}

unsetautospot()
{
    if ( !isplayer( self ) )
        return;

    self notify( "endAutoSpotAdsWatcher" );
    self autospotoverlayoff();
}

autospotadswatcher()
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "endAutoSpotAdsWatcher" );
    level endon( "game_ended" );
    var_0 = 0;

    for (;;)
    {
        wait 0.05;

        if ( self isusingturret() )
        {
            self autospotoverlayoff();
            continue;
        }

        var_1 = self playerads();

        if ( var_1 < 1 && var_0 )
        {
            var_0 = 0;
            self autospotoverlayoff();
        }

        if ( var_1 < 1 && !var_0 )
            continue;

        if ( var_1 == 1 && !var_0 )
        {
            var_0 = 1;
            self autospotoverlayon();
        }
    }
}

setregenfaster()
{

}

unsetregenfaster()
{

}

timeoutregenfaster()
{
    self.hasregenfaster = undefined;
    maps\mp\_utility::_unsetperk( "specialty_regenfaster" );
    self setclientdvar( "ui_regen_faster_end_milliseconds", 0 );
    self notify( "timeOutRegenFaster" );
}

sethardshell()
{
    self.shellshockreduction = 0.25;
}

unsethardshell()
{
    self.shellshockreduction = 0;
}

setsharpfocus()
{
    thread monitorsharpfocus();
}

monitorsharpfocus()
{
    self endon( "death" );
    self endon( "disconnect" );
    level endon( "game_ended" );
    self endon( "stop_monitorSharpFocus" );

    if ( !isdefined( level.snipers ) )
    {
        level.snipers = [];
        level.snipers["iw6_gm6_mp"] = 1;
        level.snipers["iw6_l115a3_mp"] = 1;
        level.snipers["iw6_usr_mp"] = 1;
        level.snipers["iw6_vks_mp"] = 1;
        level.snipers["iw6_dlcweap03_mp"] = 1;
    }

    var_0 = self getcurrentweapon();

    for (;;)
    {
        var_1 = undefined;

        if ( isdefined( var_0 ) && var_0 != "none" )
            var_1 = getweaponbasename( var_0 );

        if ( isdefined( var_1 ) && isdefined( level.snipers[var_1] ) )
            self setviewkickscale( 0.5 );
        else
            self setviewkickscale( 0.25 );

        self waittill( "weapon_change", var_0 );
    }
}

unsetsharpfocus()
{
    self notify( "stop_monitorSharpFocus" );
    self setviewkickscale( 1.0 );
}

setdoubleload()
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "endDoubleLoad" );
    level endon( "game_ended" );

    for (;;)
    {
        self waittill( "reload" );
        var_0 = self getweaponslist( "primary" );

        foreach ( var_2 in var_0 )
        {
            var_3 = self getweaponammoclip( var_2 );
            var_4 = weaponclipsize( var_2 );
            var_5 = var_4 - var_3;
            var_6 = self getweaponammostock( var_2 );

            if ( var_3 != var_4 && var_6 > 0 )
            {
                if ( var_3 + var_6 >= var_4 )
                {
                    self setweaponammoclip( var_2, var_4 );
                    self setweaponammostock( var_2, var_6 - var_5 );
                    continue;
                }

                self setweaponammoclip( var_2, var_3 + var_6 );

                if ( var_6 - var_5 > 0 )
                {
                    self setweaponammostock( var_2, var_6 - var_5 );
                    continue;
                }

                self setweaponammostock( var_2, 0 );
            }
        }
    }
}

unsetdoubleload()
{
    self notify( "endDoubleLoad" );
}

setmarksman( var_0 )
{
    if ( !isdefined( var_0 ) )
        var_0 = 10;
    else
        var_0 = int( var_0 ) * 2;

    maps\mp\_utility::setrecoilscale( var_0 );
    self.recoilscale = var_0;
}

unsetmarksman()
{
    maps\mp\_utility::setrecoilscale( 0 );
    self.recoilscale = 0;
}

setrshieldradar()
{
    self endon( "unsetRShieldRadar" );
    wait 0.75;
    self makeportableradar();
    thread setrshieldradar_cleanup();
}

setrshieldradar_cleanup()
{
    self endon( "unsetRShieldRadar" );
    common_scripts\utility::waittill_any( "disconnect", "death" );

    if ( isdefined( self ) )
        unsetrshieldradar();
}

unsetrshieldradar()
{
    self clearportableradar();
    self notify( "unsetRShieldRadar" );
}

setrshieldscrambler()
{
    self makescrambler();
    thread setrshieldscrambler_cleanup();
}

setrshieldscrambler_cleanup()
{
    self endon( "unsetRShieldScrambler" );
    common_scripts\utility::waittill_any( "disconnect", "death" );

    if ( isdefined( self ) )
        unsetrshieldscrambler();
}

unsetrshieldscrambler()
{
    self clearscrambler();
    self notify( "unsetRShieldScrambler" );
}

setstunresistance( var_0 )
{
    if ( !isdefined( var_0 ) )
        var_0 = 10;

    var_0 = int( var_0 );

    if ( var_0 == 10 )
        self.stunscaler = 0;
    else
        self.stunscaler = var_0 / 10;
}

unsetstunresistance()
{
    self.stunscaler = 1;
}

applystunresistence( var_0 )
{
    if ( isdefined( self.stunscaler ) )
        return self.stunscaler * var_0;
    else
        return var_0;
}

setweaponlaser()
{
    if ( isagent( self ) )
        return;

    self endon( "unsetWeaponLaser" );
    wait 0.5;
    thread setweaponlaser_internal();
}

unsetweaponlaser()
{
    self notify( "unsetWeaponLaser" );

    if ( isdefined( self.perkweaponlaseron ) && self.perkweaponlaseron )
        maps\mp\_utility::disableweaponlaser();

    self.perkweaponlaseron = undefined;
    self.perkweaponlaseroffforswitchstart = undefined;
}

setweaponlaser_waitforlaserweapon( var_0 )
{
    for (;;)
    {
        var_0 = getweaponbasename( var_0 );

        if ( isdefined( var_0 ) && ( var_0 == "iw6_kac_mp" || var_0 == "iw6_arx160_mp" ) )
            break;

        self waittill( "weapon_change", var_0 );
    }
}

setweaponlaser_internal()
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "unsetWeaponLaser" );
    self.perkweaponlaseron = 0;
    var_0 = self getcurrentweapon();

    for (;;)
    {
        setweaponlaser_waitforlaserweapon( var_0 );

        if ( self.perkweaponlaseron == 0 )
        {
            self.perkweaponlaseron = 1;
            maps\mp\_utility::enableweaponlaser();
        }

        childthread setweaponlaser_monitorads();
        childthread setweaponlaser_monitorweaponswitchstart( 1.0 );
        self.perkweaponlaseroffforswitchstart = undefined;
        self waittill( "weapon_change", var_0 );

        if ( self.perkweaponlaseron == 1 )
        {
            self.perkweaponlaseron = 0;
            maps\mp\_utility::disableweaponlaser();
        }
    }
}

setweaponlaser_monitorweaponswitchstart( var_0 )
{
    self endon( "weapon_change" );

    for (;;)
    {
        self waittill( "weapon_switch_started" );
        childthread setweaponlaser_onweaponswitchstart( var_0 );
    }
}

setweaponlaser_onweaponswitchstart( var_0 )
{
    self notify( "setWeaponLaser_onWeaponSwitchStart" );
    self endon( "setWeaponLaser_onWeaponSwitchStart" );

    if ( self.perkweaponlaseron == 1 )
    {
        self.perkweaponlaseroffforswitchstart = 1;
        self.perkweaponlaseron = 0;
        maps\mp\_utility::disableweaponlaser();
    }

    wait( var_0 );
    self.perkweaponlaseroffforswitchstart = undefined;

    if ( self.perkweaponlaseron == 0 && self playerads() <= 0.6 )
    {
        self.perkweaponlaseron = 1;
        maps\mp\_utility::enableweaponlaser();
    }
}

setweaponlaser_monitorads()
{
    self endon( "weapon_change" );

    for (;;)
    {
        if ( !isdefined( self.perkweaponlaseroffforswitchstart ) || self.perkweaponlaseroffforswitchstart == 0 )
        {
            if ( self playerads() > 0.6 )
            {
                if ( self.perkweaponlaseron == 1 )
                {
                    self.perkweaponlaseron = 0;
                    maps\mp\_utility::disableweaponlaser();
                }
            }
            else if ( self.perkweaponlaseron == 0 )
            {
                self.perkweaponlaseron = 1;
                maps\mp\_utility::enableweaponlaser();
            }
        }

        common_scripts\utility::waitframe();
    }
}

setsteadyaimpro()
{
    self setaimspreadmovementscale( 0.5 );
}

unsetsteadyaimpro()
{
    self notify( "end_SteadyAimPro" );
    self setaimspreadmovementscale( 1.0 );
}

blastshieldusetracker( var_0, var_1 )
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "end_perkUseTracker" );
    level endon( "game_ended" );

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

        if ( !common_scripts\utility::isoffhandweaponenabled() )
            continue;

        self [[ var_1 ]]( maps\mp\_utility::_hasperk( "_specialty_blastshield" ) );
    }
}

perkusedeathtracker()
{
    self endon( "disconnect" );
    self waittill( "death" );
    self._useperkenabled = undefined;
}

setrearview()
{

}

unsetrearview()
{
    self notify( "end_perkUseTracker" );
}

setendgame()
{
    if ( isdefined( self.endgame ) )
        return;

    self.maxhealth = maps\mp\gametypes\_tweakables::gettweakablevalue( "player", "maxhealth" ) * 4;
    self.health = self.maxhealth;
    self.endgame = 1;
    self.attackertable[0] = "";
    self visionsetnakedforplayer( "end_game", 5 );
    thread endgamedeath( 7 );
    maps\mp\gametypes\_gamelogic::sethasdonecombat( self, 1 );
}

unsetendgame()
{
    self notify( "stopEndGame" );
    self.endgame = undefined;
    maps\mp\_utility::restorebasevisionset( 1 );

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

    self.endgametimer maps\mp\gametypes\_hud_util::destroyelem();
    self.endgameicon maps\mp\gametypes\_hud_util::destroyelem();
}

endgamedeath( var_0 )
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "joined_team" );
    level endon( "game_ended" );
    self endon( "stopEndGame" );
    wait( var_0 + 1 );
    maps\mp\_utility::_suicide();
}

setchallenger()
{
    if ( !level.hardcoremode )
    {
        self.maxhealth = maps\mp\gametypes\_tweakables::gettweakablevalue( "player", "maxhealth" );

        if ( isdefined( self.xpscaler ) && self.xpscaler == 1 && self.maxhealth > 30 )
            self.xpscaler = 2;
    }
}

unsetchallenger()
{
    self.xpscaler = 1;
}

setsaboteur()
{
    self.objectivescaler = 1.2;
}

unsetsaboteur()
{
    self.objectivescaler = 1;
}

setcombatspeed()
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "unsetCombatSpeed" );
    self.incombatspeed = 0;
    unsetcombatspeedscalar();

    for (;;)
    {
        self waittill( "damage", var_0, var_1 );

        if ( !isdefined( var_1.team ) )
            continue;

        if ( level.teambased && var_1.team == self.team )
            continue;

        if ( self.incombatspeed )
            continue;

        setcombatspeedscalar();
        self.incombatspeed = 1;
        thread endofspeedwatcher();
    }
}

endofspeedwatcher()
{
    self notify( "endOfSpeedWatcher" );
    self endon( "endOfSpeedWatcher" );
    self endon( "death" );
    self endon( "disconnect" );
    self waittill( "healed" );
    unsetcombatspeedscalar();
    self.incombatspeed = 0;
}

setcombatspeedscalar()
{
    if ( isdefined( self.isjuggernaut ) && self.isjuggernaut )
        return;

    if ( self.weaponspeed <= 0.8 )
        self.combatspeedscalar = 1.4;
    else if ( self.weaponspeed <= 0.9 )
        self.combatspeedscalar = 1.3;
    else
        self.combatspeedscalar = 1.2;

    maps\mp\gametypes\_weapons::updatemovespeedscale();
}

unsetcombatspeedscalar()
{
    self.combatspeedscalar = 1;
    maps\mp\gametypes\_weapons::updatemovespeedscale();
}

unsetcombatspeed()
{
    unsetcombatspeedscalar();
    self notify( "unsetCombatSpeed" );
}

setlightweight()
{
    if ( !isdefined( self.cranked ) )
    {
        self.movespeedscaler = maps\mp\_utility::lightweightscalar();
        maps\mp\gametypes\_weapons::updatemovespeedscale();
    }
}

unsetlightweight()
{
    self.movespeedscaler = 1;
    maps\mp\gametypes\_weapons::updatemovespeedscale();
}

setblackbox()
{
    self.killstreakscaler = 1.5;
}

unsetblackbox()
{
    self.killstreakscaler = 1;
}

setsteelnerves()
{
    maps\mp\_utility::giveperk( "specialty_bulletaccuracy", 1 );
    maps\mp\_utility::giveperk( "specialty_holdbreath", 0 );
}

unsetsteelnerves()
{
    maps\mp\_utility::_unsetperk( "specialty_bulletaccuracy" );
    maps\mp\_utility::_unsetperk( "specialty_holdbreath" );
}

setdelaymine()
{

}

unsetdelaymine()
{

}

setlocaljammer()
{
    if ( !maps\mp\_utility::isemped() )
        self makescrambler();
}

unsetlocaljammer()
{
    self clearscrambler();
}

setac130()
{
    thread killstreakthink( "ac130", 7, "end_ac130Think" );
}

unsetac130()
{
    self notify( "end_ac130Think" );
}

setsentryminigun()
{
    thread killstreakthink( "airdrop_sentry_minigun", 2, "end_sentry_minigunThink" );
}

unsetsentryminigun()
{
    self notify( "end_sentry_minigunThink" );
}

settank()
{
    thread killstreakthink( "tank", 6, "end_tankThink" );
}

unsettank()
{
    self notify( "end_tankThink" );
}

setprecision_airstrike()
{
    thread killstreakthink( "precision_airstrike", 6, "end_precision_airstrike" );
}

unsetprecision_airstrike()
{
    self notify( "end_precision_airstrike" );
}

setpredatormissile()
{
    thread killstreakthink( "predator_missile", 4, "end_predator_missileThink" );
}

unsetpredatormissile()
{
    self notify( "end_predator_missileThink" );
}

sethelicopterminigun()
{
    thread killstreakthink( "helicopter_minigun", 5, "end_helicopter_minigunThink" );
}

unsethelicopterminigun()
{
    self notify( "end_helicopter_minigunThink" );
}

killstreakthink( var_0, var_1, var_2 )
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( var_2 );

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

        if ( self.pers["cur_kill_streak"] != var_1 )
            continue;

        thread maps\mp\killstreaks\_killstreaks::givekillstreak( var_0 );
        thread maps\mp\gametypes\_hud_message::killstreaksplashnotify( var_0, var_1 );
        return;
    }
}

setthermal()
{
    self thermalvisionon();
}

unsetthermal()
{
    self thermalvisionoff();
}

setonemanarmy()
{
    thread onemanarmyweaponchangetracker();
}

unsetonemanarmy()
{
    self notify( "stop_oneManArmyTracker" );
}

onemanarmyweaponchangetracker()
{
    self endon( "death" );
    self endon( "disconnect" );
    level endon( "game_ended" );
    self endon( "stop_oneManArmyTracker" );

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

        if ( var_0 != "onemanarmy_mp" )
            continue;

        thread selectonemanarmyclass();
    }
}

isonemanarmymenu( var_0 )
{
    if ( var_0 == game["menu_onemanarmy"] )
        return 1;

    if ( isdefined( game["menu_onemanarmy_defaults_splitscreen"] ) && var_0 == game["menu_onemanarmy_defaults_splitscreen"] )
        return 1;

    if ( isdefined( game["menu_onemanarmy_custom_splitscreen"] ) && var_0 == game["menu_onemanarmy_custom_splitscreen"] )
        return 1;

    return 0;
}

selectonemanarmyclass()
{
    self endon( "death" );
    self endon( "disconnect" );
    level endon( "game_ended" );
    common_scripts\utility::_disableweaponswitch();
    common_scripts\utility::_disableoffhandweapons();
    common_scripts\utility::_disableusability();
    self openpopupmenu( game["menu_onemanarmy"] );
    thread closeomamenuondeath();
    self waittill( "menuresponse", var_0, var_1 );
    common_scripts\utility::_enableweaponswitch();
    common_scripts\utility::_enableoffhandweapons();
    common_scripts\utility::_enableusability();

    if ( var_1 == "back" || !isonemanarmymenu( var_0 ) || maps\mp\_utility::isusingremote() )
    {
        if ( self getcurrentweapon() == "onemanarmy_mp" )
        {
            common_scripts\utility::_disableweaponswitch();
            common_scripts\utility::_disableoffhandweapons();
            common_scripts\utility::_disableusability();
            self switchtoweapon( common_scripts\utility::getlastweapon() );
            self waittill( "weapon_change" );
            common_scripts\utility::_enableweaponswitch();
            common_scripts\utility::_enableoffhandweapons();
            common_scripts\utility::_enableusability();
        }

        return;
    }

    thread giveonemanarmyclass( var_1 );
}

closeomamenuondeath()
{
    self endon( "menuresponse" );
    self endon( "disconnect" );
    level endon( "game_ended" );
    self waittill( "death" );
    common_scripts\utility::_enableweaponswitch();
    common_scripts\utility::_enableoffhandweapons();
    common_scripts\utility::_enableusability();
}

giveonemanarmyclass( var_0 )
{
    self endon( "death" );
    self endon( "disconnect" );
    level endon( "game_ended" );

    if ( maps\mp\_utility::_hasperk( "specialty_omaquickchange" ) )
    {
        var_1 = 3.0;
        maps\mp\_utility::playplayerandnpcsounds( self, "foly_onemanarmy_bag3_plr", "foly_onemanarmy_bag3_npc" );
    }
    else
    {
        var_1 = 6.0;
        maps\mp\_utility::playplayerandnpcsounds( self, "foly_onemanarmy_bag6_plr", "foly_onemanarmy_bag6_npc" );
    }

    thread omausebar( var_1 );
    common_scripts\utility::_disableweapon();
    common_scripts\utility::_disableoffhandweapons();
    common_scripts\utility::_disableusability();
    wait( var_1 );
    common_scripts\utility::_enableweapon();
    common_scripts\utility::_enableoffhandweapons();
    common_scripts\utility::_enableusability();
    self.omaclasschanged = 1;
    maps\mp\gametypes\_class::giveloadout( self.pers["team"], var_0 );

    if ( isdefined( self.carryflag ) )
        self attach( self.carryflag, "J_spine4", 1 );

    self notify( "changed_kit" );
    level notify( "changed_kit" );
}

omausebar( var_0 )
{
    self endon( "disconnect" );
    var_1 = maps\mp\gametypes\_hud_util::createprimaryprogressbar();
    var_2 = maps\mp\gametypes\_hud_util::createprimaryprogressbartext();
    var_2 settext( &"MPUI_CHANGING_KIT" );
    var_1 maps\mp\gametypes\_hud_util::updatebar( 0, 1 / var_0 );

    for ( var_3 = 0; var_3 < var_0 && isalive( self ) && !level.gameended; var_3 = var_3 + 0.05 )
        wait 0.05;

    var_1 maps\mp\gametypes\_hud_util::destroyelem();
    var_2 maps\mp\gametypes\_hud_util::destroyelem();
}

setblastshield()
{
    self setweaponhudiconoverride( "primaryoffhand", "specialty_blastshield" );
}

unsetblastshield()
{
    self setweaponhudiconoverride( "primaryoffhand", "none" );
}

setfreefall()
{

}

unsetfreefall()
{

}

settacticalinsertion()
{
    self setoffhandsecondaryclass( "flash" );
    maps\mp\_utility::_giveweapon( "flare_mp", 0 );
    self givestartammo( "flare_mp" );
    thread monitortiuse();
}

unsettacticalinsertion()
{
    self notify( "end_monitorTIUse" );
}

clearprevioustispawnpoint()
{
    common_scripts\utility::waittill_any( "disconnect", "joined_team", "joined_spectators" );

    if ( isdefined( self.setspawnpoint ) )
        deleteti( self.setspawnpoint );
}

updatetispawnposition()
{
    self endon( "death" );
    self endon( "disconnect" );
    level endon( "game_ended" );
    self endon( "end_monitorTIUse" );

    while ( maps\mp\_utility::isreallyalive( self ) )
    {
        if ( isvalidtispawnposition() )
            self.tispawnposition = self.origin;

        wait 0.05;
    }
}

isvalidtispawnposition()
{
    if ( canspawn( self.origin ) && self isonground() )
        return 1;
    else
        return 0;
}

ti_overridemovingplatformdeath( var_0 )
{
    if ( maps\mp\_utility::isreallyalive( var_0.owner ) )
        var_0.owner deleteti( self );
}

monitortiuse()
{
    self endon( "death" );
    self endon( "disconnect" );
    level endon( "game_ended" );
    self endon( "end_monitorTIUse" );
    thread updatetispawnposition();
    thread clearprevioustispawnpoint();

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

        if ( var_1 != "flare_mp" )
            continue;

        if ( isdefined( self.setspawnpoint ) )
            deleteti( self.setspawnpoint );

        if ( !isdefined( self.tispawnposition ) )
            continue;

        if ( maps\mp\_utility::touchingbadtrigger() )
            continue;

        var_2 = self.tispawnposition + ( 0, 0, 16 );
        var_3 = self.tispawnposition - ( 0, 0, 2048 );
        var_4 = playerphysicstrace( var_2, var_3 ) + ( 0, 0, 1 );
        var_5 = bullettrace( var_2, var_3, 0 );
        var_6 = spawn( "script_model", var_4 );
        var_6.angles = self.angles;
        var_6.team = self.team;
        var_6.owner = self;
        var_6.enemytrigger = spawn( "script_origin", var_4 );
        var_6 thread glowsticksetupandwaitfordeath( self );
        var_6.playerspawnpos = self.tispawnposition;
        var_6 setotherent( self );
        var_6 common_scripts\utility::make_entity_sentient_mp( self.team, 1 );
        var_6 thread maps\mp\gametypes\_weapons::createbombsquadmodel( "weapon_light_stick_tactical_bombsquad", "tag_fire_fx", self );
        var_6 maps\mp\gametypes\_weapons::explosivehandlemovers( var_5["entity"] );
        maps\mp\gametypes\_weapons::ontacticalequipmentplanted( var_6 );
        self.setspawnpoint = var_6;
        return;
    }
}

glowsticksetupandwaitfordeath( var_0 )
{
    self setmodel( level.spawnglowmodel["enemy"] );

    if ( level.teambased )
        maps\mp\_entityheadicons::setteamheadicon( self.team, ( 0, 0, 20 ) );
    else
        maps\mp\_entityheadicons::setplayerheadicon( var_0, ( 0, 0, 20 ) );

    thread glowstickdamagelistener( var_0 );
    thread glowstickenemyuselistener( var_0 );
    thread glowstickuselistener( var_0 );
    thread glowstickwaitforownerdisconnect( var_0 );
    var_1 = spawn( "script_model", self.origin + ( 0, 0, 0 ) );
    var_1.angles = self.angles;
    var_1 setmodel( level.spawnglowmodel["friendly"] );
    var_1 setcontents( 0 );
    var_1 linkto( self );
    var_1 playloopsound( "emt_road_flare_burn" );
    thread glowstickteamupdater( self, var_1, var_0 );
    self waittill( "death" );
    var_1 stoploopsound();
    var_1 delete();
}

glowstickteamupdater( var_0, var_1, var_2 )
{
    var_0 endon( "death" );
    wait 0.05;
    var_3 = [];
    var_3["enemy"] = var_0;
    var_3["friendly"] = var_1;

    for (;;)
    {
        foreach ( var_5 in var_3 )
            var_5 hide();

        foreach ( var_8 in level.players )
        {
            var_9 = "friendly";

            if ( var_2 maps\mp\_utility::isenemy( var_8 ) )
                var_9 = "enemy";

            var_5 = var_3[var_9];
            var_5 show();
            playfxontagforclients( level.spawnglow[var_9], var_5, "tag_fire_fx", var_8 );
            common_scripts\utility::waitframe();
        }

        level waittill( "joined_team" );

        foreach ( var_9, var_5 in var_3 )
            stopfxontag( level.spawnglow[var_9], var_5, "tag_fire_fx" );

        common_scripts\utility::waitframe();
    }
}

deleteondeath( var_0 )
{
    self waittill( "death" );

    if ( isdefined( var_0 ) )
        var_0 delete();
}

glowstickdamagelistener( var_0 )
{
    maps\mp\gametypes\_damage::monitordamage( 100, "tactical_insertion", ::glowstickmodifydamage, ::glowstickhandledeathdamage, 1 );
}

glowstickmodifydamage( var_0, var_1, var_2, var_3 )
{
    return maps\mp\gametypes\_damage::handlemeleedamage( var_1, var_2 );
}

glowstickhandledeathdamage( var_0, var_1, var_2, var_3 )
{
    if ( isdefined( self.owner ) && var_0 != self.owner )
    {
        var_0 notify( "destroyed_insertion", self.owner );
        var_0 notify( "destroyed_equipment" );
        self.owner thread maps\mp\_utility::leaderdialogonplayer( "ti_destroyed", undefined, undefined, self.origin );
    }

    var_0 thread deleteti( self );
}

glowstickuselistener( var_0 )
{
    self endon( "death" );
    level endon( "game_ended" );
    var_0 endon( "disconnect" );
    self setcursorhint( "HINT_NOICON" );
    self sethintstring( &"MP_PATCH_PICKUP_TI" );
    thread updateenemyuse( var_0 );

    for (;;)
    {
        self waittill( "trigger", var_1 );
        var_1 playsound( "tactical_insert_flare_pu" );

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

        var_1 thread deleteti( self );
    }
}

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

    for (;;)
    {
        maps\mp\_utility::setselfusable( var_0 );
        level common_scripts\utility::waittill_either( "joined_team", "player_spawned" );
    }
}

glowstickwaitforownerdisconnect( var_0 )
{
    self endon( "death" );
    var_0 waittill( "disconnect" );
    thread deleteti( self );
}

deleteti( var_0 )
{
    if ( isdefined( var_0.enemytrigger ) )
        var_0.enemytrigger delete();

    var_1 = var_0.origin;
    var_2 = var_0.angles;
    var_3 = var_0 getlinkedparent();
    var_0 delete();
    var_4 = spawn( "script_model", var_1 );
    var_4.angles = var_2;
    var_4 setmodel( level.spawnglowmodel["friendly"] );
    var_4 setcontents( 0 );

    if ( isdefined( var_3 ) )
        var_4 linkto( var_3 );

    thread dummyglowstickdelete( var_4 );
}

dummyglowstickdelete( var_0 )
{
    wait 2.5;
    var_0 delete();
}

glowstickenemyuselistener( var_0 )
{
    self endon( "death" );
    level endon( "game_ended" );
    var_0 endon( "disconnect" );
    self.enemytrigger setcursorhint( "HINT_NOICON" );
    self.enemytrigger sethintstring( &"MP_PATCH_DESTROY_TI" );
    self.enemytrigger maps\mp\_utility::makeenemyusable( var_0 );

    for (;;)
    {
        self.enemytrigger waittill( "trigger", var_1 );
        var_1 notify( "destroyed_insertion", var_0 );
        var_1 notify( "destroyed_equipment" );

        if ( isdefined( var_0 ) && var_1 != var_0 )
            var_0 thread maps\mp\_utility::leaderdialogonplayer( "ti_destroyed", undefined, undefined, self.origin );

        var_1 thread deleteti( self );
    }
}

setlittlebirdsupport()
{
    thread killstreakthink( "littlebird_support", 2, "end_littlebird_support_think" );
}

unsetlittlebirdsupport()
{
    self notify( "end_littlebird_support_think" );
}

setpainted( var_0 )
{
    if ( isplayer( self ) )
    {
        var_1 = 1;

        if ( !maps\mp\_utility::_hasperk( "specialty_incog" ) )
        {
            self.painted = 1;

            if ( level.teambased )
            {
                var_2 = maps\mp\_utility::outlineenableforteam( self, "orange", var_0.team, 0, "perk" );
                thread watchpainted( var_2, var_1 );
                thread watchpaintedagain( var_2 );
            }
            else
            {
                var_2 = maps\mp\_utility::outlineenableforplayer( self, "orange", var_0, 0, "perk" );
                thread watchpainted( var_2, var_1 );
                thread watchpaintedagain( var_2 );
            }
        }
    }
}

watchpainted( var_0, var_1 )
{
    self notify( "painted_again" );
    self endon( "painted_again" );
    self endon( "disconnect" );
    level endon( "game_ended" );
    common_scripts\utility::waittill_any_timeout( var_1, "death" );
    self.painted = 0;
    maps\mp\_utility::outlinedisable( var_0, self );
    self notify( "painted_end" );
}

watchpaintedagain( var_0 )
{
    self endon( "disconnect" );
    level endon( "game_ended" );
    common_scripts\utility::waittill_any( "painted_again", "painted_end" );
    maps\mp\_utility::outlinedisable( var_0, self );
}

ispainted()
{
    return isdefined( self.painted ) && self.painted;
}

setassists()
{

}

unsetassists()
{

}

setrefillgrenades()
{
    if ( isdefined( self.primarygrenade ) )
        self givemaxammo( self.primarygrenade );

    if ( isdefined( self.secondarygrenade ) )
        self givemaxammo( self.secondarygrenade );
}

unsetrefillgrenades()
{

}

setrefillammo()
{
    if ( isdefined( self.primaryweapon ) )
        self givemaxammo( self.primaryweapon );

    if ( isdefined( self.secondaryweapon ) )
        self givemaxammo( self.secondaryweapon );
}

unsetrefillammo()
{

}

setgunsmith()
{
    thread setgunsmithinternal();
}

setgunsmithinternal()
{
    self endon( "disconnect" );
    self endon( "death" );
    level endon( "game_ended" );
    self endon( "unsetGunsmith" );
    self waittill( "giveLoadout" );

    if ( self.loadoutprimaryattachments.size == 0 && self.loadoutsecondaryattachments.size == 0 )
        return;

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

        if ( var_0 == "none" )
            continue;

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

        if ( !maps\mp\_utility::isstrstart( var_0, "iw5_" ) && !maps\mp\_utility::isstrstart( var_0, "iw6_" ) )
            continue;

        var_1 = undefined;

        if ( maps\mp\_utility::getweaponclass( var_0 ) == "weapon_pistol" )
        {
            if ( self.loadoutsecondaryattachments.size > 0 )
                var_1 = self.loadoutsecondaryattachments;
        }
        else if ( self.loadoutprimaryattachments.size > 0 )
            var_1 = self.loadoutprimaryattachments;

        if ( !isdefined( var_1 ) )
            continue;

        var_2 = 0;
        var_3 = maps\mp\_utility::getweaponattachmentsbasenames( var_0 );

        if ( var_3.size == 0 )
            var_2 = 1;
        else
        {
            foreach ( var_5 in var_1 )
            {
                if ( !common_scripts\utility::array_contains( var_3, var_5 ) )
                {
                    var_2 = 1;
                    break;
                }
            }
        }

        if ( !var_2 )
            continue;

        var_7 = [];
        var_8 = maps\mp\_utility::getweaponattachmentarrayfromstats( var_0 );

        foreach ( var_5 in var_1 )
        {
            if ( common_scripts\utility::array_contains( var_8, var_5 ) )
                var_7[var_7.size] = var_5;
        }

        var_1 = var_7;
        var_11 = [];

        foreach ( var_13 in var_3 )
        {
            var_14 = 1;

            foreach ( var_16 in var_1 )
            {
                if ( !maps\mp\_utility::attachmentscompatible( var_16, var_13 ) )
                {
                    var_14 = 0;
                    break;
                }
            }

            if ( var_14 )
                var_11[var_11.size] = var_13;
        }

        var_3 = var_11;
        var_19 = var_1.size + var_3.size;

        if ( var_19 > 4 )
            var_3 = common_scripts\utility::array_randomize( var_3 );

        for ( var_20 = 0; var_1.size < 4 && var_20 < var_3.size; var_20++ )
            var_1[var_1.size] = var_3[var_20];

        var_21 = getweaponbasename( var_0 );
        var_22 = var_21;

        foreach ( var_20, var_5 in var_1 )
        {
            var_24 = maps\mp\_utility::attachmentmap_tounique( var_5, var_0 );
            var_1[var_20] = var_24;
        }

        var_1 = common_scripts\utility::alphabetize( var_1 );

        foreach ( var_5 in var_1 )
            var_22 = var_22 + ( "_" + var_5 );

        if ( var_22 != var_21 )
        {
            var_27 = self getweaponammoclip( var_0 );
            var_28 = self getweaponammostock( var_0 );
            self takeweapon( var_0 );
            self giveweapon( var_22 );
            self setweaponammoclip( var_22, var_27 );
            self setweaponammostock( var_22, var_28 );
            self switchtoweapon( var_22 );
        }
    }
}

unsetgunsmith()
{
    self notify( "unsetGunsmith" );
}

setgambler()
{
    self setclientomnvar( "ui_gambler_show", -1 );
    setgamblerinternal();
}

setgamblerinternal()
{
    level.abilitymaxval = [];
    var_0 = maps\mp\gametypes\_class::getnumabilitycategories();
    var_1 = maps\mp\gametypes\_class::getnumsubability();
    var_2 = [];
    var_3 = 0;
    var_4 = undefined;

    if ( isai( self ) )
        var_4 = self.pers["loadoutPerks"];

    if ( !isdefined( level.perknamesforgambler ) )
    {
        level.perknamesforgambler = [];
        level.perkcostsforgambler = [];
        level.perkrowsforgambler = [];

        for ( var_5 = 0; var_5 < var_0; var_5++ )
        {
            for ( var_6 = 0; var_6 < var_1; var_6++ )
            {
                var_7 = tablelookup( "mp/cacAbilityTable.csv", 0, var_5 + 1, 4 + var_6 );
                level.perknamesforgambler[var_5][var_6] = var_7;

                for ( var_8 = 0; tablelookupbyrow( "mp/perktable.csv", var_8, 0 ) != ""; var_8++ )
                {
                    if ( var_7 == tablelookupbyrow( "mp/perktable.csv", var_8, 1 ) )
                    {
                        level.perkcostsforgambler[var_5][var_6] = int( tablelookupbyrow( "mp/perktable.csv", var_8, 10 ) );
                        level.perkrowsforgambler[var_5][var_6] = var_8;
                        break;
                    }
                }
            }
        }
    }

    var_9 = gamblercommonchecker();
    var_10 = 0;

    if ( level.gametype == "infect" )
        var_9 = 0;

    if ( isdefined( self.teamname ) )
        var_10 = getmatchrulesdata( "defaultClasses", self.teamname, self.class_num, "class", "abilitiesPicked", 6, 0 );

    for ( var_5 = 0; var_5 < var_0; var_5++ )
    {
        for ( var_6 = 0; var_6 < var_1; var_6++ )
        {
            var_11 = level.perknamesforgambler[var_5][var_6];
            var_12 = perkpickedchecker( var_11, var_5, var_6 );

            if ( var_12 && ( self.streaktype == "specialist" || !self.perkpickedspecialist ) )
                continue;

            if ( !isdefined( var_11 ) )
                continue;

            if ( var_11 == "" )
                continue;

            if ( var_11 == "specialty_extra_attachment" || var_11 == "specialty_twoprimaries" )
                continue;

            if ( isdefined( var_9 ) && !var_9 && !var_10 )
            {
                if ( var_11 == "specialty_extraammo" || var_11 == "specialty_extra_equipment" || var_11 == "specialty_extra_deadly" )
                    continue;
            }

            if ( self.streaktype == "support" )
            {
                if ( var_11 == "specialty_hardline" )
                    continue;
            }

            if ( isai( self ) && isdefined( var_4 ) && common_scripts\utility::array_contains( var_4, var_11 ) )
                continue;

            var_13 = level.perkcostsforgambler[var_5][var_6];
            var_8 = level.perkrowsforgambler[var_5][var_6];

            switch ( var_13 )
            {
                case 1:
                    var_3 = 150;
                    break;
                case 2:
                    var_3 = 40;
                    break;
                case 3:
                    var_3 = 60;
                    break;
                case 4:
                    var_3 = 20;
                    break;
                case 5:
                    var_3 = 20;
                    break;
                default:
                    break;
            }

            var_2[var_2.size] = spawnstruct();
            var_2[var_2.size - 1].row = var_8;
            var_2[var_2.size - 1].id = var_11;
            var_2[var_2.size - 1].weight = var_3;
        }
    }

    self.perkpickedspecialist = undefined;

    if ( var_2.size > 0 )
        thread givegamblerchoice( var_2 );
}

gamblercommonchecker()
{
    if ( !isai( self ) )
        return self getcacplayerdata( "loadouts", self.class_num, "abilitiesPicked", 6, 0 );
    else
    {
        var_0 = [];

        if ( isdefined( self.pers["loadoutPerks"] ) )
            var_0 = common_scripts\utility::array_combine( var_0, self.pers["loadoutPerks"] );

        foreach ( var_2 in var_0 )
        {
            if ( maps\mp\_utility::getbaseperkname( var_2 ) == "specialty_gambler" )
                return 1;
        }
    }

    return 0;
}

perkpickedchecker( var_0, var_1, var_2 )
{
    self.perkpickedspecialist = 0;

    if ( !isdefined( var_0 ) )
        return 0;

    if ( var_0 == "" )
        return 0;

    if ( !isai( self ) )
    {
        var_3 = maps\mp\gametypes\_class::getnumabilitycategories();
        var_4 = maps\mp\gametypes\_class::getnumsubability();

        if ( self getcacplayerdata( "loadouts", self.class_num, "abilitiesPicked", var_1, var_2 ) )
            return 1;

        for ( var_5 = 0; var_5 < 3; var_5++ )
        {
            var_6 = self getcacplayerdata( "loadouts", self.class_num, "specialistStreaks", var_5 );

            if ( isdefined( var_6 ) && var_6 != "none" )
            {
                var_7 = maps\mp\_utility::getbaseperkname( var_6 );

                if ( var_7 == var_0 )
                {
                    self.perkpickedspecialist = 1;
                    return 1;
                }
            }
        }

        var_8 = self getcacplayerdata( "loadouts", self.class_num, "specialistBonusStreaks", var_1, var_2 );

        if ( isdefined( var_8 ) && var_8 )
        {
            var_9 = level.perknamesforgambler[var_1][var_2];

            if ( var_9 == var_0 )
            {
                self.perkpickedspecialist = 1;
                return 1;
            }
        }
    }
    else
    {
        var_10 = [];

        if ( isdefined( self.pers["loadoutPerks"] ) )
            var_10 = common_scripts\utility::array_combine( var_10, self.pers["loadoutPerks"] );

        foreach ( var_12 in var_10 )
        {
            if ( maps\mp\_utility::getbaseperkname( var_12 ) == var_0 )
                return 1;
        }

        var_10 = [];

        if ( isdefined( self.pers["specialistStreaks"] ) )
            var_10 = common_scripts\utility::array_combine( var_10, self.pers["specialistStreaks"] );

        if ( isdefined( self.pers["specialistBonusStreaks"] ) )
            var_10 = common_scripts\utility::array_combine( var_10, self.pers["specialistBonusStreaks"] );

        foreach ( var_12 in var_10 )
        {
            if ( maps\mp\_utility::getbaseperkname( var_12 ) == var_0 )
            {
                self.perkpickedspecialist = 1;
                return 1;
            }
        }
    }

    return 0;
}

givegamblerchoice( var_0 )
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "unsetGambler" );
    level endon( "game_ended" );

    if ( !maps\mp\_utility::gameflag( "prematch_done" ) )
        maps\mp\_utility::gameflagwait( "prematch_done" );
    else if ( maps\mp\_utility::gameflag( "prematch_done" ) && self.streaktype != "specialist" )
        self waittill( "giveLoadout" );

    if ( !isdefined( self.abilitychosen ) )
        self.abilitychosen = 0;

    if ( !self.abilitychosen )
    {
        var_1 = getrandomability( var_0 );
        self.gamblerability = var_1;
    }
    else
        var_1 = self.gamblerability;

    maps\mp\_utility::giveperk( var_1.id, 0 );

    if ( var_1.id == "specialty_hardline" )
        maps\mp\killstreaks\_killstreaks::setstreakcounttonext();

    if ( showgambler() )
    {
        self playlocalsound( "mp_suitcase_pickup" );
        self setclientomnvar( "ui_gambler_show", var_1.row );
        thread gambleranimwatcher();
    }

    if ( level.gametype != "infect" )
        self.abilitychosen = 1;
}

showgambler()
{
    var_0 = 1;

    if ( !level.ingraceperiod && self.abilitychosen )
        var_0 = 0;

    if ( !maps\mp\_utility::allowclasschoice() && level.gametype != "infect" )
        var_0 = 0;

    return var_0;
}

gambleranimwatcher()
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "unsetGambler" );
    level endon( "game_ended" );
    self waittill( "luinotifyserver", var_0, var_1 );

    if ( var_0 == "gambler_anim_complete" )
        self setclientomnvar( "ui_gambler_show", -1 );
}

getrandomability( var_0 )
{
    var_1 = [];
    var_1 = thread sortbyweight( var_0 );
    var_1 = thread setbucketval( var_1 );
    var_2 = randomint( level.abilitymaxval["sum"] );
    var_3 = undefined;

    foreach ( var_5 in var_1 )
    {
        if ( !var_5.weight || var_5.id == "specialty_gambler" )
            continue;

        if ( var_5.weight > var_2 )
        {
            var_3 = var_5;
            break;
        }
    }

    return var_3;
}

sortbyweight( var_0 )
{
    var_1 = [];
    var_2 = [];

    for ( var_3 = 1; var_3 < var_0.size; var_3++ )
    {
        var_4 = var_0[var_3].weight;
        var_1 = var_0[var_3];

        for ( var_5 = var_3 - 1; var_5 >= 0 && is_weight_a_less_than_b( var_0[var_5].weight, var_4 ); var_5-- )
        {
            var_2 = var_0[var_5];
            var_0[var_5] = var_1;
            var_0[var_5 + 1] = var_2;
        }
    }

    return var_0;
}

is_weight_a_less_than_b( var_0, var_1 )
{
    return var_0 < var_1;
}

setbucketval( var_0 )
{
    level.abilitymaxval["sum"] = 0;

    foreach ( var_2 in var_0 )
    {
        if ( !var_2.weight )
            continue;

        level.abilitymaxval["sum"] = level.abilitymaxval["sum"] + var_2.weight;
        var_2.weight = level.abilitymaxval["sum"];
    }

    return var_0;
}

unsetgambler()
{
    self notify( "unsetGambler" );
}

setcomexp()
{
    var_0 = level.comexpfuncs["giveComExpBenefits"];
    self [[ var_0 ]]();
}

unsetcomexp()
{
    var_0 = level.comexpfuncs["removeComExpBenefits"];
    self [[ var_0 ]]();
}

settagger()
{
    thread settaggerinternal();
}

settaggerinternal()
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "unsetTagger" );
    level endon( "game_ended" );

    for (;;)
    {
        self waittill( "eyesOn" );
        var_0 = self getplayerssightingme();

        foreach ( var_2 in var_0 )
        {
            if ( level.teambased && var_2.team == self.team )
                continue;

            if ( isalive( var_2 ) && var_2.sessionstate == "playing" )
            {
                if ( !isdefined( var_2.perkoutlined ) )
                    var_2.perkoutlined = 0;

                if ( !var_2.perkoutlined )
                    var_2.perkoutlined = 1;

                var_2 thread outlinewatcher( self );
            }
        }
    }
}

outlinewatcher( var_0 )
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "eyesOff" );
    level endon( "game_ended" );

    for (;;)
    {
        var_1 = 1;
        var_2 = var_0 getplayerssightingme();

        foreach ( var_4 in var_2 )
        {
            if ( var_4 == self )
            {
                var_1 = 0;
                break;
            }
        }

        if ( var_1 )
        {
            self.perkoutlined = 0;
            self notify( "eyesOff" );
        }

        wait 0.5;
    }
}

unsettagger()
{
    self notify( "unsetTagger" );
}

setpitcher()
{
    thread setpitcherinternal();
}

setpitcherinternal()
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "unsetPitcher" );
    level endon( "game_ended" );
    maps\mp\_utility::_setperk( "specialty_throwback", 0 );
    self setgrenadecookscale( 1.5 );

    for (;;)
    {
        self setgrenadethrowscale( 1.25 );
        self waittill( "grenade_pullback", var_0 );

        if ( var_0 == "airdrop_marker_mp" || var_0 == "killstreak_uplink_mp" || var_0 == "deployable_vest_marker_mp" || var_0 == "deployable_weapon_crate_marker_mp" || var_0 == "airdrop_juggernaut_mp" )
            self setgrenadethrowscale( 1 );

        self waittill( "grenade_fire", var_1, var_2 );
    }
}

unsetpitcher()
{
    self setgrenadecookscale( 1 );
    self setgrenadethrowscale( 1 );
    maps\mp\_utility::_unsetperk( "specialty_throwback" );
    self notify( "unsetPitcher" );
}

setboom()
{

}

setboominternal( var_0 )
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "unsetBoom" );
    level endon( "game_ended" );
    var_0 endon( "death" );
    var_0 endon( "disconnect" );
    common_scripts\utility::waitframe();
    triggerportableradarping( self.origin, var_0 );
    var_0 boomtrackplayers( self.origin );
}

boomtrackplayers( var_0 )
{
    foreach ( var_2 in level.players )
    {
        if ( maps\mp\_utility::isenemy( var_2 ) && isalive( var_2 ) && !var_2 maps\mp\_utility::_hasperk( "specialty_gpsjammer" ) && distancesquared( var_0, var_2.origin ) <= 490000 )
            var_2.markedbyboomperk[maps\mp\_utility::getuniqueid()] = gettime() + 2000;
    }
}

unsetboom()
{
    self notify( "unsetBoom" );
}

setsilentkill()
{

}

unsetsilentkill()
{

}

setbloodrush()
{
    self.bloodrushregenspeedmod = 1;
    self.bloodrushregenhealthmod = 1;
}

setbloodrushinternal()
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "unsetBloodrush" );
    level endon( "game_ended" );

    if ( !isdefined( self.isjuiced ) || !self.isjuiced )
    {
        self.rushtime = 5;
        thread customjuiced( self.rushtime );
        self.bloodrushregenspeedmod = 0.25;
        self.bloodrushregenhealthmod = 5;
        self notify( "bloodrush_active" );
    }

    self waittill( "unset_custom_juiced" );
    unsetbloodrush();
}

customjuiced( var_0 )
{
    self endon( "death" );
    self endon( "faux_spawn" );
    self endon( "disconnect" );
    self endon( "unset_custom_juiced" );
    level endon( "game_ended" );
    self.isjuiced = 1;
    self.movespeedscaler = 1.1;
    maps\mp\gametypes\_weapons::updatemovespeedscale();
    maps\mp\_utility::giveperk( "specialty_fastreload", 0 );
    maps\mp\_utility::giveperk( "specialty_quickdraw", 0 );
    maps\mp\_utility::giveperk( "specialty_stalker", 0 );
    maps\mp\_utility::giveperk( "specialty_fastoffhand", 0 );
    maps\mp\_utility::giveperk( "specialty_fastsprintrecovery", 0 );
    maps\mp\_utility::giveperk( "specialty_quickswap", 0 );
    thread unsetcustomjuicedondeath();
    thread unsetcustomjuicedonride();
    thread unsetcustomjuicedonmatchend();
    var_1 = var_0 * 1000 + gettime();

    if ( !isai( self ) )
        self setclientdvar( "ui_juiced_end_milliseconds", var_1 );

    wait( var_0 );
    unsetcustomjuiced();
}

unsetcustomjuiced( var_0 )
{
    if ( !isdefined( var_0 ) )
    {
        if ( maps\mp\_utility::isjuggernaut() )
        {
            if ( isdefined( self.juggmovespeedscaler ) )
                self.movespeedscaler = self.juggmovespeedscaler;
            else
                self.movespeedscaler = 0.7;
        }
        else
        {
            self.movespeedscaler = 1;

            if ( maps\mp\_utility::_hasperk( "specialty_lightweight" ) )
                self.movespeedscaler = maps\mp\_utility::lightweightscalar();
        }

        maps\mp\gametypes\_weapons::updatemovespeedscale();
    }

    maps\mp\_utility::_unsetperk( "specialty_fastreload" );
    maps\mp\_utility::_unsetperk( "specialty_quickdraw" );
    maps\mp\_utility::_unsetperk( "specialty_stalker" );
    maps\mp\_utility::_unsetperk( "specialty_fastoffhand" );
    maps\mp\_utility::_unsetperk( "specialty_fastsprintrecovery" );
    maps\mp\_utility::_unsetperk( "specialty_quickswap" );

    if ( isdefined( self.pers["loadoutPerks"] ) )
        maps\mp\perks\_abilities::giveperksfromknownloadout( self.pers["loadoutPerks"] );

    self.isjuiced = undefined;

    if ( !isai( self ) )
        self setclientdvar( "ui_juiced_end_milliseconds", 0 );

    self notify( "unset_custom_juiced" );
}

unsetcustomjuicedonride()
{
    self endon( "disconnect" );
    self endon( "unset_custom_juiced" );

    for (;;)
    {
        wait 0.05;

        if ( maps\mp\_utility::isusingremote() )
        {
            thread unsetcustomjuiced();
            break;
        }
    }
}

unsetcustomjuicedondeath()
{
    self endon( "disconnect" );
    self endon( "unset_custom_juiced" );
    common_scripts\utility::waittill_any( "death", "faux_spawn" );
    thread unsetcustomjuiced( 1 );
}

unsetcustomjuicedonmatchend()
{
    self endon( "disconnect" );
    self endon( "unset_custom_juiced" );
    level common_scripts\utility::waittill_any( "round_end_finished", "game_ended" );
    thread unsetcustomjuiced();
}

regenspeedwatcher()
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "unsetBloodrush" );
    level endon( "game_ended" );

    for (;;)
    {
        self waittill( "bloodrush_active" );
        self.regenspeed = self.bloodrushregenspeedmod;
        break;
    }
}

unsetbloodrush()
{
    self.bloodrushregenspeedmod = 1;
    self.regenspeed = 1;
    self notify( "unsetBloodrush" );
}

settriggerhappy()
{

}

settriggerhappyinternal()
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "unsetTriggerHappy" );
    level endon( "game_ended" );
    var_0 = self.lastdroppableweapon;
    var_1 = self getweaponammostock( var_0 );
    var_2 = self getweaponammoclip( var_0 );
    self givestartammo( var_0 );
    var_3 = self getweaponammoclip( var_0 );
    var_4 = var_3 - var_2;
    var_5 = var_1 - var_4;

    if ( var_4 > var_1 )
    {
        self setweaponammoclip( var_0, var_2 + var_1 );
        var_5 = 0;
    }

    self setweaponammostock( var_0, var_5 );
    self playlocalsound( "ammo_crate_use" );
    self setclientomnvar( "ui_trigger_happy", 1 );
    wait 0.2;
    self setclientomnvar( "ui_trigger_happy", 0 );
}

unsettriggerhappy()
{
    self setclientomnvar( "ui_trigger_happy", 0 );
    self notify( "unsetTriggerHappy" );
}

setdeadeye()
{
    self.critchance = 10;
    self.deadeyekillcount = 0;
}

setdeadeyeinternal()
{
    if ( self.critchance < 50 )
        self.critchance = ( self.deadeyekillcount + 1 ) * 10;
    else
        self.critchance = 50;

    var_0 = randomint( 100 );

    if ( var_0 <= self.critchance )
        maps\mp\_utility::giveperk( "specialty_moredamage", 0 );
}

unsetdeadeye()
{
    if ( maps\mp\_utility::_hasperk( "specialty_moredamage" ) )
        maps\mp\_utility::_unsetperk( "specialty_moredamage" );
}

setincog()
{

}

unsetincog()
{

}

setblindeye()
{

}

unsetblindeye()
{
    maps\mp\_utility::_unsetperk( "specialty_noplayertarget" );
    self notify( "removed_specialty_noplayertarget" );
}

setquickswap()
{

}

unsetquickswap()
{
    maps\mp\_utility::_unsetperk( "specialty_fastoffhand" );
}

setextraammo()
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "unset_extraammo" );
    level endon( "game_ended" );

    if ( self.gettingloadout )
        self waittill( "giveLoadout" );

    var_0 = maps\mp\_utility::getvalidextraammoweapons();

    foreach ( var_2 in var_0 )
    {
        if ( isdefined( var_2 ) && var_2 != "none" )
            self givemaxammo( var_2 );
    }
}

unsetextraammo()
{
    self notify( "unset_extraammo" );
}

setextraequipment()
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "unset_extraequipment" );
    level endon( "game_ended" );

    if ( self.gettingloadout )
        self waittill( "giveLoadout" );

    var_0 = self.loadoutperkoffhand;

    if ( isdefined( var_0 ) && var_0 != "specialty_null" )
    {
        if ( var_0 != "specialty_tacticalinsertion" )
            self setweaponammoclip( var_0, 2 );
    }
}

unsetextraequipment()
{
    self notify( "unset_extraequipment" );
}

setextradeadly()
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "unset_extradeadly" );
    level endon( "game_ended" );

    if ( self.gettingloadout )
        self waittill( "giveLoadout" );

    var_0 = self.loadoutperkequipment;

    if ( isdefined( var_0 ) && var_0 != "specialty_null" )
        self setweaponammoclip( var_0, 2 );
}

unsetextradeadly()
{
    self notify( "unset_extradeadly" );
}

setfinalstand()
{
    maps\mp\_utility::giveperk( "specialty_pistoldeath", 0 );
}

unsetfinalstand()
{
    maps\mp\_utility::_unsetperk( "specialty_pistoldeath" );
}

setcarepackage()
{
    thread maps\mp\killstreaks\_killstreaks::givekillstreak( "airdrop_assault", 0, 0, self );
}

unsetcarepackage()
{

}

setuav()
{
    thread maps\mp\killstreaks\_killstreaks::givekillstreak( "uav", 0, 0, self );
}

unsetuav()
{

}

setstoppingpower()
{
    maps\mp\_utility::giveperk( "specialty_bulletdamage", 0 );
    thread watchstoppingpowerkill();
}

watchstoppingpowerkill()
{
    self notify( "watchStoppingPowerKill" );
    self endon( "watchStoppingPowerKill" );
    self endon( "disconnect" );
    level endon( "game_ended" );
    self waittill( "killed_enemy" );
    unsetstoppingpower();
}

unsetstoppingpower()
{
    maps\mp\_utility::_unsetperk( "specialty_bulletdamage" );
    self notify( "watchStoppingPowerKill" );
}

setc4death()
{
    if ( !maps\mp\_utility::_hasperk( "specialty_pistoldeath" ) )
        maps\mp\_utility::giveperk( "specialty_pistoldeath", 0 );
}

unsetc4death()
{
    if ( maps\mp\_utility::_hasperk( "specialty_pistoldeath" ) )
        maps\mp\_utility::_unsetperk( "specialty_pistoldeath" );
}

setjuiced( var_0 )
{
    self endon( "death" );
    self endon( "faux_spawn" );
    self endon( "disconnect" );
    self endon( "unset_juiced" );
    level endon( "game_ended" );
    self.isjuiced = 1;
    self.movespeedscaler = 1.25;
    maps\mp\gametypes\_weapons::updatemovespeedscale();
    maps\mp\_utility::giveperk( "specialty_fastreload", 0 );
    maps\mp\_utility::giveperk( "specialty_quickdraw", 0 );
    maps\mp\_utility::giveperk( "specialty_stalker", 0 );
    maps\mp\_utility::giveperk( "specialty_fastoffhand", 0 );
    maps\mp\_utility::giveperk( "specialty_fastsprintrecovery", 0 );
    maps\mp\_utility::giveperk( "specialty_quickswap", 0 );
    thread unsetjuicedondeath();
    thread unsetjuicedonride();
    thread unsetjuicedonmatchend();

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

    var_1 = var_0 * 1000 + gettime();

    if ( !isai( self ) )
        self setclientdvar( "ui_juiced_end_milliseconds", var_1 );

    wait( var_0 );
    unsetjuiced();
}

unsetjuiced( var_0 )
{
    if ( !isdefined( var_0 ) )
    {
        if ( !maps\mp\_utility::is_aliens() )
        {

        }

        if ( maps\mp\_utility::isjuggernaut() )
        {
            if ( isdefined( self.juggmovespeedscaler ) )
                self.movespeedscaler = self.juggmovespeedscaler;
            else
                self.movespeedscaler = 0.7;
        }
        else
        {
            self.movespeedscaler = 1;

            if ( maps\mp\_utility::_hasperk( "specialty_lightweight" ) )
                self.movespeedscaler = maps\mp\_utility::lightweightscalar();
        }

        maps\mp\gametypes\_weapons::updatemovespeedscale();
    }

    maps\mp\_utility::_unsetperk( "specialty_fastreload" );
    maps\mp\_utility::_unsetperk( "specialty_quickdraw" );
    maps\mp\_utility::_unsetperk( "specialty_stalker" );
    maps\mp\_utility::_unsetperk( "specialty_fastoffhand" );
    maps\mp\_utility::_unsetperk( "specialty_fastsprintrecovery" );
    maps\mp\_utility::_unsetperk( "specialty_quickswap" );

    if ( isdefined( self.pers["loadoutPerks"] ) )
        maps\mp\perks\_abilities::giveperksfromknownloadout( self.pers["loadoutPerks"] );

    self.isjuiced = undefined;

    if ( !isai( self ) )
        self setclientdvar( "ui_juiced_end_milliseconds", 0 );

    self notify( "unset_juiced" );
}

unsetjuicedonride()
{
    self endon( "disconnect" );
    self endon( "unset_juiced" );

    for (;;)
    {
        wait 0.05;

        if ( maps\mp\_utility::isusingremote() )
        {
            thread unsetjuiced();
            break;
        }
    }
}

unsetjuicedondeath()
{
    self endon( "disconnect" );
    self endon( "unset_juiced" );
    common_scripts\utility::waittill_any( "death", "faux_spawn" );
    thread unsetjuiced( 1 );
}

unsetjuicedonmatchend()
{
    self endon( "disconnect" );
    self endon( "unset_juiced" );
    level common_scripts\utility::waittill_any( "round_end_finished", "game_ended" );
    thread unsetjuiced();
}

hasjuiced()
{
    return isdefined( self.isjuiced );
}

setcombathigh()
{
    self endon( "death" );
    self endon( "disconnect" );
    self endon( "unset_combathigh" );
    level endon( "end_game" );
    self.damageblockedtotal = 0;

    if ( level.splitscreen )
    {
        var_0 = 56;
        var_1 = 21;
    }
    else
    {
        var_0 = 112;
        var_1 = 32;
    }

    if ( isdefined( self.juicedtimer ) )
        self.juicedtimer destroy();

    if ( isdefined( self.juicedicon ) )
        self.juicedicon destroy();

    self.combathighoverlay = newclienthudelem( self );
    self.combathighoverlay.x = 0;
    self.combathighoverlay.y = 0;
    self.combathighoverlay.alignx = "left";
    self.combathighoverlay.aligny = "top";
    self.combathighoverlay.horzalign = "fullscreen";
    self.combathighoverlay.vertalign = "fullscreen";
    self.combathighoverlay setshader( "combathigh_overlay", 640, 480 );
    self.combathighoverlay.sort = -10;
    self.combathighoverlay.archived = 1;
    self.combathightimer = maps\mp\gametypes\_hud_util::createtimer( "hudsmall", 1.0 );
    self.combathightimer maps\mp\gametypes\_hud_util::setpoint( "CENTER", "CENTER", 0, var_0 );
    self.combathightimer settimer( 10.0 );
    self.combathightimer.color = ( 0.8, 0.8, 0 );
    self.combathightimer.archived = 0;
    self.combathightimer.foreground = 1;
    self.combathighicon = maps\mp\gametypes\_hud_util::createicon( "specialty_painkiller", var_1, var_1 );
    self.combathighicon.alpha = 0;
    self.combathighicon maps\mp\gametypes\_hud_util::setparent( self.combathightimer );
    self.combathighicon maps\mp\gametypes\_hud_util::setpoint( "BOTTOM", "TOP" );
    self.combathighicon.archived = 1;
    self.combathighicon.sort = 1;
    self.combathighicon.foreground = 1;
    self.combathighoverlay.alpha = 0.0;
    self.combathighoverlay fadeovertime( 1.0 );
    self.combathighicon fadeovertime( 1.0 );
    self.combathighoverlay.alpha = 1.0;
    self.combathighicon.alpha = 0.85;
    thread unsetcombathighondeath();
    thread unsetcombathighonride();
    wait 8;
    self.combathighicon fadeovertime( 2.0 );
    self.combathighicon.alpha = 0.0;
    self.combathighoverlay fadeovertime( 2.0 );
    self.combathighoverlay.alpha = 0.0;
    self.combathightimer fadeovertime( 2.0 );
    self.combathightimer.alpha = 0.0;
    wait 2;
    self.damageblockedtotal = undefined;
    maps\mp\_utility::_unsetperk( "specialty_combathigh" );
}

unsetcombathighondeath()
{
    self endon( "disconnect" );
    self endon( "unset_combathigh" );
    self waittill( "death" );
    thread maps\mp\_utility::_unsetperk( "specialty_combathigh" );
}

unsetcombathighonride()
{
    self endon( "disconnect" );
    self endon( "unset_combathigh" );

    for (;;)
    {
        wait 0.05;

        if ( maps\mp\_utility::isusingremote() )
        {
            thread maps\mp\_utility::_unsetperk( "specialty_combathigh" );
            break;
        }
    }
}

unsetcombathigh()
{
    self notify( "unset_combathigh" );
    self.combathighoverlay destroy();
    self.combathighicon destroy();
    self.combathightimer destroy();
}

setlightarmor( var_0 )
{
    self notify( "give_light_armor" );

    if ( isdefined( self.lightarmorhp ) )
        unsetlightarmor();

    thread removelightarmorondeath();
    thread removelightarmoronmatchend();
    self.lightarmorhp = 150;

    if ( isdefined( var_0 ) )
        self.lightarmorhp = var_0;

    if ( isplayer( self ) )
    {
        self setclientomnvar( "ui_light_armor", 1 );
        maps\mp\_utility::_setnameplatematerial( "player_name_bg_green_vest", "player_name_bg_red_vest" );
    }
}

removelightarmorondeath()
{
    self endon( "disconnect" );
    self endon( "give_light_armor" );
    self endon( "remove_light_armor" );
    self waittill( "death" );
    unsetlightarmor();
}

unsetlightarmor()
{
    self.lightarmorhp = undefined;

    if ( isplayer( self ) )
    {
        self setclientomnvar( "ui_light_armor", 0 );
        maps\mp\_utility::_restorepreviousnameplatematerial();
    }

    self notify( "remove_light_armor" );
}

removelightarmoronmatchend()
{
    self endon( "disconnect" );
    self endon( "remove_light_armor" );
    level common_scripts\utility::waittill_any( "round_end_finished", "game_ended" );
    thread unsetlightarmor();
}

haslightarmor()
{
    return isdefined( self.lightarmorhp ) && self.lightarmorhp > 0;
}

hasheavyarmor( var_0 )
{
    return isdefined( var_0.heavyarmorhp ) && var_0.heavyarmorhp > 0;
}

setheavyarmor( var_0 )
{
    if ( isdefined( var_0 ) )
        self.heavyarmorhp = var_0;
}

setrevenge()
{
    self notify( "stopRevenge" );
    wait 0.05;

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

    if ( level.teambased && self.team == self.lastkilledby.team )
        return;

    var_0 = spawnstruct();
    var_0.showto = self;
    var_0.icon = "compassping_revenge";
    var_0.offset = ( 0, 0, 64 );
    var_0.width = 10;
    var_0.height = 10;
    var_0.archived = 0;
    var_0.delay = 1.5;
    var_0.constantsize = 0;
    var_0.pintoscreenedge = 1;
    var_0.fadeoutpinnedicon = 0;
    var_0.is3d = 0;
    self.revengeparams = var_0;
    self.lastkilledby maps\mp\_entityheadicons::setheadicon( var_0.showto, var_0.icon, var_0.offset, var_0.width, var_0.height, var_0.archived, var_0.delay, var_0.constantsize, var_0.pintoscreenedge, var_0.fadeoutpinnedicon, var_0.is3d );
    thread watchrevengedeath();
    thread watchrevengekill();
    thread watchrevengedisconnected();
    thread watchrevengevictimdisconnected();
    thread watchstoprevenge();
}

watchrevengedeath()
{
    self endon( "stopRevenge" );
    self endon( "disconnect" );
    var_0 = self.lastkilledby;

    for (;;)
    {
        var_0 waittill( "spawned_player" );
        var_0 maps\mp\_entityheadicons::setheadicon( self.revengeparams.showto, self.revengeparams.icon, self.revengeparams.offset, self.revengeparams.width, self.revengeparams.height, self.revengeparams.archived, self.revengeparams.delay, self.revengeparams.constantsize, self.revengeparams.pintoscreenedge, self.revengeparams.fadeoutpinnedicon, self.revengeparams.is3d );
    }
}

watchrevengekill()
{
    self endon( "stopRevenge" );
    self waittill( "killed_enemy" );
    self notify( "stopRevenge" );
}

watchrevengedisconnected()
{
    self endon( "stopRevenge" );
    self.lastkilledby waittill( "disconnect" );
    self notify( "stopRevenge" );
}

watchstoprevenge()
{
    var_0 = self.lastkilledby;
    self waittill( "stopRevenge" );

    if ( !isdefined( var_0 ) )
        return;

    foreach ( var_3, var_2 in var_0.entityheadicons )
    {
        if ( !isdefined( var_2 ) )
            continue;

        var_2 destroy();
    }
}

watchrevengevictimdisconnected()
{
    var_0 = self.objidfriendly;
    var_1 = self.lastkilledby;
    var_1 endon( "disconnect" );
    level endon( "game_ended" );
    self endon( "stopRevenge" );
    self waittill( "disconnect" );

    if ( !isdefined( var_1 ) )
        return;

    foreach ( var_4, var_3 in var_1.entityheadicons )
    {
        if ( !isdefined( var_3 ) )
            continue;

        var_3 destroy();
    }
}

unsetrevenge()
{
    self notify( "stopRevenge" );
}
