@name O2's Hover Vehicle
@inputs Vehicle:wirelink
@persist Bearing JVel Jump JumpHeight
@outputs HeightRanger:ranger Vel SVel Speed Speed2 Turbo Pos:vector
@persist JumpPower JumpPower2 Gravity Height Torque
@persist SX SY Alpha Hologram Timer

runOnTick(1)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  String="I'm Using Hover Vehicle [Made By O2]"
###SETTINGS###
if(first()|duped()){
    print(4,String)
    print(String)
    hint(String,7)
    concmd("say "+String)
    JumpPower=7  #Min = 5     Max = 10
    Gravity=200  #Min = 100   Max = 300
    Speed=40     #Min = 20    Max = 40
    Height=20    #Min = 20    Max = 40
    Torque=5     #Min = 5     Max = 10
}
###CODE###
E = entity():isWeldedTo()
E:setMass(50000)
rangerHitWater(1)
rangerFilter(E)
HeightRanger=rangerOffset(E:massCenter(),-vec(0,0,10^10))
if(first()|duped()){
    E:soundPlay(0,0,"vehicles/apc/apc_cruise_loop3.wav")
    soundPlay(1,0,"vehicles/apc/apc_firstgear_loop1.wav")
    E:setTrails(10,0,1,"Trails/physbeam",vec(255,255,255),255)
    JumpHeight=E:massCenter():z()
    holoCreate(77777)
}
holoScaleUnits(77777,vec(SX,SY,30))
holoAlpha(77777,Alpha)
holoColor(77777,vec(100,100,100))
holoModel(77777,"hqtorus2")
soundPitch(0,toUnit("km/h",E:vel():length()))
soundPitch(1,toUnit("km/h",E:vel():length()))
Pos=vec(E:massCenter():x(),E:massCenter():y(),JumpHeight)
Pos+=E:eye()*Vel
JumpHeight+=JVel
if(Vehicle:number("W")){if(Vel<Speed2){Vel+=Speed/100},if(Vel>Speed2){Vel-=Speed/100}}
elseif(Vehicle:number("S")){if(Vel>-Speed2/2){Vel-=Speed/100},if(Vel<-Speed2/2){Vel+=Speed/100}}
else{if(!(JumpHeight>HeightRanger:position():z()+Height|JVel>0)){if(Vel<0){Vel+=Speed/100},if(Vel>0){Vel-=Speed/100}}}
if(Vehicle:number("A")){Bearing=-Torque}
elseif(Vehicle:number("D")){Bearing=Torque}
else{Bearing=0}
if(changed(Vehicle:number("Shift"))&Vehicle:number("Shift")&Turbo==0){
    Turbo=1
    E:soundPlay(2,1.5,"weapons/cguard/charging.wav")
    timer("charging",1500)
}
if(clk("charging")){
    E:setColor(0,255,0)
    E:soundPlay(3,0,"weapons/mortar/mortar_explode1.wav")
    E:soundPlay(4,0,"weapons/mortar/mortar_explode2.wav")
    E:soundPlay(5,0,"weapons/mortar/mortar_explode3.wav")
    soundPlay(6,0,"vehicles/fast_windloop1.wav")
    E:soundPlay(6,0,"vehicles/fast_windloop1.wav")
    Vel=Speed*2
    Speed2=Speed*4
    JumpPower2=JumpPower*1.75
    holoPos(77777,E:massCenter()-E:forward()*E:boxSize()*1.5)
    holoAng(77777,E:angles()+ang(90,0,0))
    Hologram=1
    timer("Turbo2",3500)
}
if(Hologram){SX+=3,SY+=3,Alpha-=2}
if(Alpha<=0){Hologram=0,SX=0,SY=0,timer("reset2",1000)}
if(clk("reset2")){Alpha=255}
if(clk("Turbo2")){Turbo=2,timer("Turbo",7000)}
if(Turbo==2){JumpPower2=JumpPower*1.3,Speed2=Speed*2}
if(Turbo==0|Turbo==4){JumpPower2=JumpPower,Speed2=Speed,soundStop(6,3)}
if(Turbo==3){JumpPower2=JumpPower/1.5,Speed2=Speed/2,soundStop(6,3)}
if(clk("Turbo")){Turbo=3,E:setColor(255,0,0),timer("Turbodelay",12500)}
if(clk("Turbodelay")){Turbo=4,E:setColor(255,255,255),timer("Turbodelay2",5000)}
if(clk("Turbodelay2")){Turbo=0}
if(changed(Vehicle:number("Space"))&Vehicle:number("Space")&!Jump&Timer>=15){
    Jump=1
    Timer=0
    E:soundPlay(7,0,"weapons/airboat/airboat_gun_energy1.wav")
    E:soundPlay(8,0,"weapons/airboat/airboat_gun_energy2.wav")
    JVel=JumpPower2
}
if(JumpHeight>HeightRanger:position():z()+Height|JVel>0){
    Jump=1
    JVel-=Gravity/1000
}
else{
    JVel=0
    Jump=0
}
if(JumpHeight<HeightRanger:position():z()+Height){
    JumpHeight=HeightRanger:position():z()+Height-1
    Timer++
}
E:applyForce(((Pos-E:pos())*20-E:vel())*E:mass())
E:applyAngForce((-ang(E:angles():pitch(),Bearing,E:angles():roll())*25-E:angVel())*E:inertia():length()*10)
###CLAMPING###
if(first()|duped()){
    Speed=clamp(Speed,20,40)
    Torque=clamp(Torque,5,10)
    JumpPower=clamp(JumpPower,5,10)
    Gravity=clamp(Gravity,100,300)
    Height=clamp(Height,20,40)
}
