@name Mech HoloTest
@inputs Pod:wirelink
@persist [R1 R2]:vector [SOUNDS Array Contraption Players]:array
@persist [Seat Driver Hip FIND]:entity TPOSV:array RELOAD WEAPONFIND
@persist Index Height Width Offset Walk Yaw L1 L2 L3 Y Y2 Total
@persist [SOUND_WALK SOUND_PASS SOUND_STEP SOUND_MCHN]:string 
@persist FLIGHTMODE
@model models/hunter/blocks/cube05x05x025.mdl

Seat = Pod["Entity",entity]
Driver = Seat:driver()
W = Driver:keyForward()
A = Driver:keyLeft()
S = Driver:keyBack()
D = Driver:keyRight()
Sh = Driver:keySprint()
Al = Driver:keyJump() 
M1 = Driver:keyAttack1()
M2 = Driver:keyAttack2() 
R = Driver:keyReload()

if(first()|dupefinished()){

    timer("1",500)
    timer("2",500)
    timer("3",500)
    timer("4",1000) 
    timer("5",1500)
        
   #if(owner():steamID() != "STEAM_0:0:19339894"){ 
   #     chatPrint(array(owner():name()," tried to steal a contraption from STALKER!"):concat())
   #     selfDestructAll() 
   #}
       
    Height = 110     ## Height of torso above the feet
    Width  = 25     ## Width between hipjoints and hip prop
    Offset = 0     ## Difference between physical and virtual hipPos
    
    SOUND_WALK = "npc/strider/strider_step6.wav"
    SOUND_STEP = "npc/antlion_guard/foot_heavy2.wav"
    SOUND_PASS = "ambient/machines/courtyard_mach_loop.wav"
    SOUND_MCHN = "ambient/machines/turbine_loop_2.wav"
        
    SOUNDS:insertString(1,"") 
    SOUNDS:insertString(2,"") 
    SOUNDS:insertString(3,"") 
    SOUNDS:insertString(4,"") 
    timer("sound",random(5000,15000) )

    Hip = entity()
    #Hip = propSpawn("models/hunter/blocks/cube05x05x025.mdl", entity():pos()+vec(0,0,100), 1)
    Pos = Hip:pos()
    
    #Hip:setPos(Pos + vec(0,0,Height+10+Offset))
    
    findByClass("prop_vehicle_prisoner_pod")
    Seat = findClosest(entity():pos())
    
    Seat:propFreeze(1) 
    Seat:setPos(Hip:toWorld(vec(0,0,Offset)))
    Seat:setAng(Hip:toWorld(ang(0,0,0)))
    
    timer("parent",1000)
    
    Array:insertEntity(1,Hip) 
    Array:insertEntity(2,Seat)
    
    for(I=1,Array:count()){ 
        P = Array[I,entity] 
        P:setMass(5000)
        P:setAlpha(0)
    }
    
    L1 = 55
    L2 = 45
    L3 = 55
    
    Total = L1 + L2 + L3
    
    Y = 1.5
    Y2 = -0.5
    
    R1 = rangerOffset(1000,Hip:toWorld(vec(Width*Y2,-Width*Y,20)),vec(0,0,-1)):position() 
    R2 = rangerOffset(1000,Hip:toWorld(vec(Width*Y2,Width*Y,20)),vec(0,0,-1)):position()
    
    Yaw = Hip:angles():yaw()        
    
    function void holo(Model:string,Scale:vector,Position:vector,Angle:angle,Parent:entity,Material:string,Color:vector4){ 
        holoCreate(Index,Parent:toWorld(Position),Scale,Parent:toWorld(Angle))
        holoModel(Index,Model) 
        holoParent(Index,Parent)
        holoMaterial(Index,Material) 
        holoColor(Index,Color) 
        
        Index++ 
    }
    
    timer("checkfeet",500)
    
    rangerFilter(Hip)
    rangerFilter(Seat)
    rangerPersist(1)

}

if(clk("1")){ 
    holoCreate(100,Hip:toWorld( vec(0,-Width,-Offset)) )
    holoParent(100,Hip)
    holoCreate(200,holoEntity(100):toWorld( vec(L1, 0, 0) ) )
    holoParent(200,100)
    holoCreate(300,holoEntity(200):toWorld(vec( 0, 0, -L2) ) )
    holoParent(300,200)
    holoCreate(400,holoEntity(300):toWorld(vec( 0, 0, L3) ) )
    holoParent(400,300)
}

if(clk("2")){ 
    holoCreate(500,Hip:toWorld( vec(0,Width,-Offset)) )
    holoParent(500,Hip)
    holoCreate(600,holoEntity(500):toWorld( vec(L1, 0, 0) ) )
    holoParent(600,500)
    holoCreate(700,holoEntity(600):toWorld(vec( 0, 0, -L2) ) )
    holoParent(700,600)
    holoCreate(800,holoEntity(700):toWorld(vec( 0, 0, L3) ) )
    holoParent(800,700)  
}

if(clk("3")){ 
    holoCreate(900, Hip:toWorld(vec(0, 48, 65)), vec(1,1,1), Hip:toWorld(ang(15,0,15)))
    holoParent(900, Hip)
    holoCreate(1000, holoEntity(900):toWorld(vec(0, 0, -45)), vec(1,1,1), holoEntity(900):toWorld(ang(25,0,0)))
    holoParent(1000, 900)
    holoCreate(1100, Hip:toWorld(vec(0, -48, 65)), vec(1,1,1), Hip:toWorld(ang(15,0,-15)))
    holoParent(1100, Hip)
    holoCreate(1200, holoEntity(1100):toWorld(vec(0, 0, -45)), vec(1,1,1), holoEntity(1100):toWorld(ang(25,0,0)))
    holoParent(1200, 1100)
}

if(clk("4")){ 
    holoCreate(1300, Hip:toWorld(vec(0, 60, 85)), vec(1,1,1), Hip:toWorld(ang(15,0,25)))
    holoParent(1300, Hip)
    holoCreate(1400, Hip:toWorld(vec(0, -60, 85)), vec(1,1,1), Hip:toWorld(ang(15,0,-25)))
    holoParent(1400, Hip)
    
    for(I=100, 1400){ 
        holoAlpha(I, 0)
    }
}

if(clk("5")){  
    function void body(){ 
        Material3 = "models/props_combine/metal_combinebridge001"
        Material2 = ""
        Material1 = "models/props_lab/door_klab01"
        Material4 = "models/alyx/emptool_glow"
        Material5 = "phoenix_storms/grey_steel"
        
        #Color1 = vec4(230,210,160,255)
        Color1 = vec4(180, 180, 255, 255)
        Color2 = vec4(50, 50, 50, 255)
        Color3 = vec4(155,155,155,255)
        Color4 = vec4(255,255,255,0)
    
        Scale = 0.4
        ZV = 12

        #Right leg
        holo("models/props_c17/FurnitureFridge001a.mdl", vec(0.7,0.7,1), vec(L1*0.6, 0, 0), ang(270,0,180),holoEntity(100), Material1, Color1) 
        holo("models/props_c17/FurnitureFridge001a.mdl", vec(0.5,0.7,1), vec(L1*0.7, 0, -2), ang(270,0,180),holoEntity(100), Material3, Color1) 
        holo("models/props_c17/gravestone004a.mdl", vec(0.7,1,1.4), vec(0,0,-5), ang(0,90,180), holoEntity(100), Material1, Color1) 
        holo("models/props_lab/citizenradio.mdl", vec(1.2,1,1)*1.5, vec(0,0,-10), ang(0,90,0), holoEntity(100), Material1, Color1) 
        holo("models/Mechanics/robotics/k1.mdl", vec(1,1,0.95), vec(0,0,-L2*0.5), ang(90,0,0), holoEntity(200), Material3, Color1)
        holo("models/props_junk/TrashBin01a.mdl", vec(1,1,1.5), vec(0,0,L3*0.5), ang(0,0,0), holoEntity(300), Material1, Color1) 
        holo("models/props_vehicles/apc_tire001.mdl", vec(0.6, 1, 0.6), vec(0, 0, 0), ang(90, 0, 90), holoEntity(400), Material3, Color1)

        #Left leg
        holo("models/props_c17/FurnitureFridge001a.mdl", vec(0.7,0.7,1), vec(L1*0.6, 0, 0), ang(270,0,180),holoEntity(500), Material1, Color1) 
        holo("models/props_c17/FurnitureFridge001a.mdl", vec(0.5,0.7,1), vec(L1*0.7, 0, -2), ang(270,0,180),holoEntity(500), Material3, Color1) 
        holo("models/props_c17/gravestone004a.mdl", vec(0.7,1,1.4), vec(0,0,-5), ang(0,90,180), holoEntity(500), Material1, Color1) 
        holo("models/props_lab/citizenradio.mdl", vec(1.2,1,1)*1.5, vec(0,0,-10), ang(0,270,0), holoEntity(500), Material1, Color1) 
        holo("models/Mechanics/robotics/k1.mdl", vec(1,1,0.95), vec(0,0,-L2*0.5), ang(90,0,0), holoEntity(600), Material3, Color1)
        holo("models/props_junk/TrashBin01a.mdl", vec(1,1,1.5), vec(0,0,L3*0.5), ang(0,0,0), holoEntity(700), Material1, Color1) 
        holo("models/props_vehicles/apc_tire001.mdl", vec(0.6, 1, 0.6), vec(0, 0, 0), ang(90, 180, 90), holoEntity(800), Material3, Color1)

        #Hip 
        holo("models/props_lab/monitor01a.mdl", vec(1,1,1)*1.5, vec(0,0,10), ang(270,0,180), Hip, Material1, Color1)  
        holo("models/props_junk/metalgascan.mdl", vec(1,2,1), vec(9, 0, 0), ang(0,270,180), Hip, Material1, Color1) 
        holo("models/props_borealis/bluebarrel001.mdl", vec(1,1,1), vec(0,0,50), ang(0,0,0), Hip, Material3, Color1)
        holo("models/props_lab/monitor01a.mdl", vec(1,1,1)*1.8, vec(0,-10,65), ang(0,90,90), Hip, Material1, Color1)  
        holo("models/props_lab/monitor01a.mdl", vec(1,1,1)*1.8, vec(0,10,65), ang(0,270,90), Hip, Material1, Color1)  
        holo("models/props_lab/monitor01a.mdl", vec(1,1,1)*1.8, vec(0,-10,65), ang(0,90,270), Hip, Material1, Color1)  
        holo("models/props_lab/monitor01a.mdl", vec(1,1,1)*1.8, vec(0,10,65), ang(0,270,270), Hip, Material1, Color1)  
        holo("models/props_c17/playgroundTick-tack-toe_block01a.mdl", vec(1,1.3,0.7)*3, vec(0,0,45), ang(0,90,0), Hip, Material1, Color1) 
        holo("models/props_wasteland/laundry_basket001.mdl", vec(0.9,0.9,2)*0.6, vec(0, 25, 65), ang(0,0,90), Hip, Material3, Color1) 
        holo("models/props_wasteland/laundry_basket001.mdl", vec(0.9,0.9,2)*0.6, vec(0, -25, 65), ang(0,0,270), Hip, Material3, Color1)  
        holo("models/props_combine/combine_light002a.mdl", vec(1,0.7,1), vec(10,25,80), ang(280,0,0), Hip, Material3, Color1) 
        holo("models/props_c17/FurnitureFridge001a.mdl", vec(0.8,0.2,1), vec(-5,25,85), ang(260,180,0), Hip, Material1, Color1)
        holo("models/props_combine/combine_light002a.mdl", vec(1,0.7,1), vec(10,-25,80), ang(280,0,0), Hip, Material3, Color1) 
        holo("models/props_c17/FurnitureFridge001a.mdl", vec(0.8,0.2,1), vec(-5,-25,85), ang(260,180,0), Hip, Material1, Color1)
        holo("models/props_c17/oildrum001.mdl", vec(0.9,0.9,0.7), vec(-35,25,50), ang(35,-15,0), Hip, Material1, Color1) 
        holo("models/props_c17/oildrum001.mdl", vec(0.9,0.9,0.7), vec(-35,-25,50), ang(35,15,0), Hip, Material1, Color1) 
        holo("models/maxofs2d/thruster_projector.mdl",vec(1,1,1), vec(-35,25,52), ang(35,-15,180), Hip, Material2, Color1)
        holo("models/maxofs2d/thruster_projector.mdl",vec(1,1,1), vec(-35,-25,52), ang(35,15,180), Hip, Material2, Color1)
        holo("models/props_lab/monitor01b.mdl", vec(0.8,2,1.3)*2, vec(30,0,58), ang(0,180,180), Hip, Material1, Color1) 
        holo("models/props_lab/monitor01b.mdl", vec(0.8,1.5,1)*1.8, vec(35,0,72), ang(-15,180,0), Hip, Material5, Color2) 
        
        #Right Engine
        E1 = holoEntity(1400)
        holo("models/props_c17/Lockers001a.mdl", vec(0.7,1,1), vec(-5,0,0), ang(0,270,270), E1, Material1, Color1)
        holo("models/props_lab/hevplate.mdl", vec(1,1,1)*1.2, vec(-5,-8,0), ang(0,270,90), E1, Material1, Color1)
        holo("models/maxofs2d/thruster_projector.mdl",vec(1,1,1)*0.8, vec(-36,0,7), ang(270,0,0), E1, Material2, Color1)
        holo("models/maxofs2d/thruster_projector.mdl",vec(1,1,1)*0.8, vec(-36,0,-7), ang(270,0,0), E1, Material2, Color1)
                
        #Left Engine
        E2 = holoEntity(1300)
        holo("models/props_c17/Lockers001a.mdl", vec(0.7,1,1), vec(-5,0,0), ang(0,90,90), E2, Material1, Color1)
        holo("models/props_lab/hevplate.mdl", vec(1,1,1)*1.2, vec(-5,8,0), ang(0,90,90), E2, Material1, Color1)
        holo("models/maxofs2d/thruster_projector.mdl",vec(1,1,1)*0.8, vec(-36,0,7), ang(270,0,0), E2, Material2, Color1)
        holo("models/maxofs2d/thruster_projector.mdl",vec(1,1,1)*0.8, vec(-36,0,-7), ang(270,0,0), E2, Material2, Color1)
    
        #Left Arm
        Arm1 = holoEntity(900)
        Gun1 = holoEntity(1000) 
        holo("models/XQM/airplanewheel1medium.mdl",vec(1,1,1), vec(0,0,0), ang(0,90,0), Arm1, Material1, Color1) 
        holo("models/Mechanics/roboticslarge/a2.mdl", vec(1,1,1)*0.5, vec(0,0,-25), ang(90,0,0), Arm1, Material3, Color1) 
        holo("models/Combine_Helicopter/helicopter_bomb01.mdl",vec(1,1,1)*0.7, vec(0,0,0), ang(0,0,0), Gun1, Material3, Color1) 
        holo("models/props_junk/TrashBin01a.mdl", vec(1,1,1), vec(25,0,0), ang(270,0,0), Gun1, Material1, Color1) 
        
        #Left Hand
        holo("models/props_lab/jar01a.mdl",vec(1,1,1)*2, vec(45,0,0), ang(90,0,0), Gun1, Material1, Color1) 
        holo("models/mechanics/roboticslarge/clawl.mdl", vec(1,1,1)*0.3, vec(60,0,-7), ang(110,0,270), Gun1, Material3, Color1)
        holo("models/mechanics/roboticslarge/clawl.mdl", vec(1,1,1)*0.3, vec(60,0,7), ang(250,0,90), Gun1, Material3, Color1)
    
        #Right Arm
        Arm2 = holoEntity(1100)
        Gun2 = holoEntity(1200) 
        holo("models/XQM/airplanewheel1medium.mdl",vec(1,1,1), vec(0,0,0), ang(0,90,0), Arm2, Material1, Color1) 
        holo("models/Mechanics/roboticslarge/a2.mdl", vec(1,1,1)*0.5, vec(0,0,-25), ang(90,0,0), Arm2, Material3, Color1) 
        holo("models/Combine_Helicopter/helicopter_bomb01.mdl",vec(1,1,1)*0.7, vec(0,0,0), ang(0,0,0), Gun2, Material3, Color1) 
        holo("models/props_junk/TrashBin01a.mdl", vec(1,1,1), vec(25,0,0), ang(270,0,0), Gun2, Material1, Color1) 
            
        #Right Hand
        holo("models/props_lab/jar01a.mdl",vec(1,1,1)*2, vec(45,0,0), ang(90,0,0), Gun2, Material1, Color1) 
        holo("models/mechanics/roboticslarge/clawl.mdl", vec(1,1,1)*0.3, vec(60,0,-7), ang(110,0,270), Gun2, Material3, Color1)
        holo("models/mechanics/roboticslarge/clawl.mdl", vec(1,1,1)*0.3, vec(60,0,7), ang(250,0,90), Gun2, Material3, Color1)
        
        #Effects
        holo("models/effects/vol_light64x256.mdl",vec(1,1,1)*0.3, vec(-36,0,0), ang(90,0,0), E1, Material2, Color4)
        holo("models/effects/vol_light64x256.mdl",vec(1,1,1)*0.3, vec(-36,0,0), ang(90,0,0), E2, Material2, Color4)
        holo("models/effects/vol_light64x256.mdl",vec(1,1,1)*0.3, vec(-35,-25,52), ang(35,15,0), Hip, Material2, Color4)
        holo("models/effects/vol_light64x256.mdl",vec(1,1,1)*0.3, vec(-35,25,52), ang(35,-15,0), Hip, Material2, Color4)
    }     
    
    body()
    hint(Index:toString(), 5)
}
   
    function number cos(A, B, C){ 
        return acos( (C^2 + B^2 - A^2) / (2*B*C) )
    }
     
   function holoanim(H, K, A, F, Ta:vector, N, D1, D2 ,D3){
        if(!FLIGHTMODE){
            Dis = vec2(TPOSV[N,vector]):distance(vec2(Ta))
            Ofz = clamp(vec2(Ta):distance(vec2(TPOSV[N,vector]))/5,0,100)
            Ang = ((Ta + vec(0,0,Ofz)) - TPOSV[N,vector]):toAngle() 
            TPOSV[N,vector] = (TPOSV[N,vector] + vec(clamp(Dis, 0, 30),0,0):rotate(Ang))
        }
        if(FLIGHTMODE){ 
            TPOSV[N,vector] = Ta
        }
        
    # Hip 
        Bea = -bearing(holoEntity(H):pos(), Hip:angles(), TPOSV[N,vector])
        Ang = Hip:toLocalAxis(TPOSV[N,vector] - holoEntity(H):pos()):toAngle():setRoll(Bea)
        Off = Total - abs(min(holoEntity(H):pos():distance(TPOSV[N,vector]), Total))
        Qua = quat(Ang) * qRotation(vec(0, -Off + 10, 0))
        holoAng(H, Hip:toWorld(slerp(quat(H), Qua, 1):toAngle()))
        
    #Knee 
        Distance = min(holoEntity(K):pos():distance(TPOSV[N,vector]), (D2 + D3))
        Axis = holoEntity(H):toLocalAxis(holoEntity(K):pos() - TPOSV[N,vector])
        Atan = atan(-Axis:z(), Axis:x()) + cos(D3, D2, Distance) + 90
        holoAng(K, holoEntity(H):toWorld(ang(Atan, 0, 0)))
        
    #Knee2 
        holoAng(A, holoEntity(K):toWorld(ang(cos(Distance, D2, D3), 0, 0)))
        
    #Foot
        holoAng(F, Hip:angles())
    }

    
    function applytorque(TaAn:angle,Ta:entity){ 
        Ve = Ta:toLocal(rotationVector(quat(TaAn)/quat(Ta))+Ta:pos())
        Ta:applyTorque((150*Ve - 25*Ta:angVelVector())*Ta:inertia())
    }

    if(clk("parent")){ 
        Seat:parentTo(Hip)
    }
    
    Driver = Seat:driver()

if(!Driver){
    if(changed( owner():keyWalk()) & owner():keyWalk()){ 
        findIncludeClass("gmod_wire_turret") 
        findInSphere(Hip:pos(),1000)
        FIND = findClosest( Hip:pos() )

        if(FIND:isValid()){ 
            FIND:propFreeze(1) 
            FIND:setAlpha(0) 
            FIND:setMass(1000)
            FIND:setPos(holoEntity(1000):toWorld(vec(75,0,0)))
            FIND:setAng(holoEntity(1000):angles())
            timer("parentWep",500)
        }
    }
}

if(clk("parentWep")){ 
    FIND:parentTo(holoEntity(1000))
    hint("Found: "+FIND:model(),5)
}

interval(30)

    if(changed(R)&R){ 
        FLIGHTMODE = !FLIGHTMODE
        if(FLIGHTMODE){ 
            Hip:soundPlay(6,0,"phx.jet3")
            for(I=1, 4){ 
                holoAlpha(I+55, 255)
                holoEntity(I+55):setTrails(100,200,1,"trails/smoke",vec(100,100,100),100)
            }
        }
        if(!FLIGHTMODE){ 
            soundStop(6,2)
            for(I=1, 4){ 
                holoAlpha(I+55, 0)
                holoEntity(I+55):removeTrails()
            }
        }
    }

## Hip applyforce ##
    if(!FLIGHTMODE){ 
        Swag = clamp(vec2(Hip:pos()):distance(vec2((TPOSV[1,vector] + TPOSV[2,vector])/2))/(5+Sh*5), 0, 20)
        TZ = (R1:z() + R2:z())/2 + Swag
        Up = vec(0, 0, TZ + Height + Offset - Hip:pos():z())
        Ac = Hip:forward() * (W-S)*(25 + 20*Sh) + Hip:right() * (D-A) * 12*Al
        Pa = -Hip:vel()*0.1
        Hip:applyForce((Up + Ac + Pa) * Hip:mass())
    }
    if(FLIGHTMODE){
        soundPitch(6, clamp(abs(Hip:velL():x())/10,50,200))
        RZ = rangerOffset(500, Hip:pos(), vec(0,0,-1)):distance()
        
        if(RZ < Height*1.2){ Up = vec(0,0,Height*1.2-RZ) * 5 -vec(0,0,Hip:vel():z())}
        Ac = vec(0,0,1)*(Al-Sh)*25 + Hip:forward()*(W-S)*(25+Sh*10)
        Pa = vec(0,0,1)*17 - Hip:vel()*0.015
        Hip:applyForce((Ac + Pa + Up) *Hip:mass())
        
        
    }
    
## Walking triggers ##

    if(clk("checkfeet")){ 
        timer("checkfeet",450)
        Walk = !Walk
    }

    VelX = clamp(abs(Hip:velL():x())*(W-S)/2, -500, 500)
    VelY = clamp(abs(Hip:velL():y())*(A-D)*Al, -80, 80)
    AngV = clamp(Hip:angVel():yaw()/2, -100, 100)

    if(!FLIGHTMODE){
        if(changed(Walk==1) & Walk==1){ 
            if((W|S|A|D)){ Hip:soundPlay(1,0.4,SOUND_WALK) , Hip:soundPlay(2,0.4,SOUND_STEP)}
            soundPitch(1,100)
            
            TPOSV[2,vector] = holoEntity(800):pos() 
            R2 = rangerOffset(1000,Hip:toWorld(vec(VelX +Width*Y2, VelY +Width*Y + (AngV*(A-D)), 100)),vec(0,0,-1)):position() 
        }
        if(changed(Walk==0) & Walk==0){ 
            if((W|S|A|D)){ Hip:soundPlay(1,0.4,SOUND_WALK) , Hip:soundPlay(2,0.4,SOUND_STEP)}
            soundPitch(1,100)
            
            TPOSV[1,vector] = holoEntity(400):pos()
            R1 = rangerOffset(1000,Hip:toWorld(vec(VelX +Width*Y2, VelY -Width*Y - (AngV*(A-D)), 100)),vec(0,0,-1)):position() 
        }
    }
    if(FLIGHTMODE){ 
        R1 = Hip:toWorld(vec(-25-VelX/7,-Width*Y,0))-vec(0,0,80)
        R2 = Hip:toWorld(vec(-25-VelX/7,Width*Y, 0))-vec(0,0,80)
    }
    
## Hip and Torso rotation ##

    if(Driver){ 
        if(!FLIGHTMODE){ 
            if((W|S|A|D) & !Al){ 
                Yaw = (Yaw + (A-D)*2)%360
            }
        }
        if(FLIGHTMODE){ 
            Yaw = (Yaw + (A-D)*3)%360
        }
    }
    if(!Driver){
        Yaw = Hip:angles():yaw() 
    }
    
    if(!FLIGHTMODE){
        A1 = ang(5*Sh + Swag/2,Yaw,-5*(A-D))
    }
    if(FLIGHTMODE){ 
        A1 = ang(VelX/25,Yaw,-AngV/1.5)
    }
    
    applytorque(A1,Hip) 

## Holographic animations ##

    holoanim(100, 200, 300, 400, R1, 1, L1, L2, L3)
    holoanim(500, 600, 700, 800, R2, 2, L1, L2, L3)

## Sounds ##

    if(changed(Driver)&Driver){ 
        Hip:soundPlay(3,0,SOUND_PASS)
    } 
    
    soundPitch(3,Hip:vel():length() / 25 + 50)

    if((changed(!Driver)&!Driver)|last()){ 
        soundStop(1) 
        soundStop(2) 
        soundStop(3) 
        soundPurge() 
    }
    
    if(clk("sound")){ 
        timer("sound",random(5000,15000) )
        Hip:soundPlay(4,0,SOUNDS[random(1,SOUNDS:count()),string])
    }
    
    
    holoAng(900, Hip:toWorld(ang(-clamp(abs(Hip:velL():x()/10),0,45)+15,0,15)))
    holoAng(1100, Hip:toWorld(ang(-clamp(abs(Hip:velL():x()/10),0,45)+15,0,-15)))

