@name Omicron Speed test
@inputs 
@outputs Inc [Home Target]:vector
@persist [O E]:entity Once
@model

if( dupefinished() ){ reset() }

if( first() )
{
    runOnTick(1)
    
    O = owner()
    E = entity():isWeldedTo() ?: entity()
    
    Home = E:pos()
    Target = E:pos() + vec(100,100,0)
}

Use = O:keyUse()

Inc = clamp( Inc + ( Use - !Use ) / 100, 0, 1 )

if( changed(Use) & Use )
{
    Once=1
    Target=E:pos()+vec(100,100,0)
    V = owner():aimPos()
}
if((E:pos():distance(Target)<5)&Once){
    Target=E:pos()+vec(-100,100,0) 
    Once=0
    Inc=0
    Home=E:pos()
}
Pos = mix( Target, Home, Inc )


E:applyForce( ( ( Pos - E:pos() ) * 15 - E:vel() / 2 ) * E:mass() )
