@name Citadel
@inputs 
@outputs User:entity 
@persist A [CornerPos1 CornerPos2]:vector  
@trigger 
interval(100)

if (first()) {
    holoCreate(1)
    holoModel(1,"models/Humans/Group02/Female_02.mdl")
    holoMaterial(1,"models/props_combine/masterinterface01c")
    holoAnim(1,2)
    holoAng(1,ang(0,90,0))
    
    Scale = entity():isWeldedTo():boxSize()+vec(0,0,40)
    Door = holoCreate(2)
    
    holoScaleUnits(2,Scale)
    holoPos(2,entity():isWeldedTo():toWorld(vec(0,0,60)))
    holoAng(2,entity():isWeldedTo():angles())
    holoColor(2,vec(255,255,255),255)
    holoParent(2,entity())
    
    CornerPos1 = Scale / 2
    CornerPos2 = -CornerPos1
    
    CornerPos1 = Door:toWorld(CornerPos1)
    CornerPos2 = Door:toWorld(CornerPos2)
    
    CornerScale = vec() + 1
    
    holoCreate(3)
    holoPos(3,CornerPos1)
    holoScaleUnits(3,CornerScale)
    holoParent(3, Door)
    
    holoCreate(4)
    holoPos(4,CornerPos2)
    holoScaleUnits(4,CornerScale)
    holoParent(4, Door)
    
    for (I = 2,4) {holoColor(I,vec(),0)}
}

findInBox(CornerPos1,CornerPos2)
findIncludeClass("player")
findExcludePlayer(owner())
User = findClosest(holoEntity(1):pos())

if(User:isPlayer()) {A = 1}
else {A = 0}

if(changed(A) & !first()) {
    if(A == 1) {
        holoEntity(1):soundPlay("welcome",0,"npc/overwatch/cityvoice/f_anticitizenreport_spkr.wav")
        timer("wait",12800)
        concmd("say /cr Help! "+User:name()+" has entered my building without permission. Can you check it out for me?")
    } elseif (A == 0) {
        soundStop("welcome")
        soundStop("alarm")
        reset()
    }
}
if (clk("wait")) {
    holoEntity(1):soundPlay("alarm",0,"ambient/alarms/combine_bank_alarm_loop4.wav")
}
