@name Conrollable watermelon made by Chaquator
@inputs Pod:wirelink Cam:wirelink
@outputs 
@persist [Bomb Melon]:entity Speed Jumps Array:array Explode Pitch Model:string View
@trigger 
if(first()){
 entity():setColor(0,0,0,0)
 Model = "models/props_junk/watermelon01.mdl"
 runOnTick(1)
 Speed = 75
 Pitch = 150 
 I = 0
 #Array[I,string]=""
 #I++
 Array[I,string]="/common/bugreporter_failed.wav"
 I++
 Array[I,string]="/vo/npc/male01/hacks01.wav"
 I++
 Array[I,string]="/vo/npc/male01/no01.wav"
 I++
 Array[I,string]="/vo/npc/male01/no02.wav"
 I++
 Array[I,string]="/vo/npc/male01/ohno.wav"
 I++
 Array[I,string]="/vo/npc/male01/ok01.wav"
 I++
 Array[I,string]="/vo/npc/male01/ok02.wav"
 I++
 Array[I,string]="/vo/npc/male01/overhere01.wav"
 I++
 Array[I,string]="/vo/npc/male01/ow01.wav"
 I++
 Array[I,string]="/vo/npc/male01/ow02.wav"
 I++
 Array[I,string]="/vo/npc/male01/question01.wav"
 I++
 Array[I,string]="/vo/npc/male01/question02.wav"
 I++
 Array[I,string]="/vo/npc/male01/question03.wav"
 I++
 Array[I,string]="/vo/npc/male01/question04.wav"
 I++
 Array[I,string]="/vo/npc/male01/question05.wav"
 I++
 Array[I,string]="/vo/npc/male01/question06.wav"
 I++
 Array[I,string]="/vo/npc/male01/question07.wav"
 I++
 Array[I,string]="/vo/npc/male01/question08.wav"
 I++
 Array[I,string]="/vo/npc/male01/question09.wav"
 I++
 Array[I,string]="/vo/npc/male01/question10.wav"
 I++
 Array[I,string]="/vo/npc/male01/question11.wav"
 I++
 Array[I,string]="/vo/npc/male01/question12.wav"
 I++
 Array[I,string]="/vo/npc/male01/question13.wav"
 I++
 Array[I,string]="/vo/npc/male01/question14.wav"
 I++
 Array[I,string]="/vo/npc/male01/question15.wav"
 I++
 Array[I,string]="/vo/npc/male01/question16.wav"
 I++
 Array[I,string]="/vo/npc/male01/question17.wav"
 I++
 Array[I,string]="/vo/npc/male01/question18.wav"
 I++
 Array[I,string]="/vo/npc/male01/question19.wav"
 I++
 Array[I,string]="/vo/npc/male01/question20.wav"
 I++
 Array[I,string]="/vo/npc/male01/question21.wav"
 I++
 Array[I,string]="/vo/npc/male01/question22.wav"
 I++
 Array[I,string]="/vo/npc/male01/question23.wav"
 I++
 Array[I,string]="/vo/npc/male01/question24.wav"
 I++
 Array[I,string]="/vo/npc/male01/question25.wav"
 I++
 Array[I,string]="/vo/npc/male01/question26.wav"
 I++
 Array[I,string]="/vo/npc/male01/question27.wav"
 I++
 Array[I,string]="/vo/npc/male01/question28.wav"
 I++
 Array[I,string]="/vo/npc/male01/question29.wav"
 I++
 Array[I,string]="/vo/npc/male01/question30.wav"
 I++
 Array[I,string]="/vo/npc/male01/runforyourlife01.wav"
 I++
 Array[I,string]="/vo/npc/male01/runforyourlife02.wav"
 I++
 Array[I,string]="/vo/npc/male01/runforyourlife03.wav"
 I++
 Array[I,string]="/vo/npc/male01/strider_run.wav"
 I++
}

Active = Pod["Active",number]
Seat = Pod["Entity",entity]
Driver = Seat:driver()
W = Pod["W",number]
A = Pod["A",number]
S = Pod["S",number]
D = Pod["D",number]
Space = Pod["Space",number]
Shift = Pod["Shift",number]
Mouse1 = Pod["Mouse1",number]
Alt = Pod["Alt",number]

if(changed(Active)){
    
 if(Active){
 #Activated
 View = 0
 Cam["Activated",number]=1
 propSpawnEffect(0)
 Melon = propSpawn(Model,Seat:toWorld(vec(0,500,50)),ang(),0)
 Melon:setColor(vec(random(1,255),random(1,255),random(1,255)))
 holoCreate(1)
 holoAlpha(1,0)
 holoCreate(2)
 holoAlpha(2,0)
 holoCreate(4)
 holoModel(4,"hq_sphere")
 holoAlpha(4,0)
 holoColor(4,vec(255,100,0))
 holoVisible(4,players(),0)
 holoVisible(4,Driver,1)
 #Timer
 timer("snd",random(5000,15000))
 #Hinting
 Seat:hintDriver("WASD Controlled",3)
 Seat:hintDriver("Space to jump",3)
 Seat:hintDriver("Alt to toggle first/third person view",3)
 Seat:hintDriver("Shift to explode",3)
 Seat:hintDriver("Thats about it. Enjoy!",3)
}
 if(!Active){
 #De-Activated
 Melon:propBreak()
 stoptimer("snd")
 stoptimer("bomb")
 soundStop(1)
 Cam["Activated",number]=0
 AllowShoot = 1
 Explode = 0
 holoDeleteAll()   
}
}

if(Active){
    rangerFilter(Melon)
    Ranger = rangerOffset(1000000000,Melon:pos(),holoEntity(2):forward())
    holoPos(4,Ranger:pos())
    if(Ranger:entity():isPlayer()){
    Seat:printDriver(_HUD_PRINTCENTER,"Player : "+Ranger:entity():name()+" | Health: "+Ranger:entity():health())
    }
    if(!Ranger:entity():isPlayer()&!Ranger:hitSky()&!Ranger:hitWorld()&Ranger:hit()){
    Seat:printDriver(_HUD_PRINTCENTER,"Owner of entity : "+Ranger:entity():owner():name()+"| Model: "+Ranger:entity():model())
    }
    rangerFilter(Melon)
    JumpRanger = rangerOffset(15,Melon:pos(),-holoEntity(1):up())
    #Sound
    if(clk("snd")){
    stoptimer("snd")
    timer("snd",random(5000,15000))
    Melon:soundPlay(1,0,Array[round(random(1,Array:count())),string])
    soundPitch(1,Pitch)
    }
    if(changed(Alt)&Alt){
     View = !View   
     holoAlpha(4,View*100)
    }
    #Cam Positioning
    holoPos(1,Melon:pos())
    holoPos(2,Melon:pos())
    holoAng(1,ang(0,Driver:eyeAngles():yaw(),0))
    holoAng(2,Driver:eyeAngles())
    Cam["Angle",angle]=holoEntity(2):angles()
    if(View){
        Cam["Position",vector]=Melon:pos()
    }else{
    Cam["Position",vector]=holoEntity(2):toWorld(vec(-50,0,0))
    }
    #ApplyForce
    if(W){
     Melon:applyForce(holoEntity(1):forward()*Speed)   
    }
    if(A){
     Melon:applyForce(-holoEntity(1):right()*Speed)   
    }
    if(S){
     Melon:applyForce(-holoEntity(1):forward()*Speed)   
    }
    if(D){
     Melon:applyForce(holoEntity(1):right()*Speed)   
    }
    #Ranger = rangerOffset(10,Melon:pos(),-holoEntity(1):up())
    if(changed(Space)&Space&JumpRanger:hit()){
     Melon:applyForce(holoEntity(1):up()*(Speed*50))
    }
    if(changed(Shift)&Shift&!Explode){
        timer("bomb",1000)
        Melon:soundPlay(2,0,"/vo/npc/male01/watchout.wav")
        soundPitch(2,Pitch)
        Explode = 1
    }
    if(clk("bomb")){
     stoptimer("bomb") 
    Bomb = propSpawn("models/props_phx/misc/potato_launcher_explosive.mdl",Melon:pos(),ang(),1)
    Bomb:propBreak()  
    Melon:propBreak()
    soundStop(2)
    Explode = 0
    }
    if(holoEntity(1):pos()==vec()){
     Seat:hintDriver("Your melon is dead",2)
     Pod["Eject",number] = 1
    } else { Pod["Eject",number] = 0 }
}
if(first()){
 if(!entity():getName():find("Chaquator")){
 print("Credit stealing bastard")
 selfDestructAll()   
}   
}
if(dupefinished()){
 reset()   
}
