N@Ship Controller
I@Yawt Pitcht Active W S A D Alt Shift
O@Mul1 Fx1 Fy1 Fz1 Mul2 Fx2 Fy2 Fz2 FT X Y Z Ya P Dx Dy Dz
interval(T*1000)
T=0.03 M1=50000 M2=50000 M=250000
Ky=1 Kp=1 Kr=1
first()->Xt=extposx() Yt=extposy() Zt=extposz() Pitcho=extangp() Yawo=extangy();
clk()->
	Vecang=vector(1, 0, 0)
	Vecang=vecrotate(Vecang, Pitcht, Yawt, 0)
	Vecang=vecrotate(Vecang, 0, -extangy(), 0)
	Vecang=vecrotate(Vecang, extangp(), 0, 0)
	Vecang=vecrotate(Vecang, 0, 0, extangr())
	Active==1->
		Pitcho=vecpitch(Vecang)
		Yawo=vecyaw(Vecang)
	;
	Yawdif=angnorm(Yawo-extangy()) Pitchdif=Pitcho+extangp() Rolldif=extangr()
	YawVF=Yawdif/3/T PitchVF=Pitchdif/3/T RollVF=Rolldif/3/T

	Fyaw=(6008*M1+36100*M2)/T/50/95*rad(YawVF*cos(extangp())-extangvelr())/2
	Fpitch=(6008*M1+18050*M2)/T/50/95*rad(PitchVF+extangvely())/4
	FT=(6008*M1+18050*M2)/T/183.6375/95*rad(PitchVF+extangvely())/2
	Froll=(6008*M1+18050*M2)/T/50/95*rad(RollVF+YawVF*sin(extangp())+extangvelp())/2

	Vec1=vector(Fyaw, 0, Froll+Fpitch) Vec2=vector(-Fyaw, 0, -Froll+Fpitch)
	Vec1=vecrotate(Vec1, extangp(), extangy(), extangr()) 
	Vec2=vecrotate(Vec2, extangp(), extangy(), extangr())
	
	Speed=500
	Shift==1->Speed=1500;
	
	Vxb=Speed*cos(extangy())*cos(-extangp())
	Vyb=Speed*sin(extangy())*cos(-extangp())
	Vzb=Speed*sin(-extangp())
		
	Vx=0 Vy=0 Vz=0
	W==1->Xt+=Vxb*T Yt+=Vyb*T Zt+=Vzb*T Vx+=Vxb Vy+=Vyb Vz+=Vzb;
	S==1->Xt-=Vxb*T Yt-=Vyb*T Zt-=Vzb*T Vx-=Vxb Vy-=Vyb Vz-=Vzb;
	
	Alt==0->
		D==1->Xt+=Vyb*T Yt+=-Vxb*T  Vx+=Vyb Vy+=Vxb;
		A==1->Xt-=Vyb*T Yt-=-Vxb*T  Vx-=Vyb Vy-=Vxb;
	;
	Alt==1->
		D==1->Zt+=Speed*T Vz+=Speed;
		A==1->Zt-=Speed*T Vz-=Speed;
	;
	Dx=Xt-extposx() Dy=Yt-extposy() Dz=Zt-extposz()
	
	Xf=M/T/50*(extvelabsx()-Dx/3/T)/2 
	Yf=M/T/50*(extvelabsy()-Dy/3/T)/2
	Zf=M/T/50*(extvelabsz()-Dz/3/T)/2
	Vecp=vector(Xf, Yf, Zf)

	Vec1=vecadd(Vec1, Vecp) Vec2=vecadd(Vec2, Vecp)

	Fx1=vecx(Vec1) Fy1=vecy(Vec1) Fz1=vecz(Vec1)
	Fx2=vecx(Vec2) Fy2=vecy(Vec2) Fz2=vecz(Vec2)

	Mul1=veclength(Vec1) Mul2=veclength(Vec2)
;
