@name FailCake PortaL Radio <3
@outputs Screen Damage:array E:entity C
@persist Radio Pitchslow Broken On
@trigger all
@model models/props/radio_reference.mdl

if(first()){
Pitchslow = 100
C = 100 
On = 0
}

### DAMAGE


findByClass("Player")
A = findToArray()
M = A:count()
Ent = entity()

for(I=1,M){
    E = A[I,entity]
    if(
    (E:aimEntity()==Ent)
    &E:weapon():type()==("weapon_crowbar") 
    &changed(E:keyAttack1())
    &E:shootPos():distance(Ent:pos())<80
    ){
        C = C - 20
    }
}

if(C < 100){soundPitch(1000,C)}
if(C <= 0){C = 0
soundPitch(1000,0)
soundStop(1000)
}
### DAMAGE


##POWER ON##

for(I=1,M){
    Op = A[I,entity]
    if((Op:aimEntity()==Ent)& Op:keyUse()){
        On = On
        On = 1
    }
}

## POWER ON##


E = entity()
interval(1000)

if(On == 1){
if(E:isUnderWater() == 0 & E:isOnFire() == 0 & Broken == 0){
Radio += 1
if(Radio == 2){
E:soundPlay(1000,1000,"ambient/music/looping_radio_mix.wav")
soundPitch(1000,100)
}
}else{
Broken = 1
}



if(Broken){
Pitchslow -= 10
soundPitch(1000,Pitchslow)
if(Pitchslow <= 0){soundStop(1000)}
}
}

if(duped()){selfDestructAll()}
