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

pre_load()
{
    level.deployable_currency_ranks = [];
    level.deployable_currency_ranks[0] = 1000;
    level.deployable_currency_ranks[1] = 2000;
    level.deployable_currency_ranks[2] = 3000;
    level.deployable_currency_ranks[3] = 4000;
    level.deployable_currency_ranks[4] = 10000;
    precachestring( &"ALIEN_COLLECTIBLES_DEPLOYABLE_CURRENCY_PICKUP" );
    precachestring( &"ALIEN_COLLECTIBLES_DEPLOYABLE_CURRENCY_TAKING" );
    precachestring( &"ALIEN_COLLECTIBLES_DEPLOYABLE_CURRENCY_TAKEN" );
    level.randombox_items = [];
    randombox_table_init( 0, 99 );
}

deployables_init()
{
    var_0 = spawnstruct();
    var_0.weaponinfo = "aliendeployable_crate_marker_mp";
    var_0.modelbase = "mp_weapon_alien_crate";
    var_0.hintstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_EXPLOSIVES_PICKUP";
    var_0.capturingstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_EXPLOSIVES_TAKING";
    var_0.eventstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_EXPLOSIVES_TAKEN";
    var_0.streakname = "deployable_explosives";
    var_0.dpadname = "dpad_team_explosives";
    var_0.splashname = "used_deployable_explosives";
    var_0.shadername = "compass_objpoint_deploy_grenades_friendly";
    var_0.headiconoffset = 25;
    var_0.lifespan = 90.0;
    var_0.usexp = 0;
    var_0.vodestroyed = "ballistic_vest_destroyed";
    var_0.deployedsfx = "mp_vest_deployed_ui";
    var_0.onusesfx = "ammo_crate_use";
    var_0.onusecallback = ::onusedeployable_explosives;
    var_0.canusecallback = maps\mp\alien\_deployablebox::default_canusedeployable;
    var_0.usetime = 500;
    var_0.maxhealth = 150;
    var_0.damagefeedback = "deployable_bag";
    var_0.deathweaponinfo = "deployable_grenades_mp";
    var_0.killxp = 0;
    var_0.allowmeleedamage = 0;
    var_0.allowgrenadedamage = 0;
    var_0.maxuses = 4;
    maps\mp\alien\_deployablebox::init_deployable( "deployable_explosives", var_0 );
    var_0 = spawnstruct();
    var_0.weaponinfo = "aliendeployable_crate_marker_mp";
    var_0.modelbase = "mp_weapon_alien_crate";
    var_0.hintstring = &"KILLSTREAKS_HINTS_LIGHT_ARMOR_PICKUP";
    var_0.capturingstring = &"KILLSTREAKS_BOX_GETTING_VEST";
    var_0.eventstring = &"KILLSTREAKS_DEPLOYED_VEST";
    var_0.streakname = "deployable_vest";
    var_0.dpadname = "dpad_team_armor";
    var_0.splashname = "used_deployable_vest";
    var_0.shadername = "compass_objpoint_deploy_friendly";
    var_0.headiconoffset = 20;
    var_0.lifespan = 90.0;
    var_0.usexp = 0;
    var_0.vodestroyed = "ballistic_vest_destroyed";
    var_0.deployedsfx = "mp_vest_deployed_ui";
    var_0.onusesfx = "ammo_crate_use";
    var_0.onusecallback = ::onusedeployable_vest;
    var_0.canusecallback = maps\mp\alien\_deployablebox::default_canusedeployable;
    var_0.usetime = 500;
    var_0.maxhealth = 300;
    var_0.damagefeedback = "deployable_bag";
    var_0.killxp = 0;
    var_0.allowmeleedamage = 0;
    var_0.allowgrenadedamage = 0;
    var_0.maxuses = 3;
    maps\mp\alien\_deployablebox::init_deployable( "deployable_vest", var_0 );
    var_0 = spawnstruct();
    var_0.weaponinfo = "aliendeployable_crate_marker_mp";
    var_0.modelbase = "mp_weapon_alien_crate";
    var_0.hintstring = &"KILLSTREAKS_HINTS_DEPLOYABLE_AMMO_USE";
    var_0.capturingstring = &"KILLSTREAKS_DEPLOYABLE_AMMO_TAKING";
    var_0.eventstring = &"KILLSTREAKS_DEPLOYABLE_AMMO_TAKEN";
    var_0.streakname = "deployable_ammo";
    var_0.dpadname = "dpad_team_ammo_reg";
    var_0.splashname = "used_deployable_ammo";
    var_0.shadername = "compass_objpoint_deploy_ammo_friendly";
    var_0.headiconoffset = 25;
    var_0.lifespan = 90.0;
    var_0.usexp = 0;
    var_0.vodestroyed = "ballistic_vest_destroyed";
    var_0.deployedsfx = "mp_vest_deployed_ui";
    var_0.onusesfx = "ammo_crate_use";
    var_0.onusecallback = ::onusedeployable_ammo;
    var_0.canusecallback = maps\mp\alien\_deployablebox::default_canusedeployable;
    var_0.usetime = 500;
    var_0.maxhealth = 150;
    var_0.damagefeedback = "deployable_bag";
    var_0.killxp = 0;
    var_0.allowmeleedamage = 0;
    var_0.allowgrenadedamage = 0;
    var_0.maxuses = 3;
    maps\mp\alien\_deployablebox::init_deployable( "deployable_ammo", var_0 );

    if ( maps\mp\alien\_utility::is_chaos_mode() )
        level.randombox_table = "mp/alien/chaos_deployable_randombox.csv";

    if ( !isdefined( level.randombox_table ) )
        level.randombox_table = "mp/alien/deployable_randombox.csv";

    var_0 = spawnstruct();
    var_0.weaponinfo = "aliendeployable_crate_marker_mp";
    var_0.modelbase = "mp_weapon_alien_crate";
    var_0.hintstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_RANDOM_PICKUP";
    var_0.capturingstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_RANDOM_TAKING";
    var_0.streakname = "deployable_randombox";
    var_0.dpadname = "dpad_team_randombox";
    var_0.splashname = "used_deployable_randombox";
    var_0.shadername = "compass_objpoint_deploy_grenades_friendly";
    var_0.headiconoffset = 25;
    var_0.lifespan = 90.0;
    var_0.usexp = 0;
    var_0.vodestroyed = "ballistic_vest_destroyed";
    var_0.deployedsfx = "mp_vest_deployed_ui";
    var_0.onusesfx = "ammo_crate_use";
    var_0.onusecallback = ::onusedeployable_randombox;
    var_0.canusecallback = maps\mp\alien\_deployablebox::default_canusedeployable;
    var_0.usetime = 500;
    var_0.maxhealth = 150;
    var_0.damagefeedback = "deployable_bag";
    var_0.deathweaponinfo = "deployable_grenades_mp";
    var_0.killxp = 0;
    var_0.allowmeleedamage = 0;
    var_0.allowgrenadedamage = 0;
    var_0.maxuses = 3;
    maps\mp\alien\_deployablebox::init_deployable( "deployable_randombox", var_0 );
    var_0 = spawnstruct();
    var_0.weaponinfo = "aliendeployable_crate_marker_mp";
    var_0.modelbase = "mp_weapon_alien_crate";
    var_0.hintstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_CURRENCY_PICKUP";
    var_0.capturingstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_CURRENCY_TAKING";
    var_0.eventstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_CURRENCY_TAKEN";
    var_0.streakname = "deployable_currency";
    var_0.dpadname = "dpad_team_currency";
    var_0.splashname = "used_deployable_currency";
    var_0.shadername = "compass_objpoint_deploy_friendly";
    var_0.headiconoffset = 25;
    var_0.lifespan = 90.0;
    var_0.usexp = 0;
    var_0.vodestroyed = "ballistic_vest_destroyed";
    var_0.deployedsfx = "mp_vest_deployed_ui";
    var_0.onusesfx = "ammo_crate_use";
    var_0.onusecallback = ::onusedeployable_currency;
    var_0.canusecallback = maps\mp\alien\_deployablebox::default_canusedeployable;
    var_0.usetime = 500;
    var_0.maxhealth = 150;
    var_0.damagefeedback = "deployable_bag";
    var_0.deathweaponinfo = "deployable_grenades_mp";
    var_0.killxp = 0;
    var_0.allowmeleedamage = 0;
    var_0.allowgrenadedamage = 0;
    var_0.maxuses = 4;
    var_0.icon_name = "alien_dpad_icon_team_money";
    maps\mp\alien\_deployablebox::init_deployable( "deployable_currency", var_0 );
    var_0 = spawnstruct();
    var_0.weaponinfo = "aliendeployable_crate_marker_mp";
    var_0.modelbase = "mp_weapon_alien_crate";
    var_0.hintstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_ADRENALINE_PICKUP";
    var_0.capturingstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_BOOST_TAKING";
    var_0.eventstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_BOOST_TAKEN";
    var_0.streakname = "deployable_adrenalinebox";
    var_0.dpadname = "dpad_team_adrenaline";
    var_0.splashname = "used_deployable_juicebox";
    var_0.shadername = "compass_objpoint_deploy_juiced_friendly";
    var_0.headiconoffset = 25;
    var_0.lifespan = 90.0;
    var_0.usexp = 0;
    var_0.vodestroyed = "ballistic_vest_destroyed";
    var_0.deployedsfx = "mp_vest_deployed_ui";
    var_0.onusesfx = "ammo_crate_use";
    var_0.onusecallback = ::onusedeployable_adrenaline;
    var_0.canusecallback = maps\mp\alien\_deployablebox::default_canusedeployable;
    var_0.usetime = 500;
    var_0.maxhealth = 300;
    var_0.damagefeedback = "deployable_bag";
    var_0.deathweaponinfo = "deployable_ammo_mp";
    var_0.killxp = 0;
    var_0.allowmeleedamage = 0;
    var_0.allowgrenadedamage = 0;
    var_0.maxuses = 3;
    level.custom_adrenalinebox_logic = ::custom_adrenalinebox_logic;
    maps\mp\alien\_deployablebox::init_deployable( "deployable_adrenalinebox", var_0 );
    var_0 = spawnstruct();
    var_0.weaponinfo = "aliendeployable_crate_marker_mp";
    var_0.modelbase = "mp_weapon_alien_crate";
    var_0.hintstring = &"KILLSTREAKS_HINTS_DEPLOYABLE_JUICEBOX_PICKUP";
    var_0.capturingstring = &"KILLSTREAKS_DEPLOYABLE_JUICEBOX_TAKING";
    var_0.eventstring = &"KILLSTREAKS_DEPLOYABLE_JUICEBOX_TAKEN";
    var_0.streakname = "deployable_juicebox";
    var_0.dpadname = "dpad_team_boost";
    var_0.splashname = "used_deployable_juicebox";
    var_0.shadername = "compass_objpoint_deploy_juiced_friendly";
    var_0.headiconoffset = 25;
    var_0.lifespan = 90.0;
    var_0.usexp = 0;
    var_0.vodestroyed = "ballistic_vest_destroyed";
    var_0.deployedsfx = "mp_vest_deployed_ui";
    var_0.onusesfx = "ammo_crate_use";
    var_0.onusecallback = ::onusedeployable_juicebox;
    var_0.canusecallback = maps\mp\alien\_deployablebox::default_canusedeployable;
    var_0.usetime = 500;
    var_0.maxhealth = 300;
    var_0.damagefeedback = "deployable_bag";
    var_0.deathweaponinfo = "deployable_ammo_mp";
    var_0.killxp = 0;
    var_0.allowmeleedamage = 0;
    var_0.allowgrenadedamage = 0;
    var_0.maxuses = 3;
    level.custom_juicebox_logic = ::custom_juicebox_logic;
    maps\mp\alien\_deployablebox::init_deployable( "deployable_juicebox", var_0 );
}

specialammo_init()
{
    var_0 = "";
    var_1 = "dpad_team_ammo_in";
    var_2 = spawnstruct();
    var_2.weaponinfo = "aliendeployable_crate_marker_mp";
    var_2.modelbase = "mp_weapon_alien_crate";
    var_2.hintstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_INCENDIARYAMMO_PICKUP";
    var_2.capturingstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_AMMO_TAKING";
    var_2.eventstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_AMMO_TAKEN";
    var_2.streakname = "deployable_specialammo_in";
    var_2.dpadname = "dpad_team_ammo_in";
    var_2.splashname = "used_deployable_in_ammo";
    var_2.shadername = "compass_objpoint_deploy_grenades_friendly";
    var_2.headiconoffset = 25;
    var_2.lifespan = 90.0;
    var_2.usexp = 0;
    var_2.vodestroyed = "ballistic_vest_destroyed";
    var_2.deployedsfx = "mp_vest_deployed_ui";
    var_2.onusesfx = "ammo_crate_use";
    var_2.onusecallback = ::default_specialammo_onusedeployable;
    var_2.canusecallback = maps\mp\alien\_deployablebox::default_canusedeployable;
    var_2.usetime = 500;
    var_2.maxhealth = 150;
    var_2.damagefeedback = "deployable_bag";
    var_2.deathweaponinfo = "deployable_specialammo_mp";
    var_2.killxp = 0;
    var_2.allowmeleedamage = 0;
    var_2.allowgrenadedamage = 0;
    var_2.maxuses = 3;

    if ( maps\mp\alien\_utility::is_chaos_mode() )
        var_2.maxuses = 1;

    maps\mp\alien\_deployablebox::init_deployable( "deployable_specialammo_in", var_2 );
    var_2 = spawnstruct();
    var_2.weaponinfo = "aliendeployable_crate_marker_mp";
    var_2.modelbase = "mp_weapon_alien_crate";
    var_2.hintstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_EXPLOSIVEAMMO_PICKUP";
    var_2.capturingstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_AMMO_TAKING";
    var_2.eventstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_AMMO_TAKEN";
    var_2.streakname = "deployable_specialammo_explo";
    var_2.dpadname = "dpad_team_ammo_explo";
    var_2.splashname = "used_deployable_exp_ammo";
    var_2.shadername = "compass_objpoint_deploy_grenades_friendly";
    var_2.headiconoffset = 25;
    var_2.lifespan = 90.0;
    var_2.usexp = 0;
    var_2.vodestroyed = "ballistic_vest_destroyed";
    var_2.deployedsfx = "mp_vest_deployed_ui";
    var_2.onusesfx = "ammo_crate_use";
    var_2.onusecallback = ::default_specialammo_onusedeployable;
    var_2.canusecallback = maps\mp\alien\_deployablebox::default_canusedeployable;
    var_2.usetime = 500;
    var_2.maxhealth = 150;
    var_2.damagefeedback = "deployable_bag";
    var_2.deathweaponinfo = "deployable_specialammo_mp";
    var_2.killxp = 0;
    var_2.allowmeleedamage = 0;
    var_2.allowgrenadedamage = 0;
    var_2.maxuses = 3;

    if ( maps\mp\alien\_utility::is_chaos_mode() )
        var_2.maxuses = 1;

    maps\mp\alien\_deployablebox::init_deployable( "deployable_specialammo_explo", var_2 );
    var_2 = spawnstruct();
    var_2.weaponinfo = "aliendeployable_crate_marker_mp";
    var_2.modelbase = "mp_weapon_alien_crate";
    var_2.hintstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_STUNAMMO_PICKUP";
    var_2.capturingstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_AMMO_TAKING";
    var_2.eventstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_AMMO_TAKEN";
    var_2.streakname = "deployable_specialammo";
    var_2.dpadname = "dpad_team_ammo_stun";
    var_2.splashname = "used_deployable_stun_ammo";
    var_2.shadername = "compass_objpoint_deploy_grenades_friendly";
    var_2.headiconoffset = 25;
    var_2.lifespan = 90.0;
    var_2.usexp = 0;
    var_2.vodestroyed = "ballistic_vest_destroyed";
    var_2.deployedsfx = "mp_vest_deployed_ui";
    var_2.onusesfx = "ammo_crate_use";
    var_2.onusecallback = ::default_specialammo_onusedeployable;
    var_2.canusecallback = maps\mp\alien\_deployablebox::default_canusedeployable;
    var_2.usetime = 500;
    var_2.maxhealth = 150;
    var_2.damagefeedback = "deployable_bag";
    var_2.deathweaponinfo = "deployable_specialammo_mp";
    var_2.killxp = 0;
    var_2.allowmeleedamage = 0;
    var_2.allowgrenadedamage = 0;
    var_2.maxuses = 3;

    if ( maps\mp\alien\_utility::is_chaos_mode() )
        var_2.maxuses = 1;

    maps\mp\alien\_deployablebox::init_deployable( "deployable_specialammo", var_2 );
    var_2 = spawnstruct();
    var_2.weaponinfo = "aliendeployable_crate_marker_mp";
    var_2.modelbase = "mp_weapon_alien_crate";
    var_2.hintstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_APAMMO_PICKUP";
    var_2.capturingstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_AMMO_TAKING";
    var_2.eventstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_AMMO_TAKEN";
    var_2.streakname = "deployable_specialammo_ap";
    var_2.dpadname = "dpad_team_ammo_ap";
    var_2.splashname = "used_deployable_ap_ammo";
    var_2.shadername = "compass_objpoint_deploy_grenades_friendly";
    var_2.headiconoffset = 25;
    var_2.lifespan = 90.0;
    var_2.usexp = 0;
    var_2.vodestroyed = "ballistic_vest_destroyed";
    var_2.deployedsfx = "mp_vest_deployed_ui";
    var_2.onusesfx = "ammo_crate_use";
    var_2.onusecallback = ::default_specialammo_onusedeployable;
    var_2.canusecallback = maps\mp\alien\_deployablebox::default_canusedeployable;
    var_2.usetime = 500;
    var_2.maxhealth = 150;
    var_2.damagefeedback = "deployable_bag";
    var_2.deathweaponinfo = "deployable_specialammo_mp";
    var_2.killxp = 0;
    var_2.allowmeleedamage = 0;
    var_2.allowgrenadedamage = 0;
    var_2.maxuses = 3;

    if ( maps\mp\alien\_utility::is_chaos_mode() )
        var_2.maxuses = 1;

    maps\mp\alien\_deployablebox::init_deployable( "deployable_specialammo_ap", var_2 );
    var_2 = spawnstruct();
    var_2.weaponinfo = "aliendeployable_crate_marker_mp";
    var_2.modelbase = "mp_weapon_alien_crate";
    var_2.hintstring = &"ALIENS_PATCH_COMBINED_AMMO_PICKUP";
    var_2.capturingstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_AMMO_TAKING";
    var_2.eventstring = &"ALIEN_COLLECTIBLES_DEPLOYABLE_AMMO_TAKEN";
    var_2.streakname = "deployable_specialammo_comb";
    var_2.dpadname = "dpad_placeholder_ammo_2";
    var_2.splashname = "used_deployable_ammo";
    var_2.shadername = "compass_objpoint_deploy_ammo_friendly";
    var_2.headiconoffset = 25;
    var_2.lifespan = 90.0;
    var_2.usexp = 0;
    var_2.vodestroyed = "ballistic_vest_destroyed";
    var_2.deployedsfx = "mp_vest_deployed_ui";
    var_2.onusesfx = "ammo_crate_use";
    var_2.onusecallback = ::default_specialammo_onusedeployable;
    var_2.canusecallback = maps\mp\alien\_deployablebox::default_canusedeployable;
    var_2.usetime = 500;
    var_2.maxhealth = 150;
    var_2.damagefeedback = "deployable_bag";
    var_2.killxp = 0;
    var_2.allowmeleedamage = 0;
    var_2.allowgrenadedamage = 0;
    var_2.maxuses = 3;
    maps\mp\alien\_deployablebox::init_deployable( "deployable_specialammo_comb", var_2 );
}

default_specialammo_onusedeployable( var_0, var_1, var_2, var_3 )
{
    self endon( "disconnect" );

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

    if ( var_1 )
    {
        thread maps\mp\alien\_persistence::deployablebox_used_track( var_0 );
        maps\mp\alien\_utility::deployable_box_onuse_message( var_0 );
    }

    while ( maps\mp\_utility::ischangingweapon() )
        wait 0.05;

    if ( !isdefined( var_3 ) )
        var_3 = var_0.boxtype;

    var_4 = undefined;
    var_5 = undefined;
    var_6 = 0;

    switch ( var_3 )
    {
        case "deployable_specialammo_ap":
            if ( !isdefined( self.special_ammocount_ap ) )
                self.special_ammocount_ap = [];

            var_5 = "piercing";
            break;
        case "deployable_specialammo_in":
            if ( !isdefined( self.special_ammocount_in ) )
                self.special_ammocount_in = [];

            var_5 = "incendiary";
            break;
        case "deployable_specialammo":
            if ( !isdefined( self.special_ammocount ) )
                self.special_ammocount = [];

            var_5 = "stun";
            break;
        case "deployable_specialammo_explo":
            if ( !isdefined( self.special_ammocount_explo ) )
                self.special_ammocount_explo = [];

            var_5 = "explosive";
            break;
        case "deployable_specialammo_comb":
            if ( !isdefined( self.special_ammocount_comb ) )
                self.special_ammocount_comb = [];

            var_5 = "combined";
            break;
    }

    var_7 = self getweaponslistprimaries();

    foreach ( var_9 in var_7 )
    {
        if ( !weapon_can_use_specialammo( var_9 ) && !maps\mp\alien\_utility::is_chaos_mode() )
            continue;

        var_10 = maps\mp\alien\_utility::give_special_ammo_by_weaponclass( var_0, var_9, var_2 );

        if ( var_10 == 0 )
            continue;

        var_11 = maps\mp\alien\_utility::getrawbaseweaponname( var_9 );
        maps\mp\alien\_utility::handle_existing_ammo( var_11, var_9, var_5 );

        switch ( var_3 )
        {
            case "deployable_specialammo_ap":
                if ( !isdefined( self.special_ammocount_ap[var_11] ) )
                    self.special_ammocount_ap[var_11] = 0;

                if ( self.special_ammocount_ap[var_11] + var_10 > weaponmaxammo( var_9 ) + weaponclipsize( var_9 ) )
                    self.special_ammocount_ap[var_11] = weaponmaxammo( var_9 );

                if ( self.special_ammocount_ap[var_11] > 0 )
                    var_6 = 1;

                self.special_ammocount_ap[var_11] = self.special_ammocount_ap[var_11] + var_10;
                self setweaponammostock( var_9, self.special_ammocount_ap[var_11] );
                break;
            case "deployable_specialammo_in":
                if ( !isdefined( self.special_ammocount_in[var_11] ) )
                    self.special_ammocount_in[var_11] = 0;

                if ( self.special_ammocount_in[var_11] + var_10 > weaponmaxammo( var_9 ) + weaponclipsize( var_9 ) )
                    self.special_ammocount_in[var_11] = weaponmaxammo( var_9 );

                if ( self.special_ammocount_in[var_11] > 0 )
                    var_6 = 1;

                self.special_ammocount_in[var_11] = self.special_ammocount_in[var_11] + var_10;
                self setweaponammostock( var_9, self.special_ammocount_in[var_11] );
                break;
            case "deployable_specialammo":
                if ( !isdefined( self.special_ammocount[var_11] ) )
                    self.special_ammocount[var_11] = 0;

                if ( self.special_ammocount[var_11] + var_10 > weaponmaxammo( var_9 ) + weaponclipsize( var_9 ) )
                    self.special_ammocount[var_11] = weaponmaxammo( var_9 );

                if ( self.special_ammocount[var_11] > 0 )
                    var_6 = 1;

                self.special_ammocount[var_11] = self.special_ammocount[var_11] + var_10;
                self setweaponammostock( var_9, self.special_ammocount[var_11] );
                break;
            case "deployable_specialammo_explo":
                if ( !isdefined( self.special_ammocount_explo[var_11] ) )
                    self.special_ammocount_explo[var_11] = 0;

                if ( self.special_ammocount_explo[var_11] + var_10 > weaponmaxammo( var_9 ) + weaponclipsize( var_9 ) )
                    self.special_ammocount_explo[var_11] = weaponmaxammo( var_9 );

                if ( self.special_ammocount_explo[var_11] > 0 )
                    var_6 = 1;

                self.special_ammocount_explo[var_11] = self.special_ammocount_explo[var_11] + var_10;
                self setweaponammostock( var_9, self.special_ammocount_explo[var_11] );
                break;
            case "deployable_specialammo_comb":
                if ( !isdefined( self.special_ammocount_comb[var_11] ) )
                    self.special_ammocount_comb[var_11] = 0;

                if ( self.special_ammocount_comb[var_11] + var_10 > weaponmaxammo( var_9 ) + weaponclipsize( var_9 ) )
                    self.special_ammocount_comb[var_11] = weaponmaxammo( var_9 );

                if ( self.special_ammocount_comb[var_11] > 0 )
                    var_6 = 1;

                self.special_ammocount_comb[var_11] = self.special_ammocount_comb[var_11] + var_10;
                self setweaponammostock( var_9, self.special_ammocount_comb[var_11] );
        }

        if ( !var_6 && !maps\mp\alien\_utility::is_chaos_mode() )
            maps\mp\alien\_utility::zero_out_specialammo_clip( var_9 );
    }

    var_13 = self getcurrentprimaryweapon();

    if ( weapon_can_use_specialammo( var_13 ) && maps\mp\alien\_utility::give_special_ammo_by_weaponclass( var_0, var_13, var_2 ) > 0 || maps\mp\alien\_utility::is_chaos_mode() )
    {
        switch ( var_5 )
        {
            case "incendiary":
                self.has_incendiary_ammo = 1;
                self setclientomnvar( "ui_alien_specialammo", 2 );
                break;
            case "explosive":
                if ( !maps\mp\_utility::_hasperk( "specialty_explosivebullets" ) )
                    maps\mp\_utility::giveperk( "specialty_explosivebullets", 0 );

                self setclientomnvar( "ui_alien_specialammo", 3 );
                break;
            case "stun":
                if ( !maps\mp\_utility::_hasperk( "specialty_bulletdamage" ) )
                    maps\mp\_utility::giveperk( "specialty_bulletdamage", 0 );

                self setclientomnvar( "ui_alien_specialammo", 1 );
                break;
            case "piercing":
                if ( !maps\mp\_utility::_hasperk( "specialty_armorpiercing" ) )
                    maps\mp\_utility::giveperk( "specialty_armorpiercing", 0 );

                self setclientomnvar( "ui_alien_specialammo", 4 );
                break;
            case "combined":
                if ( !maps\mp\_utility::_hasperk( "specialty_explosivebullets" ) )
                    maps\mp\_utility::giveperk( "specialty_explosivebullets", 0 );

                if ( !maps\mp\_utility::_hasperk( "specialty_bulletdamage" ) )
                    maps\mp\_utility::giveperk( "specialty_bulletdamage", 0 );

                if ( !maps\mp\_utility::_hasperk( "specialty_armorpiercing" ) )
                    maps\mp\_utility::giveperk( "specialty_armorpiercing", 0 );

                self.has_incendiary_ammo = 1;
                self setclientomnvar( "ui_alien_specialammo", 5 );
                break;
        }
    }

    if ( maps\mp\alien\_utility::is_chaos_mode() )
    {
        var_14 = undefined;

        if ( var_5 != "incendiary" )
            self.has_incendiary_ammo = undefined;
        else if ( var_5 != "stun" )
            var_14 = "specialty_bulletdamage";
        else if ( var_5 != "piercing" )
            var_14 = "specialty_armorpiercing";
        else if ( var_5 != "explosive" )
            var_14 = "specialty_explosivebullets";

        if ( isdefined( var_14 ) )
        {
            if ( maps\mp\_utility::_hasperk( var_14 ) )
            {
                maps\mp\_utility::_unsetperk( var_14 );
                return;
            }

            return;
        }
    }
    else
    {
        thread maps\mp\alien\_utility::special_ammo_weapon_change_monitor( var_5 );
        thread maps\mp\alien\_utility::special_ammo_weapon_fire_monitor( var_5 );
    }
}

addratiomaxstockcombinedtoallweapons( var_0 )
{
    var_1 = self getweaponslistprimaries();

    foreach ( var_3 in var_1 )
    {
        if ( maps\mp\alien\_utility::is_incompatible_weapon( var_3 ) )
            continue;

        if ( maps\mp\gametypes\_weapons::isbulletweapon( var_3 ) )
        {
            if ( var_3 != "iw6_alienminigun_mp" && var_3 != "iw6_alienminigun1_mp" && var_3 != "iw6_alienminigun2_mp" && var_3 != "iw6_alienminigun3_mp" && var_3 != "iw6_alienminigun4_mp" && weapontype( var_3 ) != "riotshield" )
            {
                var_4 = maps\mp\alien\_utility::getrawbaseweaponname( var_3 );
                var_5 = self getweaponammostock( var_3 );
                var_6 = weaponmaxammo( var_3 );
                var_7 = var_5 + var_6 * var_0;
                self setweaponammostock( var_3, int( min( var_7, var_6 ) ) );
            }
        }
    }
}

addfullcombinedcliptoallweapons()
{
    var_0 = self getweaponslistprimaries();

    foreach ( var_2 in var_0 )
    {
        if ( maps\mp\alien\_utility::is_incompatible_weapon( var_2 ) )
            continue;

        if ( maps\mp\gametypes\_weapons::isbulletweapon( var_2 ) )
        {
            if ( var_2 != "iw6_alienminigun_mp" && var_2 != "iw6_alienminigun1_mp" && var_2 != "iw6_alienminigun2_mp" && var_2 != "iw6_alienminigun3_mp" && var_2 != "iw6_alienminigun4_mp" && weapontype( var_2 ) != "riotshield" )
            {
                var_3 = maps\mp\alien\_utility::getrawbaseweaponname( var_2 );
                var_4 = weaponclipsize( var_2 );

                if ( maps\mp\alien\_utility::is_akimbo_weapon( var_2 ) )
                {
                    self setweaponammoclip( var_2, var_4, "left" );
                    self setweaponammoclip( var_2, var_4, "right" );
                }
                else
                    self setweaponammoclip( var_2, var_4 );
            }
        }
    }
}

weapon_can_use_specialammo( var_0 )
{
    if ( maps\mp\gametypes\_weapons::isbulletweapon( var_0 ) && !maps\mp\alien\_utility::is_incompatible_weapon( var_0 ) )
        return 1;

    return 0;
}

onusedeployable_randombox( var_0 )
{
    thread maps\mp\alien\_persistence::deployablebox_used_track( var_0 );
    giverandomdeployable( var_0 );
}

giverandomdeployable( var_0 )
{
    choose_item_inside_randombox( var_0 );
}

choose_item_inside_randombox( var_0 )
{
    var_1 = [];
    var_2 = 0;
    var_3 = var_0.upgrade_rank;

    foreach ( var_7, var_5 in level.randombox_items )
    {
        if ( var_3 == 0 )
            var_2 = var_5.level_0_weight;
        else if ( var_3 == 1 )
            var_2 = var_5.level_1_weight;
        else if ( var_3 == 2 )
            var_2 = var_5.level_2_weight;
        else if ( var_3 == 3 )
            var_2 = var_5.level_3_weight;
        else if ( var_3 == 4 )
            var_2 = var_5.level_4_weight;

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

    var_8 = var_1[randomintrange( 0, var_1.size )];
    give_randombox_item( var_8, var_0 );
}

give_randombox_item( var_0, var_1 )
{
    switch ( var_0.ref )
    {
        case "ammo":
            give_ammo_item( var_1 );
            break;
        case "soflam":
            give_soflam_item( var_1 );
            break;
        case "flare":
            give_flare_item( var_1 );
            break;
        case "leash":
            give_leash_item( var_1 );
            break;
        case "armor":
            give_armor_item( var_1 );
            break;
        case "boost":
            give_boost_item( var_1 );
            break;
        case "explosives":
            give_explosive_item( var_1 );
            break;
        case "trophy":
            give_trophy_item( var_1 );
            break;
        case "feral":
            give_feral_item( var_1 );
            break;
        case "specialammo":
            give_special_ammo( var_1 );
            break;
    }
}

give_ammo_item( var_0 )
{
    addalienweaponammo( var_0 );
    maps\mp\_utility::setlowermessage( "ammo_message", &"ALIEN_COLLECTIBLES_DEPLOYABLE_AMMO_TAKEN", 3 );
}

give_soflam_item( var_0 )
{
    maps\mp\_utility::_giveweapon( "aliensoflam_mp" );
    maps\mp\_utility::setlowermessage( "soflam_messgae", &"ALIEN_COLLECTIBLES_FOUND_SOFLAM", 3 );
}

give_flare_item( var_0 )
{
    if ( self hasweapon( "alienthrowingknife_mp" ) )
        self takeweapon( "alienthrowingknife_mp" );

    if ( self hasweapon( "alientrophy_mp" ) )
        self takeweapon( "alientrophy_mp" );

    if ( isdefined( level.give_randombox_item_check ) )
        self [[ level.give_randombox_item_check ]]( "flare" );

    self setoffhandsecondaryclass( "flash" );
    maps\mp\_utility::_giveweapon( "alienflare_mp" );
    self setweaponammoclip( "alienflare_mp", 1 );
    maps\mp\_utility::setlowermessage( "flare_message", &"ALIEN_COLLECTIBLES_FOUND_FLARE", 3 );
}

give_leash_item( var_0 )
{
    self setoffhandsecondaryclass( "throwingknife" );
    maps\mp\_utility::_giveweapon( "alienthrowingknife_mp" );
    maps\mp\_utility::setlowermessage( "pet_leash_message", &"ALIEN_COLLECTIBLES_FOUND_PET_LEASH", 3 );
}

give_armor_item( var_0 )
{
    if ( !maps\mp\_utility::isjuggernaut() )
    {
        var_0.boxtype = "deployable_vest";
        onusedeployable_vest( var_0 );
        maps\mp\_utility::setlowermessage( "armor_mesage", &"ALIEN_COLLECTIBLES_DEPLOYED_VEST", 3 );
    }
}

give_explosive_item( var_0 )
{
    var_0.boxtype = "deployable_explosives";
    onusedeployable_explosives( var_0 );
    maps\mp\_utility::setlowermessage( "explosives_message", &"ALIEN_COLLECTIBLES_DEPLOYABLE_EXPLOSIVES_TAKEN", 3 );
}

give_boost_item( var_0 )
{
    onusedeployable_juicebox( var_0 );
    maps\mp\_utility::setlowermessage( "mortar_shell_message", &"ALIEN_COLLECTIBLES_DEPLOYABLE_BOOST_TAKEN", 3 );
}

give_feral_item( var_0 )
{
    onusedeployable_adrenaline( var_0 );
    maps\mp\_utility::setlowermessage( "feral_message", &"ALIEN_COLLECTIBLES_DEPLOYABLE_ADRENALINE_TAKEN", 3 );
}

give_trophy_item( var_0 )
{
    if ( self hasweapon( "alienthrowingknife_mp" ) )
        self takeweapon( "alienthrowingknife_mp" );

    if ( self hasweapon( "alienflare_mp" ) )
        self takeweapon( "alienflare_mp" );

    if ( isdefined( level.give_randombox_item_check ) )
        self [[ level.give_randombox_item_check ]]( "trophy" );

    self setoffhandsecondaryclass( "flash" );
    self giveweapon( "alientrophy_mp", 0 );
    self setweaponammoclip( "alientrophy_mp", 1 );
    maps\mp\_utility::setlowermessage( "trophy_message", &"ALIEN_COLLECTIBLES_FOUND_TROPHY", 3 );
}

give_special_ammo( var_0 )
{
    var_1 = maps\mp\alien\_utility::get_specialized_ammo_type();

    if ( var_1 == "none" )
        var_1 = common_scripts\utility::random( [ "stun_ammo", "incendiary_ammo", "ap_ammo", "explosive_ammo" ] );

    switch ( var_1 )
    {
        case "stun_ammo":
            default_specialammo_onusedeployable( var_0, 0, 0, "deployable_specialammo" );
            maps\mp\_utility::setlowermessage( "sp_ammo", &"ALIENS_PATCH_STUN_AMMO_TAKEN", 3 );
            break;
        case "incendiary_ammo":
            default_specialammo_onusedeployable( var_0, 0, 0, "deployable_specialammo_in" );
            maps\mp\_utility::setlowermessage( "sp_ammo", &"ALIEN_COLLECTIBLES_INCENDIARY_AMMO_TAKEN", 3 );
            break;
        case "ap_ammo":
            default_specialammo_onusedeployable( var_0, 0, 0, "deployable_specialammo_ap" );
            maps\mp\_utility::setlowermessage( "sp_ammo", &"ALIEN_COLLECTIBLES_AP_AMMO_TAKEN", 3 );
            break;
        case "explosive_ammo":
            default_specialammo_onusedeployable( var_0, 0, 0, "deployable_specialammo_explo" );
            maps\mp\_utility::setlowermessage( "sp_ammo", &"ALIEN_COLLECTIBLES_EXPLOSIVE_AMMO_TAKEN", 3 );
            break;
        case "combined_ammo":
            default_specialammo_onusedeployable( var_0, 0, 0, "deployable_specialammo_comb" );
            maps\mp\_utility::setlowermessage( "sp_ammo", &"ALIEN_COLLECTIBLES_DEPLOYABLE_AMMO_TAKEN", 3 );
            break;
    }
}

randombox_table_init( var_0, var_1 )
{
    for ( var_2 = var_0; var_2 < var_1; var_2++ )
    {
        var_3 = spawnstruct();
        var_3.ref = tablelookup( level.randombox_table, 0, var_2, 1 );

        if ( var_3.ref == "" )
            break;

        var_3.level_0_weight = int( tablelookup( level.randombox_table, 0, var_2, 2 ) );
        var_3.level_1_weight = int( tablelookup( level.randombox_table, 0, var_2, 3 ) );
        var_3.level_2_weight = int( tablelookup( level.randombox_table, 0, var_2, 4 ) );
        var_3.level_3_weight = int( tablelookup( level.randombox_table, 0, var_2, 5 ) );
        var_3.level_4_weight = int( tablelookup( level.randombox_table, 0, var_2, 6 ) );
        level.randombox_items[var_3.ref] = var_3;
    }
}

onusedeployable_currency( var_0 )
{
    maps\mp\alien\_deployablebox::default_onusedeployable( var_0 );
    givecurrency( var_0 );
}

givecurrency( var_0 )
{
    if ( isdefined( var_0.upgrade_rank ) && var_0.upgrade_rank == 0 )
        maps\mp\alien\_persistence::give_player_currency( level.deployable_currency_ranks[0] );

    if ( isdefined( var_0.upgrade_rank ) && var_0.upgrade_rank == 1 )
        maps\mp\alien\_persistence::give_player_currency( level.deployable_currency_ranks[1] );

    if ( isdefined( var_0.upgrade_rank ) && var_0.upgrade_rank == 2 )
        maps\mp\alien\_persistence::give_player_currency( level.deployable_currency_ranks[2] );

    if ( isdefined( var_0.upgrade_rank ) && var_0.upgrade_rank == 3 )
        maps\mp\alien\_persistence::give_player_currency( level.deployable_currency_ranks[3] );

    if ( isdefined( var_0.upgrade_rank ) && var_0.upgrade_rank == 4 )
        maps\mp\alien\_persistence::give_player_currency( level.deployable_currency_ranks[4] );
}

onusedeployable_adrenaline( var_0 )
{
    thread maps\mp\alien\_persistence::deployablebox_used_track( var_0 );

    if ( isdefined( level.custom_adrenalinebox_logic ) )
        self thread [[ level.custom_adrenalinebox_logic ]]( level.deployablebox_adrenalinebox_rank[var_0.upgrade_rank], var_0.upgrade_rank );
}

custom_adrenalinebox_logic( var_0, var_1 )
{
    self endon( "death" );
    self endon( "faux_spawn" );
    self endon( "disconnect" );
    self endon( "unset_adrenaline" );
    level endon( "game_ended" );

    if ( isdefined( self.adrenalinetime ) )
        self.adrenalinetime = self.adrenalinetime + var_0;
    else
        self.adrenalinetime = var_0;

    if ( isdefined( self.adrenalinetime ) && self.adrenalinetime > level.deployablebox_adrenalinebox_max )
        self.adrenalinetime = level.deployablebox_adrenalinebox_max;

    if ( isdefined( self.isferal ) && self.isferal )
        return;

    self.isferal = 1;
    self.movespeedscaler = 1.1;
    maps\mp\_utility::giveperk( "specialty_selectivehearing", 0 );
    maps\mp\alien\_utility::restore_client_fog( 0 );
    self playlocalsound( "alien_feral_instinct_bed" );
    thread maps\mp\alien\_outline_proto::set_alien_outline();
    thread unsetadrenalineondeath();
    var_2 = var_0 * 1000 + gettime();

    if ( var_1 == 1 )
        self.movespeedscaler = 1.2;

    if ( var_1 == 2 )
    {
        self.movespeedscaler = 1.2;
        activateregenfaster();
    }

    if ( var_1 == 3 )
    {
        self.movespeedscaler = 1.2;
        activateregenfaster();
    }

    if ( var_1 == 4 )
    {
        maps\mp\_utility::giveperk( "specialty_longersprint", 0 );
        activateregenfaster();
        self.movespeedscaler = 1.2;
    }

    maps\mp\alien\_perkfunctions::updatecombatspeedscalar();

    while ( isdefined( self.adrenalinetime ) )
    {
        wait 1;
        self.adrenalinetime--;

        if ( self.adrenalinetime < 0 )
        {
            self.adrenalinetime = undefined;
            self setclientdvar( "ui_juiced_end_milliseconds", 0 );
            break;
        }

        var_2 = self.adrenalinetime * 1000 + gettime();
    }

    custom_unset_adrenaline();
}

activateregenfaster()
{
    self.regenspeed = level.regenhealthmod;
    self.ishealthboosted = 1;
}

unsetadrenalineondeath()
{
    self endon( "disconnect" );
    self endon( "unset_adrenaline" );
    common_scripts\utility::waittill_any( "death", "faux_spawn", "last_stand" );
    thread custom_unset_adrenaline( 1 );
}

custom_unset_adrenaline( var_0 )
{
    maps\mp\_utility::_unsetperk( "specialty_longersprint" );
    maps\mp\_utility::_unsetperk( "specialty_selectivehearing" );
    self.ishealthboosted = undefined;
    self.regenspeed = 1;

    if ( maps\mp\alien\_perk_utility::has_perk( "perk_medic" ) )
    {
        self.movespeedscaler = maps\mp\alien\_perk_utility::perk_getmovespeedscalar();

        if ( maps\mp\alien\_perk_utility::has_perk( "perk_medic", [ 2, 3, 4 ] ) )
            maps\mp\_utility::giveperk( "specialty_longersprint", 0 );
    }
    else
        self.movespeedscaler = maps\mp\alien\_prestige::prestige_getmoveslowscalar();

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

    if ( !maps\mp\alien\_utility::is_true( level.easter_egg_lodge_sign_active ) )
        thread maps\mp\alien\_outline_proto::unset_alien_outline();

    maps\mp\alien\_utility::restore_client_fog( 0 );
    self.isferal = undefined;

    if ( !maps\mp\alien\_utility::is_true( level.easter_egg_lodge_sign_active ) )
        self notify( "unset_adrenaline" );
}

onusedeployable_juicebox( var_0 )
{
    thread maps\mp\alien\_persistence::deployablebox_used_track( var_0 );

    if ( isdefined( level.custom_juicebox_logic ) )
        self thread [[ level.custom_juicebox_logic ]]( level.deployablebox_juicebox_rank[var_0.upgrade_rank], var_0.upgrade_rank );
}

custom_juicebox_logic( var_0, var_1, var_2 )
{
    self endon( "death" );
    self endon( "faux_spawn" );
    self endon( "disconnect" );
    self endon( "unset_juiced" );
    level endon( "game_ended" );

    if ( isdefined( self.juicetime ) )
        self.juicetime = self.juicetime + var_0;
    else
        self.juicetime = var_0;

    if ( isdefined( self.juicetime ) && self.juicetime > level.deployablebox_juicebox_max )
        self.juicetime = level.deployablebox_juicebox_max;

    if ( maps\mp\alien\_utility::is_true( var_2 ) )
        self.juicetime = var_0;

    if ( isdefined( self.isjuiced ) && self.isjuiced )
        return;

    self.isjuiced = 1;
    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 );
    maps\mp\_utility::giveperk( "specialty_fastermelee", 0 );

    if ( var_1 == 2 || var_1 == 3 || var_1 == 4 )
        self.drillspeedmodifier = 0.75;
    else
        self.drillspeedmodifier = 1.0;

    thread unsetjuiceboxondeath();
    var_3 = var_0 * 1000 + gettime();

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

    while ( isdefined( self.juicetime ) )
    {
        wait 1;
        self.juicetime--;

        if ( self.juicetime < 0 )
        {
            self.juicetime = undefined;
            self setclientdvar( "ui_juiced_end_milliseconds", 0 );
            break;
        }

        var_3 = self.juicetime * 1000 + gettime();
        self setclientdvar( "ui_juiced_end_milliseconds", var_3 );
    }

    custom_unset_juicebox();
}

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

custom_unset_juicebox( var_0 )
{
    var_1 = maps\mp\alien\_persistence::get_perk_0_level();

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

    if ( maps\mp\alien\_perk_utility::has_perk( "perk_medic", [ 2, 3, 4 ] ) )
        maps\mp\_utility::giveperk( "specialty_longersprint", 0 );

    maps\mp\_utility::_unsetperk( "specialty_fastreload" );
    self.drillspeedmodifier = 1.0;
    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" );
    maps\mp\_utility::_unsetperk( "specialty_fastermelee" );

    if ( maps\mp\alien\_perk_utility::has_perk( "perk_bullet_damage" ) )
    {
        switch ( var_1 )
        {
            case 0:
                maps\mp\alien\_perkfunctions::set_perk_bullet_damage_0();
                break;
            case 1:
                maps\mp\alien\_perkfunctions::set_perk_bullet_damage_1();
                break;
            case 2:
                maps\mp\alien\_perkfunctions::set_perk_bullet_damage_2();
                break;
            case 3:
                maps\mp\alien\_perkfunctions::set_perk_bullet_damage_3();
                break;
            case 4:
                maps\mp\alien\_perkfunctions::set_perk_bullet_damage_4();
                break;
        }
    }

    self.isjuiced = undefined;

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

    self notify( "unset_juiced" );
}

onusedeployable_ammo( var_0 )
{
    maps\mp\alien\_deployablebox::default_onusedeployable( var_0 );
    addalienweaponammo( var_0 );
}

addratiomaxstocktoallweapons( var_0 )
{
    var_1 = self getweaponslistprimaries();

    foreach ( var_3 in var_1 )
    {
        if ( maps\mp\alien\_utility::is_incompatible_weapon( var_3 ) )
            continue;

        if ( maps\mp\gametypes\_weapons::isbulletweapon( var_3 ) )
        {
            if ( var_3 != "iw6_alienminigun_mp" && var_3 != "iw6_alienminigun1_mp" && var_3 != "iw6_alienminigun2_mp" && var_3 != "iw6_alienminigun3_mp" && var_3 != "iw6_alienminigun4_mp" && weapontype( var_3 ) != "riotshield" )
            {
                var_4 = maps\mp\alien\_utility::getrawbaseweaponname( var_3 );

                if ( maps\mp\alien\_utility::player_has_specialized_ammo( var_4 ) )
                {
                    if ( isdefined( self.stored_ammo[var_4] ) )
                    {
                        if ( self.stored_ammo[var_4].ammostock < weaponmaxammo( var_3 ) )
                        {
                            var_5 = weaponmaxammo( var_3 );
                            var_6 = self.stored_ammo[var_4].ammostock + var_5 * var_0;
                            self.stored_ammo[var_4].ammostock = int( floor( var_6 ) );
                        }
                    }
                }
                else
                {
                    var_7 = self getweaponammostock( var_3 );
                    var_5 = weaponmaxammo( var_3 );
                    var_6 = var_7 + var_5 * var_0;
                    self setweaponammostock( var_3, int( min( var_6, var_5 ) ) );
                }
            }
        }
    }
}

addfullcliptoallweapons( var_0 )
{
    var_1 = self getweaponslistprimaries();

    foreach ( var_3 in var_1 )
    {
        if ( maps\mp\alien\_utility::is_incompatible_weapon( var_3 ) )
            continue;

        if ( maps\mp\gametypes\_weapons::isbulletweapon( var_3 ) )
        {
            if ( var_3 != "iw6_alienminigun_mp" && var_3 != "iw6_alienminigun1_mp" && var_3 != "iw6_alienminigun2_mp" && var_3 != "iw6_alienminigun3_mp" && var_3 != "iw6_alienminigun4_mp" && weapontype( var_3 ) != "riotshield" )
            {
                var_4 = maps\mp\alien\_utility::getrawbaseweaponname( var_3 );

                if ( maps\mp\alien\_utility::player_has_specialized_ammo( var_4 ) )
                    continue;
                else
                {
                    var_5 = weaponclipsize( var_3 );

                    if ( isdefined( var_0 ) )
                        var_5 = int( self getweaponammoclip( var_3 ) + var_5 * var_0 );

                    if ( maps\mp\alien\_utility::is_akimbo_weapon( var_3 ) )
                    {
                        var_6 = var_5;
                        var_7 = var_5;

                        if ( isdefined( var_0 ) )
                        {
                            var_6 = int( self getweaponammoclip( var_3, "left" ) + var_5 * var_0 );
                            var_7 = int( self getweaponammoclip( var_3, "right" ) + var_5 * var_0 );
                        }

                        self setweaponammoclip( var_3, var_6, "left" );
                        self setweaponammoclip( var_3, var_7, "right" );
                    }
                    else
                        self setweaponammoclip( var_3, var_5 );
                }
            }
        }
    }
}

addalienweaponammo( var_0 )
{
    var_1 = self getweaponslistprimaries();
    var_2 = check_for_nerf_min_ammo();

    if ( var_2 != 1.0 )
    {
        addratiomaxstocktoallweapons( var_2 );

        if ( var_0.upgrade_rank == 3 || var_0.upgrade_rank == 4 )
            addfullcliptoallweapons( var_2 );

        return;
    }

    switch ( var_0.upgrade_rank )
    {
        case 0:
            addratiomaxstocktoallweapons( 0.4 );
            break;
        case 1:
            addratiomaxstocktoallweapons( 0.7 );
            break;
        case 2:
            addratiomaxstocktoallweapons( 1.0 );
            break;
        case 3:
            addratiomaxstocktoallweapons( 1.0 );
            addfullcliptoallweapons();
            break;
        case 4:
            addratiomaxstocktoallweapons( 1.0 );
            addfullcliptoallweapons();
            break;
    }
}

check_for_nerf_min_ammo()
{
    return maps\mp\alien\_prestige::prestige_getminammo();
}

onusedeployable_vest( var_0 )
{
    maps\mp\alien\_deployablebox::default_onusedeployable( var_0 );
    var_1 = 0;

    if ( isdefined( self.bodyarmorhp ) )
        var_1 = self.bodyarmorhp;

    var_2 = get_adjusted_armor( var_1, var_0.upgrade_rank );
    maps\mp\alien\_damage::setbodyarmor( var_2 );
    self notify( "enable_armor" );
}

get_adjusted_armor( var_0, var_1 )
{
    if ( var_0 + level.deployablebox_vest_rank[var_1] > level.deployablebox_vest_max )
        return level.deployablebox_vest_max;

    return var_0 + level.deployablebox_vest_rank[var_1];
}

onusedeployable_explosives( var_0 )
{
    maps\mp\alien\_deployablebox::default_onusedeployable( var_0 );
    fillteamexplosives( var_0 );
}

fillteamexplosives( var_0 )
{
    if ( isdefined( var_0.upgrade_rank ) && var_0.upgrade_rank == 0 )
    {
        self setoffhandprimaryclass( "other" );
        filloffhandweapons( "aliensemtex_mp", 2 );
        filllaunchers( var_0, 4 );
    }

    if ( isdefined( var_0.upgrade_rank ) && var_0.upgrade_rank == 1 )
    {
        self setoffhandprimaryclass( "other" );
        filloffhandweapons( "alienmortar_shell_mp", 2 );
        filllaunchers( var_0, 6 );
    }

    if ( isdefined( var_0.upgrade_rank ) && var_0.upgrade_rank == 2 )
    {
        self setoffhandprimaryclass( "other" );
        filloffhandweapons( "alienbetty_mp", 2 );
        filllaunchers( var_0, 8 );
    }

    if ( isdefined( var_0.upgrade_rank ) && var_0.upgrade_rank == 3 )
    {
        self setoffhandprimaryclass( "other" );
        filloffhandweapons( "alienclaymore_mp", 4 );
        filllaunchers( var_0, 10 );
    }

    if ( isdefined( var_0.upgrade_rank ) && var_0.upgrade_rank == 4 )
    {
        self setoffhandprimaryclass( "other" );
        filloffhandweapons( "alienbetty_mp", 5 );
        filllaunchers( var_0, 12 );
    }
}

filloffhandweapons( var_0, var_1 )
{
    var_2 = self getweaponslistoffhands();
    var_3 = 0;
    var_4 = undefined;
    var_5 = 0;

    foreach ( var_7 in var_2 )
    {
        if ( var_7 != var_0 )
        {
            if ( var_7 != "none" && var_7 != "alienthrowingknife_mp" && var_7 != "alienflare_mp" && var_7 != "alientrophy_mp" && var_7 != "iw6_aliendlc21_mp" )
                self takeweapon( var_7 );

            continue;
        }

        if ( isdefined( var_7 ) && var_7 != "none" )
        {
            var_5 = self getammocount( var_7 );
            self setweaponammostock( var_7, var_5 + var_1 );
            var_3 = 1;
            break;
        }
    }

    if ( var_3 == 0 )
    {
        maps\mp\_utility::_giveweapon( var_0 );
        self setweaponammostock( var_0, var_1 );
    }
}

filllaunchers( var_0, var_1 )
{
    var_2 = self getweaponslistall();

    if ( isdefined( var_2 ) )
    {
        foreach ( var_4 in var_2 )
        {
            if ( maps\mp\alien\_utility::is_incompatible_weapon( var_4 ) )
                continue;

            var_5 = weaponclass( var_4 );
            var_6 = weaponinventorytype( var_4 );

            if ( var_4 != "iw6_alienmk32_mp" && var_4 != "iw6_alienmk321_mp" && var_4 != "iw6_alienmk322_mp" && var_4 != "iw6_alienmk323_mp" && var_4 != "iw6_alienmk324_mp" && var_4 != "aliensoflam_mp" )
            {
                if ( var_5 == "rocketlauncher" || var_5 == "grenade" )
                {
                    if ( var_6 == "primary" || var_6 == "altmode" )
                    {
                        var_7 = weaponclipsize( var_4 );
                        var_8 = check_for_nerf_min_ammo();
                        var_1 = int( var_1 * var_8 );
                        var_9 = self getweaponammostock( var_4 );
                        var_10 = var_9 + var_1;
                        var_11 = weaponmaxammo( var_4 );

                        if ( var_10 > var_11 )
                            var_10 = var_11;

                        self setweaponammostock( var_4, var_10 );
                    }
                }
            }
        }
    }
}
