@name C4
@inputs Arm
@outputs Detonate Lamp Time Active
@persist StartTime
@trigger all

#C4, tIMED BOMB

if(first())
{
    StartTime = 45
}

if(Arm & !Active)
{
    soundPlay(0,0,"weapons/c4/c4_plant.wav")
    Active = 1
    Time = StartTime
    timer("countdown",1000)
    timer("beep",1000)
}
if(clk("countdown"))
{
    Time--
    timer("countdown",1000)   
    if(Time <= 0)
    {
        Detonate = 1
        selfDestructAll()
    }
}

if(clk("beep"))
{
    soundPlay(1,0,"weapons/c4/c4_beep1.wav")
    timer("beep",Time / StartTime * 1000)
    Lamp = !Lamp
}
