@name Ammuts Roomba
@inputs W A S D Space Seat:entity Active Turret:entity M1 M2 
@outputs CamPos:vector CamAng:angle Holo:entity Pos:vector Jump J
@persist Sheild:entity View UBER MoveVel Fall String:array
@trigger 
if(first()|dupefinished()){
 #entity():setColor(0,0,0,0)
 runOnTick(1)
 runOnChat(1)
 holoCreate(1)
 holoModel(1,"hq_rcylinder")

 holoSkin(1,1)
holoAng(1,ang(holoEntity(1):angles():yaw() * 180))
holoColor(1,vec(100,100,100))
holoScale(1,vec(1,1,0.15))
holoCreate(8)
holoModel(8,"hq_sphere")
holoPos(8,holoEntity(1):pos() + vec(0,0,1))
holoScale(8,vec(0.13,0.13,0.1))
holoCreate(9)
holoModel(9,"hq_torus")
holoScale(9,vec(1,1,0.1))
holoPos(9,holoEntity(1):pos() + vec(0,0,1))
holoCreate(10)
holoModel(10,"hq_torus")
holoScale(10,vec(0.2,0.2,0.2))
holoPos(10,holoEntity(1):pos() + vec(0,0,0.8))
holoParent(8,1)
holoParent(9,1)
holoParent(10,1)

holoColor(9,vec(0,0,0))

holoColor(10,vec(0,0,0))

 holoCreate(5)
 holoAlpha(5,0)
 timer("Startup",750)
 MoveVel = 6


}

Random = 4000

if(Active ==1){
    holoColor(8,vec(0,255,0))
}
if(Active ==0){
    holoColor(8,vec(255,0,0))
}



Ranger = rangerOffset(100000,holoEntity(1):pos()+vec(0,0,5000),-holoEntity(1):up())


if(W){
 holoPos(1,holoEntity(1):pos()+holoEntity(1):forward()*MoveVel)

}

if(A){
 holoPos(1,holoEntity(1):pos()+holoEntity(1):right()*-MoveVel)
}

if(S){
 holoPos(1,holoEntity(1):pos()+holoEntity(1):forward()*-MoveVel)
}

if(D){
 holoPos(1,holoEntity(1):pos()+holoEntity(1):right()*MoveVel)
}

CamPos = holoEntity(5):toWorld(vec(-75,0,0))
CamAng = holoEntity(5):angles()

Holo = holoEntity(1)
Ang = Seat:driver():eyeAngles() 

holoAng(1,ang(0,Ang:yaw(),0))

holoAng(5,Ang)
holoPos(5,holoEntity(1):pos() + vec(0,0,100))



if(dupefinished()){
 reset()   
}

if(~M1 & M1){
 UBER = !UBER   
}



if(clk("boom")){
}

if(chatClk(owner())){
    if(owner():lastSaid()=="/kill"){
        Seat:killPod()
        hideChat(1)
    }    
}

if(~M2 & M2){
 View = !View
}

if(View){
    holoAng(5,Ang-ang(0,180,0))

} else {
holoAng(5,Ang)

}




Ranger = rangerOffset(500000000,holoEntity(1):pos()+vec(0,0,15),-holoEntity(1):up())
G = rangerOffsetHull(holoEntity(1):toWorld(vec(0,0,50)),holoEntity(1):toWorld(vec(0,0,-3)),vec(-10,-10,1),vec(10,10,1))

if(!G:hit()){

    if(!Fall){Fall = 1}
    if (Jump==0){
    Fall+=0.15
    Fall = clamp(Fall,-25,25)
    holoPos(1,holoEntity(1):pos()-vec(0,0,Fall))
}
}
if(G:hit()){Fall = 0 holoPos(1,G:position())
    }

if(Ranger:pos():z()>holoEntity(1):pos():z()){
    holoPos(1,Ranger:pos())
}

if(!holoEntity(1):pos():isInWorld()){
 holoPos(1,holoEntity(1):toWorld(vec(-50,0,0)))
}


if (J<=-1){Jump=0}

if(changed(G:hit())){
 }
