@name Apollo
@inputs W A S D Space
@outputs Hohe L1RD L2RD R1RD R2RD LX ToR
@persist Rotation LX WHEELMODEL:string
@trigger 
@model models/hunter/blocks/cube05x05x05.mdl

interval(10)
E = entity()
WHEELMODEL = "models/sprops/rectangles/size_1/rect_3x3x3.mdl"
Heigth = 40
if(dupefinished()) { reset() }
if(first()) { E:setMass(251) }

RF = array(E)

rangerFilter(RF) L1R = rangerOffset(Heigth, E:pos()+E:right()*10-E:forward()*10, -E:up())
rangerFilter(RF) L2R = rangerOffset(Heigth, E:pos()-E:right()*10-E:forward()*10, -E:up())

rangerFilter(RF) R1R = rangerOffset(Heigth, E:pos()+E:right()*10+E:forward()*10, -E:up())
rangerFilter(RF) R2R = rangerOffset(Heigth, E:pos()-E:right()*10+E:forward()*10, -E:up())

Hohe = (L1R:distance()+L2R:distance()+R1R:distance()+R2R:distance())/6

if(Hohe<Heigth) {

E:applyForce(E:up()* (20 - Hohe - E:velL():z()/9 ) * E:mass()*5 )
E:applyOffsetForce( E:forward() * -E:velL():x() * E:mass()*0.1,E:pos()+E:right()*11)
E:applyOffsetForce(-E:right() *clamp( -E:velL():y(),-40,40) * E:mass()/(50-Space*49),E:pos()-vec(0,0,Space))


L1RD = L1R:distance()
L2RD = L2R:distance()

R1RD = R1R:distance()
R2RD = R2R:distance()

E:applyAngForce( (ang( (R1RD+R2RD)-(L1RD+L2RD),0,(L1RD+R1RD)-(R2RD+L2RD)) - E:angVel()/5) *E:mass()*7)

L1RP = L1R:pos()
L2RP = L2R:pos()

R1RP = R1R:pos()
R2RP = R2R:pos()

if(first()) {
    holoCreate(1) holoModel(1,WHEELMODEL) holoParent(1,E)
    holoCreate(2) holoModel(2,WHEELMODEL) holoParent(2,E)
    holoCreate(3) holoModel(3,WHEELMODEL) holoParent(3,E)
    holoCreate(4) holoModel(4,WHEELMODEL) holoParent(4,E)
}

holoPos(1,L1RP+vec(0,0,1.5) )
holoPos(2,L2RP+vec(0,0,1.5) )
holoPos(3,R1RP+vec(0,0,1.5) )
holoPos(4,R2RP+vec(0,0,1.5) )

}
if(Hohe > 22) {
    E:applyForce(E:up()*E:vel():z()*E:mass()/200)
}

if (Space) {
    E:applyForce(E:up()*E:mass()*100)
}
