@name hover
@inputs Pod:wirelink
@outputs RRRR DBG DBG3 DBG5 W1:entity W2:entity
@persist TR DDBUG P HE:entity Z5 Z6 T2 PA MOD OPS RRR Driver:entity DBG4 RRRR AAAA Rand DBG3 VV2 K VV YY RR WE:entity DBG DBG2 [A2]:angle Z4 R:array [V8,V7,V6,V4,V5,V3,V2,V]:vector Y Z
@persist RD2:ranger RD:ranger RD3:ranger HE2:entity RD4:ranger Roll
@persist HE3:entity Z7 Scale Z2 FIR WE2:entity DBG5
@trigger 
runOnTick(1)
OPS = ops()
WE2 = Pod:entity("Entity")
if(first() | duped())
{
    reset()
}
if(!FIR)
{ 
    WE = entity():isWeldedTo()
    R = WE:getConstraints()
    R:pushEntity(WE)
    RRRR = 1
    Rand = randint(0,65535)
    holoCreate(Rand,WE:pos()+WE:forward()*50)
    WE:soundPlay(Rand,0,"weapons/airboat/airboat_gun_loop2.wa")
    holoAng(Rand,WE:angles())
    holoParent(Rand,WE)
    holoCreate(Rand+45,WE:pos())
    holoParent(Rand+45,WE)
    holoAlpha(Rand+45,0)
    holoCreate(Rand+2,WE:pos()+WE:forward()/10)
    holoAng(Rand+2,WE:angles())
    holoParent(Rand+2,WE)
    holoAlpha(Rand+2,0)
    holoCreate(Rand+466,WE:pos()+WE:right()*10)
    holoAng(Rand+466,WE:angles())
    holoParent(Rand+466,WE)
    holoAlpha(Rand+466,0)
    HE2 = holoEntity(Rand+2)
    WE:setAlpha(255)
    WE:setMass(50000)
    WE:setTrails(20,0,5,"trails/laser",vec(-1,-1,-1),255)
    FIR = 1
}
Driver = Pod:entity("Entity")
rangerHitWater(1)
rangerFilter(R)
DBG2 = Pod:number("Active")
if(changed(DBG2))
{
    Driver:hintDriver("Welcome to Hover Chair",7)
    Driver:hintDriver("WASD to Controll this Chair",7)
    Driver:hintDriver("Shift to getting slow",7)
    Driver:hintDriver("Alt to Toggle TURBO On/Off(Default is Off)",7)
}
DBG4 = Pod:number("Alt")
if($DBG4 == 1 & !first() & !Scale)
{
    if(DBG3%2 == 0)
    {    
        WE:soundPlay(Rand+4,2,"weapons/physgun_off.wav")
        timer("AAAA",2000)
        TR = 1
    }
##    HE2:setTrails(20,100,5.5,"trails/smoke",vec(255,255,255),255)
    DBG3++
}
if(DBG5)
{
    soundPitch(Rand+456,DBG*2)
    soundPitch(Rand,DBG*2)
}
RD = rangerOffset(WE:pos(),WE:pos()-vec(0,0,60))
#RD3 = rangerOffset(WE:pos()-vec(0,0,30),WE:pos()-vec(0,0,10^10))
#RD2 = rangerOffset((WE:pos()+WE:forward())-vec(0,0,30),(WE:pos()+WE:forward()/10)-vec(0,0,100)+WE:forward()/10)
#RD4 = rangerOffset(WE:pos()-vec(0,0,30)+WE:right(),WE:pos()-vec(0,0,30)+WE:right()-vec(0,0,100))
Z4 = RD:distance()
#Z5 = RD3:distance()+30
#Z7 = RD4:distance()+30
#Z6 = RD2:distance()+30
if(Z4 <60)
{
    V6 = vec(0,0,abs(60-Z4))
}
else {V6 = vec(0,0,0)}
##if(Pod:number("Shift"))
##{
##    RRR = 50
##    RR = 5
##}
##else
##{
##    RR = 1 
##    RRR = 100
##}
if(DBG3%2 == 1 & !first())
{
    if(clk("AAAA"))
    {
        DBG5 = 1
        WE:soundPlay(Rand+4,0,"weapons/explode5.wa")
        RRRR = 1.5
#        WE:soundPlay(Rand+455,0,"vehicles/v8/third.wav")
#        WE2:soundPlay(Rand+456,0,"vehicles/Airboat/fan_blade_fullthrottle_loop1.wav")
        holoCreate(Rand+455)
        holoModel(Rand+455,"cube")
        timer("AA",0)
    }
}
elseif(DBG3%2 == 0 & !first())
{
    RRRR = 1
    if(TR)
    {
        DBG5 = 0
        soundStop(Rand+456)
##        HE2:removeTrails()
        TR = 0
    }
    soundPitch(Rand+456,DBG)
    soundPitch(Rand,DBG)
}
if(clk("AA"))
{
    if(Scale<255)
    {
        Scale+=3
        holoColor(Rand+455,vec(255,255-Scale,0))
        holoScale(Rand+455,vec(Scale,Scale,Scale))
        holoAlpha(Rand+455,350-Scale)
        timer("AA",0)
    }
    else{holoDelete(Rand+455) Scale = 0}
}
if(Pod:number("W"))
{
    VV2 = 0
    if(VV<90*RRRR)
    {
    VV+=0.2*RRRR
    }
    elseif(VV>90*RRRR) {VV -= 0.7}
    V = WE:angles():forward()*VV
}
if(Pod:number("S"))
{
    VV = 0
    if(VV<90*RRRR)
    {
    VV2+=0.2*RRRR
    }
    elseif(VV>90*RRRR) {VV -= 0.7}
    V = -WE:angles():forward()*VV2
}
if((Pod:number("A") | Pod:number("D")))
{
    if(YY<120) {YY+=1}
}
elseif(YY>0) {YY -= 1.45}
if(Pod:number("A"))
{
    if(Roll>-45)
    {
        Roll--
    }
    Y+=((YY/20)*RRRR)/3
}
if(Pod:number("D"))
{
    if(Roll<45)
    {
        Roll++
    }
    Y-=((YY/20)*RRRR)/3
}
if(!Pod:number("A") & !Pod:number("D"))
{
    if(Roll>0)
    {
        Roll--
    }
    if(Roll<0)
    {
        Roll++
    }
}
V2 = -(WE:vel()/40)
WE:applyForce(V2*1000)   
if(!Pod:number("W") & !Pod:number("S"))
{
    if(VV>0) {VV-=0.7}
    if(VV2>0) {VV2-=0.7}
    V = vec(0,0,0)
}
#DBG = VV/RR+VV2/RR+abs(V5:z())+abs(YY*(RRR/200))+25*RRRR
DBG = (vec(WE:angVel()):length()/15+WE:vel():length()/15)/2+25
##if(Pod:number("Space") & Z == 0)
##{
##    Z = WE:pos():z()
##    V5 = vec(0,0,10*RRRR)
##    timer("AAAAAAA",100)
##    MOD = 1
##}
##if(clk("AAAAAAA"))
##{
##    V5 = vec()
##    Z = 0
##}
if(Pod:number("Space"))
{
    if(P>-55)
    {
        P--
    }
}
if(Pod:number("Shift"))
{
    if(P<55)
    {
        P++
    }
}
if(!Pod:number("Shift") & !Pod:number("Space"))
{
    if(P>0)
    {
        P--
    }
    if(P<0)
    {
        P++
    }
}
#if(MOD == 1)
#{
#    T2+=5
#    V5 = vec(0,0,abs(cos(T2*(RRR/70))))*100/2
#    if(T2>=100)
#    {
#        MOD = 2
#    }
#}
#elseif(MOD == 2)
#{
#    Z2 = WE:pos():z()
#    T2-=3
#    V5 = -vec(0,0,abs(cos(T2*(RRR/70))))*100/2
#    if(T2<=0 | !Z2<Z)
#    {
#        MOD = 0
#        Z = 0 V5 = vec(0,0,0)
#    }
#}
#if(abs(Z5-Z4)<0.5)
#{
#    if(RD:hitNormal():y()<0)
#    {
#        P = (((Z6-Z4)*RD:hitNormal():toAngle():pitch())/25)
#    }
#    elseif(RD:hitNormal():y()>0)
#    {
#        P = (((Z6-Z4)*RD:hitNormal():toAngle():pitch())/25)
#    }
#    else{P = 0}
#}
#if(abs(Z5-Z4)<0.1)
#{
#    if((Z5-Z6)<-0.1)
#    {
#        P = angnorm(RD:hitNormal():toAngle():pitch()+100)
#    }
#    elseif((Z5-Z6)>0.1)
#    {
#        P = angnorm(-RD:hitNormal():toAngle():pitch()-100)
#    }
#}
A2 = angnorm(ang(P,Y,Roll)-WE:angles())
WE:applyAngForce((A2*30-WE:angVel())*WE:inertia():length()*20)
V7 = V+V3+V4+V5+V6
WE:applyForce(($V7*15+V7)*WE:mass())
