@name AimTurret
@inputs E:entity Motor:entity M1 Bearing Elevation
@persist A:angle

interval(1)
if(Bearing != 0 & Elevation != 0){
    A = angnorm(ang(0,Bearing+90,-Elevation)-E:angles())
}
else{
    A = angnorm(E:angles():setPitch(0)-E:angles())
}
E:applyAngForce((A*12.5-E:angVel())*shiftL(E:inertia()):length()*12.5)
if(M1 & Motor:angVel():yaw() < 1000){
    Motor:applyAngForce(ang(0,5,0))
}
