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

init()
{
    var_0 = spawnstruct();
    var_0.streakname = "placeable_barrier";
    var_0.weaponinfo = "ims_projectile_mp";
    var_0.modelbase = "placeable_barrier";
    var_0.modeldestroyed = "placeable_barrier_destroyed";
    var_0.modelplacement = "placeable_barrier_obj";
    var_0.modelplacementfailed = "placeable_barrier_obj_red";
    var_0.hintstring = &"KILLSTREAKS_HINTS_PLACEABLE_COVER_PICKUP";
    var_0.placestring = &"KILLSTREAKS_HINTS_PLACEABLE_COVER_PLACE";
    var_0.cannotplacestring = &"KILLSTREAKS_HINTS_PLACEABLE_COVER_CANNOT_PLACE";
    var_0.headiconheight = 75;
    var_0.splashname = "used_placeable_barrier";
    var_0.lifespan = 60.0;
    var_0.maxhealth = 500;
    var_0.allowmeleedamage = 0;
    var_0.damagefeedback = "ims";
    var_0.xppopup = "destroyed_ims";
    var_0.destroyedvo = "ims_destroyed";
    var_0.onplaceddelegate = ::onplaced;
    var_0.oncarrieddelegate = ::oncarried;
    var_0.placedsfx = "ims_plant";
    var_0.ondamageddelegate = ::ondamaged;
    var_0.ondeathdelegate = ::ondeath;
    var_0.deathvfx = loadfx( "vfx/gameplay/mp/killstreaks/vfx_ballistic_vest_death" );
    var_0.colradius = 72;
    var_0.colheight = 36;
    level.placeableconfigs["placeable_barrier"] = var_0;
    setupbrushmodel();
    level.killstreakfuncs["placeable_barrier"] = ::tryuseplaceable;
}

tryuseplaceable( var_0, var_1 )
{
    var_2 = maps\mp\killstreaks\_placeable::giveplaceable( "placeable_barrier" );

    if ( var_2 )
        maps\mp\_matchdata::logkillstreakevent( "placeable_barrier", self.origin );

    self.iscarrying = undefined;
    return var_2;
}

createobject( var_0 )
{

}

onplaced( var_0 )
{
    var_1 = level.placeableconfigs[var_0];
    self setmodel( var_1.modelbase );
    var_2 = common_scripts\utility::spawn_tag_origin();
    var_2 show();
    var_2.origin = self.origin;

    if ( !isdefined( level.barriercollision ) )
        setupbrushmodel();

    var_2 clonebrushmodeltoscriptmodel( level.barriercollision );
    var_3 = maps\mp\_utility::getotherteam( self.owner.team );
    badplace_cylinder( var_0 + self getentitynumber(), -1, self.origin, var_1.colradius, var_1.colheight, var_3 );
    self.collision = var_2;
}

oncarried( var_0 )
{
    disablecollision( var_0 );
}

ondamaged( var_0, var_1, var_2, var_3 )
{
    return var_3;
}

ondestroyed( var_0, var_1, var_2, var_3 )
{

}

ondeath( var_0 )
{
    disablecollision( var_0 );
    var_1 = level.placeableconfigs[var_0];

    if ( isdefined( var_1.deathsfx ) )
        self playsound( var_1.deathsfx );

    playfx( var_1.deathvfx, self.origin );
    wait 0.5;
}

disablecollision( var_0 )
{
    if ( isdefined( self.collision ) )
    {
        badplace_delete( var_0 + self getentitynumber() );
        self.collision delete();
        self.collision = undefined;
    }
}

setupbrushmodel()
{
    var_0 = getent( "barrier_collision", "targetname" );

    if ( isdefined( var_0 ) )
    {
        level.barriercollision = getent( var_0.target, "targetname" );
        var_0 delete();
    }

    if ( !isdefined( level.barriercollision ) )
        level.barriercollision = level.airdropcratecollision;
}
