@name Bunker
@persist [P1,P2,P3,P4]:entity Opened  Opnd Timer [E O]:entity 
if(first() ){
    
    propSpawnEffect(0)
    
    runOnTick(1)
    
    E = entity()
    O = owner()
    

    P1=propSpawn("models/props_phx/misc/bunker01.mdl",E:toWorld(vec(0,0,-2)),ang(0,0,0),1)
    P1:setMaterial("phoenix_storms/metalbox2")
    P1:setMass(50000)
    
    E:parentTo(P1)
    
    P2=propSpawn("models/props_doors/door03_slotted_left.mdl",P1:toWorld(vec(-101,59.5,56)),ang(0,0,0),1)
    P2:setMass(1)
    
    P3=propSpawn("models/Items/ammocrate_ar2.mdl",P1:toWorld(vec(-65,7,15.9)),ang(0,0,0),1)
    P3:setAlpha(0)
    P3:parentTo(P1)
    Opnd = 0
    
    P4=propSpawn("models/hunter/blocks/cube025x05x025.mdl",P1:toWorld(vec(-98,51,53)),ang(0,0,90),1)
    P4:setMass(1)
    P4:parentTo(P1)
    P4:setAlpha(0)
    
    holoCreate(1)
    holoModel(1,"models/Items/ammocrate_ar2.mdl")
    holoPos(1,P1:toWorld(vec(-65,7,18.3)))
    holoAng(1,ang(0,0,0))
    holoParent(1,P1)
    Opened = 0
    
    holoCreate(2)
    holoModel(2,"models/props_lab/eyescanner.mdl")
    holoPos(2,P1:toWorld(vec(-107,45,39)))
    holoAng(2,ang(0,180,0))
    holoParent(2,P1)
    
    holoCreate(3)
    holoModel(3,"models/props_lab/eyescanner.mdl")
    holoPos(3,P1:toWorld(vec(-9,33,39)))
    holoAng(3,ang(0,-90,0))
    holoParent(3,P1)
}


local Use = O:keyUse()

if((O:aimEntity() == P3 ) & changed(Use) & Use){
    if(Opened) {holoAnim(1,2)} else {holoAnim(1,1)}
    Opened = !Opened
}

if(( O:aimEntity() == P4 ) & changed(Use) & Use){
    Opnd = !Opnd
}


if(Opnd & Timer < 1) {Timer += 0.01}       
if(!Opnd & Timer > 0) {Timer -= 0.01}


local Vector = mix(vec(-101,10,56), vec(-101,59.5,56),Timer)
P2:setPos(E:toWorld(Vector))
P2:setAngle(P1:angles())
P2:propFreeze(1)
