@name Robotboy655's Expression Two: Vuvuzela
@persist Key1 Key2 Use Next1 Mode Pitch

if(duped())
{
    hint("Robotboy655: My chips are for personal use!",5)
    selfDestruct()
}

interval(10)

Key1 = owner():keyAttack1()
Key2 = owner():keyAttack2()
Use = owner():keyUse()

if(first())
{
    # SMALL
    #SWEP.Pitch = 160
    #SWEP.Size = 0.5
    #SWEP.RandomPitch = 10
    
    # NORMAL
    #SWEP.Pitch = 100
    #SWEP.Size = 1
    #SWEP.RandomPitch = 10
    
    #BIG
    #SWEP.Pitch = 40
    #SWEP.Size = 2
    #SWEP.RandomPitch = 0
    
    owner():soundPlay(1,0,"vuvuzela_loop_close.wav")
    soundVolume(1,0)
    
    Mode = 1
    Pitch = 100
}

if($Key1 & Key1 & !Key2)
{
    Local_Path = "vuvuzela_oneshot_" + randint(1,5) + ".mp3"
    if (!Next1)
    {
        Local_Pitch = Pitch + randint(-2,2) * (Pitch / 255)
        Local_Time = Local_Pitch / 255 * -1 + 0.5
        owner():soundPlay(0,1,Local_Path)
        soundPitch(0,Local_Pitch)
        #self:ReverbRelease()
        Next1 = 1
        timer("ResetNext1",soundDuration(Local_Path) + Local_Time * 1000)
    }
}

if(clk("ResetNext1"))
{
    Next1 = 0
}

if($Key2 & Key2)
{
    soundVolume(1,1)
    soundPitch(1,Pitch)
}
if(!Key2)
{
    soundVolume(1,0)
}

if($Use & Use)
{
    if(Mode == 2)
    {
        print("Small Vuvuzela")
        Pitch = 160
        Mode = 0
    }
    elseif(Mode == 0)
    {
        print("Normal Vuvuzela")
        Pitch = 100
        Mode = 1
    }
    elseif(Mode == 1)
    {
        print("Big Vuvuzela")
        Pitch = 40
        Mode = 2
    }
}


