@name Cubist's Default AimTurret
@inputs E:entity Motor:entity M1 Bearing Elevation HeliPitch
@persist A:angle

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