@name Hoverball Stabalizer
@inputs Ranger Distance Elevation Sky
@outputs FL FR AR AL 
@persist 
@trigger 
interval(100)
MaxDist=200 MaxDist2=1000 MinDist=100 Afterburn=5 
Maxhov=30 Minhov=20 Maxhov2=200 ABHov=5 #Hovoff=Moveout Strength=10000 
#Height=sin(Elevation)*Distance
Flip=Sky <40 
#if((Height < 20) & (Height > -40)){Chaser=1}else{Chaser=3}
#Chased=(Distance != 0)*0.01
#Chase=(( (Height>=(-30))*Chaser-(Height<=(-20))*Chaser))*(Distance != 0)*!(Ranger<Minhov | Flip)+Chased
Hovercontroller=((Ranger<Minhov)-((Ranger>Maxhov)&(Ranger<Maxhov2)+((Ranger>Maxhov2)*ABHov)))#*!Chase+Chase+Divedown
Pitch=entity():angles():pitch() #extangp()
Roll=entity():angles():roll() #extangr()

Sc=4 #scale
Pitch1=-3.5 #negative angle limit
Pitch2=3.5 #positive angle limit
Roll1=-3.5 #negative angle limit
Roll2=3.5 #positive angle limit

PC=(Pitch > Pitch1) - (Pitch < Pitch2) #pitch control
RC=(Roll > Roll1) - (Roll < Roll2) #roll control

Hover = (!PC&!RC) & Hovercontroller + Flip
I=((90 > Roll) | (-90 < Roll))-((90 < Roll) | (-90 > Roll))
Flipover = Roll > 170 | Roll < -170
if(Flipover==1){F=6}
if(Flipover==0){F=0}
FL = sign(PC - RC*I)/Sc + Hover - F
FR = sign(PC + RC*I)/Sc + Hover + F
AR= sign(-PC + RC*I)/Sc + Hover+ F
AL = sign(-PC - RC*I)/Sc + Hover -F
