@name Decoy 
@persist Ar:array E:entity W T B
@model models/props_borealis/bluebarrel001.mdl
if(first())
{
    #include "lib/functions"
    
    E = entity()
    E:setColor(0,0,0,0)
    
    B = 1
    
    runOnTick(1)
    Ar = array("models/player/alyx.mdl","models/player/arctic.mdl","models/player/barney.mdl","models/player/breen.mdl","models/player/charple.mdl","models/player/combine_soldier.mdl","models/player/combine_soldier_prisonguard.mdl","models/player/combine_super_soldier.mdl","models/player/corpse1.mdl","models/player/eli.mdl","models/player/gasmask.mdl","models/player/gman_high.mdl","models/player/guerilla.mdl","models/player/kleiner.mdl","models/player/leet.mdl","models/player/magnusson.mdl","models/player/monk.mdl","models/player/mossman.mdl","models/player/mossman_arctic.mdl","models/player/odessa.mdl","models/player/phoenix.mdl","models/player/police.mdl","models/player/police_fem.mdl","models/player/riot.mdl","models/player/skeleton.mdl","models/player/soldier_stripped.mdl","models/player/swat.mdl","models/player/urban.mdl")
    
    holoCreate(1,E:toWorld(vec(0,0,-40)))
    holoModel(1,Ar[randint(1,Ar:count()),string])
    holoAnim(1,"ACT_HL2MP_IDLE_CROUCH_physgun")
    holoParent(1,E)
    holoSetPose(1,"move_x",1)
    
    holoCreate(2,holoEntity(1):attachmentPos("anim_attachment_RH"))
    holoPos(2,holoEntity(2):toWorld(vec(0,0,3)))
    holoAng(2,holoEntity(1):attachmentAng("anim_attachment_RH"))
    holoAng(2,holoEntity(2):toWorld(ang(-20,-15,15)))
    holoModel(2,"models/weapons/w_physics.mdl")
    holoSkin(2,1)
    holoParentAttachment(2,holoEntity(1),"anim_attachment_RH")
    
    W = randint(0,1)
    timer("w",random(3000,5000))
    
    T = random(-180,180)
    timer("t",random(3000,5000))
    
    timer("rdy",100)
}

if(clk("rdy"))
{
    stoptimer("rdy")
    E:propFreeze(0)
}

R = rangerOffset(42.5,E:pos(),vec(0,0,-1))
if(changed(R:hit()))
{
    if(R:hit())
    {
        if(W)
        {
            holoAnim(1,"ACT_HL2MP_RUN_physgun")
        }else
        {
            holoAnim(1,"ACT_HL2MP_IDLE_physgun")
        }
    }else
    {
        holoAnim(1,"ACT_HL2MP_JUMP_physgun")
    }
}
E:turnTo(ang(0,T,0))
if(R:hit())
{
    E:goto(R:pos()+vec(0,0,40)+(E:forward()*W*20))
}

if(!W)
{
    if(findCanQuery())
    {
        if(B)
        {
            findByClass("player")
            findSortByDistance(E:pos())
            if(find():pos():distance(E:pos())<100)
            {
                soundPlay("s",1.25,"radio/blow.wav")
                timer("b",1300)
                B = 0
            }
        }
    }
}

if(clk("b"))
{
    propSpawn("models/props_phx/amraam.mdl",1):propBreak()
    selfDestruct()
}

FR = rangerOffset(140,E:pos(),E:forward())

if(clk("w"))
{
    stoptimer("w")
    timer("w",random(3000,5000))
    W = randint(0,1)
}
if(changed(W))
{
    if(R:hit())
    {
        if(W)
        {
            holoAnim(1,"ACT_HL2MP_RUN_physgun")
        }else
        {
            holoAnim(1,"ACT_HL2MP_IDLE_physgun")
        }
    }
}

if(clk("t"))
{
    stoptimer("t")
    timer("t",random(3000,5000))
    if(W)
    {
        T += randint(45)
    }
}elseif(FR:hit())
{
    stoptimer("t")
    timer("t",random(3000,5000))
    T += 45
}

J = !inrange(E:angles(),ang(-3,-360,-3),ang(3,360,3))
if(J)
{
    #E:applyForce(vec(0,0,25)*((abs(E:angles():roll())+abs(E:angles():pitch()))/10)*E:mass())
}

if(E:isUnderWater())
{
    selfDestruct()
}
