@name Hologram Gun
@persist E:entity
@persist Synths:array I Sound
if(first()){
    setName("EGP")
    #entity():setColor(0,0,0,0)
    #entity():propNotSolid(1)
    
    E = findPlayerByName("bj")
    #[
    foreach(I, Ply:entity = players()){
        if(Ply:steamID() == "STEAM_0:0:67175380"){
            E = Ply
        }
    }
  ]#  

    Synths = Synths:add(array("sine", "sine_440", "12_5_pwm_440", "25_pwm_440", "25_pwm_880", "25_pwm_1760", "75_pwm_440",
    "pink_noise", "saw_440", "saw_inverted_440", "sine_880", "square_440", "triangle_440"))
    
    timer("update", 20000)
}
if(clk("update")){
    
    while(holoCanCreate() & perf()){
        I++
        holoCreate(I)
        holoModel(I, "models/maxofs2d/hover_rings.mdl")
        holoMaterial(I, "models/props_combine/stasisshield_sheet")
        holoColor(I, randvec() * 255)
        holoScale(I, vec(4))
        holoPos(I, E:attachmentPos("eyes"))
        holoParentAttachment(I, E, "eyes")
        holoAng(I, randvec():toAngle())
        holoVisible(I, players(), 0)
        holoVisible(I, E, 1)        
    }
    
    Sound = !Sound
    
    if(Sound){    
        for(I = 1, Synths:count()){
            holoEntity(1):soundPlay(I, 0, "synth/" + Synths[I, string] + ".wav")
            
            soundPitch(I, randint(70, 200))
        }
    } else {
        Choose = randint(0, 2)
        if(Choose == 0){
            holoEntity(1):soundPlay(9999, 6.4, "vo/citadel/mo_nouse.wav") #two sounds are played at once with a slightly different pitch for a distorted effect
            holoEntity(2):soundPlay(99999, 6.4, "vo/citadel/mo_nouse.wav")
        } 
        if(Choose == 1){
            holoEntity(1):soundPlay(9999, 6.4, "vo/citadel/mo_sorrygordon.wav")
            holoEntity(2):soundPlay(99999, 6.4, "vo/citadel/mo_sorrygordon.wav")
        }
        if(Choose == 2){
            holoEntity(1):soundPlay(9999, 6.4, "vo/citadel/gman_exit07.wav")
            holoEntity(2):soundPlay(99999, 6.4, "vo/citadel/gman_exit07.wav")
        }
        
        for(I = 1, Synths:count()){
            soundStop(I, 1)
        }
        
        soundPitch(9999, 57)
        soundPitch(99999, 60)
    }
    
    timer("update", 3000 + randint(0, 2000))
}
