@name Spiderboatinizer
@inputs
@outputs Vel Fast Slow E:entity W S Space Shift Alt M2 R List:array Thrust
#@persist Last Cur 
@persist List:array E:entity
#@model models/expression 2/cpu_microchip_nano.mdl
@model models/props_junk/PopCan01a.mdl
@trigger 
O=owner()

#By Captain Maim STEAM_0:1:8017844
#[instructions: 
1) spawn chip somewhere. Doesn't matter where.  
2) spawn an airboat, it doesn't matter what kind as long as it's just an hl2 airboat.
3) crouch and look directly at the airboat.
4) while crouching press use key.
5) observe the blue text indicating you've selected an airboat.
6) get in, and observe the controls: 
A) handels like a normal airboat but with higher acceleration
B) it goes up walls and on ceilings
C) to jump press spacebar
D) to float hold right mouse button and no spacebar
E) to travel faster hold run key
F) to travel slower hold walk key
G) if someone gives you prop protection you can turn their airboats into spiderboats
H) you can make as many spiderboats as you want, given you have prop protection or own them all.

]#


#runOnTick(1)
#Last=Cur
#entity():setAlpha(10)
#if(first()){
#    Last=curtime()-0.015
#}
#Cur=curtime()
#Time=Cur-Last
#Time=0.015
Time=0.020#*(List:count()+!List:count())
if(first()){List=array()}

interval(Time*1000)
if(O:aimEntity():type()=="prop_vehicle_airboat"&O:keyDuck()&O:keyUse()){
    
    E=O:aimEntity()  
    for(C=1,List:count()){
        if(E==List[C,entity]){
            Found=1
        }
        if(List[C,entity]==noentity()){
            List:remove(C)   
        }
        
    }
    if(!Found){
        print("You've Spiderboatinized Airboat Entity: "+E:id())
        List:pushEntity(E)
    }
  
}
for(C=1,List:count()){
    E=List[C,entity]
    
    Driver=E:driver()!=noentity()
    Drive=E:driver()
    
    W=Drive:keyForward()*Driver
    S=Drive:keyBack()*Driver
    Space=Drive:keyJump()*Driver
    Shift=Drive:keySprint()*Driver
    #R=O:keyReload()
    Alt=Drive:keyWalk()*Driver
    M2=Drive:keyAttack2()*Driver

    if(E){#:driver()==O){
        #E=entity():isConstrainedTo()
        Mass=E:mass()
        if(E:type()=="prop_vehicle_airboat"){
            Gravity=600
            #Gravity=vec(0,0,392.4725)
        }
        #if(!R&E){
           # E:applyOffsetForce(Gravity*Time*Mass*E:forward()*8,E:massCenter())#-E:forward()*8)
        #}
    }
        Velocity=797.9*0.5
        Slow=(Alt*0.5)+(!Alt)
        Fast=(Shift*1.6)+(!Shift)
        Jump=(!Space*-1)+Space
        Vel=(Velocity*(Slow*Fast))-E:vel():length()
        Thrust=(40*(Vel/30)*(E:mass()/50))
        if(Space){Jump=-1}else{Jump=1}
       
        E:applyForce(-Gravity*E:up()*Time*Mass*!M2*Jump)
        E:applyForce((Thrust*Mass*Time*E:forward()*(W-S)))
        E:applyForce(Gravity*vec(0,0,0.70)*Time*Mass*!R)
}    
