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

init()
{
    var_0 = spawnstruct();
    var_0.id = "deployable_vest";
    var_0.weaponinfo = "deployable_vest_marker_mp";
    var_0.modelbase = "prop_ballistic_vest_iw6";
    var_0.modelbombsquad = "prop_ballistic_vest_iw6_bombsquad";
    var_0.hintstring = &"KILLSTREAKS_HINTS_LIGHT_ARMOR_PICKUP";
    var_0.capturingstring = &"KILLSTREAKS_BOX_GETTING_VEST";
    var_0.event = "deployable_vest_taken";
    var_0.streakname = "deployable_vest";
    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 = 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 = 1000;
    var_0.maxhealth = 300;
    var_0.damagefeedback = "deployable_bag";
    var_0.deathvfx = loadfx( "vfx/gameplay/mp/killstreaks/vfx_ballistic_vest_death" );
    var_0.allowmeleedamage = 1;
    var_0.allowgrenadedamage = 0;
    var_0.maxuses = 4;
    var_0.canuseotherboxes = 0;
    level.boxsettings["deployable_vest"] = var_0;
    level.killstreakfuncs["deployable_vest"] = ::tryusedeployablevest;
    level.deployable_box["deployable_vest"] = [];
}

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

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

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

    return 1;
}

canusedeployable( var_0 )
{
    if ( !maps\mp\_utility::is_aliens() )
        return !maps\mp\perks\_perkfunctions::haslightarmor() && !maps\mp\_utility::isjuggernaut();

    if ( isdefined( var_0 ) && var_0.owner == self && !isdefined( var_0.air_dropped ) )
        return 0;

    return !maps\mp\_utility::isjuggernaut();
}

onusedeployable( var_0 )
{
    if ( maps\mp\_utility::is_aliens() )
    {
        var_1 = 0;

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

        var_2 = get_adjusted_armor( var_1, var_0.upgrade_rank );
        maps\mp\perks\_perkfunctions::setlightarmor( var_2 );
        self notify( "enable_armor" );
    }
    else
        maps\mp\perks\_perkfunctions::setlightarmor();
}

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