@name Door
@inputs [Door Egp]:entity EGP:wirelink
@outputs 
@persist I Cracking 
@trigger 
interval(50)

findInSphere(Door:pos(),100)
findIncludeClass("player")
Target = findResult(1)

if (first()) {
    holoCreate(1)
    holoPos(1,Door:pos()+vec(0,-25,0))
    holoAlpha(1,0)
    
    holoCreate(2)
    holoPos(2,Door:pos()+vec(0,25,0))
    holoParent(2,Door)
    holoAlpha(2,0)
    
    Door:parentTo(holoEntity(1))
    
    EGP:egpClear()
    Egp:setPos(Door:pos()+vec(2,-1,-50))
    
    Name = find():name()
    Find = find()
    Tool = "keypad_cracker"
    Target = findResult(1)
}

if(owner():aimEntity() == Door & changed(owner():keyUse()) & owner():keyUse() & I<1){
    holoAng(1,Door:toWorld(ang(0,90,0)))
    Door:soundPlay("Open",0,"doors/handle_pushbar_open1.wav")
    Door:setAng(holoEntity(1):angles())
    noCollideAll(Door,1)
    #printColor(vec(255,105,0),+Name,vec(0,255,255),"  has opened your door.")
    I++
    timer("close",5000)
}
if(clk("close")){
    holoAng(1,ang(0,0,0))
    Door:soundPlay("Close",0,"doors/metal_stop1.wav")
    Door:setAng(holoEntity(1):angles())  
    noCollideAll(Door,0)
    I=0
}
if(Target:keyAttack1()&Target:weapon():type()=="keypad_cracker"){
    Door:soundPlay(1,0,"buttons/blip2.wav")
    EGP:egpClear()
    EGP:egpText(1,"Cracking...",vec2(170,326))
    EGP:egpSize(1,40)
    EGP:egpColor(1,vec(255,0,0))
    timer("crack",30000)
}
if(Target:keyAttack1()&Target:weapon():type()=="lockpick"){
    Door:soundPlay(2,0,"weapons/357/357_reload1.wav")
    EGP:egpClear()
    EGP:egpText(1,"Lock Picking...",vec2(166,336))
    EGP:egpSize(1,30)
    EGP:egpColor(1,vec(255,0,0))
    timer("crack",30000)
}
if(clk("crack")){
    holoAng(1,Door:toWorld(ang(0,90,0)))
    Door:soundPlay("Open",0,"doors/handle_pushbar_open1.wav")
    Door:setAng(holoEntity(1):angles())
    noCollideAll(Door,1)
    EGP:egpClear()
    #printColor(vec(255,105,0),+Name,vec(0,255,255),"  has opened your door.")
    I++
    timer("Close",5000)
}
if(clk("Close")){
    holoAng(1,ang(0,0,0))
    Door:soundPlay("Close",0,"doors/metal_stop1.wav")
    Door:setAng(holoEntity(1):angles())  
    EGP:egpClear()
    noCollideAll(Door,0)
    I=0
}
