@name Pick up that can
@persist Found [E B T]:entity Suc Ac UF PIT H
@model models/props_trainstation/trashcan_indoor001b.mdl
if(first())
{
    entity():setAng((owner():pos()-entity():pos()):normalized():toAngle():setPitch(0):setRoll(0))
    runOnTick(1)
    timer("start",70)
}
if(clk("start"))
{
    stoptimer("start")
    E = propSpawn("models/props_junk/PopCan01a.mdl",entity():toWorld(vec(15.5,-0.501370,27.6)),entity():toWorld(ang()),1)
    holoCreate(1)
    holoModel(1,"models/police.mdl")
    holoPos(1,entity():toWorld(vec(10,33,-22)))
    holoParent(1,entity())
    holoCreate(2)
    holoModel(2,"models/weapons/w_stunbaton.mdl")
    holoPos(2,holoEntity(1):attachmentPos("anim_attachment_RH"))
    holoPos(2,holoEntity(2):toWorld(vec(7,0,0)))
    holoAng(2,holoEntity(1):attachmentAng("anim_attachment_RH")+ang(-45,-90,0))
    holoParentAttachment(2,holoEntity(1),"anim_attachment_RH")
    holoAnim(1,"batonidle2")
    timer("activate",2000)
}
if(Ac)
{
    if(!Found)
    {
        findByClass("player")
        findSortByDistance(entity():pos())
        Found = find():pos():distance(entity():pos())<65
        T = find()
    }
    if(changed(Found))
    {
        if(Found)
        {
            B = propSpawn("models/hunter/tubes/tube4x4x3.mdl",entity():toWorld(vec(0,0,50)),1)
            B:setColor(0,0,0,0)
            holoAnim(1,"itemhit")
            timer("hit",-250+holoAnimLength(1)*1000)
            timer("hituf",-630+holoAnimLength(1)*1000)
            timer("hitreset",holoAnimLength(1)*1000)
        }else
        {
            stoptimer("hit")
            stoptimer("hit1")
            stoptimer("hit2")
            stoptimer("hituf")
            holoAnim(1,"batonidle2")
        }
    }
    
    if(UF)
    {
        PIT = E:isPlayerHolding()&T:aimEntity()==E
        if(changed(PIT)&PIT)
        {
            if(!H)
            {
                H = 1
            }
            stoptimer("hit")
            stoptimer("hit1")
            stoptimer("hit2")
            stoptimer("hitgen")
            soundStop("hit")
            soundStop("hit1")
            soundStop("hit2")
            soundStop("hitgen")
        }
        if(changed(H))
        {
            if(H)
            {
                holoEntity(1):soundPlay("PIT1",2.5,"npc/metropolice/vo/putitinthetrash1.wav")
            }
        }
        Suc = E:pos():distance(entity():pos())<6.25
        if(Suc)
        {
            if(changed(Suc))
            {
                E:propDelete()
                B:propDelete()
                holoEntity(1):soundPlay("Suc",0.8,"npc/metropolice/vo/nowgetoutofhere.wav")
                holoDelete(3)
                timer("del",3000)
                Found = 0
                H = 0
                UF = 0
                Ac = 0
            }
        }
    }
}else
{
    if(clk("activate"))
    {
        stoptimer("activate")
        Ac = 1
    }
}

if(clk("hit"))
{
    stoptimer("hit")
    timer("hit1",5000)
    holoEntity(1):soundPlay("hit",1,"npc/metropolice/vo/pickupthecan1.wav")
}
if(clk("hit1"))
{
    stoptimer("hit1")
    timer("hit2",5000)
    holoEntity(1):soundPlay("hit1",1.5,"npc/metropolice/vo/pickupthecan2.wav")
}
if(clk("hit2"))
{
    stoptimer("hit2")
    timer("hitgen",random(3000,5000))
    holoEntity(1):soundPlay("hit2",1.5,"npc/metropolice/vo/pickupthecan3.wav")
}
if(clk("hitgen"))
{
    stoptimer("hitgen")
    timer("hitgen",random(3000,5000))
    soundPlay("hitgen",1.5,"npc/metropolice/vo/pickupthecan"+randint(2,3)+".wav")
}
if(clk("hituf"))
{
    stoptimer("hituf")
    UF = 1
    E:propFreeze(0)
    E:applyForce(entity():forward()*75)
    E:applyAngForce(ang(30,0,0))
}
if(clk("hitreset"))
{
    stoptimer("hitreset")
    holoAnim(1,"batonidle2")
}
if(clk("del"))
{
    TE = propSpawn("models/props_phx/amraam.mdl",entity():toWorld(vec(0,0,5)),1)
    TE:propBreak()
    holoDelete(1)
    holoCreate(100,entity():toWorld(vec(0,-70,5)))
    holoModel(100,"models/bots/boss_bot/boss_tank_part1_destruction.mdl")
    holoScale(100,vec(1.5))
    holoColor(100,vec4(0))
    entity():setColor(0,0,0,0)
    entity():propNotSolid(1)
    timer("fdel",750)
}
if(clk("fdel"))
{
    stoptimer("fdel")
    selfDestruct()
}
