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

init()
{
    var_0 = spawnstruct();
    var_0.weaponinfo = "deployable_vest_marker_mp";
    var_0.modelbase = "mil_ammo_case_1_open";
    var_0.hintstring = &"KILLSTREAKS_HINTS_DEPLOYABLE_AMMO_USE";
    var_0.capturingstring = &"KILLSTREAKS_DEPLOYABLE_AMMO_TAKING";
    var_0.event = "deployable_ammo_taken";
    var_0.streakname = "deployable_ammo";
    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 = 50;
    var_0.xppopup = "destroyed_vest";
    var_0.vodestroyed = "ballistic_vest_destroyed";
    var_0.deployedsfx = "mp_vest_deployed_ui";
    var_0.onusesfx = "ammo_crate_use";
    var_0.onusecallback = ::onusedeployable;
    var_0.canusecallback = ::canusedeployable;
    var_0.usetime = 500;
    var_0.maxhealth = 150;
    var_0.damagefeedback = "deployable_bag";
    var_0.deathweaponinfo = "deployable_ammo_mp";
    var_0.deathvfx = loadfx( "fx/explosions/clusterbomb_exp_direct_runner" );
    var_0.deathdamageradius = 256;
    var_0.deathdamagemax = 130;
    var_0.deathdamagemin = 50;
    var_0.allowmeleedamage = 1;
    var_0.allowgrenadedamage = 1;
    var_0.maxuses = 4;
    level.boxsettings["deployable_ammo"] = var_0;
    level.killstreakfuncs["deployable_ammo"] = ::tryusedeployableammo;
    level.deployable_box["deployable_ammo"] = [];
}

tryusedeployableammo( var_0, var_1 )
{
    var_2 = maps\mp\killstreaks\_deployablebox::begindeployableviamarker( var_0, "deployable_ammo" );

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

    if ( !maps\mp\_utility::is_aliens() )
        maps\mp\_matchdata::logkillstreakevent( "deployable_ammo", self.origin );

    return 1;
}

onusedeployable( var_0 )
{
    if ( maps\mp\_utility::is_aliens() )
        addalienweaponammo( var_0 );
    else
        addallweaponammo();
}

addallweaponammo()
{
    var_0 = self getweaponslistall();

    if ( isdefined( var_0 ) )
    {
        foreach ( var_2 in var_0 )
        {
            if ( maps\mp\gametypes\_weapons::isbulletweapon( var_2 ) )
            {
                addoneweaponammo( var_2, 2 );
                continue;
            }

            if ( weaponclass( var_2 ) == "rocketlauncher" )
                addoneweaponammo( var_2, 1 );
        }
    }
}

addoneweaponammo( var_0, var_1 )
{
    var_2 = weaponclipsize( var_0 );
    var_3 = self getweaponammostock( var_0 );
    self setweaponammostock( var_0, var_3 + var_1 * var_2 );
}

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

    foreach ( var_3 in var_1 )
    {
        if ( maps\mp\gametypes\_weapons::isbulletweapon( var_3 ) )
        {
            if ( var_3 != "iw6_alienminigun_mp" )
            {
                var_4 = self getweaponammostock( var_3 );
                var_5 = weaponmaxammo( var_3 );
                var_6 = var_4 + var_5 * var_0;
                self setweaponammostock( var_3, int( min( var_6, var_5 ) ) );
            }
        }
    }
}

addfullcliptoallweapons()
{
    var_0 = self getweaponslistprimaries();

    foreach ( var_2 in var_0 )
    {
        var_3 = weaponclipsize( var_2 );
        self setweaponammoclip( var_2, var_3 );
    }
}

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

    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;
    }
}

canusedeployable( var_0 )
{
    if ( maps\mp\_utility::is_aliens() && isdefined( var_0 ) && var_0.owner == self && !isdefined( var_0.air_dropped ) )
        return 0;

    if ( !maps\mp\_utility::is_aliens() )
        return !maps\mp\_utility::isjuggernaut();
    else
        return 1;
}
