From 098db3a0c30157b61440e706bac4ff5ee6b6ce49 Mon Sep 17 00:00:00 2001 From: Butata <1046295287@qq.com> Date: Thu, 12 Dec 2024 01:04:54 +0800 Subject: [PATCH] - Update the Airboss[CN].lua to fix bugs from old version. - Delete my own Airboss.lua * Current Airboss is using MOOSE version which didn't perform as I excepted. Such as the audio and subtitles and hints. --- ScriptTest.miz | Bin 1842467 -> 1842877 bytes Scripts/Airboss.lua | 95 - Scripts/Airboss[CN].lua | 25465 ++++++++++++------------------------ Scripts/Mission_Init.lua | 3 +- Scripts/spawnListener.lua | 7 + 5 files changed, 8314 insertions(+), 17256 deletions(-) delete mode 100644 Scripts/Airboss.lua diff --git a/ScriptTest.miz b/ScriptTest.miz index 2ffea9339c82e4f19b59a6d37109812ebaa1fc0c..685d7135b30bfddec5e26ffdbbbc4705d335db3b 100644 GIT binary patch delta 13350 zcmZ8{1yoe)7cVe$cg@hCbV*5vASK=1-5{aBDBTT*P5}X>ap;zAr9_Y}1*99^aJg^& z?|aPJ=kWdZ{&szP@3Yp-DQb3WYjcCDDS?oQ5s(nj5fBh)5yqBgJ3T275J1-m2xxG` z+1}IB-qmH#*wJH6DCtg2JXE@)nZXGM@h?SP3qfu9&prE&ZVl~MFGoXy(rB|BBflr4 zRQx0gc;D7}wad;%ru`i9+omv02dJ+83g8(!2lU0_t*yFcCIDM9s5@%?WR;%GMly#K% z7qE-4VJ#N5Wu`|2PbL~NOhBUi{r%cbjoSIa$ zX)#I5BP55>HevRuvoc;Xv|*t(`Nq5>#SD;lRVsvbGGAS@Bh-!+t*}G023NN>Csgef zB$h7Y{inz;^RhZL^6HSlbL;VA1$!bU7`oS695&9S?rw$-3p5|{KR}b*ivH++JHRUn z!7=kiov&m(4YVL$;-&$kVt+|KsMcUxJ^+f&U=- zRGG#uofH)}9<`1!_DS)}B7Grd3G! zFsyoSO||j)dTEctrteTqZU^OysktGWq6Rw()|dd z$_P*HW_`M7#Wt?YXgu_lZPw};Nhj_2aHUy4`w?Pou{o+okPbWhZCYuMi zQ5vYNxiAT1o)a7A=nchknU;FSBD{fV`4y-JP z(2dpE@b46c=~^B@kg9^h<8cy(_O+`Wdw4xft zN>+p2=-VnM_Zbb;p52}yZTf&tJ}8T)RODA_`Y96SIQ5bFMto5g6zxkYX(lgDde%#; z<3NwT%0-gP1&gg8pDLUbXZBGKT}DP*21}k{&K?Y|i|J>bf6p!Up&f8Mw_*u-N(PjN z3Yh+$A5v|aM+tgj!@hGlC|1g_(EiL*NwdsV0FOjON!P;c9=9XO4^M){8_|7)qcrnNz_C| zxYnS=*d8MCrTKMsGH0q=rF)UUiB!~8(e{^CYN@L4s*-BMBd>O>6wTj#g>KNb9)gt_IAh&5frmEj#3>Nh@iU)S164*AtwMd8RK7J2r) z(s)e+2+4WXo4N~B|1vi<)|TV`M81#o1$XSRT4#LFSSYx3!m#5bN8yG7AGRDK)me~& z-{OGLkRkhP%mx%Rtr?LDsG5nJIEuOAS`Vr(5I85lPm^`rSNvsul_X{ZgGDvBU|-jZ zjlah3EjeRZ-Z7u1iMGgB7@Oll_UjSEwqR5DcHir|_jx0P?H1N5Lwgp28*Edq){{CH z{4fjIQK)~G{mvrdDES53TN^)4dL68$FvsV;;>597u0+pKr5mj&dykE>AfzVuSh~tV ziROMB!+ft+DRfd(Fa*hX@4IM#8)X$`7A_J&*R8XeR?!$xuy}bG zWZ5tB;6fwwqw?-3$LL#8+wZtF+)R=aEiia77`~FQGh`D_(yTZU#L&i&iX6P3ln+?3dM7yKum({QhaF9lztN*w9a0QA@){^l27k39$T5r|*2EsS_@L(}J4Q13VRS>_ z{;RyZ?3Mso+6@_lEIDnS^B5_QS61TcI`lKQhEbPF)}+OTb#_{7j8ZhSXUwG{t^_%Y z^bMp^%8y`$H0k0ia}Dw{D!E7wz4gBsgc8}Zjd+3X(nq{<5e&_q6m&sy0D;A32RT!2 z{u~oZ%TC=evs9rgaQtFo!y|XSqmg$j8k6BGvF8@A2D?;Lzr4HX*RyK9YrZZjacD+g zSOMi7se#B}4WkUEXDu%~N(_#L+5RvT>jxNP&as;eLYj-8yfrCM^=*Nvw+m{4LAnn1 zhJ~&1sf^TQhBCKpX1SsA*3r-CTkZ@w_aE$OGJ2`DN`2BhWa3SB;+e(uLUYj7MqVbp zztF=*HJQ~&t@I`^J-rFJ6CL)5y+mY@!rD;$LDy^7ddpowJhoW&?9@&7>nn{)M5({m zc;=ng^cv;@E1FQ|pi>X~E(JM`w})Hur<<*u;+(Mpo_%4*zC*8ib+Tm2`o72CDrnft zJ1DRbM5P-ot-f!^EH$Pa&n|$9-RGLb$yuOU&9omhq&`C*zh1L*t4jIQ-E79-6r}ks z5+q*1ZB6?6XaiA%la8b31meb#;1H$bg}T#^@$GYMZMrNt>J|5qOv@2$2 zZ(3}5#72!;!`+yq6;az&0n?k(nNO+BNo7MaX(;1Nr?!~UGUV8lWOqH#A}#)=aI>n9 zq(7GwiZ$uDLSI~1=x0nlqg>h?)KYTrp-N>_v^(EoSP)9P8c%;p?xL8&^gfDT-IvIk zV%M#2ak}I^_G$X&PbrN{2X_uM*W|7kr0}A?*ThT-aBL&_ePa2})n_cX^B^_PZ>sPK|LGrwxh2PGU~}ppJ>+jGs=V^Cej! zN}PF9uDRj}{_rs!X=nYjk1#NRT~YC= z;f>!3dhgi-$~8E8ixq!zOc0eEp4u%0oy)Q$6vi6klCUHU{g^u%{Nw z=NYbvOoB@UdSB(+_fc~s^~{D`tciXf*SnpLiS3`4=IIA3Q2TN=T+CF+ zhstEpC;73Mf-l?h1gctS_}dl{ggAfYrzTg-5#V23ge7hXeCUAkXOn8T88PDKe$QT7 z;+jJTml5ABY3 zFwWLdTBMdIE|X7b%6;*fXL2FAJm@0xEv@>VGpFe_7lVzg+^1Mws){d^=lu>|U+nl- z_sC=0Oelp}dNbKStbUdZM$Gb2 zPCfbeGNjYLQVY(K_RUb=MAx z)pL>$Q(rU-(^fKb7lQo7v#+J&o-jGsqH!7wfHIYxI8-Bb8k*9HLjP2}=Lrn3pIq$x zC6LmuA=E)Q^ea&`h~tGprKQD!bi^McYQ)ghdgWmc(b+n$BReF$QduJ+x7IZM;Wec} zOBM<>1>`?+)KCnh7@y%TT%K1}g~l>+*zuhn*u3_H!xPeS340j`w84LH1%4iAP{Tmr zd7Gr|(vM^TM>M6{;-68}=O-*6i2kAnd&HHD7v;xa3f83Csxt3j@7d>cD~5iOtWrpz zt?EMqrIFY=?uE@hZq}E9h<(IOPN+Vh5wG%Kau{BZ9aL!8Pw757bKaD?rG!PztV z+}QauBHTbb<)~>?*&YAh{^%tBx^+lDjAnZIDHraLK!@Xqs*UL13eod>x4zYrKlis= z(A#l|`^%2|!(XqOT9x|UB&LZ}$De4LzP53U?ic@?n|Iww{V^5M_6FPP$AFf|;TIG- zCbAZC=)zoiZ?JlSq2N((eITVlIfw__To8{d7mu3DR3-7M|KhOJRBGNn?V?mbeRD%e5G&ud8BEE=#Izn-jO>CL`|WbC^jCO7 zf^NFNFNb$z_DHR@3O5{wi~Rm0Qhd~3G`(e744_qtq;4(W+P8mcIV0Z&Hij)W$ITmf zNIheXo6vZwaV z!k@r+frG<%i}CkZH%(i~d=B--u#k#b!-L>z2eKoMxT6C^V7JV~K7XWWJz0Cl5#P>I~TM z!OOh%KVPP#HaXPk8ajRJnBiRg5+_{O4T@qe5`k7Dp{Q&0d3MkEWITbR5}B{se9+>8 z2NSiP;Y&mG*PxkCKdE&q-)#O`U(h)4h~(D7m|@b1A8?m3k4S|W{4N9N3QJAGK2GN) zRmgYX-h509FtlnOR>G&FIQTP467gf><Ei`)@)Kt4B}G&hM5EU0<`DqeJHdo@)~| z$#i(Md(v%*v?;cx>=HlB)7KXGs=Vk2)okAX>!8yekE zue@&mNQXJIICV*d?P1T{UOcoJ^N*d^F(2ge4_oc7A}$RR1d1-#9X{Q#HO7pmJ4t@XR-=UMe;EJfN%)qWtgy%EWLCvyvJd|`mI@(mS+ zk2EnO-7OnKW7qtFGB2b~c@^wWUu*gO$L2Bx4G#}FFZ=i#YDx_Iq`zv-1fuJA*Y*35jB zbmyl3Aj^3acjsu4&1vQf{Ow<@71pi>V_V|>Ex`HNNa_NWY?zupEQhJD3B`k$9jv#D z`t-FBn6=p&?&n-assv{f+#8~>r!GjAfk|Nc8JBzQ$OaO0I9A?S{uxZBer1s6*?qxy zQ zwznqNs{r&D;Qgf7h9t6q!~4lsDw4dkpBA=LK4>JSR5vq`9)N6>$Ij$Ctr~lZ-!fVO zjRy_{=aL2p6}R0N+TT$AdGg&l5lU9ag- zZ1G-D!o>SWF>6Wrkb7BF!*@dcYN=JcUf=c?hquDya=WTyEaQDHc!LAH>gpF#wv|qI zHL>&=N91AZ|VfBylwkSf5J^V z0?@+ZkD_-Rc~oj46rX@GX>37t>vemCuM)%W%RH>TRsgY-5lsnw?aQni98OOuszst` zwS%A)Mo3=YDdYFBE|TTTXEY4XBlKlPk&Cu-vx!4(NnI;&!l70~Y^qIJ{#*)OEhxv2 zyzM@ku4Q|nbsZM>%D}!~7}ez!PPGeby+&+9_LM#GjC!#qe`^h{Mb5ezRq0<=;v(%L za-UEO#>^jfL?aA+EkV+&u@kX#Kaf=;_i)V8d>KxdbX3V_@Q-$DGB3*XUU`=Kpz{WM zyv-NC#R=;59@z`7OSpV8p>M?i^_mI)6(sn&#!La#l(;IWx~!{$eO1a@$Tn8D?2wh; zq*#Sw);HB4(4kfF{~~=A-+falt2EZM{|9b>|FZ5I_Eyjm3A!8k(EV!D zjJ5wQu4cwB)F(AzUx__t1~gF7ULK)`L`@%ITMIhK=n1hUN4e;UFTayg+%}@gV3b9B$m4A*zX$6VwL*p+YrZ_ zuTYFpJ7T=8;LO>S9=?<^^H4H3EH&!hVEr-ai^4y}o%gM|NoY6~ zksmdw3ry`+(J~N9ewr)=QT}#^9#qFI*Tid16y*rY>`-xa6lgF1k+R}~{F9_etH|CJxBJPZx^CNoi6?-|w1HCE(Z z2Iq;*j71gbSf&$j_pgJ~16j_Qcs~3@IKY(7|3-UD&iD-KAHazh6({GFu<5XB>w)@$ zN=J|5@OOUmcLEEmw?7X;XM3m3>H;Y|d71nJj)A#(#0ug zSZ%C^Lpw?J4)KIuR`KB`=_20`dyE_rnuYho7^QJj_uL&%Nv(4{W$&YVQ?Ra`Kd4Xl z-n)q42aj|D-qtgxPq+kuU)$RqlNj0adB!km?fWS3KUBHhxu^DC#|s?VhxA|}#s%b| zGLF3uqbf1)k}n~Ojuyp87K?32hSq}I(xt7bnxPBn-#=jUve@lmLEzbM|6=OYYhH#Upo`G@M4nOixQ$C2425J%rfntj%30>|1@BM`S)2-`O-FaibQ6IG0d9E-#Lk{1oB< znP9f2UG038ELwWFq~dkELe}}})+ux?;Qjg3bNN<0d+)}N-wz~8`Jf;4-^0Oa|XMrUgy8O)jeGJ`OfXScUZieyDLrFN zRhDqqygTXCZ5KK#nwyni>60C7G`>mbPb?_DhBNnf0vFhmLxrO zSqqsI#`FLgSe|`4KtCkH$Vw=9Ub$QR(~%}84Myz-aq<>%tD`AjjEJb#TX4)4`8+F!m-m=9e}!hQONLe84txU(8bwMUP`%*AO98o+wnZ0Z5g7?66+Eb$mOQ?wsqH9Hti{a zfr~Rmz<82+w9R)AenP25JW`lxiyKC&zat8ooHy-xX;9enLY{6}=tfYK$2J%P@pZO3 z#n#KGR++E;yi?3aMhA*Dp7p2-mZws@k2D0GHKozX4&vF3+eIY_@wpt7ax2isn%VQ{ zYjAg1E5`PQ`YgtAHa}M5Sy|DT zlRP7(-pv$%rk{%94cXc?*j!5(!79HylYVx!-dW7b#nyOC-qEyPuwl%+ED@k{cS9en z&5-GyT3|jPZ8(ymp`jgax!g@Bl3OvkE1Yt2fsgM&P4SC16*}VnnnD3QPB$}iS@^=X z%81MvW8oIdC1CVZGQDcFe_WCLdhObfPI2=(K}mZff-T*cacGYDZ@C;UZC~1qiaE`l z;E=VwRbwfEpm!>>3BM3XI0vn9-|!^qHzL#PqeiLI z!6SUhU_oU^oD3}jGmZD^taiOlWosM#QaQ1z#=GBK`DVQmT?RIyAQJR()RG`r1dRU9 zUuE&7vgg(xEwvuiJlA3i!Me1cJs;2w7HGp`F+|RU7iBV8BDe(V^fx}`>#N#*lIg05 z9VMBnbwDCu>iqLDD8796sq$QQs(&T5C`t0~N(jkGDrysS;Afv8j6bG9-Fz7t6?nxF zSK`l8D<{{DjE0-d{<~{()J@O+x8!b!vsZxF_ad3-k>*;21G3sHpXRD0hbyFFhH>HE zp-_sKSr;srb4ZvlZ|>L8T^D`H5~&^TUCz1~+qNhw%xX#uoOm;FAMqnJNUyo3nSSOE zf33n@Pi>8Z9?8r5-iW)nr?pAH|B+B7*+RRO;53~1w&Z0UY7FS_kD({p?jla0Pfcj0 ztdwk7At}9nWX-P$B@4y0ck5Y6`M3o-?hzBbsJ8GY7&9UaU9tuo?pNRVUteyn9@UGM zP;IPGsE{hm42GW+>=+s(a*KNUX3hMLCUVLtIObHyg)$7}ErRk-qQ}-an2~AwuG3M< zJ*;0iF83D3dj5G=bZpXhSMTxTNW$7oTELL~_O5Wa(eW+k=j+J~?Zajsm)vPltKQ$r zhFPa^2FhBC^f`Pw%^F{Ll_k;9j!*N9HwARoh$zN;u_QUUC z%rTZANiOKJSJ$A7tcCzN&QnUnZ2G{@Mr|e)<*0(l z3wf?tI-??b8t0Wfd|s@t7VGi8e2f{*>!X4wJy8mS_5^1Y^!;_cu+d9vH|usxqDji% zAoJHBXs8q43?oMQR+MDW8e9j$=z={>xuhewm7sxUw<(Ifq%x8plC5&$ZqB&r9i=_j zogJB;9$)13hsw@2gze6j{eDGN|1NAfvp1BkW&RJY-dz!f-W#ecBXT#>(rB+O1^y#XRFvP)Tt^>$7osxX*2J|XgtGp7Z{f1 z(|1Ig`uxqt4aoH()Pd0C6Bf_BdB!v*)?QyiSpHmI$l>Fd9^cs z<4lRUGk0vs-C{Dlm}Rs@b@Ra+6O&xfbbWJB@Y3;=w)ets4$oSZT?Ey##C1goCT~Ho9m~zM|bT_OkSueAP9=~ z5}Ln7b>?BrZW&=v&#VtxL~L&Rba|A^ql4sUeVAhhvc8%oSiBpMR zP<^dfa5&QzVo$+L7rQKY6HJ?zUkw3`plWn1_fGoEF0e3@*wWjqq109 z2MikvuazAe!u3!T2+AGJ^W1v ze7y_59FN?A!C^!>Hu|&I$7bJsM-P2I{V@D|h?oR0w!RqNO=dg%Ev4{7H;2kl!o1O= z1KrIOt%ytJdU(g_z9aj$U^r%ACx4Z*7wig$1E8dvSv|YLm7%0uC2QsP#ARp@TQ-Bh>e;zW5#r(W<@i_uoa4u23EpK|jB zPAaWZCCJXD^^Nz7Bou1GS~$ZR>}$}|c2U=zb10~i=#hi3Q^$ka3vAfF69Q0FZ?Yp= z+=6U`!;j)0o@PzOU%uC|dfLLQy_9q;ND^FGri<| z&sV{;j7Hd}bg{%|M!qUZK;1A0UN{a*4=$hWh1jZYqH~%ekNWiQN-NVu*K45zwHK<> z_BboM=1hCMUHhFy?9gW{_JjA(w{_wlNhSzKeQtiZzc74>lS;)p6qlGzF7@8$&m=K+ z#^3@4Myb)u@|bI6J^J6z0%Zjxgt_hd<`KSkBi5l-S|<;iy`-zvIcXUwH=H!yzMAu1 z{`GB+_QiBy1{FXdjfVooT0;(F%(eNpM zRwgF7GW^#4Z%Ao*r4?j`AY7R5r$t+zJHP0{FtVq1aNEwC)Xs5(U`qQp7NMZ$26;!0 zRevTvJ^4$y+AQ(rEW1!xDt=#tUIn&apAh(DEOS_{bGM+$d%zQ>#j+%RURC8!6`l6# zV}{H(I=QudYIob7b1@PjEi`DCsq;~$vu%dsSoB=>W%jmkp0is=QO*dHMuVv9DgBM> z3GGEsGzBzCZ^mcCN^9KXUhdh4dLFPr6_k<3uh*O|qWRA2^iuBmTu9^P$%gWIk@!Lp zWzI%HsV|R67)<+k*__9~vD?4V2R7Do3whP9sxv$|Xr$*v#!_w4C3F2wv-c{0_pYC5xMPw+(&LZN(@)j{`hjDsk~2$+hm)10EIy#x=FCKbv(Ok(1jyuU6vv1=kpM< z^vmmsS5kC*+(##wYK3c(Etv1aRLW%I8y)oB09 z>UzQ<8aTL&qTI4Xj8Hgm5cbg`d!wht%5Hp`N|y?)@xmTkvP9&PDT$O{Qy!xMIv()c6vSYWpL>+1qlWDA% zHRBdUVD}p1Cqs$3%^&d97{cdsf?C@XH=|>J9}=W*NowtolNatyWwD#>!-zH7+U(QJ zhRZFj8!n?t@&)n2>`Fy!Qpc=ee&XcNodX1V#AWZ@u8^z_DAAbkg8nCTN1Gqpy8)Ve zlh+{q7nG-uAiM(P70NWO(cI^zB*P;Mjhc^o(J<) zFA%+y_+$4pHz0LF)yEZV(D9lnmUrj9)Z8u?F2=aZitky4iZnkM)*`tJT;B;+P^GiO`fW1 zF#Ua=MDyaBp*t2U81e9=@idJ$h|EV`)JZ2d1<^YHU<$0;YOU1cft+X53-yD}2OmQD5 z_2Ttfv6o!H>7Ij3Nu!@D7ntt-EK_Czu061AmHU+2Up-xV14yM3$($bJ%JU5?nPyGE z{wd|iCIMB>iqB7R9UI~)wzAM_TiF=r{^|qSK9wvGS}|Rc{ktMNak_}vDjL7hACz%O zfpV`A9*v>>>q`udfc+=WCg2yQKSgGIV6k~1a|hi=r@}j0Z2~(Y+unZ2rdFoCY?Hy= z;P_o8Y=@HKQ~~vUQaK)!wPPsgvgaQ3_!?`lvSGNgAtIcR-~@sx8zR59f!T;q&e4S5 zVW7YX6?TV#w#yG&O9Z2^!78oMs$l>d8U!DTL@ z5tA?zD)b#iSaC1z4g*YL4g)F#+m=Ab34$M^$*Ao#&_YPy{2{4TX!3TP^kjVf{YzQuF(-F5r5B9W= zVwE#IZW|XCw~e>+6y^iLxu6X9uEB>B0h|coLdIFZ1K6i#GtB8Pd`P}C5^R)uiK zd0`l*6vlD@CNew@omg}kx^QtrN|?AIxL5$zj*nUR1h(A@&JxD_-;2IL>^WE#GadfY zuM-cq3zsZlegTF6Vi#a+JTmwjzz=_j|6FANq6_c~#A8730xW@;3#4CwWf5tCr3)|> z`2YXj>3_Sf0Mbh^AJVcBpnM5dKw35i2trV(lA%Vp04Xj6KlwTgANwEm|6IZ&fcNQ? zQ~=f$m>bEW5+GP7q)5K~ga=q(fmx9-R)NGTur3HDfC%se;z0nkYcM~E&IS=6fIz@N zhZQ0UV0sN^1!1QDE0CK`i4Ig>gM~oMw}^oH76}!AeghUjddde#-hdTB4Tea7IzI&k zPy$Cm3voyQPa_f~aCrmf1ywfvvtoL%jSsy1frO9qKS#eU{KF&$K3#&*f$UrGGbBYM zVDc8MjwGq`aHjyo?!Y2QHqj3Y5+MH?E(Y9z$pCmY{x{-RJ&)3{B9s`wG9|n&?(e{q zNK9*w`?&AHVxT-;l*b68@4;LkR%4V0FaI^o8G?fO=;84_m=Y9Ljshg=6OgAeLxe%q z8;|=^-$A&Lv?)_-APPvY#Njs*U|E9@6;QQCMFpr3A*@I)F8@Q_QsJn>16l|CgZ|?? ztR0o$(av{72qluhPdJMLz(9gf0a6eMB?ylK?H|JcW)c_&AjgIW;*JEziC>@r?kI54 zQX~i$2+0o(kh%ebffFRiGth@Zw8wnE0KtzB-iDN*-s^v%dmT(%zzyD+4?Rf*9Ka2J2TUI<)Qe#}YKo*nCj`nLECgV~Bh86;5TXR?u;FPFM}CA=JP-cs`IM-TwnOp+TgPoR9v4P(BD&!V3l@@dE2HLAzbZn83juykz6i;m-QU z!10F!{nH8)=0-AiPNL z-ajA|0Q(gVI^g;+7xUoRMl$Yvgug$O4t!ivBFSw%AnG7SRJ=#;o1<{C0q2K8yQhFV zA}sk2P7MfCLdbvt_|btNu6PgLPylz>@UZ1R<2}?KC7_K15dl>r<3Ffj2Rd*dte`W^ ze^w9x9T%QZ_~iX>=qLcZmLL4cgW#Y5ix_Z={9{W!RFN9;{ffra6NiEa6Jzb z1O*Sm14=<8c-*Lg2hWYiQ-Vjw^YP$yiD5wSu$cw8!GrIsPWYE6ix1~*SHo8iTB526 zFoA4*xBztLUx5vLh$QHRCgG!iGy(kFoFfSz%_I}R%_M&$1P&45-Yz}xqSoO&LU>Hv z>xB4^{i{U?&!)^Pz>N^1396hYdUR@)5F!Y|#v*x)=o2Oh79c?cH;f}f@+c5N1ov#& z{NL5=!%8!hj8$1CIol zK!KnD=wuLnB-iOjX(KWSHs`#V5cJaij@503QP30a734(-Z)HtcT%;fdYTt|JMhvcJQOY n5eP(p4*u{)@UpWu_wuk-Q$j&~c)t0-KbcGj2soEu`0D=vcVQ}; delta 13006 zcmZ8{bzGEP@GtDrNcZm2AzcDe(jd|)ozk7stkRvrgS04(l*ob-(xFI6hjce04R?8Y zf4}?Q`^PNLd}q$goH;Xd_VcjK&2I0%xWP4)!Dyr?AQUVV6cjp?5$=cF##AUMH5Vu- zm`KFg-qX|G)n(Vj$YWVJ{o18U=3P}8mXRt-pu(U^ScQsSHC?mZUT>8O;Y&bvW1!E#ihmaMu~KX1tUaI3B-pgZT_Xw z&48^O;3T>uOx2E@+Tr(c!kKt72CGe^1HzGL)316prTd#zgS? zhIi{>sBlKnwI*+oaK=ZqU_Ym1;u-{K9!$=l6}{aS!e7FCCR~ zKeGzk3#pE}g9SH7UgZ%xtuKO^;h{(IHSppjayKP1lcVXTLsl5ZbY#4}Xlw^dI9pTdPrq%*VWwwWj>8x9*wD6aN6)adA;eqsJdI2pv1TLrOKsSp3Qrn-lyz$P0Fm{)uuNzvel)Wa7@qoyM-KwV>T^!zqT%>LtU+W z=9e0}a9Tar*)X=*a-JShnp!xo)1@yBk(^$^^4=T#{7749lqFmy?4`?q7yI*3HF?dG z@@n*z=nwi0MO`N5JCg7b{mgj%++YG};@O18*>j1m3W|)w9Ts@S)l09-{rvh78SQjb z&*LbkdG*T4&tDnfMmxq?-f4J!({pt5@r{0ur`!}4FP^+@dgyqZJN@Yo&8w!D>ggbH z5#uuQ>A;V+9FnUx6ey~3`Xk4wgT@I?mp^}SsTQ_OiRwD~wYZr7`aHV__r8UwD;ZjbGRY2D1n zz~e-{-UP!89Y{~YM;Ge#0%c}n=h-s6pjVo3(z!GWrj4` zqxX&kUkDd=6))jGcP0NF@`wyy$@=t0IEAK+wM0^xF->{^-VOh#z46g3o4a83nZN@D zRO-JW&-@m91N+4|y>UK=W9Y1jmBTem-6b$Al$JX%8i3$QMF~lv^>}6HPh%XE-@#fm z;<9s98_yjqhyU^_YDrGm3;F5plEO_4X4lGI&}=+0?mFMv9mELcS3XNg^JDXg-F?IJ ztTpZ3M>nUv&Xi2J$m7uwS4;uzg{s*x>4+DGTvn6`i~buL0^GBzqXIQ!?c{u%Dk|I6 z2gj`k(a)+^&A(a;4<%XWm$8z#@L1u8Npg#18fR!#6zq^#uDe-?(0MdW&iiFYxW=)V zy*Qr_=M1*^^!d55@J{;*g$pV+&9?k68H}&QAL&_Mr$}k+Ba>lG1Lx8(7t;Cb-owm^mD(uG+B2+G!MB`68*P@gQ9rp@V%TT~EerJhu09r63=|P>=f79EcKK9%*Jbk+HZ`0*G2L7WK^xV zwaF13c%D7zkIi6`6VK^jstMz#W{Kv~Svf!@rufM)kEv&z)D(xk6t!o}5|uP8KTC(q z8?n0LPD;q!pFZmpx?#k3Z-y0*MztdjiMPk{;n9{cHJ)!-(+Rs?6bR>92IyA=Wp3cp zs=Vlc>*L*$8Hycg8NX!~`}(xC$na8>V~4TOB*-LYk~28P&r8|)Z<9>k!OQ)EK-Ur> zjFw*`^>Ti+9P;Aa^`d%hkN|Cx3btx|TKle$V9v;i)~(R(SQcbioDAhDNQ)d9)%vg1 z!qyHOs5%E|Pc-Y(77R~dm9|-x!!q0oMQk?k^{dhZtXkt9`>9?*>Y2}o<0OPaLE_^x5jTDy_{P9b52Aq)%?CL;V*9SA<)q-=o^pT|w@;nZB z78>p~j|+u^qG&SCBOlqYPFw<`D6r?0`jXv9!_o5K!q>;sd?#6vX$s^&m5v*Ng4iZr zv7W6HSbV!=(6SI((1x=XoOsyxC4Q!WC+N6VZZGYQjN1I1bfeK|jGuJyWF5=6sF8fe zj`xhqp6DG`|0);FM!DNm;rd&Sx^;LF9C)8hiE8k9KfrkvtNr>$7!vrLp}d-V5-ST! zHtZW}o^A$ztmygCD{3Gq-NHY?u|ZK#jzcu`YB_A+W3XX%*ucng$&$504$dsCU4K^- z+YhFCCms59OxdwxAB-f`KcfU(Z+*7je)g!e(q5%k4qaEge%ro8h!NTyetW>G3s;qp zt<%%N-PnuT?yE=}H3yjlU1iSnlv7B@9mYVR(=+m1+^!?5ao(94*SuMA&J@OZ0Pd68>6i#R7gme{4!=v#xA<6 zQHPnwb|X#sLyRtK3A^>EjZh<;tVPuTQ-;8x#1wVB|9w#0_2wIV5&F{7lHN~rnZx>( zXlW~}d}VK*Z&O$egax8t(P+c-iC>0u_K(M=_KNGIBW9EZ*r06sCXC^^H z6&NGK3|GR}ns`P-k`a$1`Ly|+P}SGRne#5MX@LEq{x)4FY^?0Sj^0!#eB?L8G`7qX zKRWcGVDaNKT!nT8Z5+6(_Ew$e_}opHjDb{d;8r%98hY4Y5~l``P%YnN?J?LD6(Z0V1Es3n z&Y5w(s;R?M>T)7va*a^N{*ME%ulX>WxH7?3k^`uoc>|~j{&!9B58vozfd}pIebqn3 zo}xIKqB~}LH5uT1E5QqKhM-xghJKqFC2XKi^px{BxkXV?(|EgU;M_So<>PSr*xP5c3K7X>kK0@G`&`qj($pYqFJ#bn!PO$ z%H;`wd=Br{Synu~{X9+MCgA|9p3uHAA=(+2zSdJ5gx6*NHhtB%(suK}4rEj;Z%h)^ zly0zmSa_hXgrP%>`W4>BC@pp5A~H!|6s=O{*dMh>q@RGA%Cfj0!^Xzg`&Y$0N%|!w zbk8TcXLm@U{w>o5+m<}-b&tKSx}&C!P#xvdZ?uB}V&SsbEn7{_8x0!!M@N-0xXC#Kth{Ea_-XF>$W;W(V z?I^o+o{hgTsI`fe%42B?c1)>d)38`H?@0+FePU=m>Te5)e7J{L=0j)jyY(f97hR8P zn@OUqxM`~$+RW}ap@a$Jv8aK4v&lUERx0G%srGlTw8Xu7{}vRrK)!Rk&`kM-s5%P$ zWeDm#e{J)C0*WMj6pM8C;Z)%C6qa#wYs-ypmAl?Ycgty)zot3MmNO$%?1^{#6sv2$HhgvkNEw6I~u>=fh@#ruF?GbAqBYRGxFH z-n!({mrKsLa2X};mwfd#y3wA_NAo?k6LE`VdewE;7S}CLbIN`jl(l3-_Kou%Bl>;FMIZCN`n_Bd7UF^qM;u+y>^*u<9Vmm~KrqhPGGe~c1gLlO&HJ=)^4o{hPl6G!In zN|PjxMbr$Ud8Ll!y_^wsUb(5_KIAtWf&=&`ta;s^!k4r4&jkkx#0lzrrnDKh({eAu z03>~eb2Bo$Iy%ogrMC4JTsxjJ|h-^!K4q5aUb)6(oPyQ<3^&MZ-#OJnM0G*I09 z=~Fc0wE(~9yzT8@195=sXFA|zJa3j`;*&RMJ!~}iS?{-c+Lz zW#!bL;Ax7%l`0voMGxL9{B=*>pD%FNLUYPMrm13yO6#?P10L?H6`ZuZQ98F z+dS=J!u)Y<-j?5Dj=$**1w83b-a3~5cX)Tv4VJ&relYzN^@SP08_=UE9;i)|frg;) zXiw_KHgXzXwL4dOs6y@qRfnG-l56Y-4X!)C4#+V5CKjfSmX?ExAI40a4Qtgf zX_r7+(s{!KnM%NK*Irz$p{Uo5ps15ve ze1@huZkY7_<{!#mtkLq3nh}hSeS)8TpWKC-p#OF7Iu?MP?>wsAQo@HT`CijgV$(jK z$Q4^x*>do0>PdyFib(F%Otoxnuw#`|d_Zm0;1IZl1Rcw6^pJ=;Vc~pMW4~$iH$VUE zP1ex=bt2y7(pWFD{4&sEM_h}AQ$$}_l+0BYog zJGLR-;wXj>A!uk^rd>Xc*6zy(2yNJ>2ZwkPgj0^crnf!_*eI9B9A?a^@rS%O1(oM# zcQYxbNF{=PU=~vsNss$12g-Z%sqLnbonw858yX}NX!*#;9zCu2jyrjJF8%s(U0#b* zLUL0=6&`Dh%pm}(bJq4H>6Ry5|>@5JlZQQG}m)8bU;yhn*q@71MVcDG4b z(YEM02r zSu-|CIn2)T6q7pC3HxZJ~M#z5~LYOyU`RQHWAdQo7Blr-%!dbn&C^k`W2 zXfX6>EOl$V@78$Ht-;W(0blOYDCp97(WSxIrLo+pQP8PjDHlp88&4n`jgKcJ(98R) zfj7ONK;SG>a1|tjte(EwI2A!^Z61S@6y3Xz&rg+~vthG(Ggk2LVpD9CHVH7ih098w z&|?AJZ3hXJ)#X!A%D%K1A1xDeb?NDEw6PsqI&ChzaUyMzLT>P7!v@qbCB2^V;CM)n zA52P<;{~nY&jOHisbT4L&&wCVO^ph1<+_$h-BnVpaV-@ze$P^^xhVb^xyU)lLK>-S z@zifJ&Iy8EG8HaOrpEV0D4U1sk+?35Y8US}nBR_w1pIC}L#)+OaTHFIMgO&aa<#m& zCHvd?R9&J;a{ClMP0@PQQul~Wuw1dix#khuUddVA3b|Nni&)9o)&c_m%~wwUwD(VC zwYrL|E7Ubl7MsfDXTkQ^6@PJ$^;9Vu5csfuRoG|{Kb*|9(`;Am(<3tEYYf-ucJ{v+ zai|#;`V6)EfziBuwK>eM>mKwr;6K}6K|2vsZovh{z7;~?WG`yocDt=?GbvUT@G!7z z^T9HAN7YKxV$kQC8h7fHbyalJmbJ(nOPOmmLO;+(9R@}(4Q{(pmP(2gi$lLYVPX6( zC%=f9(^z}nBNSuVKgb)`&T6{-NW!z3)4<_=H6Gkh^&PXdR35#D`s1$+j6Wxz%J>PjdO>6H>s2)r){1f7BmCMmk}5#`r&C_@!+ENer{;BU zDEH36lHz}51%V@3nZapVDH`gvpUz%ai(h86y9?oJJ<$>>JYTqh0Vx%y$Ct zK>uOqMEY|+R4yOwGo0!*l2!FpHyV19g0G#T7n>KWY}u5KXBz3{YqBEU5rM3@+h-b; z5d`uAfhFu|y(2^=519Gv+9Hqc_@}XUiqGmJB$>}Na1zLe4}QS#d^px+ryvq_)o`eW5<_@`cloeF|hbk{BOHew93H&r3krHkd9OVZY& zwgY;l=j?)Jg=$n2foTv)yNfjG3U_Y&dTFu>mnW_MhKr^I{J|N9V@5(K6BkBt?I3K#0z-~oeq1<^Ka(1s zp|@z!BS#Y%KEqWMT*%id8F$e~hhJn5M{65}2jZiMgHdPK1XXK`*Ze*Q-?Xg@nhOG3 z<`RV^!V$?i3{&PD7T#7G-a0st0aEddEY_8Ez^4J^6eseBamL+01w-JYJK|r`*$g zkF{QavGmkJ|F9_9+?-t)lfOz(@Jd=s`uj*liXf8gv*O@O4U=>%zS`@J)AqqmKGRQW zRG$3sx;0lO2?7)peS!Ob)VR8NA^%U~*$kaYnW;Z%yulfi2r#jCt)ab;ivGepqQuP*?Q)l!lNF8}y;h-Zt~CuMQ46jH2?nMv zy#~?}X-47^*AwBPy+&&Kak5_dD;f4#^&Rxn{4z-d8&pEiF|lZCs`4NYv2pFwO&j6u8&)RH{sVsz zOdQe4<2P>bQ>~`e_L&MCGa^OU_L-e|5NauD>5aF#8zD1h0sQy;`wVkBiKmkj)vB&a z$qcn~peLYVDbDZ)6eX-tHLO{hw9FR3154Iim~lsnvOjQ0;Q>Q0o-Xr`hjz+}-`ePi zmw_a-ts+T@pr)1^#ifN8wbyp~1drh*uUrtnc-pUi)fPER%j6tKb$i`dZRe3#G!1@h z7!nC&EkrR^9J6K03-80l7sRl8!%yhGQ1mQ!)Ytammzx7rb8ShZC11UToIjYv`!bok zRqQ91Rcr%!_RklF45+M@b--UPBMkmn*@-Jl+Y75t%3bt$Mh1}PlRfUXAE<1H<5B9b z?LJ%mynq+Ybg1Zt6D!(Hib+pcHG^g?{r#m@J40q76-K%@ssi?RcRPPMHe!lNwpt<^ z^2e<9kp6ncU}n=c)0m`AiD7e+?3^O{xn0i=!EcFk*^sbDupv3%^8q?Nkpk}qo|;k( zZwlx7uF89I67x(nZJelCmk0D@i`R(|Pmuby{l z>j~D4SC9)m?>AliQC+=)Cr=2XVluJl_GD``2dpHfnsaR^?~@$vnG7cO$#X@*pREnhX`RcxE;(04qkW#v=$hZBZL znceNI_5j{z4AeQ*04H0hgQM+^-StZswVzf}dt$SZFCP>KY$23Oz?3#}zAFYt z)j;V;E$8C!U*enR#b#03LVfQt`-;9*d3~@T!?Sk^tqPNqN#QpNVP}CWy>>I2fS$8j zZK=UVIZ=zW=n-Gp?bbhh=2B|-@Ki(7z`WbNk~sNXnCVkU*>8M-_dNJaI&X`gGv&+c z=-OM8lg>!qez-c7k0?{%f2`{s@ovrOu-2onfk}b3=UbR;eUr+2U4{yBddP}6cZ>9D z#xgrmP*9S?ApQ7wS3##eoX3R18EfW-S}WLkg4j=M#Xfn^jdU?4KD~vBSlhxlWR!5d zvVEvJP2CoEjOMjnAe%j@;s zUndeTa9W&_uXjoch18SX&T?AJws>0b?COAy>}zhlv4l!YzV`#1$&704s);9sZ$S+L zZ~9H7Kj&(^EwhNWZ>(=rFl>>fD?-c25v@;rr*84+IsccyqhHJuCZb!di2}Xyb3#}C z+WR%*A0Gw$pqmjmYJfXWQ!q~O6SD}rp&*=4BOixKr)epgRO4Z$5oe(cw;P<2Y3$?J z7rrvX$)(9RTJet5Z{(M?Cy|l=ZYcG8JfYadJ;-yvPkr?*5XW0)w!9VjR5#IVIbkNIbltO2zRV+ z#%qsl1yEVVaZf3~PE;;C5clfWN2n2H?ulS)(WVmxPlt1*_3w_zN( zT5-UEmKYW`!BdR)vzF1gSD>YQ=OulAn3c9EpX!O%ywfuD>~n}}+4tFnPsyFVHCEUj~`a^iZK`2CbQAObRtxYBPIUyzr8XmXc}2d7r%HB*`thD5#ueA}e( zLj-y~vg_N}+iL%NOzfb1oBbNQ&8hl_zn)2QbG@ymu_T=8iD9NY4~>b{>$4?A0?a_` zza0jH?l#8w@B_I;wIPQ`^}{QdHoLyv7ljMo2E|Amqsw~pY4*@7`1EU-l!LP?Q@*S_ zuU9JfVeKRh|0W4`-`d+0f~%)&4~p52PF|*@^v6d9{;Vq#x`jD5hy5A--EnZqT7^YM z@9iHXS$Fa$)!KoCze0AN`TgRlx*8GM#Yw8mDRF7c`ApM*caXze7 zGl(h<25-~leL`sE_o8#gV3aD~WmFlA-igW{O#4NURI34NZ`NApXBn?tQZo&H_l5$= zz|N-oi}+;i&Zm9n3&#hem(K1+FU=qNl8B7kOMPjA%9wW1jrMnNd`%W!KdNt)X2lD5 z-f4rEk8)y@#qB$kiVl%#wA7qB4{X`Q8A~${(}pLwUW$?HykyETE!n@=T;fic@F%F4 znTh@SjcBij!sp}0&c)icb+)7#LFBmDyMg(}!RE=`v=oXtLA7Hv(>Q#8ttlD$r;`!g zRmDV|=*2ECt1!IjY=}6=CIqKD82-}Ybuh`GT91=oSB&dc=Hol(Wqk~sMAkWml z3=hMvV$$VUcCu#rlg=4AE!_BMJ5&=vzfBv)?L->2wCH}m`!Ee1mKka+kR~MNj(|L4 z45y~ZO56zd7V$eE^+QMJEaCH0Y3I(yg5`i*!0#5+5|Fhh|yg`Kc|^M;rG zbuvqbS-2;bsEMAa9?xQ^@{A2T58T3>JmC2fA~RirQr6Z%j~mCKB9h-Z?U3K(_3L_I8eDP$uw}x6E*C;VDwQ#;$B;8r0cl9=rB5~fbv977> zq9$Ob|01E=(UyUBWp8E4<4|}JrK#%-kPQ0NMbGoZYHDzN+1GMAN^iR-9Px5!rN`?@6V@E_R51m0iNGn>WubvqlbFdbUbCO508np$JHEXh#T%}=E(BLX*~ZL)rgHD<`b3};FOw6%_~R;cNod_ z?v)i_i83>I`=S7+v6^Oa7EPOn?&jtG{-B9mT)Ehg*}=&*%4YKk&snfWg0u7+v*f@$ zw2$T;K)CJ8pD(>7Zw_Rk#NSw0pTUl@Wa*xo{3Y`)(J=0NMcDJ^oSumBqeQ7|L8J+w zDHzEh7xfNIPxnI1}?!N zs;kQ8!O3}EYlh2fYF8T*^R_AFuU>VaSEi>^kWG?_^)B@Ev3%Dmo9@6i6Efu~`jM_IeXTz+prr|JOD{6&Q&Q6xX9Rc*ltOr- z5kCyylXkDL=BciE$czb8^*xOD7V_~BuZ880{&)^qi}Y}+t&P5T_&7!msz-8M{&rDX zB>=~&ScNo9ft^RQUCi($ zRwDorOe7i>iv~sPKEZBLLST?%-7+CIBq7@L2;}?qs9}WTH~dW&1iBcOARppQ1vXq5 zu>e2|SP)Y^Au=Wo7ZDTpz%>~`0uY`-BF|dz5N9p; zo~VeXZmL0kz#9+gab1v#0uiu|KcJ5&kHX$$jAVBuK(MMU?{2Sq|tzd#{?>ID+Q z27E7|)X@L`y$A9)swk*;A1KQ}^#xP_q+pbKWlRg8UqabI3dR86B~%x*8vzU(fyjXT zF$!#;=n~2U>aDm#sDOh@s0he);U6YdVu=*czk;%ZsRdDici1o*;QbZ!5jfHc6<7qp zpunFiC=b{z9Tl)Jz^4YNsbQFaat10spnr{AlW>U&3_rn!0q?G%kHPW$Ab?K}lM*<- zhVp@-hW~PsH%OUuJP2qjz=Qy)H&A{sX~VzV(hXD)EHeF%CMm#u3l#%bqoCbefrHTS zfo1~ac@^A3A>bmNfANVstsl{7_nz}&(J<45kxDbzFbMcl8``}aVjLI*S(Fg)0XF(S z2(l(0gB=Xe?{~$33gZEvgreVh`o}L8;D!nl0Ba8a15pC4s4!7bzyn|b1cLz-Afz^( zG{&7a6<~?vK$O<^qN+PaB<+q-1_!rb+y}J-U=RUDU>G|X6^sd3kie(_r&){#z(+7L zP-H7Wz|)eL_tu=SU}OLR8WPI4{s*D~l+ch16EgqdD1k&Ym=Kt^6Z38t%)l-h(gLz= zAYct@tUG7ifX!Wskex$__fJXu^C4n~b)N?wax82h92cp9?5h822*+aq$t_T7AP|NO z0NHH+6~wnFVy!uzw z7!R2NWE1~acvXabpDbQ6EUfzwf8XtkZ}Q(ouo^OafB_3e3M^40@oGYx`;1Z2AUz@b z|G&nx9{(#u+@<%V8Ssy>O*BHnJBREb!-0GFpU|rbVAOylE;7INNclfw!JGn_ zqW~lXAZPD?Pu8x6@V?ws36TxlvGK2d;wB*`P(p}olv@-cpazwQ=Kh?)L`bW1EJXLU z{e%cvzFr1I_ZB1!iHLv6|Bq34$i0?hq<~n*_!Sx+%VA{77Izpp)f0#sE~Q0$7kD z*GS!+F0yHG03K2pFDeyaP72cn`{0n>M>j+Y69oH;lHEtnOoj|h+2UW$>yB#)BfB47 z$N@wKjFZ72s9L}w8O#VQuugU#ts^xZ|E%*Qo%=&^1f|0s9<7XqAJRN?Lm;Ct^NL& zt6re|cOI}~QT?|RB9X)QpF3#=g0v+dNOiyZMvw~s{_tgy6%Tgsqq_GI1VvtE)W|{w zQ*~3_@9a4~@}!WL^?$8i{-L@LniYnuKI9$#U!lGjf diff --git a/Scripts/Airboss.lua b/Scripts/Airboss.lua deleted file mode 100644 index 56b2f25..0000000 --- a/Scripts/Airboss.lua +++ /dev/null @@ -1,95 +0,0 @@ -Airboss = {} ---[[ - Airboss funcitons: - - Control zone. - - Turn into wind. - - LSO. - - Marshal. - - Rescue Helo. - - Recover Tanker. - - -]] - -do - - function Airboss:New(groupName) - local obj = {} - - - setmetatable(obj, self) - self.__index = self - - return obj - end - - - - - -end - -RescueHelo = {} - -do - - RescueHelo.allHeloes = {} - - function RescueHelo:New(carrierUnitName,heloGroupName) - if not carrierUnitName or not heloGroupName then return end - if not Group.getByName(heloGroupName) then return end - - local obj = {} - - obj.deBug = false - - -- basic params - obj.heloGroupName = heloGroupName - obj.heloGroup = Group.getByName(heloGroupName) - - obj.unitName = obj.heloGroup:getUnit(1) - - obj.modex = 12 - - - -- FSM - obj.isRescuing = false - obj.isReturning = false - obj.isRunning = false - obj.isStoped = false - - -- Sim params - obj.homeBase = "" - obj.carrier = carrierUnitName - obj.carrierstop = false - obj.carriertype= 'CVN71' - - obj.performRescue = true - - -- control params - obj.altitude = 1 - - obj.offSetX = 1 - obj.offSetZ = 2 - - obj.rescueRadius = 28000 -- meter - obj.rescueDuration = 300 -- second - obj.homeFuel = 5 -- % - - setmetatable(obj, self) - self.__index = self - - local ev = {} - - function ev:onEvent(event) - if event.id == world.event.S_EVENT_EJECTION or event.id == world.event.S_EVENT_CRASH then - - --function - end - - end - world.addEventHandler(ev) - - return obj - end -end \ No newline at end of file diff --git a/Scripts/Airboss[CN].lua b/Scripts/Airboss[CN].lua index e29083b..337611e 100644 --- a/Scripts/Airboss[CN].lua +++ b/Scripts/Airboss[CN].lua @@ -1,146 +1,127 @@ --- @field #AIRBOSS -AIRBOSS = { - ClassName = "AIRBOSS", - Debug = false, - lid = nil, - theatre = nil, - carrier = nil, - carriertype = nil, - carrierparam = {}, - alias = nil, - airbase = nil, - waypoints = {}, - currentwp = nil, - beacon = nil, - TACANon = nil, - TACANchannel = nil, - TACANmode = nil, - TACANmorse = nil, - ICLSon = nil, - ICLSchannel = nil, - ICLSmorse = nil, - LSORadio = nil, - LSOFreq = nil, - LSOModu = nil, - MarshalRadio = nil, - MarshalFreq = nil, - MarshalModu = nil, - TowerFreq = nil, - radiotimer = nil, - zoneCCA = nil, - zoneCCZ = nil, - players = {}, - menuadded = {}, - BreakEntry = {}, - BreakEarly = {}, - BreakLate = {}, - Abeam = {}, - Ninety = {}, - Wake = {}, - Final = {}, - Groove = {}, - Platform = {}, - DirtyUp = {}, - Bullseye = {}, - defaultcase = nil, - case = nil, - defaultoffset = nil, - holdingoffset = nil, - recoverytimes = {}, - flights = {}, - Qpattern = {}, - Qmarshal = {}, - Qwaiting = {}, - Qspinning = {}, - RQMarshal = {}, - RQLSO = {}, - TQMarshal = 0, - TQLSO = 0, - Nmaxpattern = nil, - Nmaxmarshal = nil, - NmaxSection = nil, - NmaxStack = nil, - handleai = nil, - xtVoiceOvers = nil, - xtVoiceOversAI = nil, - tanker = nil, - Corientation = nil, - Corientlast = nil, - Cposition = nil, - defaultskill = nil, - adinfinitum = nil, - magvar = nil, - Tcollapse = nil, - recoverywindow = nil, - usersoundradio = nil, - Tqueue = nil, - dTqueue = nil, - dTstatus = nil, - menumarkzones = nil, - menusmokezones = nil, - playerscores = nil, - autosave = nil, - autosavefile = nil, - autosavepath = nil, - marshalradius = nil, - airbossnice = nil, - staticweather = nil, - windowcount = 0, - LSOdT = nil, - senderac = nil, - radiorelayLSO = nil, - radiorelayMSH = nil, - turnintowind = nil, - detour = nil, - squadsetAI = nil, - excludesetAI = nil, - menusingle = nil, - collisiondist = nil, - holdtimestamp = nil, - Tmessage = nil, - soundfolder = nil, - soundfolderLSO = nil, - soundfolderMSH = nil, - despawnshutdown= nil, - dTbeacon = nil, - Tbeacon = nil, - LSOCall = nil, - MarshalCall = nil, - lowfuelAI = nil, - emergency = nil, - respawnAI = nil, - gle = {}, - lue = {}, - trapsheet = nil, - trappath = nil, - trapprefix = nil, - initialmaxalt = nil, - welcome = nil, - skipperMenu = nil, - skipperSpeed = nil, - skipperTime = nil, - skipperOffset = nil, - skipperUturn = nil, -} - ---- Aircraft types capable of landing on carrier (human+AI). --- @type AIRBOSS.AircraftCarrier --- @field #string AV8B AV-8B Night Harrier. Works only with the HMS Hermes, HMS Invincible, USS Tarawa, USS America, and Juan Carlos I. --- @field #string A4EC A-4E Community mod. --- @field #string HORNET F/A-18C Lot 20 Hornet by Eagle Dynamics. --- @field #string F14A F-14A by Heatblur. --- @field #string F14B F-14B by Heatblur. --- @field #string F14A_AI F-14A Tomcat (AI). --- @field #string FA18C F/A-18C Hornet (AI). --- @field #string S3B Lockheed S-3B Viking. --- @field #string S3BTANKER Lockheed S-3B Viking tanker. --- @field #string E2D Grumman E-2D Hawkeye AWACS. --- @field #string C2A Grumman C-2A Greyhound from Military Aircraft Mod. --- @field #string T45C T-45C by VNAO. --- @field #string RHINOE F/A-18E Superhornet (mod). --- @field #string RHINOF F/A-18F Superhornet (mod). --- @field #string GROWLER FEA-18G Superhornet (mod). -AIRBOSS.AircraftCarrier={ +AIRBOSS={ + ClassName="AIRBOSS", + Debug=false, + lid=nil, + theatre=nil, + carrier=nil, + carriertype=nil, + carrierparam={}, + alias=nil, + airbase=nil, + waypoints={}, + currentwp=nil, + beacon=nil, + TACANon=nil, + TACANchannel=nil, + TACANmode=nil, + TACANmorse=nil, + ICLSon=nil, + ICLSchannel=nil, + ICLSmorse=nil, + LSORadio=nil, + LSOFreq=nil, + LSOModu=nil, + MarshalRadio=nil, + MarshalFreq=nil, + MarshalModu=nil, + TowerFreq=nil, + radiotimer=nil, + zoneCCA=nil, + zoneCCZ=nil, + players={}, + menuadded={}, + BreakEntry={}, + BreakEarly={}, + BreakLate={}, + Abeam={}, + Ninety={}, + Wake={}, + Final={}, + Groove={}, + Platform={}, + DirtyUp={}, + Bullseye={}, + defaultcase=nil, + case=nil, + defaultoffset=nil, + holdingoffset=nil, + recoverytimes={}, + flights={}, + Qpattern={}, + Qmarshal={}, + Qwaiting={}, + Qspinning={}, + RQMarshal={}, + RQLSO={}, + TQMarshal=0, + TQLSO=0, + Nmaxpattern=nil, + Nmaxmarshal=nil, + NmaxSection=nil, + NmaxStack=nil, + handleai=nil, + xtVoiceOvers=nil, + xtVoiceOversAI=nil, + tanker=nil, + Corientation=nil, + Corientlast=nil, + Cposition=nil, + defaultskill=nil, + adinfinitum=nil, + magvar=nil, + Tcollapse=nil, + recoverywindow=nil, + usersoundradio=nil, + Tqueue=nil, + dTqueue=nil, + dTstatus=nil, + menumarkzones=nil, + menusmokezones=nil, + playerscores=nil, + autosave=nil, + autosavefile=nil, + autosavepath=nil, + marshalradius=nil, + airbossnice=nil, + staticweather=nil, + windowcount=0, + LSOdT=nil, + senderac=nil, + radiorelayLSO=nil, + radiorelayMSH=nil, + turnintowind=nil, + detour=nil, + squadsetAI=nil, + excludesetAI=nil, + menusingle=nil, + collisiondist=nil, + holdtimestamp=nil, + Tmessage=nil, + soundfolder=nil, + soundfolderLSO=nil, + soundfolderMSH=nil, + despawnshutdown=nil, + dTbeacon=nil, + Tbeacon=nil, + LSOCall=nil, + MarshalCall=nil, + lowfuelAI=nil, + emergency=nil, + respawnAI=nil, + gle={}, + lue={}, + trapsheet=nil, + trappath=nil, + trapprefix=nil, + initialmaxalt=nil, + welcome=nil, + skipperMenu=nil, + skipperSpeed=nil, + skipperTime=nil, + skipperOffset=nil, + skipperUturn=nil, + } + AIRBOSS.AircraftCarrier={ AV8B="AV8BNA", HORNET="FA-18C_hornet", A4EC="A-4E-C", @@ -156,17636 +137,8800 @@ AIRBOSS.AircraftCarrier={ RHINOE="FA-18E", RHINOF="FA-18F", GROWLER="EA-18G", -} - ---- Carrier types. --- @type AIRBOSS.CarrierType --- @field #string ROOSEVELT USS Theodore Roosevelt (CVN-71) [Super Carrier Module] --- @field #string LINCOLN USS Abraham Lincoln (CVN-72) [Super Carrier Module] --- @field #string WASHINGTON USS George Washington (CVN-73) [Super Carrier Module] --- @field #string STENNIS USS John C. Stennis (CVN-74) --- @field #string TRUMAN USS Harry S. Truman (CVN-75) [Super Carrier Module] --- @field #string FORRESTAL USS Forrestal (CV-59) [Heatblur Carrier Module] --- @field #string VINSON USS Carl Vinson (CVN-70) [Deprecated!] --- @field #string HERMES HMS Hermes (R12) [V/STOL Carrier] --- @field #string INVINCIBLE HMS Invincible (R05) [V/STOL Carrier] --- @field #string TARAWA USS Tarawa (LHA-1) [V/STOL Carrier] --- @field #string AMERICA USS America (LHA-6) [V/STOL Carrier] --- @field #string JCARLOS Juan Carlos I (L61) [V/STOL Carrier] --- @field #string HMAS Canberra (L02) [V/STOL Carrier] --- @field #string KUZNETSOV Admiral Kuznetsov (CV 1143.5) -AIRBOSS.CarrierType = { - ROOSEVELT = "CVN_71", - LINCOLN = "CVN_72", - WASHINGTON = "CVN_73", - TRUMAN = "CVN_75", - STENNIS = "Stennis", - FORRESTAL = "Forrestal", - VINSON = "VINSON", - HERMES = "HERMES81", - INVINCIBLE = "hms_invincible", - TARAWA = "LHA_Tarawa", - AMERICA = "USS America LHA-6", - JCARLOS = "L61", - CANBERRA = "L02", - KUZNETSOV = "KUZNECOW", -} - ---- Carrier specific parameters. --- @type AIRBOSS.CarrierParameters --- @field #number rwyangle Runway angle in degrees. for carriers with angled deck. For USS Theodore Roosevelt -9 degrees. --- @field #number sterndist Distance in meters from carrier position to stern of carrier. For USS Theodore Roosevelt -150 meters. --- @field #number deckheight Height of deck in meters. For USS Theodore Roosevelt ~63 ft = 19 meters. --- @field #number wire1 Distance in meters from carrier position to first wire. --- @field #number wire2 Distance in meters from carrier position to second wire. --- @field #number wire3 Distance in meters from carrier position to third wire. --- @field #number wire4 Distance in meters from carrier position to fourth wire. --- @field #number landingdist Distance in meeters to the landing position. --- @field #number rwylength Length of the landing runway in meters. --- @field #number rwywidth Width of the landing runway in meters. --- @field #number totlength Total length of carrier. --- @field #number totwidthstarboard Total with of the carrier from stern position to starboard side (asymmetric carriers). --- @field #number totwidthport Total with of the carrier from stern position to port side (asymmetric carriers). - ---- Aircraft specific Angle of Attack (AoA) (or alpha) parameters. --- @type AIRBOSS.AircraftAoA --- @field #number OnSpeedMin Minimum on speed AoA. Values below are fast --- @field #number OnSpeedMax Maximum on speed AoA. Values above are slow. --- @field #number OnSpeed Optimal on-speed AoA. --- @field #number Fast Fast AoA threshold. Smaller means faster. --- @field #number Slow Slow AoA threshold. Larger means slower. --- @field #number FAST Really fast AoA threshold. --- @field #number SLOW Really slow AoA threshold. - ---- Glideslope error thresholds in degrees. --- @type AIRBOSS.GLE --- @field #number _max Max _OK_ value. Default 0.4 deg. --- @field #number _min Min _OK_ value. Default -0.3 deg. --- @field #number High (H) threshold. Default 0.8 deg. --- @field #number Low (L) threshold. Default -0.6 deg. --- @field #number HIGH H threshold. Default 1.5 deg. --- @field #number LOW L threshold. Default -0.9 deg. - ---- Lineup error thresholds in degrees. --- @type AIRBOSS.LUE --- @field #number _max Max _OK_ value. Default 0.5 deg. --- @field #number _min Min _OK_ value. Default -0.5 deg. --- @field #number Left (LUR) threshold. Default -1.0 deg. --- @field #number Right (LUL) threshold. Default 1.0 deg. --- @field #number LeftMed threshold for AA/OS measuring. Default -2.0 deg. --- @field #number RightMed threshold for AA/OS measuring. Default 2.0 deg. --- @field #number LEFT LUR threshold. Default -3.0 deg. --- @field #number RIGHT LUL threshold. Default 3.0 deg. - ---- Pattern steps. --- @type AIRBOSS.PatternStep --- @field #string UNDEFINED "Undefined". --- @field #string REFUELING "Refueling". --- @field #string SPINNING "Spinning". --- @field #string COMMENCING "Commencing". --- @field #string HOLDING "Holding". --- @field #string WAITING "Waiting for free Marshal stack". --- @field #string PLATFORM "Platform". --- @field #string ARCIN "Arc Turn In". --- @field #string ARCOUT "Arc Turn Out". --- @field #string DIRTYUP "Dirty Up". --- @field #string BULLSEYE "Bullseye". --- @field #string INITIAL "Initial". --- @field #string BREAKENTRY "Break Entry". --- @field #string EARLYBREAK "Early Break". --- @field #string LATEBREAK "Late Break". --- @field #string ABEAM "Abeam". --- @field #string NINETY "Ninety". --- @field #string WAKE "Wake". --- @field #string FINAL "Final". --- @field #string GROOVE_XX "Groove X". --- @field #string GROOVE_IM "Groove In the Middle". --- @field #string GROOVE_IC "Groove In Close". --- @field #string GROOVE_AR "Groove At the Ramp". --- @field #string GROOVE_AL "Groove Abeam Landing Spot". --- @field #string GROOVE_LC "Groove Level Cross". --- @field #string GROOVE_IW "Groove In the Wires". --- @field #string BOLTER "Bolter Pattern". --- @field #string EMERGENCY "Emergency Landing". --- @field #string DEBRIEF "Debrief". -AIRBOSS.PatternStep = { - UNDEFINED = "Undefined", - REFUELING = "Refueling", - SPINNING = "Spinning", - COMMENCING = "Commencing", - HOLDING = "Holding", - WAITING = "Waiting for free Marshal stack", - PLATFORM = "Platform", - ARCIN = "Arc Turn In", - ARCOUT = "Arc Turn Out", - DIRTYUP = "Dirty Up", - BULLSEYE = "Bullseye", - INITIAL = "Initial", - BREAKENTRY = "Break Entry", - EARLYBREAK = "Early Break", - LATEBREAK = "Late Break", - ABEAM = "Abeam", - NINETY = "Ninety", - WAKE = "Wake", - FINAL = "Turn Final", - GROOVE_XX = "Groove X", - GROOVE_IM = "Groove In the Middle", - GROOVE_IC = "Groove In Close", - GROOVE_AR = "Groove At the Ramp", - GROOVE_IW = "Groove In the Wires", - GROOVE_AL = "Groove Abeam Landing Spot", - GROOVE_LC = "Groove Level Cross", - BOLTER = "Bolter Pattern", - EMERGENCY = "Emergency Landing", - DEBRIEF = "Debrief", -} - ---- Groove position. --- @type AIRBOSS.GroovePos --- @field #string X0 "X0": Entering the groove. --- @field #string XX "XX": At the start, i.e. 3/4 from the run down. --- @field #string IM "IM": In the middle. --- @field #string IC "IC": In close. --- @field #string AR "AR": At the ramp. --- @field #string AL "AL": Abeam landing position (V/STOL). --- @field #string LC "LC": Level crossing (V/STOL). --- @field #string IW "IW": In the wires. -AIRBOSS.GroovePos = { - X0 = "X0", - XX = "XX", - IM = "IM", - IC = "IC", - AR = "AR", - AL = "AL", - LC = "LC", - IW = "IW", -} - ---- Radio. --- @type AIRBOSS.Radio --- @field #number frequency Frequency in Hz. --- @field #number modulation Band modulation. --- @field #string alias Radio alias. - ---- Radio sound file and subtitle. --- @type AIRBOSS.RadioCall --- @field #string file Sound file name without suffix. --- @field #string suffix File suffix/extension, e.g. "ogg". --- @field #boolean loud Loud version of sound file available. --- @field #string subtitle Subtitle displayed during transmission. --- @field #number duration Duration of the sound in seconds. This is also the duration the subtitle is displayed. --- @field #number subduration Duration in seconds the subtitle is displayed. --- @field #string modexsender Onboard number of the sender (optional). --- @field #string modexreceiver Onboard number of the receiver (optional). --- @field #string sender Sender of the message (optional). Default radio alias. - ---- Pilot radio calls. --- type AIRBOSS.PilotCalls --- @field #AIRBOSS.RadioCall N0 "Zero" call. --- @field #AIRBOSS.RadioCall N1 "One" call. --- @field #AIRBOSS.RadioCall N2 "Two" call. --- @field #AIRBOSS.RadioCall N3 "Three" call. --- @field #AIRBOSS.RadioCall N4 "Four" call. --- @field #AIRBOSS.RadioCall N5 "Five" call. --- @field #AIRBOSS.RadioCall N6 "Six" call. --- @field #AIRBOSS.RadioCall N7 "Seven" call. --- @field #AIRBOSS.RadioCall N8 "Eight" call. --- @field #AIRBOSS.RadioCall N9 "Nine" call. --- @field #AIRBOSS.RadioCall POINT "Point" call. --- @field #AIRBOSS.RadioCall BALL "Ball" call. --- @field #AIRBOSS.RadioCall HARRIER "Harrier" call. --- @field #AIRBOSS.RadioCall HAWKEYE "Hawkeye" call. --- @field #AIRBOSS.RadioCall HORNET "Hornet" call. --- @field #AIRBOSS.RadioCall SKYHAWK "Skyhawk" call. --- @field #AIRBOSS.RadioCall TOMCAT "Tomcat" call. --- @field #AIRBOSS.RadioCall VIKING "Viking" call. --- @field #AIRBOSS.RadioCall BINGOFUEL "Bingo Fuel" call. --- @field #AIRBOSS.RadioCall GASATDIVERT "Going for gas at the divert field" call. --- @field #AIRBOSS.RadioCall GASATTANKER "Going for gas at the recovery tanker" call. - ---- LSO radio calls. --- @type AIRBOSS.LSOCalls --- @field #AIRBOSS.RadioCall BOLTER "Bolter, Bolter" call. --- @field #AIRBOSS.RadioCall CALLTHEBALL "Call the Ball" call. --- @field #AIRBOSS.RadioCall CHECK "CHECK" call. --- @field #AIRBOSS.RadioCall CLEAREDTOLAND "Cleared to land" call. --- @field #AIRBOSS.RadioCall COMELEFT "Come left" call. --- @field #AIRBOSS.RadioCall DEPARTANDREENTER "Depart and re-enter" call. --- @field #AIRBOSS.RadioCall EXPECTHEAVYWAVEOFF "Expect heavy wavoff" call. --- @field #AIRBOSS.RadioCall EXPECTSPOT75 "Expect spot 7.5" call. --- @field #AIRBOSS.RadioCall EXPECTSPOT5 "Expect spot 5" call. --- @field #AIRBOSS.RadioCall FAST "You're fast" call. --- @field #AIRBOSS.RadioCall FOULDECK "Foul Deck" call. --- @field #AIRBOSS.RadioCall HIGH "You're high" call. --- @field #AIRBOSS.RadioCall IDLE "Idle" call. --- @field #AIRBOSS.RadioCall LONGINGROOVE "You're long in the groove" call. --- @field #AIRBOSS.RadioCall LOW "You're low" call. --- @field #AIRBOSS.RadioCall N0 "Zero" call. --- @field #AIRBOSS.RadioCall N1 "One" call. --- @field #AIRBOSS.RadioCall N2 "Two" call. --- @field #AIRBOSS.RadioCall N3 "Three" call. --- @field #AIRBOSS.RadioCall N4 "Four" call. --- @field #AIRBOSS.RadioCall N5 "Five" call. --- @field #AIRBOSS.RadioCall N6 "Six" call. --- @field #AIRBOSS.RadioCall N7 "Seven" call. --- @field #AIRBOSS.RadioCall N8 "Eight" call. --- @field #AIRBOSS.RadioCall N9 "Nine" call. --- @field #AIRBOSS.RadioCall PADDLESCONTACT "Paddles, contact" call. --- @field #AIRBOSS.RadioCall POWER "Power" call. --- @field #AIRBOSS.RadioCall RADIOCHECK "Paddles, radio check" call. --- @field #AIRBOSS.RadioCall RIGHTFORLINEUP "Right for line up" call. --- @field #AIRBOSS.RadioCall ROGERBALL "Roger ball" call. --- @field #AIRBOSS.RadioCall SLOW "You're slow" call. --- @field #AIRBOSS.RadioCall STABILIZED "Stabilized" call. --- @field #AIRBOSS.RadioCall WAVEOFF "Wave off" call. --- @field #AIRBOSS.RadioCall WELCOMEABOARD "Welcome aboard" call. --- @field #AIRBOSS.RadioCall CLICK Radio end transmission click sound. --- @field #AIRBOSS.RadioCall NOISE Static noise sound. --- @field #AIRBOSS.RadioCall SPINIT "Spin it" call. - ---- Marshal radio calls. --- @type AIRBOSS.MarshalCalls --- @field #AIRBOSS.RadioCall AFFIRMATIVE "Affirmative" call. --- @field #AIRBOSS.RadioCall ALTIMETER "Altimeter" call. --- @field #AIRBOSS.RadioCall BRC "BRC" call. --- @field #AIRBOSS.RadioCall CARRIERTURNTOHEADING "Turn to heading" call. --- @field #AIRBOSS.RadioCall CASE "Case" call. --- @field #AIRBOSS.RadioCall CHARLIETIME "Charlie Time" call. --- @field #AIRBOSS.RadioCall CLEAREDFORRECOVERY "You're cleared for case" call. --- @field #AIRBOSS.RadioCall DECKCLOSED "Deck closed" sound. --- @field #AIRBOSS.RadioCall DEGREES "Degrees" call. --- @field #AIRBOSS.RadioCall EXPECTED "Expected" call. --- @field #AIRBOSS.RadioCall FLYNEEDLES "Fly your needles" call. --- @field #AIRBOSS.RadioCall HOLDATANGELS "Hold at angels" call. --- @field #AIRBOSS.RadioCall HOURS "Hours" sound. --- @field #AIRBOSS.RadioCall MARSHALRADIAL "Marshal radial" call. --- @field #AIRBOSS.RadioCall N0 "Zero" call. --- @field #AIRBOSS.RadioCall N1 "One" call. --- @field #AIRBOSS.RadioCall N2 "Two" call. --- @field #AIRBOSS.RadioCall N3 "Three" call. --- @field #AIRBOSS.RadioCall N4 "Four" call. --- @field #AIRBOSS.RadioCall N5 "Five" call. --- @field #AIRBOSS.RadioCall N6 "Six" call. --- @field #AIRBOSS.RadioCall N7 "Seven" call. --- @field #AIRBOSS.RadioCall N8 "Eight" call. --- @field #AIRBOSS.RadioCall N9 "Nine" call. --- @field #AIRBOSS.RadioCall NEGATIVE "Negative" sound. --- @field #AIRBOSS.RadioCall NEWFB "New final bearing" call. --- @field #AIRBOSS.RadioCall OBS "Obs" call. --- @field #AIRBOSS.RadioCall POINT "Point" call. --- @field #AIRBOSS.RadioCall RADIOCHECK "Radio check" call. --- @field #AIRBOSS.RadioCall RECOVERY "Recovery" call. --- @field #AIRBOSS.RadioCall RECOVERYOPSSTOPPED "Recovery ops stopped" sound. --- @field #AIRBOSS.RadioCall RECOVERYPAUSEDNOTICE "Recovery paused until further notice" call. --- @field #AIRBOSS.RadioCall RECOVERYPAUSEDRESUMED "Recovery paused and will be resumed at" call. --- @field #AIRBOSS.RadioCall RESUMERECOVERY "Resuming aircraft recovery" call. --- @field #AIRBOSS.RadioCall REPORTSEEME "Report see me" call. --- @field #AIRBOSS.RadioCall ROGER "Roger" call. --- @field #AIRBOSS.RadioCall SAYNEEDLES "Say needles" call. --- @field #AIRBOSS.RadioCall STACKFULL "Marshal stack is currently full. Hold outside 10 NM zone and wait for further instructions" call. --- @field #AIRBOSS.RadioCall STARTINGRECOVERY "Starting aircraft recovery" call. --- @field #AIRBOSS.RadioCall CLICK Radio end transmission click sound. --- @field #AIRBOSS.RadioCall NOISE Static noise sound. - ---- Difficulty level. --- @type AIRBOSS.Difficulty --- @field #string EASY Flight Student. Shows tips and hints in important phases of the approach. --- @field #string NORMAL Naval aviator. Moderate number of hints but not really zip lip. --- @field #string HARD TOPGUN graduate. For people who know what they are doing. Nearly *ziplip*. -AIRBOSS.Difficulty = { - EASY = "Flight Student", - NORMAL = "Naval Aviator", - HARD = "TOPGUN Graduate", -} - ---- Recovery window parameters. --- @type AIRBOSS.Recovery --- @field #number START Start of recovery in seconds of abs mission time. --- @field #number STOP End of recovery in seconds of abs mission time. --- @field #number CASE Recovery case (1-3) of that time slot. --- @field #number OFFSET Angle offset of the holding pattern in degrees. Usually 0, +-15, or +-30 degrees. --- @field #boolean OPEN Recovery window is currently open. --- @field #boolean OVER Recovery window is over and closed. --- @field #boolean WIND Carrier will turn into the wind. --- @field #number SPEED The speed in knots the carrier has during the recovery. --- @field #boolean UTURN If true, carrier makes a U-turn to the point it came from before resuming its route to the next waypoint. --- @field #number ID Recovery window ID. - ---- Groove data. --- @type AIRBOSS.GrooveData --- @field #number Step Current step. --- @field #number Time Time in seconds. --- @field #number Rho Distance in meters. --- @field #number X Distance in meters. --- @field #number Z Distance in meters. --- @field #number AoA Angle of Attack. --- @field #number Alt Altitude in meters. --- @field #number GSE Glideslope error in degrees. --- @field #number LUE Lineup error in degrees. --- @field #number Pitch Pitch angle in degrees. --- @field #number Roll Roll angle in degrees. --- @field #number Yaw Yaw angle in degrees. --- @field #number Vel Total velocity in m/s. --- @field #number Vy Vertical velocity in m/s. --- @field #number Gamma Relative heading player to carrier's runway. 0=parallel, +-90=perpendicular. --- @field #string Grade LSO grade. --- @field #number GradePoints LSO grade points --- @field #string GradeDetail LSO grade details. --- @field #string FlyThrough Fly through up "/" or fly through down "\\". - ---- LSO grade data. --- @type AIRBOSS.LSOgrade --- @field #string grade LSO grade, i.e. _OK_, OK, (OK), --, CUT --- @field #number points Points received. --- @field #number finalscore Points received after player has finally landed. This is the average over all incomplete passes (bolter, waveoff) before. --- @field #string details Detailed flight analysis. --- @field #number wire Wire caught. --- @field #number Tgroove Time in the groove in seconds. --- @field #number case Recovery case. --- @field #string wind Wind speed on deck in knots. --- @field #string modex Onboard number. --- @field #string airframe Aircraft type name of player. --- @field #string carriertype Carrier type name. --- @field #string carriername Carrier name/alias. --- @field #string theatre DCS map. --- @field #string mitime Mission time in hh:mm:ss+d format --- @field #string midate Mission date in yyyy/mm/dd format. --- @field #string osdate Real live date. Needs **os** to be desanitized. - ---- Checkpoint parameters triggering the next step in the pattern. --- @type AIRBOSS.Checkpoint --- @field #string name Name of checkpoint. --- @field #number Xmin Minimum allowed longitual distance to carrier. --- @field #number Xmax Maximum allowed longitual distance to carrier. --- @field #number Zmin Minimum allowed latitudal distance to carrier. --- @field #number Zmax Maximum allowed latitudal distance to carrier. --- @field #number LimitXmin Latitudal threshold for triggering the next step if XXmax. --- @field #number LimitZmin Latitudal threshold for triggering the next step if ZZmax. - ---- Parameters of a flight group. --- @type AIRBOSS.FlightGroup --- @field Wrapper.Group#GROUP group Flight group. --- @field #string groupname Name of the group. --- @field #number nunits Number of units in group. --- @field #number dist0 Distance to carrier in meters when the group was first detected inside the CCA. --- @field #number time Timestamp in seconds of timer.getAbsTime() of the last important event, e.g. added to the queue. --- @field #number flag Flag value describing the current stack. --- @field #boolean ai If true, flight is purly AI. --- @field #string actype Aircraft type name. --- @field #table onboardnumbers Onboard numbers of aircraft in the group. --- @field #string onboard Onboard number of player or first unit in group. --- @field #number case Recovery case of flight. --- @field #string seclead Name of section lead. --- @field #table section Other human flight groups belonging to this flight. This flight is the lead. --- @field #boolean holding If true, flight is in holding zone. --- @field #boolean ballcall If true, flight called the ball in the groove. --- @field #table elements Flight group elements. --- @field #number Tcharlie Charlie (abs) time in seconds. --- @field #string name Player name or name of first AI unit. --- @field #boolean refueling Flight is refueling. - ---- Parameters of an element in a flight group. --- @type AIRBOSS.FlightElement --- @field Wrapper.Unit#UNIT unit Aircraft unit. --- @field #string unitname Name of the unit. --- @field #boolean ai If true, AI sits inside. If false, human player is flying. --- @field #string onboard Onboard number of the aircraft. --- @field #boolean ballcall If true, flight called the ball in the groove. --- @field #boolean recovered If true, element was successfully recovered. - ---- Player data table holding all important parameters of each player. --- @type AIRBOSS.PlayerData --- @field Wrapper.Unit#UNIT unit Aircraft of the player. --- @field #string unitname Name of the unit. --- @field Wrapper.Client#CLIENT client Client object of player. --- @field #string callsign Callsign of player. --- @field #string difficulty Difficulty level. --- @field #string step Current/next pattern step. --- @field #boolean warning Set true once the player got a warning. --- @field #number passes Number of passes. --- @field #boolean attitudemonitor If true, display aircraft attitude and other parameters constantly. --- @field #table debrief Debrief analysis of the current step of this pass. --- @field #table lastdebrief Debrief of player performance of last completed pass. --- @field #boolean landed If true, player landed or attempted to land. --- @field #boolean boltered If true, player boltered. --- @field #boolean waveoff If true, player was waved off during final approach. --- @field #boolean wop If true, player was waved off during the pattern. --- @field #boolean lig If true, player was long in the groove. --- @field #boolean owo If true, own waveoff by player. --- @field #boolean wofd If true, player was waved off because of a foul deck. --- @field #number Tlso Last time the LSO gave an advice. --- @field #number Tgroove Time in the groove in seconds. --- @field #number TIG0 Time in groove start timer.getTime(). --- @field #number wire Wire caught by player when trapped. --- @field #AIRBOSS.GroovePos groove Data table at each position in the groove. Elements are of type @{#AIRBOSS.GrooveData}. --- @field #table points Points of passes until finally landed. --- @field #number finalscore Final score if points are averaged over multiple passes. --- @field #boolean valid If true, player made a valid approach. Is set true on start of Groove X. --- @field #boolean subtitles If true, display subtitles of radio messages. --- @field #boolean showhints If true, show step hints. --- @field #table trapsheet Groove data table recorded every 0.5 seconds. --- @field #boolean trapon If true, save trap sheets. --- @field #string debriefschedulerID Debrief scheduler ID. --- --- @field Sound.SRS#MSRS SRS --- @field Sound.SRS#MSRSQUEUE SRSQ --- --- @extends #AIRBOSS.FlightGroup - ---- Main group level radio menu: F10 Other/Airboss. --- @field #table MenuF10 -AIRBOSS.MenuF10 = {} - ---- Airboss mission level F10 root menu. --- @field #table MenuF10Root -AIRBOSS.MenuF10Root = nil - ---- Airboss class version. --- @field #string version -AIRBOSS.version = "1.3.3" -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- TODO list -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - --- DONE: Handle tanker and AWACS. Put them into pattern. --- TODO: Handle cases where AI crashes on carrier deck ==> Clean up deck. --- TODO: Player eject and crash debrief "gradings". --- TODO: PWO during case 2/3. --- TODO: PWO when player comes too close to other flight. --- DONE: Spin pattern. Add radio menu entry. Not sure what to add though?! --- DONE: Despawn AI after engine shutdown option. --- DONE: What happens when section lead or member dies? --- DONE: Do not remove recovered elements but only set switch. Remove only groups which are completely recovered. --- DONE: Option to filter AI groups for recovery. --- DONE: Rework radio messages. Better control over player board numbers. --- DONE: Case I & II/III zone so that player gets into pattern automatically. Case I 3 position on the circle. Case II/III when the player enters the approach corridor maybe? --- DONE: Add static weather information. --- DONE: Allow up to two flights per Case I marshal stack. --- DONE: Add max stack for Case I and define waiting queue outside CCZ. --- DONE: Maybe do an additional step at the initial (Case II) or bullseye (Case III) and register player in case he missed some steps. --- DONE: Subtitles off options on player level. --- DONE: Persistence of results. --- DONE: Foul deck waveoff. --- DONE: Get Charlie time estimate function. --- DONE: Average player grades until landing. --- DONE: Check player heading at zones, e.g. initial. --- DONE: Fix bug that player leaves the approach zone if he boltered or was waved off during Case II or III. NOTE: Partly due to increasing approach zone size. --- DONE: Fix bug that player gets an altitude warning if stack collapses. NOTE: Would not work if two stacks Case I and II/III are used. --- DONE: Improve radio messages. Maybe usersound for messages which are only meant for players? --- DONE: Add voice over fly needs and welcome aboard. --- DONE: Improve trapped wire calculation. --- DONE: Carrier zone with dimensions of carrier. to check if landing happened on deck. --- DONE: Carrier runway zone for fould deck check. --- DONE: More Hints for Case II/III. --- DONE: Set magnetic declination function. --- DONE: First send AI to marshal and then allow them into the landing pattern ==> task function when reaching the waypoint. --- DONE: Extract (static) weather from mission for cloud cover etc. --- DONE: Check distance to players during approach. --- DONE: Option to turn AI handling off. --- DONE: Add user functions. --- DONE: Update AI holding pattern wrt to moving carrier. --- DONE: Generalize parameters for other carriers. --- DONE: Generalize parameters for other aircraft. --- DONE: Add radio check (LSO, AIRBOSS) to F10 radio menu. --- DONE: Right pattern step after bolter/wo/patternWO? Guess so. --- DONE: Set case II and III times (via recovery time). --- DONE: Get correct wire when trapped. DONE but might need further tweaking. --- DONE: Add radio transmission queue for LSO and airboss. --- DONE: CASE II. --- DONE: CASE III. --- NOPE: Strike group with helo bringing cargo etc. Not yet. --- DONE: Handle crash event. Delete A/C from queue, send rescue helo. --- DONE: Get fuel state in pounds. (working for the hornet, did not check others) --- DONE: Add aircraft numbers in queue to carrier info F10 radio output. --- DONE: Monitor holding of players/AI in zoneHolding. --- DONE: Transmission via radio. --- DONE: Get board numbers. --- DONE: Get an _OK_ pass if long in groove. Possible other pattern wave offs as well?! --- DONE: Add scoring to radio menu. --- DONE: Optimized debrief. --- DONE: Add automatic grading. --- DONE: Fix radio menu. - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- Constructor -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ---- Create a new AIRBOSS class object for a specific aircraft carrier unit. --- @param #AIRBOSS self --- @param carriername Name of the aircraft carrier unit as defined in the mission editor. --- @param alias (Optional) Alias for the carrier. This will be used for radio messages and the F10 radius menu. Default is the carrier name as defined in the mission editor. --- @return #AIRBOSS self or nil if carrier unit does not exist. -function AIRBOSS:New( carriername, alias ) - - -- Inherit everthing from FSM class. - local self = BASE:Inherit( self, FSM:New() ) -- #AIRBOSS - - -- Debug. - self:F2( { carriername = carriername, alias = alias } ) - - -- Set carrier unit. - self.carrier = UNIT:FindByName( carriername ) - - -- Check if carrier unit exists. - if self.carrier == nil then - -- Error message. - local text = string.format( "ERROR: Carrier unit %s could not be found! Make sure this UNIT is defined in the mission editor and check the spelling of the unit name carefully.", carriername ) - MESSAGE:New( text, 120 ):ToAll() - self:E( text ) - return nil + } + AIRBOSS.CarrierType={ + ROOSEVELT="CVN_71", + LINCOLN="CVN_72", + WASHINGTON="CVN_73", + TRUMAN="CVN_75", + STENNIS="Stennis", + FORRESTAL="Forrestal", + VINSON="VINSON", + HERMES="HERMES81", + INVINCIBLE="hms_invincible", + TARAWA="LHA_Tarawa", + AMERICA="USS America LHA-6", + JCARLOS="L61", + CANBERRA="L02", + KUZNETSOV="KUZNECOW", + } + AIRBOSS.PatternStep={ + UNDEFINED="Undefined", + REFUELING="Refueling", + SPINNING="Spinning", + COMMENCING="Commencing", + HOLDING="Holding", + WAITING="Waiting for free Marshal stack", + PLATFORM="Platform", + ARCIN="Arc Turn In", + ARCOUT="Arc Turn Out", + DIRTYUP="Dirty Up", + BULLSEYE="Bullseye", + INITIAL="Initial", + BREAKENTRY="Break Entry", + EARLYBREAK="Early Break", + LATEBREAK="Late Break", + ABEAM="Abeam", + NINETY="Ninety", + WAKE="Wake", + FINAL="Turn Final", + GROOVE_XX="Groove X", + GROOVE_IM="Groove In the Middle", + GROOVE_IC="Groove In Close", + GROOVE_AR="Groove At the Ramp", + GROOVE_IW="Groove In the Wires", + GROOVE_AL="Groove Abeam Landing Spot", + GROOVE_LC="Groove Level Cross", + BOLTER="Bolter Pattern", + EMERGENCY="Emergency Landing", + DEBRIEF="Debrief", + } + AIRBOSS.GroovePos={ + X0="X0", + XX="XX", + IM="IM", + IC="IC", + AR="AR", + AL="AL", + LC="LC", + IW="IW", + } + AIRBOSS.Difficulty={ + EASY="Flight Student", + NORMAL="Naval Aviator", + HARD="TOPGUN Graduate", + } + AIRBOSS.MenuF10={} + AIRBOSS.MenuF10Root=nil + AIRBOSS.version="1.3.3" + function AIRBOSS:New(carriername,alias) + local self=BASE:Inherit(self,FSM:New()) + self:F2({carriername=carriername,alias=alias}) + self.carrier=UNIT:FindByName(carriername) + if self.carrier==nil then + local text=string.format("ERROR: Carrier unit %s could not be found! Make sure this UNIT is defined in the mission editor and check the spelling of the unit name carefully.",carriername) + MESSAGE:New(text,120):ToAll() + self:E(text) + return nil end - - -- Set some string id for output to DCS.log file. - self.lid = string.format( "AIRBOSS %s | ", carriername ) - - -- Current map. - self.theatre = env.mission.theatre - self:T2( self.lid .. string.format( "Theatre = %s.", tostring( self.theatre ) ) ) - - -- Get carrier type. - self.carriertype = self.carrier:GetTypeName() - - -- Set alias. - self.alias = alias or carriername - - -- Set carrier airbase object. - self.airbase = AIRBASE:FindByName( carriername ) - - -- Create carrier beacon. - self.beacon = BEACON:New( self.carrier ) - - -- Set Tower Frequency of carrier. + self.lid=string.format("AIRBOSS %s | ",carriername) + self.theatre=env.mission.theatre + self:T2(self.lid..string.format("Theatre = %s.",tostring(self.theatre))) + self.carriertype=self.carrier:GetTypeName() + self.alias=alias or carriername + self.airbase=AIRBASE:FindByName(carriername) + self.beacon=BEACON:New(self.carrier) self:_GetTowerFrequency() - - -- Init player scores table. - self.playerscores = {} - - -- Initialize ME waypoints. + self.playerscores={} self:_InitWaypoints() - - -- Current waypoint. - self.currentwp = 1 - - -- Patrol route. + self.currentwp=1 self:_PatrolRoute() - - ------------- - --- Defaults: - ------------- - - -- Set up Airboss radio. self:SetMarshalRadio() self:SetAirbossRadio() - - -- Set up LSO radio. self:SetLSORadio() - - -- Set LSO call interval. Default 4 sec. self:SetLSOCallInterval() - - -- Radio scheduler. - self.radiotimer = SCHEDULER:New() - - -- Set magnetic declination. + self.radiotimer=SCHEDULER:New() self:SetMagneticDeclination() - - -- Set ICSL to channel 1. self:SetICLS() - - -- Set TACAN to channel 74X. self:SetTACAN() - - -- Becons are reactivated very 5 min. self:SetBeaconRefresh() - - -- Set max aircraft in landing pattern. Default 4. self:SetMaxLandingPattern() - - -- Set max Case I Marshal stacks. Default 3. self:SetMaxMarshalStacks() - - -- Set max section members. Default 2. self:SetMaxSectionSize() - - -- Set max flights per stack. Default is 2. self:SetMaxFlightsPerStack() - - -- Set AI handling On. self:SetHandleAION() - - -- No extra voiceover/calls from player by default self:SetExtraVoiceOvers(false) - - -- No extra voiceover/calls from AI by default self:SetExtraVoiceOversAI(false) - - -- Airboss is a nice guy. self:SetAirbossNiceGuy() - - -- Allow emergency landings. self:SetEmergencyLandings() - - -- No despawn after engine shutdown by default. - self:SetDespawnOnEngineShutdown( false ) - - -- No respawning of AI groups when entering the CCA. - self:SetRespawnAI( false ) - - -- Mission uses static weather by default. + self:SetDespawnOnEngineShutdown(false) + self:SetRespawnAI(false) self:SetStaticWeather() - - -- Default recovery case. This sets self.defaultcase and self.case. Default Case I. self:SetRecoveryCase() - - -- Set time the turn starts before the window opens. self:SetRecoveryTurnTime() - - -- Set holding offset to 0 degrees. This set self.defaultoffset and self.holdingoffset. self:SetHoldingOffsetAngle() - - -- Set Marshal stack radius. Default 2.75 NM, which gives a diameter of 5.5 NM. self:SetMarshalRadius() - - -- Set max alt at initial. Default 1300 ft. self:SetInitialMaxAlt() - - -- Default player skill EASY. - self:SetDefaultPlayerSkill( AIRBOSS.Difficulty.EASY ) - - -- Default glideslope error thresholds. + self:SetDefaultPlayerSkill(AIRBOSS.Difficulty.EASY) self:SetGlideslopeErrorThresholds() - - -- Default lineup error thresholds. self:SetLineupErrorThresholds() - - -- CCA 50 NM radius zone around the carrier. self:SetCarrierControlledArea() - - -- CCZ 5 NM radius zone around the carrier. self:SetCarrierControlledZone() - - -- Carrier patrols its waypoints until the end of time. - self:SetPatrolAdInfinitum( true ) - - -- Collision check distance. Default 5 NM. + self:SetPatrolAdInfinitum(true) self:SetCollisionDistance() - - -- Set update time intervals. self:SetQueueUpdateTime() self:SetStatusUpdateTime() self:SetDefaultMessageDuration() - - -- Menu options. self:SetMenuMarkZones() self:SetMenuSmokeZones() - self:SetMenuSingleCarrier( false ) - - -- Welcome players. - self:SetWelcomePlayers( true ) - - -- Coordinates - self.landingcoord = COORDINATE:New( 0, 0, 0 ) -- Core.Point#COORDINATE - self.sterncoord = COORDINATE:New( 0, 0, 0 ) -- Core.Point#COORDINATE - self.landingspotcoord = COORDINATE:New( 0, 0, 0 ) -- Core.Point#COORDINATE - - -- Init carrier parameters. - if self.carriertype == AIRBOSS.CarrierType.STENNIS then - -- Stennis parameters were updated to match the other Super Carriers. - self:_InitNimitz() - elseif self.carriertype == AIRBOSS.CarrierType.ROOSEVELT then - self:_InitNimitz() - elseif self.carriertype == AIRBOSS.CarrierType.LINCOLN then - self:_InitNimitz() - elseif self.carriertype == AIRBOSS.CarrierType.WASHINGTON then - self:_InitNimitz() - elseif self.carriertype == AIRBOSS.CarrierType.TRUMAN then - self:_InitNimitz() - elseif self.carriertype == AIRBOSS.CarrierType.FORRESTAL then - self:_InitForrestal() - elseif self.carriertype == AIRBOSS.CarrierType.VINSON then - -- Carl Vinson is legacy now. - self:_InitStennis() - elseif self.carriertype == AIRBOSS.CarrierType.HERMES then - -- Hermes parameters. - self:_InitHermes() - elseif self.carriertype == AIRBOSS.CarrierType.INVINCIBLE then - -- Invincible parameters. - self:_InitInvincible() - elseif self.carriertype == AIRBOSS.CarrierType.TARAWA then - -- Tarawa parameters. - self:_InitTarawa() - elseif self.carriertype == AIRBOSS.CarrierType.AMERICA then - -- Use America parameters. - self:_InitAmerica() - elseif self.carriertype == AIRBOSS.CarrierType.JCARLOS then - -- Use Juan Carlos parameters. - self:_InitJcarlos() - elseif self.carriertype == AIRBOSS.CarrierType.CANBERRA then - -- Use Juan Carlos parameters at this stage. - self:_InitCanberra() - elseif self.carriertype == AIRBOSS.CarrierType.KUZNETSOV then - -- Kusnetsov parameters - maybe... - self:_InitStennis() + self:SetMenuSingleCarrier(false) + self:SetWelcomePlayers(true) + self.landingcoord=COORDINATE:New(0,0,0) + self.sterncoord=COORDINATE:New(0,0,0) + self.landingspotcoord=COORDINATE:New(0,0,0) + if self.carriertype==AIRBOSS.CarrierType.STENNIS then + self:_InitNimitz() + elseif self.carriertype==AIRBOSS.CarrierType.ROOSEVELT then + self:_InitNimitz() + elseif self.carriertype==AIRBOSS.CarrierType.LINCOLN then + self:_InitNimitz() + elseif self.carriertype==AIRBOSS.CarrierType.WASHINGTON then + self:_InitNimitz() + elseif self.carriertype==AIRBOSS.CarrierType.TRUMAN then + self:_InitNimitz() + elseif self.carriertype==AIRBOSS.CarrierType.FORRESTAL then + self:_InitForrestal() + elseif self.carriertype==AIRBOSS.CarrierType.VINSON then + self:_InitStennis() + elseif self.carriertype==AIRBOSS.CarrierType.HERMES then + self:_InitHermes() + elseif self.carriertype==AIRBOSS.CarrierType.INVINCIBLE then + self:_InitInvincible() + elseif self.carriertype==AIRBOSS.CarrierType.TARAWA then + self:_InitTarawa() + elseif self.carriertype==AIRBOSS.CarrierType.AMERICA then + self:_InitAmerica() + elseif self.carriertype==AIRBOSS.CarrierType.JCARLOS then + self:_InitJcarlos() + elseif self.carriertype==AIRBOSS.CarrierType.CANBERRA then + self:_InitCanberra() + elseif self.carriertype==AIRBOSS.CarrierType.KUZNETSOV then + self:_InitStennis() else - self:E( self.lid .. string.format( "ERROR: Unknown carrier type %s!", tostring( self.carriertype ) ) ) - return nil + self:E(self.lid..string.format("ERROR: Unknown carrier type %s!",tostring(self.carriertype))) + return nil end - - -- Init voice over files. self:_InitVoiceOvers() - - ------------------- - -- Debug Section -- - ------------------- - - -- Debug trace. if false then - self.Debug = true - BASE:TraceOnOff( true ) - BASE:TraceClass( self.ClassName ) - BASE:TraceLevel( 3 ) - -- self.dTstatus=0.1 + self.Debug=true + BASE:TraceOnOff(true) + BASE:TraceClass(self.ClassName) + BASE:TraceLevel(3) end - - -- Smoke zones. if false then - local case = 3 - self.holdingoffset = 30 - self:_GetZoneGroove():SmokeZone( SMOKECOLOR.Red, 5 ) - self:_GetZoneLineup():SmokeZone( SMOKECOLOR.Green, 5 ) - self:_GetZoneBullseye( case ):SmokeZone( SMOKECOLOR.White, 45 ) - self:_GetZoneDirtyUp( case ):SmokeZone( SMOKECOLOR.Orange, 45 ) - self:_GetZoneArcIn( case ):SmokeZone( SMOKECOLOR.Blue, 45 ) - self:_GetZoneArcOut( case ):SmokeZone( SMOKECOLOR.Blue, 45 ) - self:_GetZonePlatform( case ):SmokeZone( SMOKECOLOR.Blue, 45 ) - self:_GetZoneCorridor( case ):SmokeZone( SMOKECOLOR.Green, 45 ) - self:_GetZoneHolding( case, 1 ):SmokeZone( SMOKECOLOR.White, 45 ) - self:_GetZoneHolding( case, 2 ):SmokeZone( SMOKECOLOR.White, 45 ) - self:_GetZoneInitial( case ):SmokeZone( SMOKECOLOR.Orange, 45 ) - self:_GetZoneCommence( case, 1 ):SmokeZone( SMOKECOLOR.Red, 45 ) - self:_GetZoneCommence( case, 2 ):SmokeZone( SMOKECOLOR.Red, 45 ) - self:_GetZoneAbeamLandingSpot():SmokeZone( SMOKECOLOR.Red, 5 ) - self:_GetZoneLandingSpot():SmokeZone( SMOKECOLOR.Red, 5 ) + local case=3 + self.holdingoffset=30 + self:_GetZoneGroove():SmokeZone(SMOKECOLOR.Red,5) + self:_GetZoneLineup():SmokeZone(SMOKECOLOR.Green,5) + self:_GetZoneBullseye(case):SmokeZone(SMOKECOLOR.White,45) + self:_GetZoneDirtyUp(case):SmokeZone(SMOKECOLOR.Orange,45) + self:_GetZoneArcIn(case):SmokeZone(SMOKECOLOR.Blue,45) + self:_GetZoneArcOut(case):SmokeZone(SMOKECOLOR.Blue,45) + self:_GetZonePlatform(case):SmokeZone(SMOKECOLOR.Blue,45) + self:_GetZoneCorridor(case):SmokeZone(SMOKECOLOR.Green,45) + self:_GetZoneHolding(case,1):SmokeZone(SMOKECOLOR.White,45) + self:_GetZoneHolding(case,2):SmokeZone(SMOKECOLOR.White,45) + self:_GetZoneInitial(case):SmokeZone(SMOKECOLOR.Orange,45) + self:_GetZoneCommence(case,1):SmokeZone(SMOKECOLOR.Red,45) + self:_GetZoneCommence(case,2):SmokeZone(SMOKECOLOR.Red,45) + self:_GetZoneAbeamLandingSpot():SmokeZone(SMOKECOLOR.Red,5) + self:_GetZoneLandingSpot():SmokeZone(SMOKECOLOR.Red,5) end - - -- Carrier parameter debug tests. if false then - -- Stern coordinate. - local FB = self:GetFinalBearing( false ) - local hdg = self:GetHeading( false ) - - -- Stern pos. - local stern = self:_GetSternCoord() - - -- Bow pos. - local bow = stern:Translate( self.carrierparam.totlength, hdg, true ) - - -- End of rwy. - local rwy = stern:Translate( self.carrierparam.rwylength, FB, true ) - - --- Flare points and zones. - local function flareme() - - -- Carrier pos. - self:GetCoordinate():FlareYellow() - - -- Stern - stern:FlareYellow() - - -- Bow - bow:FlareYellow() - - -- Runway half width = 10 m. - local r1 = stern:Translate( self.carrierparam.rwywidth * 0.5, FB + 90, true ) - local r2 = stern:Translate( self.carrierparam.rwywidth * 0.5, FB - 90, true ) - -- r1:FlareWhite() - -- r2:FlareWhite() - - -- End of runway. - rwy:FlareRed() - - -- Right 30 meters from stern. - local cR = stern:Translate( self.carrierparam.totwidthstarboard, hdg + 90, true ) - -- cR:FlareYellow() - - -- Left 40 meters from stern. - local cL = stern:Translate( self.carrierparam.totwidthport, hdg - 90, true ) - -- cL:FlareYellow() - - -- Carrier specific. - if self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.INVINCIBLE or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.HERMES or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.TARAWA or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.AMERICA or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.JCARLOS or self.carrier:GetTypeName() ~= AIRBOSS.CarrierType.CANBERRA then - - -- Flare wires. - local w1 = stern:Translate( self.carrierparam.wire1, FB, true ) - local w2 = stern:Translate( self.carrierparam.wire2, FB, true ) - local w3 = stern:Translate( self.carrierparam.wire3, FB, true ) - local w4 = stern:Translate( self.carrierparam.wire4, FB, true ) - w1:FlareWhite() - w2:FlareYellow() - w3:FlareWhite() - w4:FlareYellow() - - else - - -- Abeam landing spot zone. - local ALSPT = self:_GetZoneAbeamLandingSpot() - ALSPT:FlareZone( FLARECOLOR.Red, 5, nil, UTILS.FeetToMeters( 120 ) ) - - -- Primary landing spot zone. - local LSPT = self:_GetZoneLandingSpot() - LSPT:FlareZone( FLARECOLOR.Green, 5, nil, self.carrierparam.deckheight ) - - -- Landing spot coordinate. - local PLSC = self:_GetLandingSpotCoordinate() - PLSC:FlareWhite() - end - - -- Flare carrier and landing runway. - local cbox = self:_GetZoneCarrierBox() - local rbox = self:_GetZoneRunwayBox() - cbox:FlareZone( FLARECOLOR.Green, 5, nil, self.carrierparam.deckheight ) - rbox:FlareZone( FLARECOLOR.White, 5, nil, self.carrierparam.deckheight ) - end - - -- Flare points every 3 seconds for 3 minutes. - SCHEDULER:New( nil, flareme, {}, 1, 3, nil, 180 ) + local FB=self:GetFinalBearing(false) + local hdg=self:GetHeading(false) + local stern=self:_GetSternCoord() + local bow=stern:Translate(self.carrierparam.totlength,hdg,true) + local rwy=stern:Translate(self.carrierparam.rwylength,FB,true) + local function flareme() + self:GetCoordinate():FlareYellow() + stern:FlareYellow() + bow:FlareYellow() + local r1=stern:Translate(self.carrierparam.rwywidth*0.5,FB+90,true) + local r2=stern:Translate(self.carrierparam.rwywidth*0.5,FB-90,true) + rwy:FlareRed() + local cR=stern:Translate(self.carrierparam.totwidthstarboard,hdg+90,true) + local cL=stern:Translate(self.carrierparam.totwidthport,hdg-90,true) + if self.carrier:GetTypeName()~=AIRBOSS.CarrierType.INVINCIBLE or self.carrier:GetTypeName()~=AIRBOSS.CarrierType.HERMES or self.carrier:GetTypeName()~=AIRBOSS.CarrierType.TARAWA or self.carrier:GetTypeName()~=AIRBOSS.CarrierType.AMERICA or self.carrier:GetTypeName()~=AIRBOSS.CarrierType.JCARLOS or self.carrier:GetTypeName()~=AIRBOSS.CarrierType.CANBERRA then + local w1=stern:Translate(self.carrierparam.wire1,FB,true) + local w2=stern:Translate(self.carrierparam.wire2,FB,true) + local w3=stern:Translate(self.carrierparam.wire3,FB,true) + local w4=stern:Translate(self.carrierparam.wire4,FB,true) + w1:FlareWhite() + w2:FlareYellow() + w3:FlareWhite() + w4:FlareYellow() + else + local ALSPT=self:_GetZoneAbeamLandingSpot() + ALSPT:FlareZone(FLARECOLOR.Red,5,nil,UTILS.FeetToMeters(120)) + local LSPT=self:_GetZoneLandingSpot() + LSPT:FlareZone(FLARECOLOR.Green,5,nil,self.carrierparam.deckheight) + local PLSC=self:_GetLandingSpotCoordinate() + PLSC:FlareWhite() end - - ----------------------- - --- FSM Transitions --- - ----------------------- - - -- Start State. - self:SetStartState( "Stopped" ) - - -- Add FSM transitions. - -- From State --> Event --> To State - self:AddTransition("Stopped", "Load", "Stopped") -- Load player scores from file. - self:AddTransition("Stopped", "Start", "Idle") -- Start AIRBOSS script. - self:AddTransition("*", "Idle", "Idle") -- Carrier is idling. - self:AddTransition("Idle", "RecoveryStart", "Recovering") -- Start recovering aircraft. - self:AddTransition("Recovering", "RecoveryStop", "Idle") -- Stop recovering aircraft. - self:AddTransition("Recovering", "RecoveryPause", "Paused") -- Pause recovering aircraft. - self:AddTransition("Paused", "RecoveryUnpause", "Recovering") -- Unpause recovering aircraft. - self:AddTransition("*", "Status", "*") -- Update status of players and queues. - self:AddTransition("*", "RecoveryCase", "*") -- Switch to another case recovery. - self:AddTransition("*", "PassingWaypoint", "*") -- Carrier is passing a waypoint. - self:AddTransition("*", "LSOGrade", "*") -- LSO grade. - self:AddTransition("*", "Marshal", "*") -- A flight was send into the marshal stack. - self:AddTransition("*", "Save", "*") -- Save player scores to file. - self:AddTransition("*", "Stop", "Stopped") -- Stop AIRBOSS FMS. - - - --- Triggers the FSM event "Start" that starts the airboss. Initializes parameters and starts event handlers. - -- @function [parent=#AIRBOSS] Start - -- @param #AIRBOSS self - - --- Triggers the FSM event "Start" that starts the airboss after a delay. Initializes parameters and starts event handlers. - -- @function [parent=#AIRBOSS] __Start - -- @param #AIRBOSS self - -- @param #number delay Delay in seconds. - - --- On after "Start" user function. Called when the AIRBOSS FSM is started. - -- @function [parent=#AIRBOSS] OnAfterStart - -- @param #AIRBOSS self - -- @param #string From From state. - -- @param #string Event Event. - -- @param #string To To state. - - --- Triggers the FSM event "Idle" that puts the carrier into state "Idle" where no recoveries are carried out. - -- @function [parent=#AIRBOSS] Idle - -- @param #AIRBOSS self - - --- Triggers the FSM delayed event "Idle" that puts the carrier into state "Idle" where no recoveries are carried out. - -- @function [parent=#AIRBOSS] __Idle - -- @param #AIRBOSS self - -- @param #number delay Delay in seconds. - - --- Triggers the FSM event "RecoveryStart" that starts the recovery of aircraft. Marshalling aircraft are send to the landing pattern. - -- @function [parent=#AIRBOSS] RecoveryStart - -- @param #AIRBOSS self - -- @param #number Case Recovery case (1, 2 or 3) that is started. - -- @param #number Offset Holding pattern offset angle in degrees for CASE II/III recoveries. - - --- Triggers the FSM delayed event "RecoveryStart" that starts the recovery of aircraft. Marshalling aircraft are send to the landing pattern. - -- @function [parent=#AIRBOSS] __RecoveryStart - -- @param #AIRBOSS self - -- @param #number delay Delay in seconds. - -- @param #number Case Recovery case (1, 2 or 3) that is started. - -- @param #number Offset Holding pattern offset angle in degrees for CASE II/III recoveries. - - --- On after "RecoveryStart" user function. Called when recovery of aircraft is started and carrier switches to state "Recovering". - -- @function [parent=#AIRBOSS] OnAfterRecoveryStart - -- @param #AIRBOSS self - -- @param #string From From state. - -- @param #string Event Event. - -- @param #string To To state. - -- @param #number Case The recovery case (1, 2 or 3) to start. - -- @param #number Offset Holding pattern offset angle in degrees for CASE II/III recoveries. - - --- Triggers the FSM event "RecoveryStop" that stops the recovery of aircraft. - -- @function [parent=#AIRBOSS] RecoveryStop - -- @param #AIRBOSS self - - --- Triggers the FSM delayed event "RecoveryStop" that stops the recovery of aircraft. - -- @function [parent=#AIRBOSS] __RecoveryStop - -- @param #AIRBOSS self - -- @param #number delay Delay in seconds. - - --- On after "RecoveryStop" user function. Called when recovery of aircraft is stopped. - -- @function [parent=#AIRBOSS] OnAfterRecoveryStop - -- @param #AIRBOSS self - -- @param #string From From state. - -- @param #string Event Event. - -- @param #string To To state. - - --- Triggers the FSM event "RecoveryPause" that pauses the recovery of aircraft. - -- @function [parent=#AIRBOSS] RecoveryPause - -- @param #AIRBOSS self - -- @param #number duration Duration of pause in seconds. After that recovery is automatically resumed. - - --- Triggers the FSM delayed event "RecoveryPause" that pauses the recovery of aircraft. - -- @function [parent=#AIRBOSS] __RecoveryPause - -- @param #AIRBOSS self - -- @param #number delay Delay in seconds. - -- @param #number duration Duration of pause in seconds. After that recovery is automatically resumed. - - --- Triggers the FSM event "RecoveryUnpause" that resumes the recovery of aircraft if it was paused. - -- @function [parent=#AIRBOSS] RecoveryUnpause - -- @param #AIRBOSS self - - --- Triggers the FSM delayed event "RecoveryUnpause" that resumes the recovery of aircraft if it was paused. - -- @function [parent=#AIRBOSS] __RecoveryUnpause - -- @param #AIRBOSS self - -- @param #number delay Delay in seconds. - - --- Triggers the FSM event "RecoveryCase" that switches the aircraft recovery case. - -- @function [parent=#AIRBOSS] RecoveryCase - -- @param #AIRBOSS self - -- @param #number Case The new recovery case (1, 2 or 3). - -- @param #number Offset Holding pattern offset angle in degrees for CASE II/III recoveries. - - --- Triggers the delayed FSM event "RecoveryCase" that sets the used aircraft recovery case. - -- @function [parent=#AIRBOSS] __RecoveryCase - -- @param #AIRBOSS self - -- @param #number delay Delay in seconds. - -- @param #number Case The new recovery case (1, 2 or 3). - -- @param #number Offset Holding pattern offset angle in degrees for CASE II/III recoveries. - - --- Triggers the FSM event "PassingWaypoint". Called when the carrier passes a waypoint. - -- @function [parent=#AIRBOSS] PassingWaypoint - -- @param #AIRBOSS self - -- @param #number waypoint Number of waypoint. - - --- Triggers the FSM delayed event "PassingWaypoint". Called when the carrier passes a waypoint. - -- @function [parent=#AIRBOSS] __PassingWaypoint - -- @param #AIRBOSS self - -- @param #number delay Delay in seconds. - -- @param #number Case Recovery case (1, 2 or 3) that is started. - -- @param #number Offset Holding pattern offset angle in degrees for CASE II/III recoveries. - - --- On after "PassingWaypoint" user function. Called when the carrier passes a waypoint of its route. - -- @function [parent=#AIRBOSS] OnAfterPassingWaypoint - -- @param #AIRBOSS self - -- @param #string From From state. - -- @param #string Event Event. - -- @param #string To To state. - -- @param #number waypoint Number of waypoint. - - --- Triggers the FSM event "Save" that saved the player scores to a file. - -- @function [parent=#AIRBOSS] Save - -- @param #AIRBOSS self - -- @param #string path Path where the file is saved. Default is the DCS installation root directory or your "Saved Games\DCS" folder if lfs was desanitized. - -- @param #string filename (Optional) File name. Default is AIRBOSS-*ALIAS*_LSOgrades.csv. - - --- Triggers the FSM delayed event "Save" that saved the player scores to a file. - -- @function [parent=#AIRBOSS] __Save - -- @param #AIRBOSS self - -- @param #number delay Delay in seconds. - -- @param #string path Path where the file is saved. Default is the DCS installation root directory or your "Saved Games\DCS" folder if lfs was desanitized. - -- @param #string filename (Optional) File name. Default is AIRBOSS-*ALIAS*_LSOgrades.csv. - - --- On after "Save" event user function. Called when the player scores are saved to disk. - -- @function [parent=#AIRBOSS] OnAfterSave - -- @param #AIRBOSS self - -- @param #string From From state. - -- @param #string Event Event. - -- @param #string To To state. - -- @param #string path Path where the file is saved. Default is the DCS installation root directory or your "Saved Games\DCS" folder if lfs was desanitized. - -- @param #string filename (Optional) File name. Default is AIRBOSS-*ALIAS*_LSOgrades.csv. - - --- Triggers the FSM event "Load" that loads the player scores from a file. AIRBOSS FSM must **not** be started at this point. - -- @function [parent=#AIRBOSS] Load - -- @param #AIRBOSS self - -- @param #string path Path where the file is located. Default is the DCS installation root directory. - -- @param #string filename (Optional) File name. Default is AIRBOSS-_LSOgrades.csv. - - --- Triggers the FSM delayed event "Load" that loads the player scores from a file. AIRBOSS FSM must **not** be started at this point. - -- @function [parent=#AIRBOSS] __Load - -- @param #AIRBOSS self - -- @param #number delay Delay in seconds. - -- @param #string path Path where the file is located. Default is the DCS installation root directory or your "Saved Games\DCS" folder if lfs was desanitized. - -- @param #string filename (Optional) File name. Default is AIRBOSS-*ALIAS*_LSOgrades.csv. - - --- On after "Load" event user function. Called when the player scores are loaded from disk. - -- @function [parent=#AIRBOSS] OnAfterLoad - -- @param #AIRBOSS self - -- @param #string From From state. - -- @param #string Event Event. - -- @param #string To To state. - -- @param #string path Path where the file is located. Default is the DCS installation root directory or your "Saved Games\DCS" folder if lfs was desanitized. - -- @param #string filename (Optional) File name. Default is AIRBOSS-*ALIAS*_LSOgrades.csv. - - --- Triggers the FSM event "LSOGrade". Called when the LSO grades a player - -- @function [parent=#AIRBOSS] LSOGrade - -- @param #AIRBOSS self - -- @param #AIRBOSS.PlayerData playerData Player Data. - -- @param #AIRBOSS.LSOgrade grade LSO grade. - - --- Triggers the FSM event "LSOGrade". Delayed called when the LSO grades a player. - -- @function [parent=#AIRBOSS] __LSOGrade - -- @param #AIRBOSS self - -- @param #number delay Delay in seconds. - -- @param #AIRBOSS.PlayerData playerData Player Data. - -- @param #AIRBOSS.LSOgrade grade LSO grade. - - --- On after "LSOGrade" user function. Called when the carrier passes a waypoint of its route. - -- @function [parent=#AIRBOSS] OnAfterLSOGrade - -- @param #AIRBOSS self - -- @param #string From From state. - -- @param #string Event Event. - -- @param #string To To state. - -- @param #AIRBOSS.PlayerData playerData Player Data. - -- @param #AIRBOSS.LSOgrade grade LSO grade. - - --- Triggers the FSM event "Marshal". Called when a flight is send to the Marshal stack. - -- @function [parent=#AIRBOSS] Marshal - -- @param #AIRBOSS self - -- @param #AIRBOSS.FlightGroup flight The flight group data. - - --- Triggers the FSM event "Marshal". Delayed call when a flight is send to the Marshal stack. - -- @function [parent=#AIRBOSS] __Marshal - -- @param #AIRBOSS self - -- @param #number delay Delay in seconds. - -- @param #AIRBOSS.FlightGroup flight The flight group data. - - --- On after "Marshal" user function. Called when a flight is send to the Marshal stack. - -- @function [parent=#AIRBOSS] OnAfterMarshal - -- @param #AIRBOSS self - -- @param #string From From state. - -- @param #string Event Event. - -- @param #string To To state. - -- @param #AIRBOSS.FlightGroup flight The flight group data. - - --- Triggers the FSM event "Stop" that stops the airboss. Event handlers are stopped. - -- @function [parent=#AIRBOSS] Stop - -- @param #AIRBOSS self - - --- Triggers the FSM event "Stop" that stops the airboss after a delay. Event handlers are stopped. - -- @function [parent=#AIRBOSS] __Stop - -- @param #AIRBOSS self - -- @param #number delay Delay in seconds. - + local cbox=self:_GetZoneCarrierBox() + local rbox=self:_GetZoneRunwayBox() + cbox:FlareZone(FLARECOLOR.Green,5,nil,self.carrierparam.deckheight) + rbox:FlareZone(FLARECOLOR.White,5,nil,self.carrierparam.deckheight) + end + SCHEDULER:New(nil,flareme,{},1,3,nil,180) + end + self:SetStartState("Stopped") + self:AddTransition("Stopped","Load","Stopped") + self:AddTransition("Stopped","Start","Idle") + self:AddTransition("*","Idle","Idle") + self:AddTransition("Idle","RecoveryStart","Recovering") + self:AddTransition("Recovering","RecoveryStop","Idle") + self:AddTransition("Recovering","RecoveryPause","Paused") + self:AddTransition("Paused","RecoveryUnpause","Recovering") + self:AddTransition("*","Status","*") + self:AddTransition("*","RecoveryCase","*") + self:AddTransition("*","PassingWaypoint","*") + self:AddTransition("*","LSOGrade","*") + self:AddTransition("*","Marshal","*") + self:AddTransition("*","Save","*") + self:AddTransition("*","Stop","Stopped") return self -end - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- USER API Functions -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ---- Set welcome messages for players. --- @param #AIRBOSS self --- @param #boolean Switch If true, display welcome message to player. --- @return #AIRBOSS self -function AIRBOSS:SetWelcomePlayers( Switch ) - - self.welcome = Switch - + end + function AIRBOSS:SetWelcomePlayers(Switch) + self.welcome=Switch return self -end - ---- Set carrier controlled area (CCA). --- This is a large zone around the carrier, which is constantly updated wrt the carrier position. --- @param #AIRBOSS self --- @param #number Radius Radius of zone in nautical miles (NM). Default 50 NM. --- @return #AIRBOSS self -function AIRBOSS:SetCarrierControlledArea( Radius ) - - Radius = UTILS.NMToMeters( Radius or 50 ) - - self.zoneCCA = ZONE_UNIT:New( "Carrier Controlled Area", self.carrier, Radius ) - -- self.zoneCCA = ZONE_UNIT:New( "航母管制空域", self.carrier, Radius ) - + end + function AIRBOSS:SetCarrierControlledArea(Radius) + Radius=UTILS.NMToMeters(Radius or 50) + self.zoneCCA=ZONE_UNIT:New("Carrier Controlled Area",self.carrier,Radius) return self -end - ---- Set carrier controlled zone (CCZ). --- This is a small zone (usually 5 NM radius) around the carrier, which is constantly updated wrt the carrier position. --- @param #AIRBOSS self --- @param #number Radius Radius of zone in nautical miles (NM). Default 5 NM. --- @return #AIRBOSS self -function AIRBOSS:SetCarrierControlledZone( Radius ) - - Radius = UTILS.NMToMeters( Radius or 5 ) - - self.zoneCCZ = ZONE_UNIT:New( "Carrier Controlled Zone", self.carrier, Radius ) - -- self.zoneCCZ = ZONE_UNIT:New( "航母管制空域", self.carrier, Radius ) - + end + function AIRBOSS:SetCarrierControlledZone(Radius) + Radius=UTILS.NMToMeters(Radius or 5) + self.zoneCCZ=ZONE_UNIT:New("Carrier Controlled Zone",self.carrier,Radius) return self -end - ---- Set distance up to which water ahead is scanned for collisions. --- @param #AIRBOSS self --- @param #number Distance Distance in NM. Default 5 NM. --- @return #AIRBOSS self -function AIRBOSS:SetCollisionDistance( Distance ) - self.collisiondist = UTILS.NMToMeters( Distance or 5 ) + end + function AIRBOSS:SetCollisionDistance(Distance) + self.collisiondist=UTILS.NMToMeters(Distance or 5) return self -end - ---- Set the default recovery case. --- @param #AIRBOSS self --- @param #number Case Case of recovery. Either 1, 2 or 3. Default 1. --- @return #AIRBOSS self -function AIRBOSS:SetRecoveryCase( Case ) - - -- Set default case or 1. - self.defaultcase = Case or 1 - - -- Current case init. - self.case = self.defaultcase - + end + function AIRBOSS:SetRecoveryCase(Case) + self.defaultcase=Case or 1 + self.case=self.defaultcase return self -end - ---- Set holding pattern offset from final bearing for Case II/III recoveries. --- Usually, this is +-15 or +-30 degrees. You should not use and offset angle >= 90 degrees, because this will cause a devision by zero in some of the equations used to calculate the approach corridor. --- So best stick to the defaults up to 30 degrees. --- @param #AIRBOSS self --- @param #number Offset Offset angle in degrees. Default 0. --- @return #AIRBOSS self -function AIRBOSS:SetHoldingOffsetAngle( Offset ) - - -- Set default angle or 0. - self.defaultoffset = Offset or 0 - - -- Current offset init. - self.holdingoffset = self.defaultoffset - + end + function AIRBOSS:SetHoldingOffsetAngle(Offset) + self.defaultoffset=Offset or 0 + self.holdingoffset=self.defaultoffset return self -end - ---- Enable F10 menu to manually start recoveries. --- @param #AIRBOSS self --- @param #number Duration Default duration of the recovery in minutes. Default 30 min. --- @param #number WindOnDeck Default wind on deck in knots. Default 25 knots. --- @param #boolean Uturn U-turn after recovery window closes on=true or off=false/nil. Default off. --- @param #number Offset Relative Marshal radial in degrees for Case II/III recoveries. Default 30°. --- @return #AIRBOSS self -function AIRBOSS:SetMenuRecovery( Duration, WindOnDeck, Uturn, Offset ) - - self.skipperMenu = true - self.skipperTime = Duration or 30 - self.skipperSpeed = WindOnDeck or 25 - self.skipperOffset = Offset or 30 - + end + function AIRBOSS:SetMenuRecovery(Duration,WindOnDeck,Uturn,Offset) + self.skipperMenu=true + self.skipperTime=Duration or 30 + self.skipperSpeed=WindOnDeck or 25 + self.skipperOffset=Offset or 30 if Uturn then - self.skipperUturn = true + self.skipperUturn=true else - self.skipperUturn = false + self.skipperUturn=false end - return self -end - ---- Add aircraft recovery time window and recovery case. --- @param #AIRBOSS self --- @param #string starttime Start time, e.g. "8:00" for eight o'clock. Default now. --- @param #string stoptime Stop time, e.g. "9:00" for nine o'clock. Default 90 minutes after start time. --- @param #number case Recovery case for that time slot. Number between one and three. --- @param #number holdingoffset Only for CASE II/III: Angle in degrees the holding pattern is offset. --- @param #boolean turnintowind If true, carrier will turn into the wind 5 minutes before the recovery window opens. --- @param #number speed Speed in knots during turn into wind leg. --- @param #boolean uturn If true (or nil), carrier wil perform a U-turn and go back to where it came from before resuming its route to the next waypoint. If false, it will go directly to the next waypoint. --- @return #AIRBOSS.Recovery Recovery window. -function AIRBOSS:AddRecoveryWindow( starttime, stoptime, case, holdingoffset, turnintowind, speed, uturn ) - - -- Absolute mission time in seconds. - local Tnow = timer.getAbsTime() - - if starttime and type( starttime ) == "number" then - starttime = UTILS.SecondsToClock( Tnow + starttime ) end - - if stoptime and type( stoptime ) == "number" then - stoptime = UTILS.SecondsToClock( Tnow + stoptime ) + function AIRBOSS:AddRecoveryWindow(starttime,stoptime,case,holdingoffset,turnintowind,speed,uturn) + local Tnow=timer.getAbsTime() + if starttime and type(starttime)=="number"then + starttime=UTILS.SecondsToClock(Tnow+starttime) end - - -- Input or now. - starttime = starttime or UTILS.SecondsToClock( Tnow ) - - -- Set start time. - local Tstart = UTILS.ClockToSeconds( starttime ) - - -- Set stop time. - local Tstop = stoptime and UTILS.ClockToSeconds( stoptime ) or Tstart + 90 * 60 - - -- Consistancy check for timing. - if Tstart > Tstop then - self:E( string.format( "ERROR: Recovery stop time %s lies before recovery start time %s! Recovery window rejected.", UTILS.SecondsToClock( Tstart ), UTILS.SecondsToClock( Tstop ) ) ) - return self + if stoptime and type(stoptime)=="number"then + stoptime=UTILS.SecondsToClock(Tnow+stoptime) end - if Tstop <= Tnow then - string.format( "WARNING: Recovery stop time %s already over. Tnow=%s! Recovery window rejected.", UTILS.SecondsToClock( Tstop ), UTILS.SecondsToClock( Tnow ) ) - return self + starttime=starttime or UTILS.SecondsToClock(Tnow) + local Tstart=UTILS.ClockToSeconds(starttime) + local Tstop=stoptime and UTILS.ClockToSeconds(stoptime)or Tstart+90*60 + if Tstart>Tstop then + self:E(string.format("ERROR: Recovery stop time %s lies before recovery start time %s! Recovery window rejected.",UTILS.SecondsToClock(Tstart),UTILS.SecondsToClock(Tstop))) + return self end - - -- Case or default value. - case = case or self.defaultcase - - -- Holding offset or default value. - holdingoffset = holdingoffset or self.defaultoffset - - -- Offset zero for case I. - if case == 1 then - holdingoffset = 0 + if Tstop<=Tnow then + string.format("WARNING: Recovery stop time %s already over. Tnow=%s! Recovery window rejected.",UTILS.SecondsToClock(Tstop),UTILS.SecondsToClock(Tnow)) + return self end - - -- Increase counter. - self.windowcount = self.windowcount + 1 - - -- Recovery window. - local recovery = {} -- #AIRBOSS.Recovery - recovery.START = Tstart - recovery.STOP = Tstop - recovery.CASE = case - recovery.OFFSET = holdingoffset - recovery.OPEN = false - recovery.OVER = false - recovery.WIND = turnintowind - recovery.SPEED = speed or 20 - recovery.ID = self.windowcount - - if uturn == nil or uturn == true then - recovery.UTURN = true + case=case or self.defaultcase + holdingoffset=holdingoffset or self.defaultoffset + if case==1 then + holdingoffset=0 + end + self.windowcount=self.windowcount+1 + local recovery={} + recovery.START=Tstart + recovery.STOP=Tstop + recovery.CASE=case + recovery.OFFSET=holdingoffset + recovery.OPEN=false + recovery.OVER=false + recovery.WIND=turnintowind + recovery.SPEED=speed or 20 + recovery.ID=self.windowcount + if uturn==nil or uturn==true then + recovery.UTURN=true else - recovery.UTURN = false + recovery.UTURN=false end - - -- Add to table - table.insert( self.recoverytimes, recovery ) - + table.insert(self.recoverytimes,recovery) return recovery -end - ---- Define a set of AI groups that are handled by the airboss. --- @param #AIRBOSS self --- @param Core.Set#SET_GROUP SetGroup The set of AI groups which are handled by the airboss. --- @return #AIRBOSS self -function AIRBOSS:SetSquadronAI( SetGroup ) - self.squadsetAI = SetGroup + end + function AIRBOSS:SetSquadronAI(SetGroup) + self.squadsetAI=SetGroup return self -end - ---- Define a set of AI groups that excluded from AI handling. Members of this set will be left allone by the airboss and not forced into the Marshal pattern. --- @param #AIRBOSS self --- @param Core.Set#SET_GROUP SetGroup The set of AI groups which are excluded. --- @return #AIRBOSS self -function AIRBOSS:SetExcludeAI( SetGroup ) - self.excludesetAI = SetGroup + end + function AIRBOSS:SetExcludeAI(SetGroup) + self.excludesetAI=SetGroup return self -end - ---- Add a group to the exclude set. If no set exists, it is created. --- @param #AIRBOSS self --- @param Wrapper.Group#GROUP Group The group to be excluded. --- @return #AIRBOSS self -function AIRBOSS:AddExcludeAI( Group ) - - self.excludesetAI = self.excludesetAI or SET_GROUP:New() - - self.excludesetAI:AddGroup( Group ) - + end + function AIRBOSS:AddExcludeAI(Group) + self.excludesetAI=self.excludesetAI or SET_GROUP:New() + self.excludesetAI:AddGroup(Group) return self -end - ---- Close currently running recovery window and stop recovery ops. Recovery window is deleted. --- @param #AIRBOSS self --- @param #number Delay (Optional) Delay in seconds before the window is deleted. -function AIRBOSS:CloseCurrentRecoveryWindow( Delay ) - - if Delay and Delay > 0 then - -- SCHEDULER:New(nil, self.CloseCurrentRecoveryWindow, {self}, delay) - self:ScheduleOnce( Delay, self.CloseCurrentRecoveryWindow, self ) + end + function AIRBOSS:CloseCurrentRecoveryWindow(Delay) + if Delay and Delay>0 then + self:ScheduleOnce(Delay,self.CloseCurrentRecoveryWindow,self) else - if self:IsRecovering() and self.recoverywindow and self.recoverywindow.OPEN then - self:RecoveryStop() - self.recoverywindow.OPEN = false - self.recoverywindow.OVER = true - self:DeleteRecoveryWindow( self.recoverywindow ) - end + if self:IsRecovering()and self.recoverywindow and self.recoverywindow.OPEN then + self:RecoveryStop() + self.recoverywindow.OPEN=false + self.recoverywindow.OVER=true + self:DeleteRecoveryWindow(self.recoverywindow) end -end - ---- Delete all recovery windows. --- @param #AIRBOSS self --- @param #number Delay (Optional) Delay in seconds before the windows are deleted. --- @return #AIRBOSS self -function AIRBOSS:DeleteAllRecoveryWindows( Delay ) - - -- Loop over all recovery windows. - for _, recovery in pairs( self.recoverytimes ) do - self:I( self.lid .. string.format( "Deleting recovery window ID %s", tostring( recovery.ID ) ) ) - self:DeleteRecoveryWindow( recovery, Delay ) end - + end + function AIRBOSS:DeleteAllRecoveryWindows(Delay) + for _,recovery in pairs(self.recoverytimes)do + self:I(self.lid..string.format("Deleting recovery window ID %s",tostring(recovery.ID))) + self:DeleteRecoveryWindow(recovery,Delay) + end return self -end - ---- Return the recovery window of the given ID. --- @param #AIRBOSS self --- @param #number id The ID of the recovery window. --- @return #AIRBOSS.Recovery Recovery window with the right ID or nil if no such window exists. -function AIRBOSS:GetRecoveryWindowByID( id ) + end + function AIRBOSS:GetRecoveryWindowByID(id) if id then - for _, _window in pairs( self.recoverytimes ) do - local window = _window -- #AIRBOSS.Recovery - if window and window.ID == id then - return window - end - end + for _,_window in pairs(self.recoverytimes)do + local window=_window + if window and window.ID==id then + return window + end + end end return nil -end - ---- Delete a recovery window. If the window is currently open, it is closed and the recovery stopped. --- @param #AIRBOSS self --- @param #AIRBOSS.Recovery Window Recovery window. --- @param #number Delay Delay in seconds, before the window is deleted. -function AIRBOSS:DeleteRecoveryWindow( Window, Delay ) - - if Delay and Delay > 0 then - -- Delayed call. - -- SCHEDULER:New(nil, self.DeleteRecoveryWindow, {self, window}, delay) - self:ScheduleOnce( Delay, self.DeleteRecoveryWindow, self, Window ) - else - - for i, _recovery in pairs( self.recoverytimes ) do - local recovery = _recovery -- #AIRBOSS.Recovery - - if Window and Window.ID == recovery.ID then - if Window.OPEN then - -- Window is currently open. - self:RecoveryStop() - else - table.remove( self.recoverytimes, i ) - end - - end - end end -end - ---- Set time before carrier turns and recovery window opens. --- @param #AIRBOSS self --- @param #number Interval Time interval in seconds. Default 300 sec. --- @return #AIRBOSS self -function AIRBOSS:SetRecoveryTurnTime( Interval ) - self.dTturn = Interval or 300 - return self -end - ---- Set multiplayer environment wire correction. --- @param #AIRBOSS self --- @param #number Dcorr Correction distance in meters. Default 12 m. --- @return #AIRBOSS self -function AIRBOSS:SetMPWireCorrection( Dcorr ) - self.mpWireCorrection = Dcorr or 12 - return self -end - ---- Set time interval for updating queues and other stuff. --- @param #AIRBOSS self --- @param #number TimeInterval Time interval in seconds. Default 30 sec. --- @return #AIRBOSS self -function AIRBOSS:SetQueueUpdateTime( TimeInterval ) - self.dTqueue = TimeInterval or 30 - return self -end - ---- Set time interval between LSO calls. Optimal time in the groove is ~16 seconds. So the default of 4 seconds gives around 3-4 correction calls in the groove. --- @param #AIRBOSS self --- @param #number TimeInterval Time interval in seconds between LSO calls. Default 4 sec. --- @return #AIRBOSS self -function AIRBOSS:SetLSOCallInterval( TimeInterval ) - self.LSOdT = TimeInterval or 4 - return self -end - ---- Airboss is a rather nice guy and not strictly following the rules. Fore example, he does allow you into the landing pattern if you are not coming from the Marshal stack. --- @param #AIRBOSS self --- @param #boolean Switch If true or nil, Airboss bends the rules a bit. --- @return #AIRBOSS self -function AIRBOSS:SetAirbossNiceGuy( Switch ) - if Switch == true or Switch == nil then - self.airbossnice = true + function AIRBOSS:DeleteRecoveryWindow(Window,Delay) + if Delay and Delay>0 then + self:ScheduleOnce(Delay,self.DeleteRecoveryWindow,self,Window) else - self.airbossnice = false + for i,_recovery in pairs(self.recoverytimes)do + local recovery=_recovery + if Window and Window.ID==recovery.ID then + if Window.OPEN then + self:RecoveryStop() + else + table.remove(self.recoverytimes,i) + end + end + end + end + end + function AIRBOSS:SetRecoveryTurnTime(Interval) + self.dTturn=Interval or 300 + return self + end + function AIRBOSS:SetMPWireCorrection(Dcorr) + self.mpWireCorrection=Dcorr or 12 + return self + end + function AIRBOSS:SetQueueUpdateTime(TimeInterval) + self.dTqueue=TimeInterval or 30 + return self + end + function AIRBOSS:SetLSOCallInterval(TimeInterval) + self.LSOdT=TimeInterval or 4 + return self + end + function AIRBOSS:SetIntoWindLegacy(SwitchOn) + if SwitchOn==nil then + SwitchOn=true + end + self.intowindold=SwitchOn + return self + end + function AIRBOSS:SetAirbossNiceGuy(Switch) + if Switch==true or Switch==nil then + self.airbossnice=true + else + self.airbossnice=false end return self -end - ---- Allow emergency landings, i.e. bypassing any pattern and go directly to final approach. --- @param #AIRBOSS self --- @param #boolean Switch If true or nil, emergency landings are okay. --- @return #AIRBOSS self -function AIRBOSS:SetEmergencyLandings( Switch ) - if Switch == true or Switch == nil then - self.emergency = true + end + function AIRBOSS:SetEmergencyLandings(Switch) + if Switch==true or Switch==nil then + self.emergency=true else - self.emergency = false + self.emergency=false end return self -end - ---- Despawn AI groups after they they shut down their engines. --- @param #AIRBOSS self --- @param #boolean Switch If true or nil, AI groups are despawned. --- @return #AIRBOSS self -function AIRBOSS:SetDespawnOnEngineShutdown( Switch ) - if Switch == true or Switch == nil then - self.despawnshutdown = true + end + function AIRBOSS:SetDespawnOnEngineShutdown(Switch) + if Switch==true or Switch==nil then + self.despawnshutdown=true else - self.despawnshutdown = false + self.despawnshutdown=false end return self -end - ---- Respawn AI groups once they reach the CCA. Clears any attached airbases and allows making them land on the carrier via script. --- @param #AIRBOSS self --- @param #boolean Switch If true or nil, AI groups are respawned. --- @return #AIRBOSS self -function AIRBOSS:SetRespawnAI( Switch ) - if Switch == true or Switch == nil then - self.respawnAI = true + end + function AIRBOSS:SetRespawnAI(Switch) + if Switch==true or Switch==nil then + self.respawnAI=true else - self.respawnAI = false + self.respawnAI=false end return self -end - ---- Give AI aircraft the refueling task if a recovery tanker is present or send them to the nearest divert airfield. --- @param #AIRBOSS self --- @param #number LowFuelThreshold Low fuel threshold in percent. AI will go refueling if their fuel level drops below this value. Default 10 %. --- @return #AIRBOSS self -function AIRBOSS:SetRefuelAI( LowFuelThreshold ) - self.lowfuelAI = LowFuelThreshold or 10 + end + function AIRBOSS:SetRefuelAI(LowFuelThreshold) + self.lowfuelAI=LowFuelThreshold or 10 return self -end - ---- Set max altitude to register flights in the initial zone. Aircraft above this altitude will not be registerered. --- @param #AIRBOSS self --- @param #number MaxAltitude Max altitude in feet. Default 1300 ft. --- @return #AIRBOSS self -function AIRBOSS:SetInitialMaxAlt( MaxAltitude ) - self.initialmaxalt = UTILS.FeetToMeters( MaxAltitude or 1300 ) + end + function AIRBOSS:SetInitialMaxAlt(MaxAltitude) + self.initialmaxalt=UTILS.FeetToMeters(MaxAltitude or 1300) return self -end - ---- Set folder path where the airboss sound files are located **within you mission (miz) file**. --- The default path is "l10n/DEFAULT/" but sound files simply copied there will be removed by DCS the next time you save the mission. --- However, if you create a new folder inside the miz file, which contains the sounds, it will not be deleted and can be used. --- @param #AIRBOSS self --- @param #string FolderPath The path to the sound files, e.g. "Airboss Soundfiles/". --- @return #AIRBOSS self -function AIRBOSS:SetSoundfilesFolder( FolderPath ) - - -- Check that it ends with / + end + function AIRBOSS:SetSoundfilesFolder(FolderPath) if FolderPath then - local lastchar = string.sub( FolderPath, -1 ) - if lastchar ~= "/" then - FolderPath = FolderPath .. "/" - end + local lastchar=string.sub(FolderPath,-1) + if lastchar~="/"then + FolderPath=FolderPath.."/" end - - -- Folderpath. - self.soundfolder = FolderPath - - -- Info message. - self:I( self.lid .. string.format( "Setting sound files folder to: %s", self.soundfolder ) ) - + end + self.soundfolder=FolderPath + self:I(self.lid..string.format("Setting sound files folder to: %s",self.soundfolder)) return self -end - ---- Set time interval for updating player status and other things. --- @param #AIRBOSS self --- @param #number TimeInterval Time interval in seconds. Default 0.5 sec. --- @return #AIRBOSS self -function AIRBOSS:SetStatusUpdateTime( TimeInterval ) - self.dTstatus = TimeInterval or 0.5 + end + function AIRBOSS:SetStatusUpdateTime(TimeInterval) + self.dTstatus=TimeInterval or 0.5 return self -end - ---- Set duration how long messages are displayed to players. --- @param #AIRBOSS self --- @param #number Duration Duration in seconds. Default 10 sec. --- @return #AIRBOSS self -function AIRBOSS:SetDefaultMessageDuration( Duration ) - self.Tmessage = Duration or 10 + end + function AIRBOSS:SetDefaultMessageDuration(Duration) + self.Tmessage=Duration or 10 return self -end - ---- Set glideslope error thresholds. --- @param #AIRBOSS self --- @param #number _max --- @param #number _min --- @param #number High --- @param #number HIGH --- @param #number Low --- @param #number LOW --- @return #AIRBOSS self - -function AIRBOSS:SetGlideslopeErrorThresholds(_max,_min, High, HIGH, Low, LOW) - - --Check if V/STOL Carrier - if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then - - -- allow a larger GSE for V/STOL operations --Pene Testing - self.gle._max=_max or 0.7 - self.gle.High=High or 1.4 - self.gle.HIGH=HIGH or 1.9 - self.gle._min=_min or -0.5 - self.gle.Low=Low or -1.2 - self.gle.LOW=LOW or -1.5 - -- CVN values + end + function AIRBOSS:SetGlideslopeErrorThresholds(_max,_min,High,HIGH,Low,LOW) + if self.carriertype==AIRBOSS.CarrierType.INVINCIBLE or self.carriertype==AIRBOSS.CarrierType.HERMES or self.carriertype==AIRBOSS.CarrierType.TARAWA or self.carriertype==AIRBOSS.CarrierType.AMERICA or self.carriertype==AIRBOSS.CarrierType.JCARLOS or self.carriertype==AIRBOSS.CarrierType.CANBERRA then + self.gle._max=_max or 0.7 + self.gle.High=High or 1.4 + self.gle.HIGH=HIGH or 1.9 + self.gle._min=_min or-0.5 + self.gle.Low=Low or-1.2 + self.gle.LOW=LOW or-1.5 else - self.gle._max=_max or 0.4 - self.gle.High=High or 0.8 - self.gle.HIGH=HIGH or 1.5 - self.gle._min=_min or -0.3 - self.gle.Low=Low or -0.6 - self.gle.LOW=LOW or -0.9 + self.gle._max=_max or 0.4 + self.gle.High=High or 0.8 + self.gle.HIGH=HIGH or 1.5 + self.gle._min=_min or-0.3 + self.gle.Low=Low or-0.6 + self.gle.LOW=LOW or-0.9 end - return self -end - ---- Set lineup error thresholds. --- @param #AIRBOSS self --- @param #number _max --- @param #number _min --- @param #number Left --- @param #number LeftMed --- @param #number LEFT --- @param #number Right --- @param #number RightMed --- @param #number RIGHT --- @return #AIRBOSS self - -function AIRBOSS:SetLineupErrorThresholds(_max,_min, Left, LeftMed, LEFT, Right, RightMed, RIGHT) - - --Check if V/STOL Carrier -- Pene testing - if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then - - -- V/STOL Values -- allow a larger LUE for V/STOL operations - self.lue._max=_max or 1.8 - self.lue._min=_min or -1.8 - self.lue.Left=Left or -2.8 - self.lue.LeftMed=LeftMed or -3.8 - self.lue.LEFT=LEFT or -4.5 - self.lue.Right=Right or 2.8 - self.lue.RightMed=RightMed or 3.8 - self.lue.RIGHT=RIGHT or 4.5 - -- CVN Values + end + function AIRBOSS:SetLineupErrorThresholds(_max,_min,Left,LeftMed,LEFT,Right,RightMed,RIGHT) + if self.carriertype==AIRBOSS.CarrierType.INVINCIBLE or self.carriertype==AIRBOSS.CarrierType.HERMES or self.carriertype==AIRBOSS.CarrierType.TARAWA or self.carriertype==AIRBOSS.CarrierType.AMERICA or self.carriertype==AIRBOSS.CarrierType.JCARLOS or self.carriertype==AIRBOSS.CarrierType.CANBERRA then + self.lue._max=_max or 1.8 + self.lue._min=_min or-1.8 + self.lue.Left=Left or-2.8 + self.lue.LeftMed=LeftMed or-3.8 + self.lue.LEFT=LEFT or-4.5 + self.lue.Right=Right or 2.8 + self.lue.RightMed=RightMed or 3.8 + self.lue.RIGHT=RIGHT or 4.5 else - self.lue._max=_max or 0.5 - self.lue._min=_min or -0.5 - self.lue.Left=Left or -1.0 - self.lue.LeftMed=LeftMed or -2.0 - self.lue.LEFT=LEFT or -3.0 - self.lue.Right=Right or 1.0 - self.lue.RightMed=RightMed or 2.0 - self.lue.RIGHT=RIGHT or 3.0 + self.lue._max=_max or 0.5 + self.lue._min=_min or-0.5 + self.lue.Left=Left or-1.0 + self.lue.LeftMed=LeftMed or-2.0 + self.lue.LEFT=LEFT or-3.0 + self.lue.Right=Right or 1.0 + self.lue.RightMed=RightMed or 2.0 + self.lue.RIGHT=RIGHT or 3.0 end - return self -end - ---- Set Case I Marshal radius. This is the radius of the valid zone around "the post" aircraft are supposed to be holding in the Case I Marshal stack. --- The post is 2.5 NM port of the carrier. --- @param #AIRBOSS self --- @param #number Radius Radius in NM. Default 2.8 NM, which gives a diameter of 5.6 NM. --- @return #AIRBOSS self -function AIRBOSS:SetMarshalRadius( Radius ) - self.marshalradius = UTILS.NMToMeters( Radius or 2.8 ) + end + function AIRBOSS:SetMarshalRadius(Radius) + self.marshalradius=UTILS.NMToMeters(Radius or 2.8) return self -end - ---- Optimized F10 radio menu for a single carrier. The menu entries will be stored directly under F10 Other/Airboss/ and not F10 Other/Airboss/"Carrier Alias"/. --- **WARNING**: If you use this with two airboss objects/carriers, the radio menu will be screwed up! --- @param #AIRBOSS self --- @param #boolean Switch If true or nil single menu is enabled. If false, menu is for multiple carriers in the mission. --- @return #AIRBOSS self -function AIRBOSS:SetMenuSingleCarrier( Switch ) - if Switch == true or Switch == nil then - self.menusingle = true + end + function AIRBOSS:SetMenuSingleCarrier(Switch) + if Switch==true or Switch==nil then + self.menusingle=true else - self.menusingle = false + self.menusingle=false end return self -end - ---- Enable or disable F10 radio menu for marking zones via smoke or flares. --- @param #AIRBOSS self --- @param #boolean Switch If true or nil, menu is enabled. If false, menu is not available to players. --- @return #AIRBOSS self -function AIRBOSS:SetMenuMarkZones( Switch ) - if Switch == nil or Switch == true then - self.menumarkzones = true + end + function AIRBOSS:SetMenuMarkZones(Switch) + if Switch==nil or Switch==true then + self.menumarkzones=true else - self.menumarkzones = false + self.menumarkzones=false end return self -end - ---- Enable or disable F10 radio menu for marking zones via smoke. --- @param #AIRBOSS self --- @param #boolean Switch If true or nil, menu is enabled. If false, menu is not available to players. --- @return #AIRBOSS self -function AIRBOSS:SetMenuSmokeZones( Switch ) - if Switch == nil or Switch == true then - self.menusmokezones = true + end + function AIRBOSS:SetMenuSmokeZones(Switch) + if Switch==nil or Switch==true then + self.menusmokezones=true else - self.menusmokezones = false + self.menusmokezones=false end return self -end - ---- Enable saving of player's trap sheets and specify an optional directory path. --- @param #AIRBOSS self --- @param #string Path (Optional) Path where to save the trap sheets. --- @param #string Prefix (Optional) Prefix for trap sheet files. File name will be saved as *prefix_aircrafttype-0001.csv*, *prefix_aircrafttype-0002.csv*, etc. --- @return #AIRBOSS self -function AIRBOSS:SetTrapSheet( Path, Prefix ) + end + function AIRBOSS:SetTrapSheet(Path,Prefix) if io then - self.trapsheet = true - self.trappath = Path - self.trapprefix = Prefix + self.trapsheet=true + self.trappath=Path + self.trapprefix=Prefix else - self:E( self.lid .. "ERROR: io is not desanitized. Cannot save trap sheet." ) + self:E(self.lid.."ERROR: io is not desanitized. Cannot save trap sheet.") end return self -end - ---- Specify weather the mission has set static or dynamic weather. --- @param #AIRBOSS self --- @param #boolean Switch If true or nil, mission uses static weather. If false, dynamic weather is used in this mission. --- @return #AIRBOSS self -function AIRBOSS:SetStaticWeather( Switch ) - if Switch == nil or Switch == true then - self.staticweather = true + end + function AIRBOSS:SetStaticWeather(Switch) + if Switch==nil or Switch==true then + self.staticweather=true else - self.staticweather = false + self.staticweather=false end return self -end - ---- Disable automatic TACAN activation --- @param #AIRBOSS self --- @return #AIRBOSS self -function AIRBOSS:SetTACANoff() - self.TACANon = false + end + function AIRBOSS:SetTACANoff() + self.TACANon=false return self -end - ---- Set TACAN channel of carrier and switches TACAN on. --- @param #AIRBOSS self --- @param #number Channel (Optional) TACAN channel. Default 74. --- @param #string Mode (Optional) TACAN mode, i.e. "X" or "Y". Default "X". --- @param #string MorseCode (Optional) Morse code identifier. Three letters, e.g. "STN". Default "STN". --- @return #AIRBOSS self -function AIRBOSS:SetTACAN( Channel, Mode, MorseCode ) - - self.TACANchannel = Channel or 74 - self.TACANmode = Mode or "X" - self.TACANmorse = MorseCode or "STN" - self.TACANon = true - + end + function AIRBOSS:SetTACAN(Channel,Mode,MorseCode) + self.TACANchannel=Channel or 74 + self.TACANmode=Mode or"X" + self.TACANmorse=MorseCode or"STN" + self.TACANon=true return self -end - ---- Disable automatic ICLS activation. --- @param #AIRBOSS self --- @return #AIRBOSS self -function AIRBOSS:SetICLSoff() - self.ICLSon = false + end + function AIRBOSS:SetICLSoff() + self.ICLSon=false return self -end - ---- Set ICLS channel of carrier. --- @param #AIRBOSS self --- @param #number Channel (Optional) ICLS channel. Default 1. --- @param #string MorseCode (Optional) Morse code identifier. Three letters, e.g. "STN". Default "STN". --- @return #AIRBOSS self -function AIRBOSS:SetICLS( Channel, MorseCode ) - - self.ICLSchannel = Channel or 1 - self.ICLSmorse = MorseCode or "STN" - self.ICLSon = true - + end + function AIRBOSS:SetICLS(Channel,MorseCode) + self.ICLSchannel=Channel or 1 + self.ICLSmorse=MorseCode or"STN" + self.ICLSon=true return self -end - ---- Set beacon (TACAN/ICLS) time refresh interfal in case the beacons die. --- @param #AIRBOSS self --- @param #number TimeInterval (Optional) Time interval in seconds. Default 1200 sec = 20 min. --- @return #AIRBOSS self -function AIRBOSS:SetBeaconRefresh( TimeInterval ) - self.dTbeacon = TimeInterval or (20 * 60) + end + function AIRBOSS:SetBeaconRefresh(TimeInterval) + self.dTbeacon=TimeInterval or(20*60) return self -end - ---- Set up SRS for usage without sound files --- @param #AIRBOSS self --- @param #string PathToSRS Path to SRS folder, e.g. "C:\\Program Files\\DCS-SimpleRadio-Standalone". --- @param #number Port Port of the SRS server, defaults to 5002. --- @param #string Culture (Optional, Airboss Culture) Culture, defaults to "en-US". --- @param #string Gender (Optional, Airboss Gender) Gender, e.g. "male" or "female". Defaults to "male". --- @param #string Voice (Optional, Airboss Voice) Set to use a specific voice. Will **override gender and culture** settings. --- @param #string GoogleCreds (Optional) Path to Google credentials, e.g. "C:\\Program Files\\DCS-SimpleRadio-Standalone\\yourgooglekey.json". --- @param #number Volume (Optional) E.g. 0.75. Defaults to 1.0 (loudest). --- @param #table AltBackend (Optional) See MSRS for details. --- @return #AIRBOSS self -function AIRBOSS:EnableSRS(PathToSRS,Port,Culture,Gender,Voice,GoogleCreds,Volume,AltBackend) - -- SRS - local Frequency = self.AirbossRadio.frequency - local Modulation = self.AirbossRadio.modulation - self.SRS = MSRS:New(PathToSRS,Frequency,Modulation,AltBackend) + end + function AIRBOSS:EnableSRS(PathToSRS,Port,Culture,Gender,Voice,GoogleCreds,Volume,AltBackend) + local Frequency=self.AirbossRadio.frequency + local Modulation=self.AirbossRadio.modulation + self.SRS=MSRS:New(PathToSRS,Frequency,Modulation,AltBackend) self.SRS:SetCoalition(self:GetCoalition()) self.SRS:SetCoordinate(self:GetCoordinate()) - self.SRS:SetCulture(Culture or "en-US") - --self.SRS:SetFrequencies(Frequencies) - self.SRS:SetGender(Gender or "male") + self.SRS:SetCulture(Culture or"en-US") + self.SRS:SetGender(Gender or"male") self.SRS:SetPath(PathToSRS) self.SRS:SetPort(Port or 5002) - self.SRS:SetLabel(self.AirbossRadio.alias or "AIRBOSS") + self.SRS:SetLabel(self.AirbossRadio.alias or"AIRBOSS") self.SRS:SetCoordinate(self.carrier:GetCoordinate()) self.SRS:SetVolume(Volume or 1) - --self.SRS:SetModulations(Modulations) if GoogleCreds then - self.SRS:SetProviderOptionsGoogle(GoogleCreds,GoogleCreds) - self.SRS:SetProvider(MSRS.Provider.GOOGLE) + self.SRS:SetProviderOptionsGoogle(GoogleCreds,GoogleCreds) + self.SRS:SetProvider(MSRS.Provider.GOOGLE) end if Voice then - self.SRS:SetVoice(Voice) + self.SRS:SetVoice(Voice) end self.SRS:SetVolume(Volume or 1.0) - -- SRSQUEUE - self.SRSQ = MSRSQUEUE:New("AIRBOSS") + self.SRSQ=MSRSQUEUE:New("AIRBOSS") self.SRSQ:SetTransmitOnlyWithPlayers(true) - if not self.PilotRadio then - self:SetSRSPilotVoice() + if not self.PilotRadio then + self:SetSRSPilotVoice() end - return self -end - ---- Set LSO radio frequency and modulation. Default frequency is 264 MHz AM. --- @param #AIRBOSS self --- @param #number Frequency (Optional) Frequency in MHz. Default 264 MHz. --- @param #string Modulation (Optional) Modulation, "AM" or "FM". Default "AM". --- @param #string Voice (Optional) SRS specific voice --- @param #string Gender (Optional) SRS specific gender --- @param #string Culture (Optional) SRS specific culture --- @return #AIRBOSS self -function AIRBOSS:SetLSORadio( Frequency, Modulation, Voice, Gender, Culture ) - - self.LSOFreq = (Frequency or 264) - Modulation = Modulation or "AM" - - if Modulation == "FM" then - self.LSOModu = radio.modulation.FM + return self + end + function AIRBOSS:SetLSORadio(Frequency,Modulation,Voice,Gender,Culture) + self.LSOFreq=(Frequency or 264) + Modulation=Modulation or"AM" + if Modulation=="FM"then + self.LSOModu=radio.modulation.FM else - self.LSOModu = radio.modulation.AM + self.LSOModu=radio.modulation.AM end - - self.LSORadio = {} -- #AIRBOSS.Radio - self.LSORadio.frequency = self.LSOFreq - self.LSORadio.modulation = self.LSOModu - self.LSORadio.alias = "LSO" - self.LSORadio.voice = Voice - self.LSORadio.gender = Gender or "male" - self.LSORadio.culture = Culture or "en-US" - + self.LSORadio={} + self.LSORadio.frequency=self.LSOFreq + self.LSORadio.modulation=self.LSOModu + self.LSORadio.alias="LSO" + self.LSORadio.voice=Voice + self.LSORadio.gender=Gender or"male" + self.LSORadio.culture=Culture or"en-US" return self -end - ---- Set Airboss radio frequency and modulation. Default frequency is Tower frequency. --- @param #AIRBOSS self --- @param #number Frequency (Optional) Frequency in MHz. Default frequency is Tower frequency. --- @param #string Modulation (Optional) Modulation, "AM" or "FM". Default "AM". --- @param #string Voice (Optional) SRS specific voice --- @param #string Gender (Optional) SRS specific gender --- @param #string Culture (Optional) SRS specific culture --- @return #AIRBOSS self --- @usage --- -- Set single frequency --- myairboss:SetAirbossRadio(127.5,"AM",MSRS.Voices.Google.Standard.en_GB_Standard_F) --- --- -- Set multiple frequencies, note you **need** to pass one modulation per frequency given! --- myairboss:SetAirbossRadio({127.5,243},{radio.modulation.AM,radio.modulation.AM},MSRS.Voices.Google.Standard.en_GB_Standard_F) -function AIRBOSS:SetAirbossRadio( Frequency, Modulation, Voice, Gender, Culture ) - - self.AirbossFreq = Frequency or self:_GetTowerFrequency() or 127.5 - Modulation = Modulation or "AM" - - if type(Modulation) == "table" then - self.AirbossModu = Modulation + end + function AIRBOSS:SetAirbossRadio(Frequency,Modulation,Voice,Gender,Culture) + self.AirbossFreq=Frequency or self:_GetTowerFrequency()or 127.5 + Modulation=Modulation or"AM" + if type(Modulation)=="table"then + self.AirbossModu=Modulation else - if Modulation == "FM" then - self.AirbossModu = radio.modulation.FM - else - self.AirbossModu = radio.modulation.AM - end - end - - self.AirbossRadio = {} -- #AIRBOSS.Radio - self.AirbossRadio.frequency = self.AirbossFreq - self.AirbossRadio.modulation = self.AirbossModu - self.AirbossRadio.alias = "AIRBOSS" - self.AirbossRadio.voice = Voice - self.AirbossRadio.gender = Gender or "male" - self.AirbossRadio.culture = Culture or "en-US" - - return self -end - ---- Set Marshal radio frequency and modulation. Default frequency is 305 MHz AM. --- @param #AIRBOSS self --- @param #number Frequency (Optional) Frequency in MHz. Default 305 MHz. --- @param #string Modulation (Optional) Modulation, "AM" or "FM". Default "AM". --- @param #string Voice (Optional) SRS specific voice --- @param #string Gender (Optional) SRS specific gender --- @param #string Culture (Optional) SRS specific culture --- @return #AIRBOSS self -function AIRBOSS:SetMarshalRadio( Frequency, Modulation, Voice, Gender, Culture ) - - self.MarshalFreq = Frequency or 305 - Modulation = Modulation or "AM" - - if Modulation == "FM" then - self.MarshalModu = radio.modulation.FM + if Modulation=="FM"then + self.AirbossModu=radio.modulation.FM else - self.MarshalModu = radio.modulation.AM + self.AirbossModu=radio.modulation.AM end - - self.MarshalRadio = {} -- #AIRBOSS.Radio - self.MarshalRadio.frequency = self.MarshalFreq - self.MarshalRadio.modulation = self.MarshalModu - self.MarshalRadio.alias = "MARSHAL" - self.MarshalRadio.voice = Voice - self.MarshalRadio.gender = Gender or "male" - self.MarshalRadio.culture = Culture or "en-US" - + end + self.AirbossRadio={} + self.AirbossRadio.frequency=self.AirbossFreq + self.AirbossRadio.modulation=self.AirbossModu + self.AirbossRadio.alias="AIRBOSS" + self.AirbossRadio.voice=Voice + self.AirbossRadio.gender=Gender or"male" + self.AirbossRadio.culture=Culture or"en-US" return self -end - ---- Set unit name for sending radio messages. --- @param #AIRBOSS self --- @param #string unitname Name of the unit. --- @return #AIRBOSS self -function AIRBOSS:SetRadioUnitName( unitname ) - self.senderac = unitname - return self -end - ---- Set unit acting as radio relay for the LSO radio. --- @param #AIRBOSS self --- @param #string unitname Name of the unit. --- @return #AIRBOSS self -function AIRBOSS:SetRadioRelayLSO( unitname ) - self.radiorelayLSO = unitname - return self -end - ---- Set unit acting as radio relay for the Marshal radio. --- @param #AIRBOSS self --- @param #string unitname Name of the unit. --- @return #AIRBOSS self -function AIRBOSS:SetRadioRelayMarshal( unitname ) - self.radiorelayMSH = unitname - return self -end - ---- Use user sound output instead of radio transmission for messages. Might be handy if radio transmissions are broken. --- @param #AIRBOSS self --- @return #AIRBOSS self -function AIRBOSS:SetUserSoundRadio() - self.usersoundradio = true - return self -end - ---- Test LSO radio sounds. --- @param #AIRBOSS self --- @param #number delay Delay in seconds be sound check starts. --- @return #AIRBOSS self -function AIRBOSS:SoundCheckLSO( delay ) - - if delay and delay > 0 then - -- Delayed call. - -- SCHEDULER:New(nil, AIRBOSS.SoundCheckLSO, {self}, delay) - self:ScheduleOnce( delay, AIRBOSS.SoundCheckLSO, self ) + end + function AIRBOSS:SetMarshalRadio(Frequency,Modulation,Voice,Gender,Culture) + self.MarshalFreq=Frequency or 305 + Modulation=Modulation or"AM" + if Modulation=="FM"then + self.MarshalModu=radio.modulation.FM else - - local text = "Playing LSO sound files:" - - for _name, _call in pairs( self.LSOCall ) do - local call = _call -- #AIRBOSS.RadioCall - - -- Debug text. - text = text .. string.format( "\nFile=%s.%s, duration=%.2f sec, loud=%s, subtitle=\"%s\".", call.file, call.suffix, call.duration, tostring( call.loud ), call.subtitle ) - - -- Radio transmission to queue. - self:RadioTransmission( self.LSORadio, call, false ) - - -- Also play the loud version. - if call.loud then - self:RadioTransmission( self.LSORadio, call, true ) - end - end - - -- Debug message. - self:T( self.lid .. text ) - + self.MarshalModu=radio.modulation.AM end -end - ---- Test Marshal radio sounds. --- @param #AIRBOSS self --- @param #number delay Delay in seconds be sound check starts. --- @return #AIRBOSS self -function AIRBOSS:SoundCheckMarshal( delay ) - - if delay and delay > 0 then - -- Delayed call. - -- SCHEDULER:New(nil, AIRBOSS.SoundCheckMarshal, {self}, delay) - self:ScheduleOnce( delay, AIRBOSS.SoundCheckMarshal, self ) + self.MarshalRadio={} + self.MarshalRadio.frequency=self.MarshalFreq + self.MarshalRadio.modulation=self.MarshalModu + self.MarshalRadio.alias="MARSHAL" + self.MarshalRadio.voice=Voice + self.MarshalRadio.gender=Gender or"male" + self.MarshalRadio.culture=Culture or"en-US" + return self + end + function AIRBOSS:SetRadioUnitName(unitname) + self.senderac=unitname + return self + end + function AIRBOSS:SetRadioRelayLSO(unitname) + self.radiorelayLSO=unitname + return self + end + function AIRBOSS:SetRadioRelayMarshal(unitname) + self.radiorelayMSH=unitname + return self + end + function AIRBOSS:SetUserSoundRadio() + self.usersoundradio=true + return self + end + function AIRBOSS:SoundCheckLSO(delay) + if delay and delay>0 then + self:ScheduleOnce(delay,AIRBOSS.SoundCheckLSO,self) else - - local text = "Playing Marshal sound files:" - - for _name, _call in pairs( self.MarshalCall ) do - local call = _call -- #AIRBOSS.RadioCall - - -- Debug text. - text = text .. string.format( "\nFile=%s.%s, duration=%.2f sec, loud=%s, subtitle=\"%s\".", call.file, call.suffix, call.duration, tostring( call.loud ), call.subtitle ) - - -- Radio transmission to queue. - self:RadioTransmission( self.MarshalRadio, call, false ) - - -- Also play the loud version. - if call.loud then - self:RadioTransmission( self.MarshalRadio, call, true ) - end - end - - -- Debug message. - self:T( self.lid .. text ) - + local text="Playing LSO sound files:" + for _name,_call in pairs(self.LSOCall)do + local call=_call + text=text..string.format("\nFile=%s.%s, duration=%.2f sec, loud=%s, subtitle=\"%s\".",call.file,call.suffix,call.duration,tostring(call.loud),call.subtitle) + self:RadioTransmission(self.LSORadio,call,false) + if call.loud then + self:RadioTransmission(self.LSORadio,call,true) end -end - ---- Set number of aircraft units, which can be in the landing pattern before the pattern is full. --- @param #AIRBOSS self --- @param #number nmax Max number. Default 4. Minimum is 1, maximum is 6. --- @return #AIRBOSS self -function AIRBOSS:SetMaxLandingPattern( nmax ) - nmax = nmax or 4 - nmax = math.max( nmax, 1 ) - nmax = math.min( nmax, 6 ) - self.Nmaxpattern = nmax + end + self:T(self.lid..text) + end + end + function AIRBOSS:SoundCheckMarshal(delay) + if delay and delay>0 then + self:ScheduleOnce(delay,AIRBOSS.SoundCheckMarshal,self) + else + local text="Playing Marshal sound files:" + for _name,_call in pairs(self.MarshalCall)do + local call=_call + text=text..string.format("\nFile=%s.%s, duration=%.2f sec, loud=%s, subtitle=\"%s\".",call.file,call.suffix,call.duration,tostring(call.loud),call.subtitle) + self:RadioTransmission(self.MarshalRadio,call,false) + if call.loud then + self:RadioTransmission(self.MarshalRadio,call,true) + end + end + self:T(self.lid..text) + end + end + function AIRBOSS:SetMaxLandingPattern(nmax) + nmax=nmax or 4 + nmax=math.max(nmax,1) + nmax=math.min(nmax,6) + self.Nmaxpattern=nmax return self -end - ---- Set number available Case I Marshal stacks. If Marshal stacks are full, flights requesting Marshal will be told to hold outside 10 NM zone until a stack becomes available again. --- Marshal stacks for Case II/III are unlimited. --- @param #AIRBOSS self --- @param #number nmax Max number of stacks available to players and AI flights. Default 3, i.e. angels 2, 3, 4. Minimum is 1. --- @return #AIRBOSS self -function AIRBOSS:SetMaxMarshalStacks( nmax ) - self.Nmaxmarshal = nmax or 3 - self.Nmaxmarshal = math.max( self.Nmaxmarshal, 1 ) + end + function AIRBOSS:SetMaxMarshalStacks(nmax) + self.Nmaxmarshal=nmax or 3 + self.Nmaxmarshal=math.max(self.Nmaxmarshal,1) return self -end - ---- Set max number of section members. Minimum is one, i.e. the section lead itself. Maximum number is four. Default is two, i.e. the lead and one other human flight. --- @param #AIRBOSS self --- @param #number nmax Number of max allowed members including the lead itself. For example, Nmax=2 means a section lead plus one member. --- @return #AIRBOSS self -function AIRBOSS:SetMaxSectionSize( nmax ) - nmax = nmax or 2 - nmax = math.max( nmax, 1 ) - nmax = math.min( nmax, 4 ) - self.NmaxSection = nmax - 1 -- We substract one because internally the section lead is not counted! + end + function AIRBOSS:SetMaxSectionSize(nmax) + nmax=nmax or 2 + nmax=math.max(nmax,1) + nmax=math.min(nmax,4) + self.NmaxSection=nmax-1 return self -end - ---- Set max number of flights per stack. All members of a section count as one "flight". --- @param #AIRBOSS self --- @param #number nmax Number of max allowed flights per stack. Default is two. Minimum is one, maximum is 4. --- @return #AIRBOSS self -function AIRBOSS:SetMaxFlightsPerStack( nmax ) - nmax = nmax or 2 - nmax = math.max( nmax, 1 ) - nmax = math.min( nmax, 4 ) - self.NmaxStack = nmax + end + function AIRBOSS:SetMaxFlightsPerStack(nmax) + nmax=nmax or 2 + nmax=math.max(nmax,1) + nmax=math.min(nmax,4) + self.NmaxStack=nmax return self -end - ---- Handle AI aircraft. --- @param #AIRBOSS self --- @return #AIRBOSS self -function AIRBOSS:SetHandleAION() - self.handleai = true + end + function AIRBOSS:SetHandleAION() + self.handleai=true return self -end - ---- Will play the inbound calls, commencing, initial, etc. from the player when requesteing marshal --- @param #AIRBOSS self --- @param #AIRBOSS status Boolean to activate (true) / deactivate (false) the radio inbound calls (default is ON) --- @return #AIRBOSS self -function AIRBOSS:SetExtraVoiceOvers(status) + end + function AIRBOSS:SetExtraVoiceOvers(status) self.xtVoiceOvers=status return self -end - ---- Will simulate the inbound call, commencing, initial, etc from the AI when requested by Airboss --- @param #AIRBOSS self --- @param #AIRBOSS status Boolean to activate (true) / deactivate (false) the radio inbound calls (default is ON) --- @return #AIRBOSS self -function AIRBOSS:SetExtraVoiceOversAI(status) + end + function AIRBOSS:SetExtraVoiceOversAI(status) self.xtVoiceOversAI=status return self -end - ---- Do not handle AI aircraft. --- @param #AIRBOSS self --- @return #AIRBOSS self -function AIRBOSS:SetHandleAIOFF() - self.handleai = false - return self -end - ---- Define recovery tanker associated with the carrier. --- @param #AIRBOSS self --- @param Ops.RecoveryTanker#RECOVERYTANKER recoverytanker Recovery tanker object. --- @return #AIRBOSS self -function AIRBOSS:SetRecoveryTanker( recoverytanker ) - self.tanker = recoverytanker - return self -end - ---- Define an AWACS associated with the carrier. --- @param #AIRBOSS self --- @param Ops.RecoveryTanker#RECOVERYTANKER awacs AWACS (recovery tanker) object. --- @return #AIRBOSS self -function AIRBOSS:SetAWACS( awacs ) - self.awacs = awacs - return self -end - ---- Set default player skill. New players will be initialized with this skill. --- --- * "Flight Student" = @{#AIRBOSS.Difficulty.Easy} --- * "Naval Aviator" = @{#AIRBOSS.Difficulty.Normal} --- * "TOPGUN Graduate" = @{#AIRBOSS.Difficulty.Hard} --- @param #AIRBOSS self --- @param #string skill Player skill. Default "Naval Aviator". --- @return #AIRBOSS self -function AIRBOSS:SetDefaultPlayerSkill( skill ) - - -- Set skill or normal. - self.defaultskill = skill or AIRBOSS.Difficulty.NORMAL - - -- Check that defualt skill is valid. - local gotit = false - for _, _skill in pairs( AIRBOSS.Difficulty ) do - if _skill == self.defaultskill then - gotit = true - end end - - -- If invalid user input, fall back to normal. + function AIRBOSS:SetHandleAIOFF() + self.handleai=false + return self + end + function AIRBOSS:SetRecoveryTanker(recoverytanker) + self.tanker=recoverytanker + return self + end + function AIRBOSS:SetAWACS(awacs) + self.awacs=awacs + return self + end + function AIRBOSS:SetDefaultPlayerSkill(skill) + self.defaultskill=skill or AIRBOSS.Difficulty.NORMAL + local gotit=false + for _,_skill in pairs(AIRBOSS.Difficulty)do + if _skill==self.defaultskill then + gotit=true + end + end if not gotit then - self.defaultskill = AIRBOSS.Difficulty.NORMAL - self:E( self.lid .. string.format( "ERROR: Invalid default skill = %s. Resetting to Naval Aviator.", tostring( skill ) ) ) + self.defaultskill=AIRBOSS.Difficulty.NORMAL + self:E(self.lid..string.format("ERROR: Invalid default skill = %s. Resetting to Naval Aviator.",tostring(skill))) end - return self -end - ---- Enable auto save of player results each time a player is *finally* graded. *Finally* means after the player landed on the carrier! After intermediate passes (bolter or waveoff) the stats are *not* saved. --- @param #AIRBOSS self --- @param #string path Path where to save the asset data file. Default is the DCS root installation directory or your "Saved Games\\DCS" folder if lfs was desanitized. --- @param #string filename File name. Default is generated automatically from airboss carrier name/alias. --- @return #AIRBOSS self -function AIRBOSS:SetAutoSave( path, filename ) - self.autosave = true - self.autosavepath = path - self.autosavefile = filename + end + function AIRBOSS:SetAutoSave(path,filename) + self.autosave=true + self.autosavepath=path + self.autosavefile=filename return self -end - ---- Activate debug mode. Display debug messages on screen. --- @param #AIRBOSS self --- @return #AIRBOSS self -function AIRBOSS:SetDebugModeON() - self.Debug = true + end + function AIRBOSS:SetDebugModeON() + self.Debug=true return self -end - ---- Carrier patrols ad inifintum. If the last waypoint is reached, it will go to waypoint one and repeat its route. --- @param #AIRBOSS self --- @param #boolean switch If true or nil, patrol until the end of time. If false, go along the waypoints once and stop. --- @return #AIRBOSS self -function AIRBOSS:SetPatrolAdInfinitum( switch ) - if switch == false then - self.adinfinitum = false + end + function AIRBOSS:SetPatrolAdInfinitum(switch) + if switch==false then + self.adinfinitum=false else - self.adinfinitum = true + self.adinfinitum=true end return self -end - ---- Set the magnetic declination (or variation). By default this is set to the standard declination of the map. --- @param #AIRBOSS self --- @param #number declination Declination in degrees or nil for default declination of the map. --- @return #AIRBOSS self -function AIRBOSS:SetMagneticDeclination( declination ) - self.magvar = declination or UTILS.GetMagneticDeclination() + end + function AIRBOSS:SetMagneticDeclination(declination) + self.magvar=declination or UTILS.GetMagneticDeclination() return self -end - ---- Deactivate debug mode. This is also the default setting. --- @param #AIRBOSS self --- @return #AIRBOSS self -function AIRBOSS:SetDebugModeOFF() - self.Debug = false + end + function AIRBOSS:SetDebugModeOFF() + self.Debug=false return self -end - - ---- Set FunkMan socket. LSO grades and trap sheets will be send to your Discord bot. --- **Requires running FunkMan program**. --- @param #AIRBOSS self --- @param #number Port Port. Default `10042`. --- @param #string Host Host. Default `"127.0.0.1"`. --- @return #AIRBOSS self -function AIRBOSS:SetFunkManOn(Port, Host) - - self.funkmanSocket=SOCKET:New(Port, Host) - + end + function AIRBOSS:SetFunkManOn(Port,Host) + self.funkmanSocket=SOCKET:New(Port,Host) return self -end - ---- Get next time the carrier will start recovering aircraft. --- @param #AIRBOSS self --- @param #boolean InSeconds If true, abs. mission time seconds is returned. Default is a clock #string. --- @return #string Clock start (or start time in abs. seconds). --- @return #string Clock stop (or stop time in abs. seconds). -function AIRBOSS:GetNextRecoveryTime( InSeconds ) + end + function AIRBOSS:GetNextRecoveryTime(InSeconds) if self.recoverywindow then - if InSeconds then - return self.recoverywindow.START, self.recoverywindow.STOP - else - return UTILS.SecondsToClock( self.recoverywindow.START ), UTILS.SecondsToClock( self.recoverywindow.STOP ) - end + if InSeconds then + return self.recoverywindow.START,self.recoverywindow.STOP else - if InSeconds then - return -1, -1 - else - return "?", "?" - end + return UTILS.SecondsToClock(self.recoverywindow.START),UTILS.SecondsToClock(self.recoverywindow.STOP) end -end - ---- Check if carrier is recovering aircraft. --- @param #AIRBOSS self --- @return #boolean If true, time slot for recovery is open. -function AIRBOSS:IsRecovering() - return self:is( "Recovering" ) -end - ---- Check if carrier is idle, i.e. no operations are carried out. --- @param #AIRBOSS self --- @return #boolean If true, carrier is in idle state. -function AIRBOSS:IsIdle() - return self:is( "Idle" ) -end - ---- Check if recovery of aircraft is paused. --- @param #AIRBOSS self --- @return #boolean If true, recovery is paused -function AIRBOSS:IsPaused() - return self:is( "Paused" ) -end - ---- Activate TACAN and ICLS beacons. --- @param #AIRBOSS self -function AIRBOSS:_ActivateBeacons() - self:T( self.lid .. string.format( "Activating Beacons (TACAN=%s, ICLS=%s)", tostring( self.TACANon ), tostring( self.ICLSon ) ) ) - - -- Activate TACAN. + else + if InSeconds then + return-1,-1 + else + return"?","?" + end + end + end + function AIRBOSS:IsRecovering() + return self:is("Recovering") + end + function AIRBOSS:IsIdle() + return self:is("Idle") + end + function AIRBOSS:IsPaused() + return self:is("Paused") + end + function AIRBOSS:_ActivateBeacons() + self:T(self.lid..string.format("Activating Beacons (TACAN=%s, ICLS=%s)",tostring(self.TACANon),tostring(self.ICLSon))) if self.TACANon then - self:I( self.lid .. string.format( "Activating TACAN Channel %d%s (%s)", self.TACANchannel, self.TACANmode, self.TACANmorse ) ) - self.beacon:ActivateTACAN( self.TACANchannel, self.TACANmode, self.TACANmorse, true ) + self:I(self.lid..string.format("Activating TACAN Channel %d%s (%s)",self.TACANchannel,self.TACANmode,self.TACANmorse)) + self.beacon:ActivateTACAN(self.TACANchannel,self.TACANmode,self.TACANmorse,true) end - - -- Activate ICLS. if self.ICLSon then - self:I( self.lid .. string.format( "Activating ICLS Channel %d (%s)", self.ICLSchannel, self.ICLSmorse ) ) - self.beacon:ActivateICLS( self.ICLSchannel, self.ICLSmorse ) + self:I(self.lid..string.format("Activating ICLS Channel %d (%s)",self.ICLSchannel,self.ICLSmorse)) + self.beacon:ActivateICLS(self.ICLSchannel,self.ICLSmorse) end - - -- Set time stamp. - self.Tbeacon = timer.getTime() -end - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- FSM event functions -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ---- On after Start event. Starts the AIRBOSS. Adds event handlers and schedules status updates of requests and queue. --- @param #AIRBOSS self --- @param #string From From state. --- @param #string Event Event. --- @param #string To To state. -function AIRBOSS:onafterStart( From, Event, To ) - - -- Events are handled my MOOSE. - self:I( self.lid .. string.format( "Starting AIRBOSS v%s for carrier unit %s of type %s on map %s", AIRBOSS.version, self.carrier:GetName(), self.carriertype, self.theatre ) ) - - -- Activate TACAN and ICLS if desired. + self.Tbeacon=timer.getTime() + end + function AIRBOSS:onafterStart(From,Event,To) + self:I(self.lid..string.format("Starting AIRBOSS v%s for carrier unit %s of type %s on map %s",AIRBOSS.version,self.carrier:GetName(),self.carriertype,self.theatre)) self:_ActivateBeacons() - - -- Schedule radio queue checks. - -- self.RQLid=self.radiotimer:Schedule(nil, AIRBOSS._CheckRadioQueue, {self, self.RQLSO, "LSO"}, 1, 0.1) - -- self.RQMid=self.radiotimer:Schedule(nil, AIRBOSS._CheckRadioQueue, {self, self.RQMarshal, "MARSHAL"}, 1, 0.1) - - -- self:I("FF: starting timer.scheduleFunction") - -- timer.scheduleFunction(AIRBOSS._CheckRadioQueueT, {airboss=self, radioqueue=self.RQLSO, name="LSO"}, timer.getTime()+1) - -- timer.scheduleFunction(AIRBOSS._CheckRadioQueueT, {airboss=self, radioqueue=self.RQMarshal, name="MARSHAL"}, timer.getTime()+1) - - -- Initial carrier position and orientation. - self.Cposition = self:GetCoordinate() - self.Corientation = self.carrier:GetOrientationX() - self.Corientlast = self.Corientation - self.Tpupdate = timer.getTime() - - -- Check if no recovery window is set. DISABLED! - if #self.recoverytimes == 0 and false then - - -- Open window in 15 minutes for 3 hours. - local Topen = timer.getAbsTime() + 15 * 60 - local Tclose = Topen + 3 * 60 * 60 - - -- Add window. - self:AddRecoveryWindow( UTILS.SecondsToClock( Topen ), UTILS.SecondsToClock( Tclose ) ) + self.Cposition=self:GetCoordinate() + self.Corientation=self.carrier:GetOrientationX() + self.Corientlast=self.Corientation + self.Tpupdate=timer.getTime() + if#self.recoverytimes==0 and false then + local Topen=timer.getAbsTime()+15*60 + local Tclose=Topen+3*60*60 + self:AddRecoveryWindow(UTILS.SecondsToClock(Topen),UTILS.SecondsToClock(Tclose)) end - - -- Check Recovery time.s self:_CheckRecoveryTimes() - - -- Time stamp for checking queues. We substract 60 seconds so the routine is called right after status is called the first time. - self.Tqueue = timer.getTime() - 60 - - -- Handle events. - self:HandleEvent( EVENTS.Birth ) - self:HandleEvent( EVENTS.Land ) - self:HandleEvent( EVENTS.EngineShutdown ) - self:HandleEvent( EVENTS.Takeoff ) - self:HandleEvent( EVENTS.Crash ) - self:HandleEvent( EVENTS.Ejection ) - self:HandleEvent( EVENTS.PlayerLeaveUnit, self._PlayerLeft ) - self:HandleEvent( EVENTS.MissionEnd ) - self:HandleEvent( EVENTS.RemoveUnit ) - - -- self.StatusScheduler=SCHEDULER:New(self) - -- self.StatusScheduler:Schedule(self, self._Status, {}, 1, 0.5) - - self.StatusTimer = TIMER:New( self._Status, self ):Start( 2, 0.5 ) - - -- Start status check in 1 second. - self:__Status( 1 ) -end - ---- On after Status event. Checks for new flights, updates queue and checks player status. --- @param #AIRBOSS self --- @param #string From From state. --- @param #string Event Event. --- @param #string To To state. -function AIRBOSS:onafterStatus( From, Event, To ) - - -- Get current time. - local time = timer.getTime() - - -- Update marshal and pattern queue every 30 seconds. - if time - self.Tqueue > self.dTqueue then - - -- Get time. - local clock = UTILS.SecondsToClock( timer.getAbsTime() ) - local eta = UTILS.SecondsToClock( self:_GetETAatNextWP() ) - - -- Current heading and position of the carrier. - local hdg = self:GetHeading() - local pos = self:GetCoordinate() - local speed = self.carrier:GetVelocityKNOTS() - - -- Check water is ahead. - local collision = false -- self:_CheckCollisionCoord(pos:Translate(self.collisiondist, hdg)) - - local holdtime = 0 - if self.holdtimestamp then - holdtime = timer.getTime() - self.holdtimestamp - end - - -- Check if carrier is stationary. - local NextWP = self:_GetNextWaypoint() - local ExpectedSpeed = UTILS.MpsToKnots( NextWP:GetVelocity() ) - if speed < 0.5 and ExpectedSpeed > 0 and not (self.detour or self.turnintowind) then - if not self.holdtimestamp then - self:E( self.lid .. string.format( "Carrier came to an unexpected standstill. Trying to re-route in 3 min. Speed=%.1f knots, expected=%.1f knots", speed, ExpectedSpeed ) ) - self.holdtimestamp = timer.getTime() - else - if holdtime > 3 * 60 then - local coord = self:GetCoordinate():Translate( 500, hdg + 10 ) - -- coord:MarkToAll("Re-route after standstill.") - self:CarrierResumeRoute( coord ) - self.holdtimestamp = nil - end - end - end - - -- Debug info. - local text = string.format( "Time %s - Status %s (case=%d) - Speed=%.1f kts - Heading=%d - WP=%d - ETA=%s - Turning=%s - Collision Warning=%s - Detour=%s - Turn Into Wind=%s - Holdtime=%d sec", clock, self:GetState(), self.case, speed, hdg, self.currentwp, eta, tostring( self.turning ), tostring( collision ), tostring( self.detour ), tostring( self.turnintowind ), holdtime ) - self:T( self.lid .. text ) - - -- Players online: - text = "Players:" - local i = 0 - for _name, _player in pairs( self.players ) do - i = i + 1 - local player = _player -- #AIRBOSS.FlightGroup - text = text .. string.format( "\n%d.) %s: Step=%s, Unit=%s, Airframe=%s", i, tostring( player.name ), tostring( player.step ), tostring( player.unitname ), tostring( player.actype ) ) - end - if i == 0 then - text = text .. " none" - end - self:T( self.lid .. text ) - - -- Check for collision. - if collision then - - -- We are currently turning into the wind. - if self.turnintowind then - - -- Carrier resumes its initial route. This disables turnintowind switch. - self:CarrierResumeRoute( self.Creturnto ) - - -- Since current window would stay open, we disable the WIND switch. - if self:IsRecovering() and self.recoverywindow and self.recoverywindow.WIND then - -- Disable turn into the wind for this window so that we do not do this all over again. - self.recoverywindow.WIND = false - end - - end - - end - - -- Check recovery times and start/stop recovery mode if necessary. - self:_CheckRecoveryTimes() - - -- Remove dead/zombie flight groups. Player leaving the server whilst in pattern etc. - -- self:_RemoveDeadFlightGroups() - - -- Scan carrier zone for new aircraft. - self:_ScanCarrierZone() - - -- Check marshal and pattern queues. - self:_CheckQueue() - - -- Check if carrier is currently turning. - self:_CheckCarrierTurning() - - -- Check if marshal pattern of AI needs an update. - self:_CheckPatternUpdate() - - -- Time stamp. - self.Tqueue = time + self.Tqueue=timer.getTime()-60 + self:HandleEvent(EVENTS.Birth) + self:HandleEvent(EVENTS.Land) + self:HandleEvent(EVENTS.EngineShutdown) + self:HandleEvent(EVENTS.Takeoff) + self:HandleEvent(EVENTS.Crash) + self:HandleEvent(EVENTS.Ejection) + self:HandleEvent(EVENTS.PlayerLeaveUnit,self._PlayerLeft) + self:HandleEvent(EVENTS.MissionEnd) + self:HandleEvent(EVENTS.RemoveUnit) + self:HandleEvent(EVENTS.UnitLost,self.OnEventRemoveUnit) + self.StatusTimer=TIMER:New(self._Status,self):Start(2,0.5) + self:__Status(1) end - - -- (Re-)activate TACAN and ICLS channels. - if time - self.Tbeacon > self.dTbeacon then - self:_ActivateBeacons() + function AIRBOSS:onafterStatus(From,Event,To) + local time=timer.getTime() + if time-self.Tqueue>self.dTqueue then + local clock=UTILS.SecondsToClock(timer.getAbsTime()) + local eta=UTILS.SecondsToClock(self:_GetETAatNextWP()) + local hdg=self:GetHeading() + local pos=self:GetCoordinate() + local speed=self.carrier:GetVelocityKNOTS() + if require then + self.magvar=pos:GetMagneticDeclination() end - - -- Call status every ~0.5 seconds. - self:__Status( -30 ) - -end - ---- Check AI status. Pattern queue AI in the groove? Marshal queue AI arrived in holding zone? --- @param #AIRBOSS self -function AIRBOSS:_Status() - - -- Check player status. - self:_CheckPlayerStatus() - - -- Check AI landing pattern status - self:_CheckAIStatus() - -end - ---- Check AI status. Pattern queue AI in the groove? Marshal queue AI arrived in holding zone? --- @param #AIRBOSS self -function AIRBOSS:_CheckAIStatus() - - -- Loop over all flights in Marshal stack. - for _, _flight in pairs( self.Qmarshal ) do - local flight = _flight -- #AIRBOSS.FlightGroup - - -- Only AI! - if flight.ai then - - -- Get fuel amount in %. - local fuel = flight.group:GetFuelMin() * 100 - - -- Debug text. - local text = string.format( "Group %s fuel=%.1f %%", flight.groupname, fuel ) - self:T3( self.lid .. text ) - - -- Check if flight is low on fuel and not yet refueling. - if self.lowfuelAI and fuel < self.lowfuelAI and not flight.refueling then - - -- Send AI for refueling at tanker or divert field. - self:_RefuelAI( flight ) - - -- Remove flight from marshal queue. - self:_RemoveFlightFromMarshalQueue( flight, true ) - - end - - end + local collision=false + local holdtime=0 + if self.holdtimestamp then + holdtime=timer.getTime()-self.holdtimestamp end - - -- Loop over all flights in landing pattern. - for _, _flight in pairs( self.Qpattern ) do - local flight = _flight -- #AIRBOSS.FlightGroup - - -- Only AI! - if flight.ai then - - -- Loop over all units in AI flight. - for _, _element in pairs( flight.elements ) do - local element = _element -- #AIRBOSS.FlightElement - - -- Unit - local unit = element.unit - - -- Get lineup and distance to carrier. - local lineup = self:_Lineup( unit, true ) - - local unitcoord = unit:GetCoord() - - local dist = unitcoord:Get2DDistance( self:GetCoord() ) - - -- Distance in NM. - local distance = UTILS.MetersToNM( dist ) - - -- Altitude in ft. - local alt = UTILS.MetersToFeet( unitcoord.y ) - - -- Check if parameters are right and flight is in the groove. - if lineup < 2 and distance <= 0.75 and alt < 500 and not element.ballcall then - - -- Paddles: Call the ball! - self:RadioTransmission( self.LSORadio, self.LSOCall.CALLTHEBALL, nil, nil, nil, true ) - - -- Pilot: "405, Hornet Ball, 3.2" - self:_LSOCallAircraftBall( element.onboard, self:_GetACNickname( unit:GetTypeName() ), self:_GetFuelState( unit ) / 1000 ) - - -- Paddles: Roger ball after 0.5 seconds. - self:RadioTransmission( self.LSORadio, self.LSOCall.ROGERBALL, nil, nil, 0.5, true ) - - -- Flight element called the ball. - element.ballcall = true - - -- This is for the whole flight. Maybe we need it. - flight.ballcall = true - end - - end - end - end - -end - ---- Check if player in the landing pattern is too close to another aircarft in the pattern. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData player Player data. -function AIRBOSS:_CheckPlayerPatternDistance( player ) - - -- Check if player is too close to another aircraft in the pattern. - -- TODO: At which steps is the really necessary. Case II/III? - if player.step==AIRBOSS.PatternStep.INITIAL or - player.step==AIRBOSS.PatternStep.BREAKENTRY or - player.step==AIRBOSS.PatternStep.EARLYBREAK or - player.step==AIRBOSS.PatternStep.LATEBREAK or - player.step==AIRBOSS.PatternStep.ABEAM or - player.step==AIRBOSS.PatternStep.GROOVE_XX or - player.step==AIRBOSS.PatternStep.GROOVE_IM then - - -- Right step but not implemented. - return - + local NextWP=self:_GetNextWaypoint() + local ExpectedSpeed=UTILS.MpsToKnots(NextWP:GetVelocity()) + if speed<0.5 and ExpectedSpeed>0 and not(self.detour or self.turnintowind)then + if not self.holdtimestamp then + self:E(self.lid..string.format("Carrier came to an unexpected standstill. Trying to re-route in 3 min. Speed=%.1f knots, expected=%.1f knots",speed,ExpectedSpeed)) + self.holdtimestamp=timer.getTime() else - -- Wrong step - no check performed. - return + if holdtime>3*60 then + local coord=self:GetCoordinate():Translate(500,hdg+10) + self:CarrierResumeRoute(coord) + self.holdtimestamp=nil end - - -- Nothing to do since we check only in the pattern. - if #self.Qpattern == 0 then - return end - - --- Function that checks if unit1 is too close to unit2. - local function _checkclose( _unit1, _unit2 ) - - local unit1 = _unit1 -- Wrapper.Unit#UNIT - local unit2 = _unit2 -- Wrapper.Unit#UNIT - - if (not unit1) or (not unit2) then - return false - end - - -- Check that this is not the same unit. - if unit1:GetName() == unit2:GetName() then - return false - end - - -- Return false when unit2 is not in air? Could be on the carrier. - if not unit2:InAir() then - return false - end - - -- Positions of units. - local c1 = unit1:GetCoordinate() - local c2 = unit2:GetCoordinate() - - -- Vector from unit1 to unit2 - local vec12 = { x = c2.x - c1.x, y = 0, z = c2.z - c1.z } -- DCS#Vec3 - - -- Distance between units. - local dist = UTILS.VecNorm( vec12 ) - - -- Orientation of unit 1 in space. - local vec1 = unit1:GetOrientationX() - vec1.y = 0 - - -- Get angle between the two orientation vectors. Does the player aircraft nose point into the direction of the other aircraft? (Could be behind him!) - local rhdg = math.deg( math.acos( UTILS.VecDot( vec12, vec1 ) / UTILS.VecNorm( vec12 ) / UTILS.VecNorm( vec1 ) ) ) - - -- Check altitude difference? - local dalt = math.abs( c2.y - c1.y ) - - -- 650 feet ~= 200 meters distance between flights - local dcrit = UTILS.FeetToMeters( 650 ) - - -- Direction in 30 degrees cone and distance < 200 meters and altitude difference <50 - -- TODO: Test parameter values. - if math.abs( rhdg ) < 10 and dist < dcrit and dalt < 50 then - return true - else - return false - end end - - -- Loop over all other flights in pattern. - for _, _flight in pairs( self.Qpattern ) do - local flight = _flight -- #AIRBOSS.FlightGroup - - -- Now we still need to loop over all units in the flight. - for _, _element in pairs( flight.elements ) do - local element = _element -- #AIRBOSS.FlightElement - - -- Check if player is too close to another aircraft in the pattern. - local tooclose = _checkclose( player.unit, element.unit ) - - -- Check if we are too close. - if tooclose then - - -- Debug message. - local text = string.format( "Player %s too close (<200 meters) to aircraft %s!", player.name, element.unit:GetName() ) - self:T2( self.lid .. text ) - -- MESSAGE:New(text, 20, "DEBUG"):ToAllIf(self.Debug) - - -- Inform player that he is too close. - -- TODO: Pattern wave off? - -- TODO: This function needs a switch so that it is not called over and over again! - -- local text=string.format("you're getting too close to the aircraft, %s, ahead of you!\nKeep a min distance of at least 650 ft.", element.onboard) - -- self:MessageToPlayer(player, text, "LSO") - end - - end + local text=string.format("Time %s - Status %s (case=%d) - Speed=%.1f kts - Heading=%d - WP=%d - ETA=%s - Turning=%s - Collision Warning=%s - Detour=%s - Turn Into Wind=%s - Holdtime=%d sec",clock,self:GetState(),self.case,speed,hdg,self.currentwp,eta,tostring(self.turning),tostring(collision),tostring(self.detour),tostring(self.turnintowind),holdtime) + self:T(self.lid..text) + text="Players:" + local i=0 + for _name,_player in pairs(self.players)do + i=i+1 + local player=_player + text=text..string.format("\n%d.) %s: Step=%s, Unit=%s, Airframe=%s",i,tostring(player.name),tostring(player.step),tostring(player.unitname),tostring(player.actype)) end - -end - ---- Check recovery times and start/stop recovery mode of aircraft. --- @param #AIRBOSS self -function AIRBOSS:_CheckRecoveryTimes() - - -- Get current abs time. - local time = timer.getAbsTime() - local Cnow = UTILS.SecondsToClock( time ) - - -- Debug output: - local text = string.format( self.lid .. "Recovery time windows:" ) - - -- Handle case with no recoveries. - if #self.recoverytimes == 0 then - text = text .. " none!" + if i==0 then + text=text.." none" end - - -- Sort windows wrt to start time. - local _sort = function( a, b ) - return a.START < b.START - end - table.sort( self.recoverytimes, _sort ) - - -- Next recovery case in the future. - local nextwindow = nil -- #AIRBOSS.Recovery - local currwindow = nil -- #AIRBOSS.Recovery - - -- Loop over all slots. - for _, _recovery in pairs( self.recoverytimes ) do - local recovery = _recovery -- #AIRBOSS.Recovery - - -- Get start/stop clock strings. - local Cstart = UTILS.SecondsToClock( recovery.START ) - local Cstop = UTILS.SecondsToClock( recovery.STOP ) - - -- Status info. - local state = "" - - -- Check if start time passed. - if time >= recovery.START then - -- Start time has passed. - - if time < recovery.STOP then - -- Stop time has NOT passed. - - if self:IsRecovering() then - -- Carrier is already recovering. - state = "in progress" - else - -- Start recovery. - self:RecoveryStart( recovery.CASE, recovery.OFFSET ) - state = "starting now" - recovery.OPEN = true - end - - -- Set current recovery window. - currwindow = recovery - - else -- Stop time HAS passed. - - if self:IsRecovering() and not recovery.OVER then - - -- Get number of airborne aircraft units(!) currently in pattern. - local _, npattern = self:_GetQueueInfo( self.Qpattern ) - - if npattern > 0 then - - -- Extend recovery time. 5 min per flight. - local extmin = 5 * npattern - recovery.STOP = recovery.STOP + extmin * 60 - - local text = string.format( "We still got flights in the pattern.\nRecovery time prolonged by %d minutes.\nNow get your act together and no more bolters!", extmin ) - self:MessageToPattern( text, "AIRBOSS", "99", 10, false, nil ) - - else - - -- Set carrier to idle. - self:RecoveryStop() - state = "closing now" - - -- Closed. - recovery.OPEN = false - - -- Window just closed. - recovery.OVER = true - - end - else - - -- Carrier is already idle. - state = "closed" - end - - end - - else - -- This recovery is in the future. - state = "in the future" - - -- This is the next to come as we sorted by start time. - if nextwindow == nil then - nextwindow = recovery - state = "next in line" - end - end - - -- Debug text. - text = text .. string.format( "\n- Start=%s Stop=%s Case=%d Offset=%d Open=%s Closed=%s Status=\"%s\"", Cstart, Cstop, recovery.CASE, recovery.OFFSET, tostring( recovery.OPEN ), tostring( recovery.OVER ), state ) - end - - -- Debug output. - self:T( self.lid .. text ) - - -- Current recovery window. - self.recoverywindow = nil - - if self:IsIdle() then - ----------------------------------------------------------------------------------------------------------------- - -- Carrier is idle: We need to make sure that incoming flights get the correct recovery info of the next window. - ----------------------------------------------------------------------------------------------------------------- - - -- Check if there is a next windows defined. - if nextwindow then - - -- Set case and offset of the next window. - self:RecoveryCase( nextwindow.CASE, nextwindow.OFFSET ) - - -- Check if time is less than 5 minutes. - if nextwindow.WIND and nextwindow.START - time < self.dTturn and not self.turnintowind then - - -- Check that wind is blowing from a direction > 5° different from the current heading. - local hdg = self:GetHeading() - local wind = self:GetHeadingIntoWind(nextwindow.SPEED) - local delta = self:_GetDeltaHeading( hdg, wind ) - local uturn = delta > 5 - - -- Check if wind is actually blowing (0.1 m/s = 0.36 km/h = 0.2 knots) - local _, vwind = self:GetWind() - if vwind < 0.1 then - uturn = false - end - - -- U-turn disabled by user input. - if not nextwindow.UTURN then - uturn = false - end - - -- Debug info - self:T( self.lid .. string.format( "Heading=%03d°, Wind=%03d° %.1f kts, Delta=%03d° ==> U-turn=%s", hdg, wind, UTILS.MpsToKnots( vwind ), delta, tostring( uturn ) ) ) - - -- Time into the wind 1 day or if longer recovery time + the 5 min early. - local t = math.max( nextwindow.STOP - nextwindow.START + self.dTturn, 60 * 60 * 24 ) - - -- Recovery wind on deck in knots. - local v = UTILS.KnotsToMps( nextwindow.SPEED ) - - -- Check that we do not go above max possible speed. - local vmax = self.carrier:GetSpeedMax() / 3.6 -- convert to m/s - v = math.min( v, vmax ) - - -- Route carrier into the wind. Sets self.turnintowind=true - self:CarrierTurnIntoWind( t, v, uturn ) - - end - - -- Set current recovery window. - self.recoverywindow = nextwindow - - else - -- No next window. Set default values. - self:RecoveryCase() - end - - else - ------------------------------------------------------------------------------------- - -- Carrier is recovering: We set the recovery window to the current one or next one. - ------------------------------------------------------------------------------------- - - if currwindow then - self.recoverywindow = currwindow - else - self.recoverywindow = nextwindow - end - end - - self:T2( { "FF", recoverywindow = self.recoverywindow } ) -end - ---- Get section lead of a flight. --- @param #AIRBOSS self --- @param #AIRBOSS.FlightGroup flight --- @return #AIRBOSS.FlightGroup The leader of the section. Could be the flight itself. --- @return #boolean If true, flight is lead. -function AIRBOSS:_GetFlightLead( flight ) - - if flight.name ~= flight.seclead then - -- Section lead of flight. - local lead = self.players[flight.seclead] - return lead, false - else - -- Flight without section or section lead. - return flight, true - end - -end - ---- On before "RecoveryCase" event. Check if case or holding offset did change. If not transition is denied. --- @param #AIRBOSS self --- @param #string From From state. --- @param #string Event Event. --- @param #string To To state. --- @param #number Case The recovery case (1, 2 or 3) to switch to. --- @param #number Offset Holding pattern offset angle in degrees for CASE II/III recoveries. -function AIRBOSS:onbeforeRecoveryCase( From, Event, To, Case, Offset ) - - -- Input or default value. - Case = Case or self.defaultcase - - -- Input or default value - Offset = Offset or self.defaultoffset - - if Case == self.case and Offset == self.holdingoffset then - return false - end - - return true -end - ---- On after "RecoveryCase" event. Sets new aircraft recovery case. Updates --- @param #AIRBOSS self --- @param #string From From state. --- @param #string Event Event. --- @param #string To To state. --- @param #number Case The recovery case (1, 2 or 3) to switch to. --- @param #number Offset Holding pattern offset angle in degrees for CASE II/III recoveries. -function AIRBOSS:onafterRecoveryCase( From, Event, To, Case, Offset ) - - -- Input or default value. - Case = Case or self.defaultcase - - -- Input or default value - Offset = Offset or self.defaultoffset - - -- Debug output. - local text = string.format( "Switching recovery case %d ==> %d", self.case, Case ) - if Case > 1 then - text = text .. string.format( " Holding offset angle %d degrees.", Offset ) - end - MESSAGE:New( text, 20, self.alias ):ToAllIf( self.Debug ) - self:T( self.lid .. text ) - - -- Set new recovery case. - self.case = Case - - -- Set holding offset. - self.holdingoffset = Offset - - -- Update case of all flights not in Marshal or Pattern queue. - for _, _flight in pairs( self.flights ) do - local flight = _flight -- #AIRBOSS.FlightGroup - if not (self:_InQueue( self.Qmarshal, flight.group ) or self:_InQueue( self.Qpattern, flight.group )) then - - -- Also not for section members. These are not in the marshal or pattern queue if the lead is. - if flight.name ~= flight.seclead then - local lead = self.players[flight.seclead] - - if lead and not (self:_InQueue( self.Qmarshal, lead.group ) or self:_InQueue( self.Qpattern, lead.group )) then - -- This is section member and the lead is not in the Marshal or Pattern queue. - flight.case = self.case - end - - else - - -- This is a flight without section or the section lead. - flight.case = self.case - - end - - end - end -end - ---- On after "RecoveryStart" event. Recovery of aircraft is started and carrier switches to state "Recovering". --- @param #AIRBOSS self --- @param #string From From state. --- @param #string Event Event. --- @param #string To To state. --- @param #number Case The recovery case (1, 2 or 3) to start. --- @param #number Offset Holding pattern offset angle in degrees for CASE II/III recoveries. -function AIRBOSS:onafterRecoveryStart( From, Event, To, Case, Offset ) - - -- Input or default value. - Case = Case or self.defaultcase - - -- Input or default value. - Offset = Offset or self.defaultoffset - - -- Radio message: "99, starting aircraft recovery case X ops. (Marshal radial XYZ degrees)" - self:_MarshalCallRecoveryStart( Case ) - - -- Switch to case. - self:RecoveryCase( Case, Offset ) -end - ---- On after "RecoveryStop" event. Recovery of aircraft is stopped and carrier switches to state "Idle". Running recovery window is deleted. --- @param #AIRBOSS self --- @param #string From From state. --- @param #string Event Event. --- @param #string To To state. -function AIRBOSS:onafterRecoveryStop( From, Event, To ) - -- Debug output. - self:T( self.lid .. string.format( "Stopping aircraft recovery." ) ) - - -- Recovery ops stopped message. - self:_MarshalCallRecoveryStopped( self.case ) - - -- If carrier is currently heading into the wind, we resume the original route. + self:T(self.lid..text) + if collision then if self.turnintowind then - - -- Coordinate to return to. - local coord = self.Creturnto - - -- No U-turn. - if self.recoverywindow and self.recoverywindow.UTURN == false then - coord = nil - end - - -- Carrier resumes route. - self:CarrierResumeRoute( coord ) + self:CarrierResumeRoute(self.Creturnto) + if self:IsRecovering()and self.recoverywindow and self.recoverywindow.WIND then + self.recoverywindow.WIND=false + end end - - -- Delete current recovery window if open. - if self.recoverywindow and self.recoverywindow.OPEN == true then - self.recoverywindow.OPEN = false - self.recoverywindow.OVER = true - self:DeleteRecoveryWindow( self.recoverywindow ) end - - -- Check recovery windows. This sets self.recoverywindow to the next window. self:_CheckRecoveryTimes() -end - ---- On after "RecoveryPause" event. Recovery of aircraft is paused. Marshal queue stays intact. --- @param #AIRBOSS self --- @param #string From From state. --- @param #string Event Event. --- @param #string To To state. --- @param #number duration Duration of pause in seconds. After that recovery is resumed automatically. -function AIRBOSS:onafterRecoveryPause( From, Event, To, duration ) - -- Debug output. - self:T( self.lid .. string.format( "Pausing aircraft recovery." ) ) - - -- Message text - + self:_ScanCarrierZone() + self:_CheckQueue() + self:_CheckCarrierTurning() + self:_CheckPatternUpdate() + self.Tqueue=time + end + if time-self.Tbeacon>self.dTbeacon then + self:_ActivateBeacons() + end + self:__Status(-30) + end + function AIRBOSS:_Status() + self:_CheckPlayerStatus() + self:_CheckAIStatus() + end + function AIRBOSS:_CheckAIStatus() + for _,_flight in pairs(self.Qmarshal)do + local flight=_flight + if flight.ai then + local fuel=flight.group:GetFuelMin()*100 + local text=string.format("Group %s fuel=%.1f %%",flight.groupname,fuel) + self:T3(self.lid..text) + if self.lowfuelAI and fuel=recovery.START then + if time0 then + local extmin=5*npattern + recovery.STOP=recovery.STOP+extmin*60 + -- local text=string.format("We still got flights in the pattern.\nRecovery time prolonged by %d minutes.\nNow get your act together and no more bolters!",extmin) + -- self:MessageToPattern(text,"AIRBOSS","99",10,false,nil) + local text=string.format("目前仍然有飞机处于程序中.\n回收程序延长 %d 分钟.\n搞快点现在, 别再勾不上了!",extmin) + self:MessageToPattern(text,"航空长","99",10,false,nil) + else + self:RecoveryStop() + state="closing now" + recovery.OPEN=false + recovery.OVER=true + end + else + state="closed" + end + end + else + state="in the future" + if nextwindow==nil then + nextwindow=recovery + state="next in line" + end + end + text=text..string.format("\n- Start=%s Stop=%s Case=%d Offset=%d Open=%s Closed=%s Status=\"%s\"",Cstart,Cstop,recovery.CASE,recovery.OFFSET,tostring(recovery.OPEN),tostring(recovery.OVER),state) + end + self:T(self.lid..text) + self.recoverywindow=nil + if self:IsIdle()then + if nextwindow then + self:RecoveryCase(nextwindow.CASE,nextwindow.OFFSET) + if nextwindow.WIND and nextwindow.START-time5 + local _,vwind=self:GetWind() + if vwind<0.1 then + uturn=false + end + if not nextwindow.UTURN then + uturn=false + end + self:T(self.lid..string.format("Heading=%03d°, Wind=%03d° %.1f kts, Delta=%03d° ==> U-turn=%s",hdg,wind,UTILS.MpsToKnots(vwind),delta,tostring(uturn))) + local t=math.max(nextwindow.STOP-nextwindow.START+self.dTturn,60*60*24) + local v=UTILS.KnotsToMps(nextwindow.SPEED) + local vmax=self.carrier:GetSpeedMax()/3.6 + v=math.min(v,vmax) + self:CarrierTurnIntoWind(t,v,uturn) + end + self.recoverywindow=nextwindow + else + self:RecoveryCase() + end + else + if currwindow then + self.recoverywindow=currwindow + else + self.recoverywindow=nextwindow + end + end + self:T2({"FF",recoverywindow=self.recoverywindow}) + end + function AIRBOSS:_GetFlightLead(flight) + if flight.name~=flight.seclead then + local lead=self.players[flight.seclead] + return lead,false + else + return flight,true + end + end + function AIRBOSS:onbeforeRecoveryCase(From,Event,To,Case,Offset) + Case=Case or self.defaultcase + Offset=Offset or self.defaultoffset + if Case==self.case and Offset==self.holdingoffset then + return false + end + return true + end + function AIRBOSS:onafterRecoveryCase(From,Event,To,Case,Offset) + Case=Case or self.defaultcase + Offset=Offset or self.defaultoffset + -- local text=string.format("Switching recovery case %d ==> %d",self.case,Case) + -- if Case>1 then + -- text=text..string.format(" Holding offset angle %d degrees.",Offset) + -- end + local text=string.format("切换回收 case %d ==> %d",self.case,Case) + if Case>1 then + text=text..string.format("保持偏移角度 %d°.",Offset) + end + MESSAGE:New(text,20,self.alias):ToAllIf(self.Debug) + self:T(self.lid..text) + self.case=Case + self.holdingoffset=Offset + for _,_flight in pairs(self.flights)do + local flight=_flight + if not(self:_InQueue(self.Qmarshal,flight.group)or self:_InQueue(self.Qpattern,flight.group))then + if flight.name~=flight.seclead then + local lead=self.players[flight.seclead] + if lead and not(self:_InQueue(self.Qmarshal,lead.group)or self:_InQueue(self.Qpattern,lead.group))then + flight.case=self.case + end + else + flight.case=self.case + end + end + end + end + function AIRBOSS:onafterRecoveryStart(From,Event,To,Case,Offset) + Case=Case or self.defaultcase + Offset=Offset or self.defaultoffset + self:_MarshalCallRecoveryStart(Case) + self:RecoveryCase(Case,Offset) + end + function AIRBOSS:onafterRecoveryStop(From,Event,To) + self:T(self.lid..string.format("Stopping aircraft recovery.")) + self:_MarshalCallRecoveryStopped(self.case) + if self.turnintowind then + local coord=self.Creturnto + if self.recoverywindow and self.recoverywindow.UTURN==false then + coord=nil + end + self:CarrierResumeRoute(coord) + end + if self.recoverywindow and self.recoverywindow.OPEN==true then + self.recoverywindow.OPEN=false + self.recoverywindow.OVER=true + self:DeleteRecoveryWindow(self.recoverywindow) + end + self:_CheckRecoveryTimes() + end + function AIRBOSS:onafterRecoveryPause(From,Event,To,duration) + self:T(self.lid..string.format("Pausing aircraft recovery.")) if duration then - - -- Auto resume. - self:__RecoveryUnpause( duration ) - - -- Time to resume. - local clock = UTILS.SecondsToClock( timer.getAbsTime() + duration ) - - -- Marshal call: "99, aircraft recovery paused and will be resume at XX:YY." - self:_MarshalCallRecoveryPausedResumedAt( clock ) + self:__RecoveryUnpause(duration) + local clock=UTILS.SecondsToClock(timer.getAbsTime()+duration) + self:_MarshalCallRecoveryPausedResumedAt(clock) else - - -- local text = string.format( "aircraft recovery is paused until further notice." ) - local text = string.format( "飞机回收暂停,待另行通知." ) - - -- Marshal call: "99, aircraft recovery paused until further notice." - self:_MarshalCallRecoveryPausedNotice() - + local text=string.format("aircraft recovery is paused until further notice.") + self:_MarshalCallRecoveryPausedNotice() end - -end - ---- On after "RecoveryUnpause" event. Recovery of aircraft is resumed. --- @param #AIRBOSS self --- @param #string From From state. --- @param #string Event Event. --- @param #string To To state. -function AIRBOSS:onafterRecoveryUnpause( From, Event, To ) - -- Debug output. - self:T( self.lid .. string.format( "Unpausing aircraft recovery." ) ) - - -- Resume recovery. + end + function AIRBOSS:onafterRecoveryUnpause(From,Event,To) + self:T(self.lid..string.format("Unpausing aircraft recovery.")) self:_MarshalCallResumeRecovery() - -end - ---- On after "PassingWaypoint" event. Carrier has just passed a waypoint --- @param #AIRBOSS self --- @param #string From From state. --- @param #string Event Event. --- @param #string To To state. --- @param #number n Number of waypoint that was passed. -function AIRBOSS:onafterPassingWaypoint( From, Event, To, n ) - -- Debug output. - self:I( self.lid .. string.format( "Carrier passed waypoint %d.", n ) ) -end - ---- On after "Idle" event. Carrier goes to state "Idle". --- @param #AIRBOSS self --- @param #string From From state. --- @param #string Event Event. --- @param #string To To state. -function AIRBOSS:onafterIdle( From, Event, To ) - -- Debug output. - self:T( self.lid .. string.format( "Carrier goes to idle." ) ) -end - ---- On after Stop event. Unhandle events. --- @param #AIRBOSS self --- @param #string From From state. --- @param #string Event Event. --- @param #string To To state. -function AIRBOSS:onafterStop( From, Event, To ) - self:I( self.lid .. string.format( "Stopping airboss script." ) ) - - -- Unhandle events. - self:UnHandleEvent( EVENTS.Birth ) - self:UnHandleEvent( EVENTS.Land ) - self:UnHandleEvent( EVENTS.EngineShutdown ) - self:UnHandleEvent( EVENTS.Takeoff ) - self:UnHandleEvent( EVENTS.Crash ) - self:UnHandleEvent( EVENTS.Ejection ) - self:UnHandleEvent( EVENTS.PlayerLeaveUnit ) - self:UnHandleEvent( EVENTS.MissionEnd ) - + end + function AIRBOSS:onafterPassingWaypoint(From,Event,To,n) + self:I(self.lid..string.format("Carrier passed waypoint %d.",n)) + end + function AIRBOSS:onafterIdle(From,Event,To) + self:T(self.lid..string.format("Carrier goes to idle.")) + end + function AIRBOSS:onafterStop(From,Event,To) + self:I(self.lid..string.format("Stopping airboss script.")) + self:UnHandleEvent(EVENTS.Birth) + self:UnHandleEvent(EVENTS.Land) + self:UnHandleEvent(EVENTS.EngineShutdown) + self:UnHandleEvent(EVENTS.Takeoff) + self:UnHandleEvent(EVENTS.Crash) + self:UnHandleEvent(EVENTS.Ejection) + self:UnHandleEvent(EVENTS.PlayerLeaveUnit) + self:UnHandleEvent(EVENTS.MissionEnd) self.CallScheduler:Clear() -end - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- Parameter initialization ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ---- Init parameters for USS Theodore Roosevelt carrier. --- @param #AIRBOSS self -function AIRBOSS:_InitStennis() - - -- Carrier Parameters. - self.carrierparam.sterndist = -153 - self.carrierparam.deckheight = 18.30 - - -- Total size of the carrier (approx as rectangle). - self.carrierparam.totlength = 310 -- Wiki says 332.8 meters overall length. - self.carrierparam.totwidthport = 40 -- Wiki says 76.8 meters overall beam. - self.carrierparam.totwidthstarboard = 30 - - -- Landing runway. - self.carrierparam.rwyangle = -9.1359 - self.carrierparam.rwylength = 225 - self.carrierparam.rwywidth = 20 - - -- Wires. - self.carrierparam.wire1 = 46 -- Distance from stern to first wire. - self.carrierparam.wire2 = 46 + 12 - self.carrierparam.wire3 = 46 + 24 - self.carrierparam.wire4 = 46 + 35 -- Last wire is strangely one meter closer. - - -- Landing distance. - self.carrierparam.landingdist = self.carrierparam.sterndist+self.carrierparam.wire3 - - -- Platform at 5k. Reduce descent rate to 2000 ft/min to 1200 dirty up level flight. - self.Platform.name = "Platform 5k" - self.Platform.Xmin = -UTILS.NMToMeters( 22 ) -- Not more than 22 NM behind the boat. Last check was at 21 NM. - self.Platform.Xmax = nil - self.Platform.Zmin = -UTILS.NMToMeters( 30 ) -- Not more than 30 NM port of boat. - self.Platform.Zmax = UTILS.NMToMeters( 30 ) -- Not more than 30 NM starboard of boat. - self.Platform.LimitXmin = nil -- Limits via zone - self.Platform.LimitXmax = nil - self.Platform.LimitZmin = nil - self.Platform.LimitZmax = nil - - -- Level out at 1200 ft and dirty up. - self.DirtyUp.name = "Dirty Up" - self.DirtyUp.Xmin = -UTILS.NMToMeters( 21 ) -- Not more than 21 NM behind the boat. - self.DirtyUp.Xmax = nil - self.DirtyUp.Zmin = -UTILS.NMToMeters( 30 ) -- Not more than 30 NM port of boat. - self.DirtyUp.Zmax = UTILS.NMToMeters( 30 ) -- Not more than 30 NM starboard of boat. - self.DirtyUp.LimitXmin = nil -- Limits via zone - self.DirtyUp.LimitXmax = nil - self.DirtyUp.LimitZmin = nil - self.DirtyUp.LimitZmax = nil - - -- Intercept glide slope and follow bullseye. - self.Bullseye.name = "Bullseye" - self.Bullseye.Xmin = -UTILS.NMToMeters( 11 ) -- Not more than 11 NM behind the boat. Last check was at 10 NM. - self.Bullseye.Xmax = nil - self.Bullseye.Zmin = -UTILS.NMToMeters( 30 ) -- Not more than 30 NM port. - self.Bullseye.Zmax = UTILS.NMToMeters( 30 ) -- Not more than 30 NM starboard. - self.Bullseye.LimitXmin = nil -- Limits via zone. - self.Bullseye.LimitXmax = nil - self.Bullseye.LimitZmin = nil - self.Bullseye.LimitZmax = nil - - -- Break entry. - self.BreakEntry.name = "Break Entry" - self.BreakEntry.Xmin = -UTILS.NMToMeters( 4 ) -- Not more than 4 NM behind the boat. Check for initial is at 3 NM with a radius of 500 m and 100 m starboard. - self.BreakEntry.Xmax = nil - self.BreakEntry.Zmin = -UTILS.NMToMeters( 0.5 ) -- Not more than 0.5 NM port of boat. - self.BreakEntry.Zmax = UTILS.NMToMeters( 1.5 ) -- Not more than 1.5 NM starboard. - self.BreakEntry.LimitXmin = 0 -- Check and next step when at carrier and starboard of carrier. - self.BreakEntry.LimitXmax = nil - self.BreakEntry.LimitZmin = nil - self.BreakEntry.LimitZmax = nil - - -- Early break. - self.BreakEarly.name = "Early Break" - self.BreakEarly.Xmin = -UTILS.NMToMeters( 1 ) -- Not more than 1 NM behind the boat. Last check was at 0. - self.BreakEarly.Xmax = UTILS.NMToMeters( 5 ) -- Not more than 5 NM in front of the boat. Enough for late breaks? - self.BreakEarly.Zmin = -UTILS.NMToMeters( 2 ) -- Not more than 2 NM port. - self.BreakEarly.Zmax = UTILS.NMToMeters( 1 ) -- Not more than 1 NM starboard. - self.BreakEarly.LimitXmin = 0 -- Check and next step 0.2 NM port and in front of boat. - self.BreakEarly.LimitXmax = nil - self.BreakEarly.LimitZmin = -UTILS.NMToMeters( 0.2 ) -- -370 m port - self.BreakEarly.LimitZmax = nil - - -- Late break. - self.BreakLate.name = "Late Break" - self.BreakLate.Xmin = -UTILS.NMToMeters( 1 ) -- Not more than 1 NM behind the boat. Last check was at 0. - self.BreakLate.Xmax = UTILS.NMToMeters( 5 ) -- Not more than 5 NM in front of the boat. Enough for late breaks? - self.BreakLate.Zmin = -UTILS.NMToMeters( 2 ) -- Not more than 2 NM port. - self.BreakLate.Zmax = UTILS.NMToMeters( 1 ) -- Not more than 1 NM starboard. - self.BreakLate.LimitXmin = 0 -- Check and next step 0.8 NM port and in front of boat. - self.BreakLate.LimitXmax = nil - self.BreakLate.LimitZmin = -UTILS.NMToMeters( 0.8 ) -- -1470 m port - self.BreakLate.LimitZmax = nil - - -- Abeam position. - self.Abeam.name = "Abeam Position" - self.Abeam.Xmin = -UTILS.NMToMeters( 5 ) -- Not more then 5 NM astern of boat. Should be LIG call anyway. - self.Abeam.Xmax = UTILS.NMToMeters( 5 ) -- Not more then 5 NM ahead of boat. - self.Abeam.Zmin = -UTILS.NMToMeters( 2 ) -- Not more than 2 NM port. - self.Abeam.Zmax = 500 -- Not more than 500 m starboard. Must be port! - self.Abeam.LimitXmin = -200 -- Check and next step 200 meters behind the ship. - self.Abeam.LimitXmax = nil - self.Abeam.LimitZmin = nil - self.Abeam.LimitZmax = nil - - -- At the Ninety. - self.Ninety.name = "Ninety" - self.Ninety.Xmin = -UTILS.NMToMeters( 4 ) -- Not more than 4 NM behind the boat. LIG check anyway. - self.Ninety.Xmax = 0 -- Must be behind the boat. - self.Ninety.Zmin = -UTILS.NMToMeters( 2 ) -- Not more than 2 NM port of boat. - self.Ninety.Zmax = nil - self.Ninety.LimitXmin = nil - self.Ninety.LimitXmax = nil - self.Ninety.LimitZmin = nil - self.Ninety.LimitZmax = -UTILS.NMToMeters( 0.6 ) -- Check and next step when 0.6 NM port. - - -- At the Wake. - self.Wake.name = "Wake" - self.Wake.Xmin = -UTILS.NMToMeters( 4 ) -- Not more than 4 NM behind the boat. - self.Wake.Xmax = 0 -- Must be behind the boat. - self.Wake.Zmin = -2000 -- Not more than 2 km port of boat. - self.Wake.Zmax = nil - self.Wake.LimitXmin = nil - self.Wake.LimitXmax = nil - self.Wake.LimitZmin = 0 -- Check and next step when directly behind the boat. - self.Wake.LimitZmax = nil - - -- Turn to final. - self.Final.name = "Final" - self.Final.Xmin = -UTILS.NMToMeters( 4 ) -- Not more than 4 NM behind the boat. - self.Final.Xmax = 0 -- Must be behind the boat. - self.Final.Zmin = -2000 -- Not more than 2 km port. - self.Final.Zmax = nil - self.Final.LimitXmin = nil -- No limits. Check is carried out differently. - self.Final.LimitXmax = nil - self.Final.LimitZmin = nil - self.Final.LimitZmax = nil - - -- In the Groove. - self.Groove.name = "Groove" - self.Groove.Xmin = -UTILS.NMToMeters( 4 ) -- Not more than 4 NM behind the boat. - self.Groove.Xmax = nil - self.Groove.Zmin = -UTILS.NMToMeters( 2 ) -- Not more than 2 NM port - self.Groove.Zmax = UTILS.NMToMeters( 2 ) -- Not more than 2 NM starboard. - self.Groove.LimitXmin = nil -- No limits. Check is carried out differently. - self.Groove.LimitXmax = nil - self.Groove.LimitZmin = nil - self.Groove.LimitZmax = nil - -end - ---- Init parameters for Nimitz class super carriers. --- @param #AIRBOSS self -function AIRBOSS:_InitNimitz() - - -- Init Stennis as default. + end + function AIRBOSS:_InitStennis() + self.carrierparam.sterndist=-153 + self.carrierparam.deckheight=18.30 + self.carrierparam.totlength=310 + self.carrierparam.totwidthport=40 + self.carrierparam.totwidthstarboard=30 + self.carrierparam.rwyangle=-9.1359 + self.carrierparam.rwylength=225 + self.carrierparam.rwywidth=20 + self.carrierparam.wire1=46 + self.carrierparam.wire2=46+12 + self.carrierparam.wire3=46+24 + self.carrierparam.wire4=46+35 + self.carrierparam.landingdist=self.carrierparam.sterndist+self.carrierparam.wire3 + self.Platform.name="Platform 5k" + self.Platform.Xmin=-UTILS.NMToMeters(22) + self.Platform.Xmax=nil + self.Platform.Zmin=-UTILS.NMToMeters(30) + self.Platform.Zmax=UTILS.NMToMeters(30) + self.Platform.LimitXmin=nil + self.Platform.LimitXmax=nil + self.Platform.LimitZmin=nil + self.Platform.LimitZmax=nil + self.DirtyUp.name="Dirty Up" + self.DirtyUp.Xmin=-UTILS.NMToMeters(21) + self.DirtyUp.Xmax=nil + self.DirtyUp.Zmin=-UTILS.NMToMeters(30) + self.DirtyUp.Zmax=UTILS.NMToMeters(30) + self.DirtyUp.LimitXmin=nil + self.DirtyUp.LimitXmax=nil + self.DirtyUp.LimitZmin=nil + self.DirtyUp.LimitZmax=nil + self.Bullseye.name="Bullseye" + self.Bullseye.Xmin=-UTILS.NMToMeters(11) + self.Bullseye.Xmax=nil + self.Bullseye.Zmin=-UTILS.NMToMeters(30) + self.Bullseye.Zmax=UTILS.NMToMeters(30) + self.Bullseye.LimitXmin=nil + self.Bullseye.LimitXmax=nil + self.Bullseye.LimitZmin=nil + self.Bullseye.LimitZmax=nil + self.BreakEntry.name="Break Entry" + self.BreakEntry.Xmin=-UTILS.NMToMeters(4) + self.BreakEntry.Xmax=nil + self.BreakEntry.Zmin=-UTILS.NMToMeters(0.5) + self.BreakEntry.Zmax=UTILS.NMToMeters(1.5) + self.BreakEntry.LimitXmin=0 + self.BreakEntry.LimitXmax=nil + self.BreakEntry.LimitZmin=nil + self.BreakEntry.LimitZmax=nil + self.BreakEarly.name="Early Break" + self.BreakEarly.Xmin=-UTILS.NMToMeters(1) + self.BreakEarly.Xmax=UTILS.NMToMeters(5) + self.BreakEarly.Zmin=-UTILS.NMToMeters(2) + self.BreakEarly.Zmax=UTILS.NMToMeters(1) + self.BreakEarly.LimitXmin=0 + self.BreakEarly.LimitXmax=nil + self.BreakEarly.LimitZmin=-UTILS.NMToMeters(0.2) + self.BreakEarly.LimitZmax=nil + self.BreakLate.name="Late Break" + self.BreakLate.Xmin=-UTILS.NMToMeters(1) + self.BreakLate.Xmax=UTILS.NMToMeters(5) + self.BreakLate.Zmin=-UTILS.NMToMeters(2) + self.BreakLate.Zmax=UTILS.NMToMeters(1) + self.BreakLate.LimitXmin=0 + self.BreakLate.LimitXmax=nil + self.BreakLate.LimitZmin=-UTILS.NMToMeters(0.8) + self.BreakLate.LimitZmax=nil + self.Abeam.name="Abeam Position" + self.Abeam.Xmin=-UTILS.NMToMeters(5) + self.Abeam.Xmax=UTILS.NMToMeters(5) + self.Abeam.Zmin=-UTILS.NMToMeters(2) + self.Abeam.Zmax=500 + self.Abeam.LimitXmin=-200 + self.Abeam.LimitXmax=nil + self.Abeam.LimitZmin=nil + self.Abeam.LimitZmax=nil + self.Ninety.name="Ninety" + self.Ninety.Xmin=-UTILS.NMToMeters(4) + self.Ninety.Xmax=0 + self.Ninety.Zmin=-UTILS.NMToMeters(2) + self.Ninety.Zmax=nil + self.Ninety.LimitXmin=nil + self.Ninety.LimitXmax=nil + self.Ninety.LimitZmin=nil + self.Ninety.LimitZmax=-UTILS.NMToMeters(0.6) + self.Wake.name="Wake" + self.Wake.Xmin=-UTILS.NMToMeters(4) + self.Wake.Xmax=0 + self.Wake.Zmin=-2000 + self.Wake.Zmax=nil + self.Wake.LimitXmin=nil + self.Wake.LimitXmax=nil + self.Wake.LimitZmin=0 + self.Wake.LimitZmax=nil + self.Final.name="Final" + self.Final.Xmin=-UTILS.NMToMeters(4) + self.Final.Xmax=0 + self.Final.Zmin=-2000 + self.Final.Zmax=nil + self.Final.LimitXmin=nil + self.Final.LimitXmax=nil + self.Final.LimitZmin=nil + self.Final.LimitZmax=nil + self.Groove.name="Groove" + self.Groove.Xmin=-UTILS.NMToMeters(4) + self.Groove.Xmax=nil + self.Groove.Zmin=-UTILS.NMToMeters(2) + self.Groove.Zmax=UTILS.NMToMeters(2) + self.Groove.LimitXmin=nil + self.Groove.LimitXmax=nil + self.Groove.LimitZmin=nil + self.Groove.LimitZmax=nil + end + function AIRBOSS:_InitNimitz() self:_InitStennis() - - -- Carrier Parameters. - self.carrierparam.sterndist = -164 - self.carrierparam.deckheight = 20.1494 -- DCS World OpenBeta\CoreMods\tech\USS_Nimitz\Database\USS_CVN_7X.lua - - -- Total size of the carrier (approx as rectangle). - self.carrierparam.totlength = 332.8 -- Wiki says 332.8 meters overall length. - self.carrierparam.totwidthport = 45 -- Wiki says 76.8 meters overall beam. - self.carrierparam.totwidthstarboard = 35 - - -- Landing runway. - self.carrierparam.rwyangle = -9.1359 -- DCS World OpenBeta\CoreMods\tech\USS_Nimitz\scripts\USS_Nimitz_RunwaysAndRoutes.lua - self.carrierparam.rwylength = 250 - self.carrierparam.rwywidth = 25 - - -- Wires. - self.carrierparam.wire1 = 55 -- Distance from stern to first wire. - self.carrierparam.wire2 = 67 - self.carrierparam.wire3 = 79 - self.carrierparam.wire4 = 92 - - -- Landing distance. - self.carrierparam.landingdist = self.carrierparam.sterndist+self.carrierparam.wire3 - -end - ---- Init parameters for Forrestal class super carriers. --- @param #AIRBOSS self -function AIRBOSS:_InitForrestal() - - -- Init Nimitz as default. + self.carrierparam.sterndist=-164 + self.carrierparam.deckheight=20.1494 + self.carrierparam.totlength=332.8 + self.carrierparam.totwidthport=45 + self.carrierparam.totwidthstarboard=35 + self.carrierparam.rwyangle=-9.1359 + self.carrierparam.rwylength=250 + self.carrierparam.rwywidth=25 + self.carrierparam.wire1=55 + self.carrierparam.wire2=67 + self.carrierparam.wire3=79 + self.carrierparam.wire4=92 + self.carrierparam.landingdist=self.carrierparam.sterndist+self.carrierparam.wire3 + end + function AIRBOSS:_InitForrestal() self:_InitNimitz() - - -- Carrier Parameters. - self.carrierparam.sterndist = -135.5 - self.carrierparam.deckheight = 20 -- 20.1494 --DCS World OpenBeta\CoreMods\tech\USS_Nimitz\Database\USS_CVN_7X.lua - - -- Total size of the carrier (approx as rectangle). - self.carrierparam.totlength = 315 -- Wiki says 325 meters overall length. - self.carrierparam.totwidthport = 45 -- Wiki says 73 meters overall beam. - self.carrierparam.totwidthstarboard = 35 - - -- Landing runway. - self.carrierparam.rwyangle = -9.1359 -- DCS World OpenBeta\CoreMods\tech\USS_Nimitz\scripts\USS_Nimitz_RunwaysAndRoutes.lua - self.carrierparam.rwylength = 212 - self.carrierparam.rwywidth = 25 - - -- Wires. - self.carrierparam.wire1 = 44 -- Distance from stern to first wire. Original from Frank - 42 - self.carrierparam.wire2 = 54 -- 51.5 - self.carrierparam.wire3 = 64 -- 62 - self.carrierparam.wire4 = 74 -- 72.5 - - -- Landing distance. - self.carrierparam.landingdist = self.carrierparam.sterndist+self.carrierparam.wire3 - -end - ---- Init parameters for R12 HMS Hermes carrier. --- @param #AIRBOSS self -function AIRBOSS:_InitHermes() - - -- Init Stennis as default. + self.carrierparam.sterndist=-135.5 + self.carrierparam.deckheight=20 + self.carrierparam.totlength=315 + self.carrierparam.totwidthport=45 + self.carrierparam.totwidthstarboard=35 + self.carrierparam.rwyangle=-9.1359 + self.carrierparam.rwylength=212 + self.carrierparam.rwywidth=25 + self.carrierparam.wire1=44 + self.carrierparam.wire2=54 + self.carrierparam.wire3=64 + self.carrierparam.wire4=74 + self.carrierparam.landingdist=self.carrierparam.sterndist+self.carrierparam.wire3 + end + function AIRBOSS:_InitHermes() self:_InitStennis() - - -- Carrier Parameters. - self.carrierparam.sterndist = -105 - self.carrierparam.deckheight = 12 -- From model viewer WL0. - - -- Total size of the carrier (approx as rectangle). - self.carrierparam.totlength = 228.19 - self.carrierparam.totwidthport = 20.5 - self.carrierparam.totwidthstarboard = 24.5 - - -- Landing runway. - self.carrierparam.rwyangle = 0 - self.carrierparam.rwylength = 215 - self.carrierparam.rwywidth = 13 - - -- Wires. - self.carrierparam.wire1 = nil - self.carrierparam.wire2 = nil - self.carrierparam.wire3 = nil - self.carrierparam.wire4 = nil - - -- Distance to landing spot. + self.carrierparam.sterndist=-105 + self.carrierparam.deckheight=12 + self.carrierparam.totlength=228.19 + self.carrierparam.totwidthport=20.5 + self.carrierparam.totwidthstarboard=24.5 + self.carrierparam.rwyangle=0 + self.carrierparam.rwylength=215 + self.carrierparam.rwywidth=13 + self.carrierparam.wire1=nil + self.carrierparam.wire2=nil + self.carrierparam.wire3=nil + self.carrierparam.wire4=nil self.carrierparam.landingspot=69 - - -- Landing distance. - self.carrierparam.landingdist = self.carrierparam.sterndist+self.carrierparam.landingspot - - -- Late break. - self.BreakLate.name = "Late Break" - self.BreakLate.Xmin = -UTILS.NMToMeters( 1 ) -- Not more than 1 NM behind the boat. Last check was at 0. - self.BreakLate.Xmax = UTILS.NMToMeters( 5 ) -- Not more than 5 NM in front of the boat. Enough for late breaks? - self.BreakLate.Zmin = -UTILS.NMToMeters( 1.6 ) -- Not more than 1.6 NM port. - self.BreakLate.Zmax = UTILS.NMToMeters( 1 ) -- Not more than 1 NM starboard. - self.BreakLate.LimitXmin = 0 -- Check and next step 0.8 NM port and in front of boat. - self.BreakLate.LimitXmax = nil - self.BreakLate.LimitZmin = -UTILS.NMToMeters( 0.5 ) -- 926 m port, closer than the stennis as abeam is 0.8-1.0 rather than 1.2 - self.BreakLate.LimitZmax = nil - -end - ---- Init parameters for R05 HMS Invincible carrier. --- @param #AIRBOSS self -function AIRBOSS:_InitInvincible() - - -- Init Stennis as default. + self.carrierparam.landingdist=self.carrierparam.sterndist+self.carrierparam.landingspot + self.BreakLate.name="Late Break" + self.BreakLate.Xmin=-UTILS.NMToMeters(1) + self.BreakLate.Xmax=UTILS.NMToMeters(5) + self.BreakLate.Zmin=-UTILS.NMToMeters(1.6) + self.BreakLate.Zmax=UTILS.NMToMeters(1) + self.BreakLate.LimitXmin=0 + self.BreakLate.LimitXmax=nil + self.BreakLate.LimitZmin=-UTILS.NMToMeters(0.5) + self.BreakLate.LimitZmax=nil + end + function AIRBOSS:_InitInvincible() self:_InitStennis() - - -- Carrier Parameters. - self.carrierparam.sterndist = -105 - self.carrierparam.deckheight = 12 -- From model viewer WL0. - - -- Total size of the carrier (approx as rectangle). - self.carrierparam.totlength = 228.19 - self.carrierparam.totwidthport = 20.5 - self.carrierparam.totwidthstarboard = 24.5 - - -- Landing runway. - self.carrierparam.rwyangle = 0 - self.carrierparam.rwylength = 215 - self.carrierparam.rwywidth = 13 - - -- Wires. - self.carrierparam.wire1 = nil - self.carrierparam.wire2 = nil - self.carrierparam.wire3 = nil - self.carrierparam.wire4 = nil - - -- Distance to landing spot. + self.carrierparam.sterndist=-105 + self.carrierparam.deckheight=12 + self.carrierparam.totlength=228.19 + self.carrierparam.totwidthport=20.5 + self.carrierparam.totwidthstarboard=24.5 + self.carrierparam.rwyangle=0 + self.carrierparam.rwylength=215 + self.carrierparam.rwywidth=13 + self.carrierparam.wire1=nil + self.carrierparam.wire2=nil + self.carrierparam.wire3=nil + self.carrierparam.wire4=nil self.carrierparam.landingspot=69 - - -- Landing distance. - self.carrierparam.landingdist = self.carrierparam.sterndist+self.carrierparam.landingspot - - -- Late break. - self.BreakLate.name = "Late Break" - self.BreakLate.Xmin = -UTILS.NMToMeters( 1 ) -- Not more than 1 NM behind the boat. Last check was at 0. - self.BreakLate.Xmax = UTILS.NMToMeters( 5 ) -- Not more than 5 NM in front of the boat. Enough for late breaks? - self.BreakLate.Zmin = -UTILS.NMToMeters( 1.6 ) -- Not more than 1.6 NM port. - self.BreakLate.Zmax = UTILS.NMToMeters( 1 ) -- Not more than 1 NM starboard. - self.BreakLate.LimitXmin = 0 -- Check and next step 0.8 NM port and in front of boat. - self.BreakLate.LimitXmax = nil - self.BreakLate.LimitZmin = -UTILS.NMToMeters( 0.5 ) -- 926 m port, closer than the stennis as abeam is 0.8-1.0 rather than 1.2 - self.BreakLate.LimitZmax = nil - -end - ---- Init parameters for LHA-1 Tarawa carrier. --- @param #AIRBOSS self -function AIRBOSS:_InitTarawa() - - -- Init Stennis as default. + self.carrierparam.landingdist=self.carrierparam.sterndist+self.carrierparam.landingspot + self.BreakLate.name="Late Break" + self.BreakLate.Xmin=-UTILS.NMToMeters(1) + self.BreakLate.Xmax=UTILS.NMToMeters(5) + self.BreakLate.Zmin=-UTILS.NMToMeters(1.6) + self.BreakLate.Zmax=UTILS.NMToMeters(1) + self.BreakLate.LimitXmin=0 + self.BreakLate.LimitXmax=nil + self.BreakLate.LimitZmin=-UTILS.NMToMeters(0.5) + self.BreakLate.LimitZmax=nil + end + function AIRBOSS:_InitTarawa() self:_InitStennis() - - -- Carrier Parameters. - self.carrierparam.sterndist = -125 - self.carrierparam.deckheight = 21 -- 69 ft - - -- Total size of the carrier (approx as rectangle). - self.carrierparam.totlength = 245 - self.carrierparam.totwidthport = 10 - self.carrierparam.totwidthstarboard = 25 - - -- Landing runway. - self.carrierparam.rwyangle = 0 - self.carrierparam.rwylength = 225 - self.carrierparam.rwywidth = 15 - - -- Wires. - self.carrierparam.wire1 = nil - self.carrierparam.wire2 = nil - self.carrierparam.wire3 = nil - self.carrierparam.wire4 = nil - - -- Distance to landing spot. + self.carrierparam.sterndist=-125 + self.carrierparam.deckheight=21 + self.carrierparam.totlength=245 + self.carrierparam.totwidthport=10 + self.carrierparam.totwidthstarboard=25 + self.carrierparam.rwyangle=0 + self.carrierparam.rwylength=225 + self.carrierparam.rwywidth=15 + self.carrierparam.wire1=nil + self.carrierparam.wire2=nil + self.carrierparam.wire3=nil + self.carrierparam.wire4=nil self.carrierparam.landingspot=57 - - -- Landing distance. - self.carrierparam.landingdist = self.carrierparam.sterndist+self.carrierparam.landingspot - - -- Late break. - self.BreakLate.name = "Late Break" - self.BreakLate.Xmin = -UTILS.NMToMeters( 1 ) -- Not more than 1 NM behind the boat. Last check was at 0. - self.BreakLate.Xmax = UTILS.NMToMeters( 5 ) -- Not more than 5 NM in front of the boat. Enough for late breaks? - self.BreakLate.Zmin = -UTILS.NMToMeters( 1.6 ) -- Not more than 1.6 NM port. - self.BreakLate.Zmax = UTILS.NMToMeters( 1 ) -- Not more than 1 NM starboard. - self.BreakLate.LimitXmin = 0 -- Check and next step 0.8 NM port and in front of boat. - self.BreakLate.LimitXmax = nil - self.BreakLate.LimitZmin = -UTILS.NMToMeters( 0.5 ) -- 926 m port, closer than the stennis as abeam is 0.8-1.0 rather than 1.2 - self.BreakLate.LimitZmax = nil - -end - ---- Init parameters for LHA-6 America carrier. --- @param #AIRBOSS self -function AIRBOSS:_InitAmerica() - - -- Init Stennis as default. + self.carrierparam.landingdist=self.carrierparam.sterndist+self.carrierparam.landingspot + self.BreakLate.name="Late Break" + self.BreakLate.Xmin=-UTILS.NMToMeters(1) + self.BreakLate.Xmax=UTILS.NMToMeters(5) + self.BreakLate.Zmin=-UTILS.NMToMeters(1.6) + self.BreakLate.Zmax=UTILS.NMToMeters(1) + self.BreakLate.LimitXmin=0 + self.BreakLate.LimitXmax=nil + self.BreakLate.LimitZmin=-UTILS.NMToMeters(0.5) + self.BreakLate.LimitZmax=nil + end + function AIRBOSS:_InitAmerica() self:_InitStennis() - - -- Carrier Parameters. - self.carrierparam.sterndist = -125 - self.carrierparam.deckheight = 20 -- 67 ft - - -- Total size of the carrier (approx as rectangle). - self.carrierparam.totlength = 257 - self.carrierparam.totwidthport = 11 - self.carrierparam.totwidthstarboard = 25 - - -- Landing runway. - self.carrierparam.rwyangle = 0 - self.carrierparam.rwylength = 240 - self.carrierparam.rwywidth = 15 - - -- Wires. - self.carrierparam.wire1 = nil - self.carrierparam.wire2 = nil - self.carrierparam.wire3 = nil - self.carrierparam.wire4 = nil - - -- Distance to landing spot. + self.carrierparam.sterndist=-125 + self.carrierparam.deckheight=20 + self.carrierparam.totlength=257 + self.carrierparam.totwidthport=11 + self.carrierparam.totwidthstarboard=25 + self.carrierparam.rwyangle=0 + self.carrierparam.rwylength=240 + self.carrierparam.rwywidth=15 + self.carrierparam.wire1=nil + self.carrierparam.wire2=nil + self.carrierparam.wire3=nil + self.carrierparam.wire4=nil self.carrierparam.landingspot=59 - - -- Landing distance. - self.carrierparam.landingdist = self.carrierparam.sterndist+self.carrierparam.landingspot - - -- Late break. - self.BreakLate.name = "Late Break" - self.BreakLate.Xmin = -UTILS.NMToMeters( 1 ) -- Not more than 1 NM behind the boat. Last check was at 0. - self.BreakLate.Xmax = UTILS.NMToMeters( 5 ) -- Not more than 5 NM in front of the boat. Enough for late breaks? - self.BreakLate.Zmin = -UTILS.NMToMeters( 1.6 ) -- Not more than 1.6 NM port. - self.BreakLate.Zmax = UTILS.NMToMeters( 1 ) -- Not more than 1 NM starboard. - self.BreakLate.LimitXmin = 0 -- Check and next step 0.8 NM port and in front of boat. - self.BreakLate.LimitXmax = nil - self.BreakLate.LimitZmin = -UTILS.NMToMeters( 0.5 ) -- 926 m port, closer than the stennis as abeam is 0.8-1.0 rather than 1.2 - self.BreakLate.LimitZmax = nil - -end - ---- Init parameters for L61 Juan Carlos carrier. --- @param #AIRBOSS self -function AIRBOSS:_InitJcarlos() - - -- Init Stennis as default. + self.carrierparam.landingdist=self.carrierparam.sterndist+self.carrierparam.landingspot + self.BreakLate.name="Late Break" + self.BreakLate.Xmin=-UTILS.NMToMeters(1) + self.BreakLate.Xmax=UTILS.NMToMeters(5) + self.BreakLate.Zmin=-UTILS.NMToMeters(1.6) + self.BreakLate.Zmax=UTILS.NMToMeters(1) + self.BreakLate.LimitXmin=0 + self.BreakLate.LimitXmax=nil + self.BreakLate.LimitZmin=-UTILS.NMToMeters(0.5) + self.BreakLate.LimitZmax=nil + end + function AIRBOSS:_InitJcarlos() self:_InitStennis() - - -- Carrier Parameters. - self.carrierparam.sterndist = -125 - self.carrierparam.deckheight = 20 -- 67 ft - - -- Total size of the carrier (approx as rectangle). - self.carrierparam.totlength = 231 - self.carrierparam.totwidthport = 10 - self.carrierparam.totwidthstarboard = 22 - - -- Landing runway. - self.carrierparam.rwyangle = 0 - self.carrierparam.rwylength = 202 - self.carrierparam.rwywidth = 14 - - -- Wires. - self.carrierparam.wire1 = nil - self.carrierparam.wire2 = nil - self.carrierparam.wire3 = nil - self.carrierparam.wire4 = nil - - -- Distance to landing spot. + self.carrierparam.sterndist=-125 + self.carrierparam.deckheight=20 + self.carrierparam.totlength=231 + self.carrierparam.totwidthport=10 + self.carrierparam.totwidthstarboard=22 + self.carrierparam.rwyangle=0 + self.carrierparam.rwylength=202 + self.carrierparam.rwywidth=14 + self.carrierparam.wire1=nil + self.carrierparam.wire2=nil + self.carrierparam.wire3=nil + self.carrierparam.wire4=nil self.carrierparam.landingspot=89 - - -- Landing distance. - self.carrierparam.landingdist = self.carrierparam.sterndist+self.carrierparam.landingspot - - -- Late break. - self.BreakLate.name = "Late Break" - self.BreakLate.Xmin = -UTILS.NMToMeters( 1 ) -- Not more than 1 NM behind the boat. Last check was at 0. - self.BreakLate.Xmax = UTILS.NMToMeters( 5 ) -- Not more than 5 NM in front of the boat. Enough for late breaks? - self.BreakLate.Zmin = -UTILS.NMToMeters( 1.6 ) -- Not more than 1.6 NM port. - self.BreakLate.Zmax = UTILS.NMToMeters( 1 ) -- Not more than 1 NM starboard. - self.BreakLate.LimitXmin = 0 -- Check and next step 0.8 NM port and in front of boat. - self.BreakLate.LimitXmax = nil - self.BreakLate.LimitZmin = -UTILS.NMToMeters( 0.5 ) -- 926 m port, closer than the stennis as abeam is 0.8-1.0 rather than 1.2 - self.BreakLate.LimitZmax = nil - -end - ---- Init parameters for L02 Canberra carrier. --- @param #AIRBOSS self -function AIRBOSS:_InitCanberra() - - -- Init Juan Carlos as default. - self:_InitJcarlos() - -end - ---- Init parameters for Marshal Voice overs *Gabriella* by HighwaymanEd. --- @param #AIRBOSS self --- @param #string mizfolder (Optional) Folder within miz file where the sound files are located. -function AIRBOSS:SetVoiceOversMarshalByGabriella( mizfolder ) - - -- Set sound files folder. - if mizfolder then - local lastchar = string.sub( mizfolder, -1 ) - if lastchar ~= "/" then - mizfolder = mizfolder .. "/" - end - self.soundfolderMSH = mizfolder - else - -- Default is the general folder. - self.soundfolderMSH = self.soundfolder + self.carrierparam.landingdist=self.carrierparam.sterndist+self.carrierparam.landingspot + self.BreakLate.name="Late Break" + self.BreakLate.Xmin=-UTILS.NMToMeters(1) + self.BreakLate.Xmax=UTILS.NMToMeters(5) + self.BreakLate.Zmin=-UTILS.NMToMeters(1.6) + self.BreakLate.Zmax=UTILS.NMToMeters(1) + self.BreakLate.LimitXmin=0 + self.BreakLate.LimitXmax=nil + self.BreakLate.LimitZmin=-UTILS.NMToMeters(0.5) + self.BreakLate.LimitZmax=nil end - - -- Report for duty. - self:I( self.lid .. string.format( "Marshal Gabriella reporting for duty! Soundfolder=%s", tostring( self.soundfolderMSH ) ) ) - - self.MarshalCall.AFFIRMATIVE.duration = 0.65 - self.MarshalCall.ALTIMETER.duration = 0.60 - self.MarshalCall.BRC.duration = 0.67 - self.MarshalCall.CARRIERTURNTOHEADING.duration = 1.62 - self.MarshalCall.CASE.duration = 0.30 - self.MarshalCall.CHARLIETIME.duration = 0.77 - self.MarshalCall.CLEAREDFORRECOVERY.duration = 0.93 - self.MarshalCall.DECKCLOSED.duration = 0.73 - self.MarshalCall.DEGREES.duration = 0.48 - self.MarshalCall.EXPECTED.duration = 0.50 - self.MarshalCall.FLYNEEDLES.duration = 0.89 - self.MarshalCall.HOLDATANGELS.duration = 0.81 - self.MarshalCall.HOURS.duration = 0.41 - self.MarshalCall.MARSHALRADIAL.duration = 0.95 - self.MarshalCall.N0.duration = 0.41 - self.MarshalCall.N1.duration = 0.30 - self.MarshalCall.N2.duration = 0.34 - self.MarshalCall.N3.duration = 0.31 - self.MarshalCall.N4.duration = 0.34 - self.MarshalCall.N5.duration = 0.30 - self.MarshalCall.N6.duration = 0.33 - self.MarshalCall.N7.duration = 0.38 - self.MarshalCall.N8.duration = 0.35 - self.MarshalCall.N9.duration = 0.35 - self.MarshalCall.NEGATIVE.duration = 0.60 - self.MarshalCall.NEWFB.duration = 0.95 - self.MarshalCall.OPS.duration = 0.23 - self.MarshalCall.POINT.duration = 0.38 - self.MarshalCall.RADIOCHECK.duration = 1.27 - self.MarshalCall.RECOVERY.duration = 0.60 - self.MarshalCall.RECOVERYOPSSTOPPED.duration = 1.25 - self.MarshalCall.RECOVERYPAUSEDNOTICE.duration = 2.55 - self.MarshalCall.RECOVERYPAUSEDRESUMED.duration = 2.55 - self.MarshalCall.REPORTSEEME.duration = 0.87 - self.MarshalCall.RESUMERECOVERY.duration = 1.55 - self.MarshalCall.ROGER.duration = 0.50 - self.MarshalCall.SAYNEEDLES.duration = 0.82 - self.MarshalCall.STACKFULL.duration = 5.70 - self.MarshalCall.STARTINGRECOVERY.duration = 1.61 - -end - ---- Init parameters for Marshal Voice overs by *Raynor*. --- @param #AIRBOSS self --- @param #string mizfolder (Optional) Folder within miz file where the sound files are located. -function AIRBOSS:SetVoiceOversMarshalByRaynor( mizfolder ) - - -- Set sound files folder. - if mizfolder then - local lastchar = string.sub( mizfolder, -1 ) - if lastchar ~= "/" then - mizfolder = mizfolder .. "/" - end - self.soundfolderMSH = mizfolder - else - -- Default is the general folder. - self.soundfolderMSH = self.soundfolder + function AIRBOSS:_InitCanberra() + self:_InitJcarlos() end - - -- Report for duty. - self:I( self.lid .. string.format( "Marshal Raynor reporting for duty! Soundfolder=%s", tostring( self.soundfolderMSH ) ) ) - - self.MarshalCall.AFFIRMATIVE.duration = 0.70 - self.MarshalCall.ALTIMETER.duration = 0.60 - self.MarshalCall.BRC.duration = 0.60 - self.MarshalCall.CARRIERTURNTOHEADING.duration = 1.87 - self.MarshalCall.CASE.duration = 0.60 - self.MarshalCall.CHARLIETIME.duration = 0.81 - self.MarshalCall.CLEAREDFORRECOVERY.duration = 1.21 - self.MarshalCall.DECKCLOSED.duration = 0.86 - self.MarshalCall.DEGREES.duration = 0.55 - self.MarshalCall.EXPECTED.duration = 0.61 - self.MarshalCall.FLYNEEDLES.duration = 0.90 - self.MarshalCall.HOLDATANGELS.duration = 0.91 - self.MarshalCall.HOURS.duration = 0.54 - self.MarshalCall.MARSHALRADIAL.duration = 0.80 - self.MarshalCall.N0.duration = 0.38 - self.MarshalCall.N1.duration = 0.30 - self.MarshalCall.N2.duration = 0.30 - self.MarshalCall.N3.duration = 0.30 - self.MarshalCall.N4.duration = 0.32 - self.MarshalCall.N5.duration = 0.41 - self.MarshalCall.N6.duration = 0.48 - self.MarshalCall.N7.duration = 0.51 - self.MarshalCall.N8.duration = 0.38 - self.MarshalCall.N9.duration = 0.34 - self.MarshalCall.NEGATIVE.duration = 0.60 - self.MarshalCall.NEWFB.duration = 1.10 - self.MarshalCall.OPS.duration = 0.46 - self.MarshalCall.POINT.duration = 0.21 - self.MarshalCall.RADIOCHECK.duration = 0.95 - self.MarshalCall.RECOVERY.duration = 0.63 - self.MarshalCall.RECOVERYOPSSTOPPED.duration = 1.36 - self.MarshalCall.RECOVERYPAUSEDNOTICE.duration = 2.8 -- Strangely the file is actually a shorter ~2.4 sec. - self.MarshalCall.RECOVERYPAUSEDRESUMED.duration = 2.75 - self.MarshalCall.REPORTSEEME.duration = 1.06 -- 0.96 - self.MarshalCall.RESUMERECOVERY.duration = 1.41 - self.MarshalCall.ROGER.duration = 0.41 - self.MarshalCall.SAYNEEDLES.duration = 0.79 - self.MarshalCall.STACKFULL.duration = 4.70 - self.MarshalCall.STARTINGRECOVERY.duration = 2.06 - -end - ---- Set parameters for LSO Voice overs by *Raynor*. --- @param #AIRBOSS self --- @param #string mizfolder (Optional) Folder within miz file where the sound files are located. -function AIRBOSS:SetVoiceOversLSOByRaynor( mizfolder ) - - -- Set sound files folder. + function AIRBOSS:SetVoiceOversMarshalByGabriella(mizfolder) if mizfolder then - local lastchar = string.sub( mizfolder, -1 ) - if lastchar ~= "/" then - mizfolder = mizfolder .. "/" - end - self.soundfolderLSO = mizfolder - else - -- Default is the general folder. - self.soundfolderLSO = self.soundfolder + local lastchar=string.sub(mizfolder,-1) + if lastchar~="/"then + mizfolder=mizfolder.."/" end - - -- Report for duty. - self:I( self.lid .. string.format( "LSO Raynor reporting for duty! Soundfolder=%s", tostring( self.soundfolderLSO ) ) ) - - self.LSOCall.BOLTER.duration = 0.75 - self.LSOCall.CALLTHEBALL.duration = 0.625 - self.LSOCall.CHECK.duration = 0.40 - self.LSOCall.CLEAREDTOLAND.duration = 0.85 - self.LSOCall.COMELEFT.duration = 0.60 - self.LSOCall.DEPARTANDREENTER.duration = 1.10 - self.LSOCall.EXPECTHEAVYWAVEOFF.duration = 1.30 - self.LSOCall.EXPECTSPOT75.duration = 1.85 - self.LSOCall.EXPECTSPOT5.duration = 1.3 - self.LSOCall.FAST.duration = 0.75 - self.LSOCall.FOULDECK.duration = 0.75 - self.LSOCall.HIGH.duration = 0.65 - self.LSOCall.IDLE.duration = 0.40 - self.LSOCall.LONGINGROOVE.duration = 1.25 - self.LSOCall.LOW.duration = 0.60 - self.LSOCall.N0.duration = 0.38 - self.LSOCall.N1.duration = 0.30 - self.LSOCall.N2.duration = 0.30 - self.LSOCall.N3.duration = 0.30 - self.LSOCall.N4.duration = 0.32 - self.LSOCall.N5.duration = 0.41 - self.LSOCall.N6.duration = 0.48 - self.LSOCall.N7.duration = 0.51 - self.LSOCall.N8.duration = 0.38 - self.LSOCall.N9.duration = 0.34 - self.LSOCall.PADDLESCONTACT.duration = 0.91 - self.LSOCall.POWER.duration = 0.45 - self.LSOCall.RADIOCHECK.duration = 0.90 - self.LSOCall.RIGHTFORLINEUP.duration = 0.70 - self.LSOCall.ROGERBALL.duration = 0.72 - self.LSOCall.SLOW.duration = 0.63 - -- self.LSOCall.SLOW.duration=0.59 --TODO - self.LSOCall.STABILIZED.duration = 0.75 - self.LSOCall.WAVEOFF.duration = 0.55 - self.LSOCall.WELCOMEABOARD.duration = 0.80 -end - ---- Set parameters for LSO Voice overs by *funkyfranky*. --- @param #AIRBOSS self --- @param #string mizfolder (Optional) Folder within miz file where the sound files are located. -function AIRBOSS:SetVoiceOversLSOByFF( mizfolder ) - - -- Set sound files folder. + self.soundfolderMSH=mizfolder + else + self.soundfolderMSH=self.soundfolder + end + self:I(self.lid..string.format("Marshal Gabriella reporting for duty! Soundfolder=%s",tostring(self.soundfolderMSH))) + self.MarshalCall.AFFIRMATIVE.duration=0.65 + self.MarshalCall.ALTIMETER.duration=0.60 + self.MarshalCall.BRC.duration=0.67 + self.MarshalCall.CARRIERTURNTOHEADING.duration=1.62 + self.MarshalCall.CASE.duration=0.30 + self.MarshalCall.CHARLIETIME.duration=0.77 + self.MarshalCall.CLEAREDFORRECOVERY.duration=0.93 + self.MarshalCall.DECKCLOSED.duration=0.73 + self.MarshalCall.DEGREES.duration=0.48 + self.MarshalCall.EXPECTED.duration=0.50 + self.MarshalCall.FLYNEEDLES.duration=0.89 + self.MarshalCall.HOLDATANGELS.duration=0.81 + self.MarshalCall.HOURS.duration=0.41 + self.MarshalCall.MARSHALRADIAL.duration=0.95 + self.MarshalCall.N0.duration=0.41 + self.MarshalCall.N1.duration=0.30 + self.MarshalCall.N2.duration=0.34 + self.MarshalCall.N3.duration=0.31 + self.MarshalCall.N4.duration=0.34 + self.MarshalCall.N5.duration=0.30 + self.MarshalCall.N6.duration=0.33 + self.MarshalCall.N7.duration=0.38 + self.MarshalCall.N8.duration=0.35 + self.MarshalCall.N9.duration=0.35 + self.MarshalCall.NEGATIVE.duration=0.60 + self.MarshalCall.NEWFB.duration=0.95 + self.MarshalCall.OPS.duration=0.23 + self.MarshalCall.POINT.duration=0.38 + self.MarshalCall.RADIOCHECK.duration=1.27 + self.MarshalCall.RECOVERY.duration=0.60 + self.MarshalCall.RECOVERYOPSSTOPPED.duration=1.25 + self.MarshalCall.RECOVERYPAUSEDNOTICE.duration=2.55 + self.MarshalCall.RECOVERYPAUSEDRESUMED.duration=2.55 + self.MarshalCall.REPORTSEEME.duration=0.87 + self.MarshalCall.RESUMERECOVERY.duration=1.55 + self.MarshalCall.ROGER.duration=0.50 + self.MarshalCall.SAYNEEDLES.duration=0.82 + self.MarshalCall.STACKFULL.duration=5.70 + self.MarshalCall.STARTINGRECOVERY.duration=1.61 + end + function AIRBOSS:SetVoiceOversMarshalByRaynor(mizfolder) if mizfolder then - local lastchar = string.sub( mizfolder, -1 ) - if lastchar ~= "/" then - mizfolder = mizfolder .. "/" - end - self.soundfolderLSO = mizfolder - else - -- Default is the general folder. - self.soundfolderLSO = self.soundfolder + local lastchar=string.sub(mizfolder,-1) + if lastchar~="/"then + mizfolder=mizfolder.."/" end - - -- Report for duty. - self:I( self.lid .. string.format( "LSO FF reporting for duty! Soundfolder=%s", tostring( self.soundfolderLSO ) ) ) - - self.LSOCall.BOLTER.duration = 0.75 - self.LSOCall.CALLTHEBALL.duration = 0.60 - self.LSOCall.CHECK.duration = 0.45 - self.LSOCall.CLEAREDTOLAND.duration = 1.00 - self.LSOCall.COMELEFT.duration = 0.60 - self.LSOCall.DEPARTANDREENTER.duration = 1.10 - self.LSOCall.EXPECTHEAVYWAVEOFF.duration = 1.20 - self.LSOCall.EXPECTSPOT75.duration = 2.00 - self.LSOCall.EXPECTSPOT5.duration = 1.3 - self.LSOCall.FAST.duration = 0.70 - self.LSOCall.FOULDECK.duration = 0.62 - self.LSOCall.HIGH.duration = 0.65 - self.LSOCall.IDLE.duration = 0.45 - self.LSOCall.LONGINGROOVE.duration = 1.20 - self.LSOCall.LOW.duration = 0.50 - self.LSOCall.N0.duration = 0.40 - self.LSOCall.N1.duration = 0.25 - self.LSOCall.N2.duration = 0.37 - self.LSOCall.N3.duration = 0.37 - self.LSOCall.N4.duration = 0.39 - self.LSOCall.N5.duration = 0.39 - self.LSOCall.N6.duration = 0.40 - self.LSOCall.N7.duration = 0.40 - self.LSOCall.N8.duration = 0.37 - self.LSOCall.N9.duration = 0.40 - self.LSOCall.PADDLESCONTACT.duration = 1.00 - self.LSOCall.POWER.duration = 0.50 - self.LSOCall.RADIOCHECK.duration = 1.10 - self.LSOCall.RIGHTFORLINEUP.duration = 0.80 - self.LSOCall.ROGERBALL.duration = 1.00 - self.LSOCall.SLOW.duration = 0.65 - self.LSOCall.SLOW.duration = 0.59 - self.LSOCall.STABILIZED.duration = 0.90 - self.LSOCall.WAVEOFF.duration = 0.60 - self.LSOCall.WELCOMEABOARD.duration = 1.00 -end - ---- Intit parameters for Marshal Voice overs by *funkyfranky*. --- @param #AIRBOSS self --- @param #string mizfolder (Optional) Folder within miz file where the sound files are located. -function AIRBOSS:SetVoiceOversMarshalByFF( mizfolder ) - - -- Set sound files folder. + self.soundfolderMSH=mizfolder + else + self.soundfolderMSH=self.soundfolder + end + self:I(self.lid..string.format("Marshal Raynor reporting for duty! Soundfolder=%s",tostring(self.soundfolderMSH))) + self.MarshalCall.AFFIRMATIVE.duration=0.70 + self.MarshalCall.ALTIMETER.duration=0.60 + self.MarshalCall.BRC.duration=0.60 + self.MarshalCall.CARRIERTURNTOHEADING.duration=1.87 + self.MarshalCall.CASE.duration=0.60 + self.MarshalCall.CHARLIETIME.duration=0.81 + self.MarshalCall.CLEAREDFORRECOVERY.duration=1.21 + self.MarshalCall.DECKCLOSED.duration=0.86 + self.MarshalCall.DEGREES.duration=0.55 + self.MarshalCall.EXPECTED.duration=0.61 + self.MarshalCall.FLYNEEDLES.duration=0.90 + self.MarshalCall.HOLDATANGELS.duration=0.91 + self.MarshalCall.HOURS.duration=0.54 + self.MarshalCall.MARSHALRADIAL.duration=0.80 + self.MarshalCall.N0.duration=0.38 + self.MarshalCall.N1.duration=0.30 + self.MarshalCall.N2.duration=0.30 + self.MarshalCall.N3.duration=0.30 + self.MarshalCall.N4.duration=0.32 + self.MarshalCall.N5.duration=0.41 + self.MarshalCall.N6.duration=0.48 + self.MarshalCall.N7.duration=0.51 + self.MarshalCall.N8.duration=0.38 + self.MarshalCall.N9.duration=0.34 + self.MarshalCall.NEGATIVE.duration=0.60 + self.MarshalCall.NEWFB.duration=1.10 + self.MarshalCall.OPS.duration=0.46 + self.MarshalCall.POINT.duration=0.21 + self.MarshalCall.RADIOCHECK.duration=0.95 + self.MarshalCall.RECOVERY.duration=0.63 + self.MarshalCall.RECOVERYOPSSTOPPED.duration=1.36 + self.MarshalCall.RECOVERYPAUSEDNOTICE.duration=2.8 + self.MarshalCall.RECOVERYPAUSEDRESUMED.duration=2.75 + self.MarshalCall.REPORTSEEME.duration=1.06 + self.MarshalCall.RESUMERECOVERY.duration=1.41 + self.MarshalCall.ROGER.duration=0.41 + self.MarshalCall.SAYNEEDLES.duration=0.79 + self.MarshalCall.STACKFULL.duration=4.70 + self.MarshalCall.STARTINGRECOVERY.duration=2.06 + end + function AIRBOSS:SetVoiceOversLSOByRaynor(mizfolder) if mizfolder then - local lastchar = string.sub( mizfolder, -1 ) - if lastchar ~= "/" then - mizfolder = mizfolder .. "/" - end - self.soundfolderMSH = mizfolder - else - -- Default is the general folder. - self.soundfolderMSH = self.soundfolder + local lastchar=string.sub(mizfolder,-1) + if lastchar~="/"then + mizfolder=mizfolder.."/" end - - -- Report for duty. - self:I( self.lid .. string.format( "Marshal FF reporting for duty! Soundfolder=%s", tostring( self.soundfolderMSH ) ) ) - - self.MarshalCall.AFFIRMATIVE.duration = 0.90 - self.MarshalCall.ALTIMETER.duration = 0.85 - self.MarshalCall.BRC.duration = 0.80 - self.MarshalCall.CARRIERTURNTOHEADING.duration = 2.48 - self.MarshalCall.CASE.duration = 0.40 - self.MarshalCall.CHARLIETIME.duration = 0.90 - self.MarshalCall.CLEAREDFORRECOVERY.duration = 1.25 - self.MarshalCall.DECKCLOSED.duration = 1.10 - self.MarshalCall.DEGREES.duration = 0.60 - self.MarshalCall.EXPECTED.duration = 0.55 - self.MarshalCall.FLYNEEDLES.duration = 0.90 - self.MarshalCall.HOLDATANGELS.duration = 1.10 - self.MarshalCall.HOURS.duration = 0.60 - self.MarshalCall.MARSHALRADIAL.duration = 1.10 - self.MarshalCall.N0.duration = 0.40 - self.MarshalCall.N1.duration = 0.25 - self.MarshalCall.N2.duration = 0.37 - self.MarshalCall.N3.duration = 0.37 - self.MarshalCall.N4.duration = 0.39 - self.MarshalCall.N5.duration = 0.39 - self.MarshalCall.N6.duration = 0.40 - self.MarshalCall.N7.duration = 0.40 - self.MarshalCall.N8.duration = 0.37 - self.MarshalCall.N9.duration = 0.40 - self.MarshalCall.NEGATIVE.duration = 0.80 - self.MarshalCall.NEWFB.duration = 1.35 - self.MarshalCall.OPS.duration = 0.48 - self.MarshalCall.POINT.duration = 0.33 - self.MarshalCall.RADIOCHECK.duration = 1.20 - self.MarshalCall.RECOVERY.duration = 0.70 - self.MarshalCall.RECOVERYOPSSTOPPED.duration = 1.65 - self.MarshalCall.RECOVERYPAUSEDNOTICE.duration = 2.9 -- Strangely the file is actually a shorter ~2.4 sec. - self.MarshalCall.RECOVERYPAUSEDRESUMED.duration = 3.40 - self.MarshalCall.REPORTSEEME.duration = 0.95 - self.MarshalCall.RESUMERECOVERY.duration = 1.75 - self.MarshalCall.ROGER.duration = 0.53 - self.MarshalCall.SAYNEEDLES.duration = 0.90 - self.MarshalCall.STACKFULL.duration = 6.35 - self.MarshalCall.STARTINGRECOVERY.duration = 2.65 - -end - ---- Init voice over radio transmission call. --- @param #AIRBOSS self -function AIRBOSS:_InitVoiceOvers() - - --------------- - -- LSO Radio -- - --------------- - - -- LSO Radio Calls. - self.LSOCall = { - BOLTER = { file = "LSO-BolterBolter", suffix = "ogg", loud = false, subtitle = "Bolter, Bolter", duration = 0.75, subduration = 5 }, - CALLTHEBALL = { file = "LSO-CallTheBall", suffix = "ogg", loud = false, subtitle = "Call the ball", duration = 0.6, subduration = 2 }, - CHECK = { file = "LSO-Check", suffix = "ogg", loud = false, subtitle = "Check", duration = 0.45, subduration = 2.5 }, - CLEAREDTOLAND = { file = "LSO-ClearedToLand", suffix = "ogg", loud = false, subtitle = "Cleared to land", duration = 1.0, subduration = 5 }, - COMELEFT = { file = "LSO-ComeLeft", suffix = "ogg", loud = true, subtitle = "Come left", duration = 0.60, subduration = 1 }, - RADIOCHECK = { file = "LSO-RadioCheck", suffix = "ogg", loud = false, subtitle = "Paddles, radio check", duration = 1.1, subduration = 5 }, - RIGHTFORLINEUP = { file = "LSO-RightForLineup", suffix = "ogg", loud = true, subtitle = "Right for line up", duration = 0.80, subduration = 1 }, - HIGH = { file = "LSO-High", suffix = "ogg", loud = true, subtitle = "You're high", duration = 0.65, subduration = 1 }, - LOW = { file = "LSO-Low", suffix = "ogg", loud = true, subtitle = "You're low", duration = 0.50, subduration = 1 }, - POWER = { file = "LSO-Power", suffix = "ogg", loud = true, subtitle = "Power", duration = 0.50, subduration = 1 }, -- duration 0.45 was too short - SLOW = { file = "LSO-Slow", suffix = "ogg", loud = true, subtitle = "You're slow", duration = 0.65, subduration = 1 }, - FAST = { file = "LSO-Fast", suffix = "ogg", loud = true, subtitle = "You're fast", duration = 0.70, subduration = 1 }, - ROGERBALL = { file = "LSO-RogerBall", suffix = "ogg", loud = false, subtitle = "Roger ball", duration = 1.00, subduration = 2 }, - WAVEOFF = { file = "LSO-WaveOff", suffix = "ogg", loud = false, subtitle = "Wave off", duration = 0.6, subduration = 5 }, - LONGINGROOVE = { file = "LSO-LongInTheGroove", suffix = "ogg", loud = false, subtitle = "You're long in the groove", duration = 1.2, subduration = 5 }, - FOULDECK = { file = "LSO-FoulDeck", suffix = "ogg", loud = false, subtitle = "Foul deck", duration = 0.62, subduration = 5 }, - DEPARTANDREENTER = { file = "LSO-DepartAndReenter", suffix = "ogg", loud = false, subtitle = "Depart and re-enter", duration = 1.1, subduration = 5 }, - PADDLESCONTACT = { file = "LSO-PaddlesContact", suffix = "ogg", loud = false, subtitle = "Paddles, contact", duration = 1.0, subduration = 5 }, - WELCOMEABOARD = { file = "LSO-WelcomeAboard", suffix = "ogg", loud = false, subtitle = "Welcome aboard", duration = 1.0, subduration = 5 }, - EXPECTHEAVYWAVEOFF = { file = "LSO-ExpectHeavyWaveoff", suffix = "ogg", loud = false, subtitle = "Expect heavy waveoff", duration = 1.2, subduration = 5 }, - EXPECTSPOT75 = { file = "LSO-ExpectSpot75", suffix = "ogg", loud = false, subtitle = "Expect spot 7.5", duration = 2.0, subduration = 5 }, - EXPECTSPOT5 = { file = "LSO-ExpectSpot5", suffix = "ogg", loud = false, subtitle = "Expect spot 5", duration = 1.3, subduration = 5 }, - STABILIZED = { file = "LSO-Stabilized", suffix = "ogg", loud = false, subtitle = "Stabilized", duration = 0.9, subduration = 5 }, - IDLE = { file = "LSO-Idle", suffix = "ogg", loud = false, subtitle = "Idle", duration = 0.45, subduration = 5 }, - N0 = { file = "LSO-N0", suffix = "ogg", loud = false, subtitle = "", duration = 0.40 }, - N1 = { file = "LSO-N1", suffix = "ogg", loud = false, subtitle = "", duration = 0.25 }, - N2 = { file = "LSO-N2", suffix = "ogg", loud = false, subtitle = "", duration = 0.37 }, - N3 = { file = "LSO-N3", suffix = "ogg", loud = false, subtitle = "", duration = 0.37 }, - N4 = { file = "LSO-N4", suffix = "ogg", loud = false, subtitle = "", duration = 0.39 }, - N5 = { file = "LSO-N5", suffix = "ogg", loud = false, subtitle = "", duration = 0.39 }, - N6 = { file = "LSO-N6", suffix = "ogg", loud = false, subtitle = "", duration = 0.40 }, - N7 = { file = "LSO-N7", suffix = "ogg", loud = false, subtitle = "", duration = 0.40 }, - N8 = { file = "LSO-N8", suffix = "ogg", loud = false, subtitle = "", duration = 0.37 }, - N9 = { file = "LSO-N9", suffix = "ogg", loud = false, subtitle = "", duration = 0.40 }, - CLICK = { file = "AIRBOSS-RadioClick", suffix = "ogg", loud = false, subtitle = "", duration = 0.35 }, - NOISE = { file = "AIRBOSS-Noise", suffix = "ogg", loud = false, subtitle = "", duration = 3.6 }, - SPINIT = { file = "AIRBOSS-SpinIt", suffix = "ogg", loud = false, subtitle = "", duration = 0.73, subduration = 5 }, + self.soundfolderLSO=mizfolder + else + self.soundfolderLSO=self.soundfolder + end + self:I(self.lid..string.format("LSO Raynor reporting for duty! Soundfolder=%s",tostring(self.soundfolderLSO))) + self.LSOCall.BOLTER.duration=0.75 + self.LSOCall.CALLTHEBALL.duration=0.625 + self.LSOCall.CHECK.duration=0.40 + self.LSOCall.CLEAREDTOLAND.duration=0.85 + self.LSOCall.COMELEFT.duration=0.60 + self.LSOCall.DEPARTANDREENTER.duration=1.10 + self.LSOCall.EXPECTHEAVYWAVEOFF.duration=1.30 + self.LSOCall.EXPECTSPOT75.duration=1.85 + self.LSOCall.EXPECTSPOT5.duration=1.3 + self.LSOCall.FAST.duration=0.75 + self.LSOCall.FOULDECK.duration=0.75 + self.LSOCall.HIGH.duration=0.65 + self.LSOCall.IDLE.duration=0.40 + self.LSOCall.LONGINGROOVE.duration=1.25 + self.LSOCall.LOW.duration=0.60 + self.LSOCall.N0.duration=0.38 + self.LSOCall.N1.duration=0.30 + self.LSOCall.N2.duration=0.30 + self.LSOCall.N3.duration=0.30 + self.LSOCall.N4.duration=0.32 + self.LSOCall.N5.duration=0.41 + self.LSOCall.N6.duration=0.48 + self.LSOCall.N7.duration=0.51 + self.LSOCall.N8.duration=0.38 + self.LSOCall.N9.duration=0.34 + self.LSOCall.PADDLESCONTACT.duration=0.91 + self.LSOCall.POWER.duration=0.45 + self.LSOCall.RADIOCHECK.duration=0.90 + self.LSOCall.RIGHTFORLINEUP.duration=0.70 + self.LSOCall.ROGERBALL.duration=0.72 + self.LSOCall.SLOW.duration=0.63 + self.LSOCall.STABILIZED.duration=0.75 + self.LSOCall.WAVEOFF.duration=0.55 + self.LSOCall.WELCOMEABOARD.duration=0.80 + end + function AIRBOSS:SetVoiceOversLSOByFF(mizfolder) + if mizfolder then + local lastchar=string.sub(mizfolder,-1) + if lastchar~="/"then + mizfolder=mizfolder.."/" + end + self.soundfolderLSO=mizfolder + else + self.soundfolderLSO=self.soundfolder + end + self:I(self.lid..string.format("LSO FF reporting for duty! Soundfolder=%s",tostring(self.soundfolderLSO))) + self.LSOCall.BOLTER.duration=0.75 + self.LSOCall.CALLTHEBALL.duration=0.60 + self.LSOCall.CHECK.duration=0.45 + self.LSOCall.CLEAREDTOLAND.duration=1.00 + self.LSOCall.COMELEFT.duration=0.60 + self.LSOCall.DEPARTANDREENTER.duration=1.10 + self.LSOCall.EXPECTHEAVYWAVEOFF.duration=1.20 + self.LSOCall.EXPECTSPOT75.duration=2.00 + self.LSOCall.EXPECTSPOT5.duration=1.3 + self.LSOCall.FAST.duration=0.70 + self.LSOCall.FOULDECK.duration=0.62 + self.LSOCall.HIGH.duration=0.65 + self.LSOCall.IDLE.duration=0.45 + self.LSOCall.LONGINGROOVE.duration=1.20 + self.LSOCall.LOW.duration=0.50 + self.LSOCall.N0.duration=0.40 + self.LSOCall.N1.duration=0.25 + self.LSOCall.N2.duration=0.37 + self.LSOCall.N3.duration=0.37 + self.LSOCall.N4.duration=0.39 + self.LSOCall.N5.duration=0.39 + self.LSOCall.N6.duration=0.40 + self.LSOCall.N7.duration=0.40 + self.LSOCall.N8.duration=0.37 + self.LSOCall.N9.duration=0.40 + self.LSOCall.PADDLESCONTACT.duration=1.00 + self.LSOCall.POWER.duration=0.50 + self.LSOCall.RADIOCHECK.duration=1.10 + self.LSOCall.RIGHTFORLINEUP.duration=0.80 + self.LSOCall.ROGERBALL.duration=1.00 + self.LSOCall.SLOW.duration=0.65 + self.LSOCall.SLOW.duration=0.59 + self.LSOCall.STABILIZED.duration=0.90 + self.LSOCall.WAVEOFF.duration=0.60 + self.LSOCall.WELCOMEABOARD.duration=1.00 + end + function AIRBOSS:SetVoiceOversMarshalByFF(mizfolder) + if mizfolder then + local lastchar=string.sub(mizfolder,-1) + if lastchar~="/"then + mizfolder=mizfolder.."/" + end + self.soundfolderMSH=mizfolder + else + self.soundfolderMSH=self.soundfolder + end + self:I(self.lid..string.format("Marshal FF reporting for duty! Soundfolder=%s",tostring(self.soundfolderMSH))) + self.MarshalCall.AFFIRMATIVE.duration=0.90 + self.MarshalCall.ALTIMETER.duration=0.85 + self.MarshalCall.BRC.duration=0.80 + self.MarshalCall.CARRIERTURNTOHEADING.duration=2.48 + self.MarshalCall.CASE.duration=0.40 + self.MarshalCall.CHARLIETIME.duration=0.90 + self.MarshalCall.CLEAREDFORRECOVERY.duration=1.25 + self.MarshalCall.DECKCLOSED.duration=1.10 + self.MarshalCall.DEGREES.duration=0.60 + self.MarshalCall.EXPECTED.duration=0.55 + self.MarshalCall.FLYNEEDLES.duration=0.90 + self.MarshalCall.HOLDATANGELS.duration=1.10 + self.MarshalCall.HOURS.duration=0.60 + self.MarshalCall.MARSHALRADIAL.duration=1.10 + self.MarshalCall.N0.duration=0.40 + self.MarshalCall.N1.duration=0.25 + self.MarshalCall.N2.duration=0.37 + self.MarshalCall.N3.duration=0.37 + self.MarshalCall.N4.duration=0.39 + self.MarshalCall.N5.duration=0.39 + self.MarshalCall.N6.duration=0.40 + self.MarshalCall.N7.duration=0.40 + self.MarshalCall.N8.duration=0.37 + self.MarshalCall.N9.duration=0.40 + self.MarshalCall.NEGATIVE.duration=0.80 + self.MarshalCall.NEWFB.duration=1.35 + self.MarshalCall.OPS.duration=0.48 + self.MarshalCall.POINT.duration=0.33 + self.MarshalCall.RADIOCHECK.duration=1.20 + self.MarshalCall.RECOVERY.duration=0.70 + self.MarshalCall.RECOVERYOPSSTOPPED.duration=1.65 + self.MarshalCall.RECOVERYPAUSEDNOTICE.duration=2.9 + self.MarshalCall.RECOVERYPAUSEDRESUMED.duration=3.40 + self.MarshalCall.REPORTSEEME.duration=0.95 + self.MarshalCall.RESUMERECOVERY.duration=1.75 + self.MarshalCall.ROGER.duration=0.53 + self.MarshalCall.SAYNEEDLES.duration=0.90 + self.MarshalCall.STACKFULL.duration=6.35 + self.MarshalCall.STARTINGRECOVERY.duration=2.65 + end + function AIRBOSS:_InitVoiceOvers() + self.LSOCall={ + -- BOLTER={file="LSO-BolterBolter",suffix="ogg",loud=false,subtitle="Bolter, Bolter",duration=0.75,subduration=5}, + -- CALLTHEBALL={file="LSO-CallTheBall",suffix="ogg",loud=false,subtitle="Call the ball",duration=0.6,subduration=2}, + -- CHECK={file="LSO-Check",suffix="ogg",loud=false,subtitle="Check",duration=0.45,subduration=2.5}, + -- CLEAREDTOLAND={file="LSO-ClearedToLand",suffix="ogg",loud=false,subtitle="Cleared to land",duration=1.0,subduration=5}, + -- COMELEFT={file="LSO-ComeLeft",suffix="ogg",loud=true,subtitle="Come left",duration=0.60,subduration=1}, + -- RADIOCHECK={file="LSO-RadioCheck",suffix="ogg",loud=false,subtitle="Paddles, radio check",duration=1.1,subduration=5}, + -- RIGHTFORLINEUP={file="LSO-RightForLineup",suffix="ogg",loud=true,subtitle="Right for line up",duration=0.80,subduration=1}, + -- HIGH={file="LSO-High",suffix="ogg",loud=true,subtitle="You're high",duration=0.65,subduration=1}, + -- LOW={file="LSO-Low",suffix="ogg",loud=true,subtitle="You're low",duration=0.50,subduration=1}, + -- POWER={file="LSO-Power",suffix="ogg",loud=true,subtitle="Power",duration=0.50,subduration=1}, + -- SLOW={file="LSO-Slow",suffix="ogg",loud=true,subtitle="You're slow",duration=0.65,subduration=1}, + -- FAST={file="LSO-Fast",suffix="ogg",loud=true,subtitle="You're fast",duration=0.70,subduration=1}, + -- ROGERBALL={file="LSO-RogerBall",suffix="ogg",loud=false,subtitle="Roger ball",duration=1.00,subduration=2}, + -- WAVEOFF={file="LSO-WaveOff",suffix="ogg",loud=false,subtitle="Wave off",duration=0.6,subduration=5}, + -- LONGINGROOVE={file="LSO-LongInTheGroove",suffix="ogg",loud=false,subtitle="You're long in the groove",duration=1.2,subduration=5}, + -- FOULDECK={file="LSO-FoulDeck",suffix="ogg",loud=false,subtitle="Foul deck",duration=0.62,subduration=5}, + -- DEPARTANDREENTER={file="LSO-DepartAndReenter",suffix="ogg",loud=false,subtitle="Depart and re-enter",duration=1.1,subduration=5}, + -- PADDLESCONTACT={file="LSO-PaddlesContact",suffix="ogg",loud=false,subtitle="Paddles, contact",duration=1.0,subduration=5}, + -- WELCOMEABOARD={file="LSO-WelcomeAboard",suffix="ogg",loud=false,subtitle="Welcome aboard",duration=1.0,subduration=5}, + -- EXPECTHEAVYWAVEOFF={file="LSO-ExpectHeavyWaveoff",suffix="ogg",loud=false,subtitle="Expect heavy waveoff",duration=1.2,subduration=5}, + -- EXPECTSPOT75={file="LSO-ExpectSpot75",suffix="ogg",loud=false,subtitle="Expect spot 7.5",duration=2.0,subduration=5}, + -- EXPECTSPOT5={file="LSO-ExpectSpot5",suffix="ogg",loud=false,subtitle="Expect spot 5",duration=1.3,subduration=5}, + -- STABILIZED={file="LSO-Stabilized",suffix="ogg",loud=false,subtitle="Stabilized",duration=0.9,subduration=5}, + -- IDLE={file="LSO-Idle",suffix="ogg",loud=false,subtitle="Idle",duration=0.45,subduration=5}, + -- N0={file="LSO-N0",suffix="ogg",loud=false,subtitle="",duration=0.40}, + -- N1={file="LSO-N1",suffix="ogg",loud=false,subtitle="",duration=0.25}, + -- N2={file="LSO-N2",suffix="ogg",loud=false,subtitle="",duration=0.37}, + -- N3={file="LSO-N3",suffix="ogg",loud=false,subtitle="",duration=0.37}, + -- N4={file="LSO-N4",suffix="ogg",loud=false,subtitle="",duration=0.39}, + -- N5={file="LSO-N5",suffix="ogg",loud=false,subtitle="",duration=0.39}, + -- N6={file="LSO-N6",suffix="ogg",loud=false,subtitle="",duration=0.40}, + -- N7={file="LSO-N7",suffix="ogg",loud=false,subtitle="",duration=0.40}, + -- N8={file="LSO-N8",suffix="ogg",loud=false,subtitle="",duration=0.37}, + -- N9={file="LSO-N9",suffix="ogg",loud=false,subtitle="",duration=0.40}, + -- CLICK={file="AIRBOSS-RadioClick",suffix="ogg",loud=false,subtitle="",duration=0.35}, + -- NOISE={file="AIRBOSS-Noise",suffix="ogg",loud=false,subtitle="",duration=3.6}, + -- SPINIT={file="AIRBOSS-SpinIt",suffix="ogg",loud=false,subtitle="",duration=0.73,subduration=5}, + BOLTER={file="LSO-BolterBolter",suffix="ogg",loud=false,subtitle="Bolter, Bolter",duration=0.75,subduration=5}, + CALLTHEBALL={file="LSO-CallTheBall",suffix="ogg",loud=false,subtitle="Call the ball",duration=0.6,subduration=2}, + CHECK={file="LSO-Check",suffix="ogg",loud=false,subtitle="Check",duration=0.45,subduration=2.5}, + CLEAREDTOLAND={file="LSO-ClearedToLand",suffix="ogg",loud=false,subtitle="允许降落 Cleared to land",duration=1.0,subduration=5}, + COMELEFT={file="LSO-ComeLeft",suffix="ogg",loud=true,subtitle="往左 Come left",duration=0.60,subduration=1}, + RADIOCHECK={file="LSO-RadioCheck",suffix="ogg",loud=false,subtitle="Paddles, 无线电检查 radio check",duration=1.1,subduration=5}, + RIGHTFORLINEUP={file="LSO-RightForLineup",suffix="ogg",loud=true,subtitle="已经对准 Right for line up",duration=0.80,subduration=1}, + HIGH={file="LSO-High",suffix="ogg",loud=true,subtitle="你高了 You're high",duration=0.65,subduration=1}, + LOW={file="LSO-Low",suffix="ogg",loud=true,subtitle="你低了 You're low",duration=0.50,subduration=1}, + POWER={file="LSO-Power",suffix="ogg",loud=true,subtitle="增加推力 Power",duration=0.50,subduration=1}, + SLOW={file="LSO-Slow",suffix="ogg",loud=true,subtitle="你慢了 You're slow",duration=0.65,subduration=1}, + FAST={file="LSO-Fast",suffix="ogg",loud=true,subtitle="你快了 You're fast",duration=0.70,subduration=1}, + ROGERBALL={file="LSO-RogerBall",suffix="ogg",loud=false,subtitle="Roger ball",duration=1.00,subduration=2}, + WAVEOFF={file="LSO-WaveOff",suffix="ogg",loud=false,subtitle="复飞 Wave off",duration=0.6,subduration=5}, + LONGINGROOVE={file="LSO-LongInTheGroove",suffix="ogg",loud=false,subtitle="你在第五边时间太长 You're long in the groove",duration=1.2,subduration=5}, + FOULDECK={file="LSO-FoulDeck",suffix="ogg",loud=false,subtitle="甲板被占用 Foul deck",duration=0.62,subduration=5}, + DEPARTANDREENTER={file="LSO-DepartAndReenter",suffix="ogg",loud=false,subtitle="脱离然后重新进入 Depart and re-enter",duration=1.1,subduration=5}, + PADDLESCONTACT={file="LSO-PaddlesContact",suffix="ogg",loud=false,subtitle="Paddles, 接触 contact",duration=1.0,subduration=5}, + WELCOMEABOARD={file="LSO-WelcomeAboard",suffix="ogg",loud=false,subtitle="欢迎登舰 Welcome aboard",duration=1.0,subduration=5}, + EXPECTHEAVYWAVEOFF={file="LSO-ExpectHeavyWaveoff",suffix="ogg",loud=false,subtitle="准备重复飞 Expect heavy waveoff",duration=1.2,subduration=5}, + EXPECTSPOT75={file="LSO-ExpectSpot75",suffix="ogg",loud=false,subtitle="Expect spot 7.5",duration=2.0,subduration=5}, + EXPECTSPOT5={file="LSO-ExpectSpot5",suffix="ogg",loud=false,subtitle="Expect spot 5",duration=1.3,subduration=5}, + STABILIZED={file="LSO-Stabilized",suffix="ogg",loud=false,subtitle="稳定了 Stabilized",duration=0.9,subduration=5}, + IDLE={file="LSO-Idle",suffix="ogg",loud=false,subtitle="Idle",duration=0.45,subduration=5}, + N0={file="LSO-N0",suffix="ogg",loud=false,subtitle="",duration=0.40}, + N1={file="LSO-N1",suffix="ogg",loud=false,subtitle="",duration=0.25}, + N2={file="LSO-N2",suffix="ogg",loud=false,subtitle="",duration=0.37}, + N3={file="LSO-N3",suffix="ogg",loud=false,subtitle="",duration=0.37}, + N4={file="LSO-N4",suffix="ogg",loud=false,subtitle="",duration=0.39}, + N5={file="LSO-N5",suffix="ogg",loud=false,subtitle="",duration=0.39}, + N6={file="LSO-N6",suffix="ogg",loud=false,subtitle="",duration=0.40}, + N7={file="LSO-N7",suffix="ogg",loud=false,subtitle="",duration=0.40}, + N8={file="LSO-N8",suffix="ogg",loud=false,subtitle="",duration=0.37}, + N9={file="LSO-N9",suffix="ogg",loud=false,subtitle="",duration=0.40}, + CLICK={file="AIRBOSS-RadioClick",suffix="ogg",loud=false,subtitle="",duration=0.35}, + NOISE={file="AIRBOSS-Noise",suffix="ogg",loud=false,subtitle="",duration=3.6}, + SPINIT={file="AIRBOSS-SpinIt",suffix="ogg",loud=false,subtitle="",duration=0.73,subduration=5}, } - - ----------------- - -- Pilot Calls -- - ----------------- - - -- Pilot Radio Calls. - self.PilotCall = { - N0 = { file = "PILOT-N0", suffix = "ogg", loud = false, subtitle = "", duration = 0.40 }, - N1 = { file = "PILOT-N1", suffix = "ogg", loud = false, subtitle = "", duration = 0.25 }, - N2 = { file = "PILOT-N2", suffix = "ogg", loud = false, subtitle = "", duration = 0.37 }, - N3 = { file = "PILOT-N3", suffix = "ogg", loud = false, subtitle = "", duration = 0.37 }, - N4 = { file = "PILOT-N4", suffix = "ogg", loud = false, subtitle = "", duration = 0.39 }, - N5 = { file = "PILOT-N5", suffix = "ogg", loud = false, subtitle = "", duration = 0.39 }, - N6 = { file = "PILOT-N6", suffix = "ogg", loud = false, subtitle = "", duration = 0.40 }, - N7 = { file = "PILOT-N7", suffix = "ogg", loud = false, subtitle = "", duration = 0.40 }, - N8 = { file = "PILOT-N8", suffix = "ogg", loud = false, subtitle = "", duration = 0.37 }, - N9 = { file = "PILOT-N9", suffix = "ogg", loud = false, subtitle = "", duration = 0.40 }, - POINT = { file = "PILOT-Point", suffix = "ogg", loud = false, subtitle = "", duration = 0.33 }, - SKYHAWK = { file = "PILOT-Skyhawk", suffix = "ogg", loud = false, subtitle = "", duration = 0.95, subduration = 5 }, - HARRIER = { file = "PILOT-Harrier", suffix = "ogg", loud = false, subtitle = "", duration = 0.58, subduration = 5 }, - HAWKEYE = { file = "PILOT-Hawkeye", suffix = "ogg", loud = false, subtitle = "", duration = 0.63, subduration = 5 }, - TOMCAT = { file = "PILOT-Tomcat", suffix = "ogg", loud = false, subtitle = "", duration = 0.66, subduration = 5 }, - HORNET = { file = "PILOT-Hornet", suffix = "ogg", loud = false, subtitle = "", duration = 0.56, subduration = 5 }, - VIKING = { file = "PILOT-Viking", suffix = "ogg", loud = false, subtitle = "", duration = 0.61, subduration = 5 }, - BALL = { file = "PILOT-Ball", suffix = "ogg", loud = false, subtitle = "", duration = 0.50, subduration = 5 }, - BINGOFUEL = { file = "PILOT-BingoFuel", suffix = "ogg", loud = false, subtitle = "", duration = 0.80 }, - GASATDIVERT = { file = "PILOT-GasAtDivert", suffix = "ogg", loud = false, subtitle = "", duration = 1.80 }, - GASATTANKER = { file = "PILOT-GasAtTanker", suffix = "ogg", loud = false, subtitle = "", duration = 1.95 }, + self.PilotCall={ + N0={file="PILOT-N0",suffix="ogg",loud=false,subtitle="",duration=0.40}, + N1={file="PILOT-N1",suffix="ogg",loud=false,subtitle="",duration=0.25}, + N2={file="PILOT-N2",suffix="ogg",loud=false,subtitle="",duration=0.37}, + N3={file="PILOT-N3",suffix="ogg",loud=false,subtitle="",duration=0.37}, + N4={file="PILOT-N4",suffix="ogg",loud=false,subtitle="",duration=0.39}, + N5={file="PILOT-N5",suffix="ogg",loud=false,subtitle="",duration=0.39}, + N6={file="PILOT-N6",suffix="ogg",loud=false,subtitle="",duration=0.40}, + N7={file="PILOT-N7",suffix="ogg",loud=false,subtitle="",duration=0.40}, + N8={file="PILOT-N8",suffix="ogg",loud=false,subtitle="",duration=0.37}, + N9={file="PILOT-N9",suffix="ogg",loud=false,subtitle="",duration=0.40}, + POINT={file="PILOT-Point",suffix="ogg",loud=false,subtitle="",duration=0.33}, + SKYHAWK={file="PILOT-Skyhawk",suffix="ogg",loud=false,subtitle="",duration=0.95,subduration=5}, + HARRIER={file="PILOT-Harrier",suffix="ogg",loud=false,subtitle="",duration=0.58,subduration=5}, + HAWKEYE={file="PILOT-Hawkeye",suffix="ogg",loud=false,subtitle="",duration=0.63,subduration=5}, + TOMCAT={file="PILOT-Tomcat",suffix="ogg",loud=false,subtitle="",duration=0.66,subduration=5}, + HORNET={file="PILOT-Hornet",suffix="ogg",loud=false,subtitle="",duration=0.56,subduration=5}, + VIKING={file="PILOT-Viking",suffix="ogg",loud=false,subtitle="",duration=0.61,subduration=5}, + GREYHOUND={file="PILOT-Greyhound",suffix="ogg",loud=false,subtitle="",duration=0.61,subduration=5}, + BALL={file="PILOT-Ball",suffix="ogg",loud=false,subtitle="",duration=0.50,subduration=5}, + BINGOFUEL={file="PILOT-BingoFuel",suffix="ogg",loud=false,subtitle="",duration=0.80}, + GASATDIVERT={file="PILOT-GasAtDivert",suffix="ogg",loud=false,subtitle="",duration=1.80}, + GASATTANKER={file="PILOT-GasAtTanker",suffix="ogg",loud=false,subtitle="",duration=1.95}, } - - ------------------- - -- MARSHAL Radio -- - ------------------- - - -- MARSHAL Radio Calls. - self.MarshalCall = { - AFFIRMATIVE = { file = "MARSHAL-Affirmative", suffix = "ogg", loud = false, subtitle = "", duration = 0.90 }, - ALTIMETER = { file = "MARSHAL-Altimeter", suffix = "ogg", loud = false, subtitle = "", duration = 0.85 }, - BRC = { file = "MARSHAL-BRC", suffix = "ogg", loud = false, subtitle = "", duration = 0.80 }, - CARRIERTURNTOHEADING = { file = "MARSHAL-CarrierTurnToHeading", suffix = "ogg", loud = false, subtitle = "", duration = 2.48, subduration = 5 }, - CASE = { file = "MARSHAL-Case", suffix = "ogg", loud = false, subtitle = "", duration = 0.40 }, - CHARLIETIME = { file = "MARSHAL-CharlieTime", suffix = "ogg", loud = false, subtitle = "", duration = 0.90 }, - CLEAREDFORRECOVERY = { file = "MARSHAL-ClearedForRecovery", suffix = "ogg", loud = false, subtitle = "", duration = 1.25 }, - DECKCLOSED = { file = "MARSHAL-DeckClosed", suffix = "ogg", loud = false, subtitle = "", duration = 1.10, subduration = 5 }, - DEGREES = { file = "MARSHAL-Degrees", suffix = "ogg", loud = false, subtitle = "", duration = 0.60 }, - EXPECTED = { file = "MARSHAL-Expected", suffix = "ogg", loud = false, subtitle = "", duration = 0.55 }, - FLYNEEDLES = { file = "MARSHAL-FlyYourNeedles", suffix = "ogg", loud = false, subtitle = "Fly your needles", duration = 0.9, subduration = 5 }, - HOLDATANGELS = { file = "MARSHAL-HoldAtAngels", suffix = "ogg", loud = false, subtitle = "", duration = 1.10 }, - HOURS = { file = "MARSHAL-Hours", suffix = "ogg", loud = false, subtitle = "", duration = 0.60, subduration = 5 }, - MARSHALRADIAL = { file = "MARSHAL-MarshalRadial", suffix = "ogg", loud = false, subtitle = "", duration = 1.10 }, - N0 = { file = "MARSHAL-N0", suffix = "ogg", loud = false, subtitle = "", duration = 0.40 }, - N1 = { file = "MARSHAL-N1", suffix = "ogg", loud = false, subtitle = "", duration = 0.25 }, - N2 = { file = "MARSHAL-N2", suffix = "ogg", loud = false, subtitle = "", duration = 0.37 }, - N3 = { file = "MARSHAL-N3", suffix = "ogg", loud = false, subtitle = "", duration = 0.37 }, - N4 = { file = "MARSHAL-N4", suffix = "ogg", loud = false, subtitle = "", duration = 0.39 }, - N5 = { file = "MARSHAL-N5", suffix = "ogg", loud = false, subtitle = "", duration = 0.39 }, - N6 = { file = "MARSHAL-N6", suffix = "ogg", loud = false, subtitle = "", duration = 0.40 }, - N7 = { file = "MARSHAL-N7", suffix = "ogg", loud = false, subtitle = "", duration = 0.40 }, - N8 = { file = "MARSHAL-N8", suffix = "ogg", loud = false, subtitle = "", duration = 0.37 }, - N9 = { file = "MARSHAL-N9", suffix = "ogg", loud = false, subtitle = "", duration = 0.40 }, - NEGATIVE = { file = "MARSHAL-Negative", suffix = "ogg", loud = false, subtitle = "", duration = 0.80, subduration = 5 }, - NEWFB = { file = "MARSHAL-NewFB", suffix = "ogg", loud = false, subtitle = "", duration = 1.35 }, - OPS = { file = "MARSHAL-Ops", suffix = "ogg", loud = false, subtitle = "", duration = 0.48 }, - POINT = { file = "MARSHAL-Point", suffix = "ogg", loud = false, subtitle = "", duration = 0.33 }, - RADIOCHECK = { file = "MARSHAL-RadioCheck", suffix = "ogg", loud = false, subtitle = "Radio check", duration = 1.20, subduration = 5 }, - RECOVERY = { file = "MARSHAL-Recovery", suffix = "ogg", loud = false, subtitle = "", duration = 0.70, subduration = 5 }, - RECOVERYOPSSTOPPED = { file = "MARSHAL-RecoveryOpsStopped", suffix = "ogg", loud = false, subtitle = "", duration = 1.65, subduration = 5 }, - RECOVERYPAUSEDNOTICE = { file = "MARSHAL-RecoveryPausedNotice", suffix = "ogg", loud = false, subtitle = "aircraft recovery paused until further notice", duration = 2.90, subduration = 5 }, - RECOVERYPAUSEDRESUMED = { file = "MARSHAL-RecoveryPausedResumed", suffix = "ogg", loud = false, subtitle = "", duration = 3.40, subduration = 5 }, - REPORTSEEME = { file = "MARSHAL-ReportSeeMe", suffix = "ogg", loud = false, subtitle = "", duration = 0.95 }, - RESUMERECOVERY = { file = "MARSHAL-ResumeRecovery", suffix = "ogg", loud = false, subtitle = "resuming aircraft recovery", duration = 1.75, subduraction = 5 }, - ROGER = { file = "MARSHAL-Roger", suffix = "ogg", loud = false, subtitle = "", duration = 0.53, subduration = 5 }, - SAYNEEDLES = { file = "MARSHAL-SayNeedles", suffix = "ogg", loud = false, subtitle = "Say needles", duration = 0.90, subduration = 5 }, - STACKFULL = { file = "MARSHAL-StackFull", suffix = "ogg", loud = false, subtitle = "Marshal Stack is currently full. Hold outside 10 NM zone and wait for further instructions", duration = 6.35, subduration = 10 }, - STARTINGRECOVERY = { file = "MARSHAL-StartingRecovery", suffix = "ogg", loud = false, subtitle = "", duration = 2.65, subduration = 5 }, - CLICK = { file = "AIRBOSS-RadioClick", suffix = "ogg", loud = false, subtitle = "", duration = 0.35 }, - NOISE = { file = "AIRBOSS-Noise", suffix = "ogg", loud = false, subtitle = "", duration = 3.6 }, + self.MarshalCall={ + AFFIRMATIVE={file="MARSHAL-Affirmative",suffix="ogg",loud=false,subtitle="",duration=0.90}, + ALTIMETER={file="MARSHAL-Altimeter",suffix="ogg",loud=false,subtitle="",duration=0.85}, + BRC={file="MARSHAL-BRC",suffix="ogg",loud=false,subtitle="",duration=0.80}, + CARRIERTURNTOHEADING={file="MARSHAL-CarrierTurnToHeading",suffix="ogg",loud=false,subtitle="",duration=2.48,subduration=5}, + CASE={file="MARSHAL-Case",suffix="ogg",loud=false,subtitle="",duration=0.40}, + CHARLIETIME={file="MARSHAL-CharlieTime",suffix="ogg",loud=false,subtitle="",duration=0.90}, + CLEAREDFORRECOVERY={file="MARSHAL-ClearedForRecovery",suffix="ogg",loud=false,subtitle="",duration=1.25}, + DECKCLOSED={file="MARSHAL-DeckClosed",suffix="ogg",loud=false,subtitle="",duration=1.10,subduration=5}, + DEGREES={file="MARSHAL-Degrees",suffix="ogg",loud=false,subtitle="",duration=0.60}, + EXPECTED={file="MARSHAL-Expected",suffix="ogg",loud=false,subtitle="",duration=0.55}, + -- FLYNEEDLES={file="MARSHAL-FlyYourNeedles",suffix="ogg",loud=false,subtitle="Fly your needles",duration=0.9,subduration=5}, + FLYNEEDLES={file="MARSHAL-FlyYourNeedles",suffix="ogg",loud=false,subtitle="跟着仪表飞 Fly your needles",duration=0.9,subduration=5}, + HOLDATANGELS={file="MARSHAL-HoldAtAngels",suffix="ogg",loud=false,subtitle="",duration=1.10}, + HOURS={file="MARSHAL-Hours",suffix="ogg",loud=false,subtitle="",duration=0.60,subduration=5}, + MARSHALRADIAL={file="MARSHAL-MarshalRadial",suffix="ogg",loud=false,subtitle="",duration=1.10}, + N0={file="MARSHAL-N0",suffix="ogg",loud=false,subtitle="",duration=0.40}, + N1={file="MARSHAL-N1",suffix="ogg",loud=false,subtitle="",duration=0.25}, + N2={file="MARSHAL-N2",suffix="ogg",loud=false,subtitle="",duration=0.37}, + N3={file="MARSHAL-N3",suffix="ogg",loud=false,subtitle="",duration=0.37}, + N4={file="MARSHAL-N4",suffix="ogg",loud=false,subtitle="",duration=0.39}, + N5={file="MARSHAL-N5",suffix="ogg",loud=false,subtitle="",duration=0.39}, + N6={file="MARSHAL-N6",suffix="ogg",loud=false,subtitle="",duration=0.40}, + N7={file="MARSHAL-N7",suffix="ogg",loud=false,subtitle="",duration=0.40}, + N8={file="MARSHAL-N8",suffix="ogg",loud=false,subtitle="",duration=0.37}, + N9={file="MARSHAL-N9",suffix="ogg",loud=false,subtitle="",duration=0.40}, + NEGATIVE={file="MARSHAL-Negative",suffix="ogg",loud=false,subtitle="",duration=0.80,subduration=5}, + NEWFB={file="MARSHAL-NewFB",suffix="ogg",loud=false,subtitle="",duration=1.35}, + OPS={file="MARSHAL-Ops",suffix="ogg",loud=false,subtitle="",duration=0.48}, + POINT={file="MARSHAL-Point",suffix="ogg",loud=false,subtitle="",duration=0.33}, + -- RADIOCHECK={file="MARSHAL-RadioCheck",suffix="ogg",loud=false,subtitle="Radio check",duration=1.20,subduration=5}, + RADIOCHECK={file="MARSHAL-RadioCheck",suffix="ogg",loud=false,subtitle="无线电检查 Radio check",duration=1.20,subduration=5}, + RECOVERY={file="MARSHAL-Recovery",suffix="ogg",loud=false,subtitle="",duration=0.70,subduration=5}, + RECOVERYOPSSTOPPED={file="MARSHAL-RecoveryOpsStopped",suffix="ogg",loud=false,subtitle="",duration=1.65,subduration=5}, + -- RECOVERYPAUSEDNOTICE={file="MARSHAL-RecoveryPausedNotice",suffix="ogg",loud=false,subtitle="aircraft recovery paused until further notice",duration=2.90,subduration=5}, + RECOVERYPAUSEDNOTICE={file="MARSHAL-RecoveryPausedNotice",suffix="ogg",loud=false,subtitle="回收作业暂停, 等待进一步通知 aircraft recovery paused until further notice",duration=2.90,subduration=5}, + RECOVERYPAUSEDRESUMED={file="MARSHAL-RecoveryPausedResumed",suffix="ogg",loud=false,subtitle="",duration=3.40,subduration=5}, + REPORTSEEME={file="MARSHAL-ReportSeeMe",suffix="ogg",loud=false,subtitle="",duration=0.95}, + RESUMERECOVERY={file="MARSHAL-ResumeRecovery",suffix="ogg",loud=false,subtitle="回复回收作业 resuming aircraft recovery",duration=1.75,subduraction=5}, + ROGER={file="MARSHAL-Roger",suffix="ogg",loud=false,subtitle="",duration=0.53,subduration=5}, + SAYNEEDLES={file="MARSHAL-SayNeedles",suffix="ogg",loud=false,subtitle="Say needles",duration=0.90,subduration=5}, + STACKFULL={file="MARSHAL-StackFull",suffix="ogg",loud=false,subtitle="调度队列已满,请在10海里外等待 Marshal Stack is currently full. Hold outside 10 NM zone and wait for further instructions",duration=6.35,subduration=10}, + STARTINGRECOVERY={file="MARSHAL-StartingRecovery",suffix="ogg",loud=false,subtitle="",duration=2.65,subduration=5}, + CLICK={file="AIRBOSS-RadioClick",suffix="ogg",loud=false,subtitle="",duration=0.35}, + NOISE={file="AIRBOSS-Noise",suffix="ogg",loud=false,subtitle="",duration=3.6}, } - - -- Default timings by Raynor self:SetVoiceOversLSOByRaynor() self:SetVoiceOversMarshalByRaynor() - -end - ---- Init voice over radio transmission call. --- @param #AIRBOSS self --- @param #AIRBOSS.RadioCall radiocall LSO or Marshal radio call object. --- @param #number duration Duration of the voice over in seconds. --- @param #string subtitle (Optional) Subtitle to be displayed along with voice over. --- @param #number subduration (Optional) Duration how long the subtitle is displayed. --- @param #string filename (Optional) Name of the voice over sound file. --- @param #string suffix (Optional) Extention of file. Default ".ogg". -function AIRBOSS:SetVoiceOver( radiocall, duration, subtitle, subduration, filename, suffix ) - radiocall.duration = duration - radiocall.subtitle = subtitle or radiocall.subtitle - radiocall.file = filename - radiocall.suffix = suffix or ".ogg" -end - ---- Get optimal aircraft AoA parameters.. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. --- @return #AIRBOSS.AircraftAoA AoA parameters for the given aircraft type. -function AIRBOSS:_GetAircraftAoA( playerData ) - - -- Get AC type. - local hornet = playerData.actype == AIRBOSS.AircraftCarrier.HORNET - or playerData.actype == AIRBOSS.AircraftCarrier.RHINOE - or playerData.actype == AIRBOSS.AircraftCarrier.RHINOF - or playerData.actype == AIRBOSS.AircraftCarrier.GROWLER - local goshawk = playerData.actype == AIRBOSS.AircraftCarrier.T45C - local skyhawk = playerData.actype == AIRBOSS.AircraftCarrier.A4EC - local harrier = playerData.actype == AIRBOSS.AircraftCarrier.AV8B - local tomcat = playerData.actype == AIRBOSS.AircraftCarrier.F14A or playerData.actype == AIRBOSS.AircraftCarrier.F14B - - -- Table with AoA values. - local aoa = {} -- #AIRBOSS.AircraftAoA - + end + function AIRBOSS:SetVoiceOver(radiocall,duration,subtitle,subduration,filename,suffix) + radiocall.duration=duration + radiocall.subtitle=subtitle or radiocall.subtitle + radiocall.file=filename + radiocall.suffix=suffix or".ogg" + end + function AIRBOSS:_GetAircraftAoA(playerData) + local hornet=playerData.actype==AIRBOSS.AircraftCarrier.HORNET + or playerData.actype==AIRBOSS.AircraftCarrier.RHINOE + or playerData.actype==AIRBOSS.AircraftCarrier.RHINOF + or playerData.actype==AIRBOSS.AircraftCarrier.GROWLER + local goshawk=playerData.actype==AIRBOSS.AircraftCarrier.T45C + local skyhawk=playerData.actype==AIRBOSS.AircraftCarrier.A4EC + local harrier=playerData.actype==AIRBOSS.AircraftCarrier.AV8B + local tomcat=playerData.actype==AIRBOSS.AircraftCarrier.F14A or playerData.actype==AIRBOSS.AircraftCarrier.F14B + local aoa={} if hornet then - -- F/A-18C Hornet parameters. - aoa.SLOW = 9.8 - aoa.Slow = 9.3 - aoa.OnSpeedMax = 8.8 - aoa.OnSpeed = 8.1 - aoa.OnSpeedMin = 7.4 - aoa.Fast = 6.9 - aoa.FAST = 6.3 + aoa.SLOW=9.8 + aoa.Slow=9.3 + aoa.OnSpeedMax=8.8 + aoa.OnSpeed=8.1 + aoa.OnSpeedMin=7.4 + aoa.Fast=6.9 + aoa.FAST=6.3 elseif tomcat then - -- F-14A/B Tomcat parameters (taken from NATOPS). Converted from units 0-30 to degrees. - -- Currently assuming a linear relationship with 0=-10 degrees and 30=+40 degrees as stated in NATOPS. - aoa.SLOW = self:_AoAUnit2Deg( playerData, 17.0 ) -- 18.33 --17.0 units - aoa.Slow = self:_AoAUnit2Deg( playerData, 16.0 ) -- 16.67 --16.0 units - aoa.OnSpeedMax = self:_AoAUnit2Deg( playerData, 15.5 ) -- 15.83 --15.5 units - aoa.OnSpeed = self:_AoAUnit2Deg( playerData, 15.0 ) -- 15.0 --15.0 units - aoa.OnSpeedMin = self:_AoAUnit2Deg( playerData, 14.5 ) -- 14.17 --14.5 units - aoa.Fast = self:_AoAUnit2Deg( playerData, 14.0 ) -- 13.33 --14.0 units - aoa.FAST = self:_AoAUnit2Deg( playerData, 13.0 ) -- 11.67 --13.0 units + aoa.SLOW=self:_AoAUnit2Deg(playerData,17.0) + aoa.Slow=self:_AoAUnit2Deg(playerData,16.0) + aoa.OnSpeedMax=self:_AoAUnit2Deg(playerData,15.5) + aoa.OnSpeed=self:_AoAUnit2Deg(playerData,15.0) + aoa.OnSpeedMin=self:_AoAUnit2Deg(playerData,14.5) + aoa.Fast=self:_AoAUnit2Deg(playerData,14.0) + aoa.FAST=self:_AoAUnit2Deg(playerData,13.0) elseif goshawk then - -- T-45C Goshawk parameters. - aoa.SLOW = 8.00 -- 19 - aoa.Slow = 7.75 -- 18 - aoa.OnSpeedMax = 7.25 -- 17.5 - aoa.OnSpeed = 7.00 -- 17 - aoa.OnSpeedMin = 6.75 -- 16.5 - aoa.Fast = 6.25 -- 16 - aoa.FAST = 6.00 -- 15 + aoa.SLOW=8.00 + aoa.Slow=7.75 + aoa.OnSpeedMax=7.25 + aoa.OnSpeed=7.00 + aoa.OnSpeedMin=6.75 + aoa.Fast=6.25 + aoa.FAST=6.00 elseif skyhawk then - -- A-4E-C Skyhawk parameters from https://forums.eagle.ru/showpost.php?p=3703467&postcount=390 - -- Note that these are arbitrary UNITS and not degrees. We need a conversion formula! - -- Github repo suggests they simply use a factor of two to get from degrees to units. - aoa.SLOW = 9.50 -- =19.0/2 - aoa.Slow = 9.25 -- =18.5/2 - aoa.OnSpeedMax = 9.00 -- =18.0/2 - aoa.OnSpeed = 8.75 -- =17.5/2 8.1 - aoa.OnSpeedMin = 8.50 -- =17.0/2 - aoa.Fast = 8.25 -- =17.5/2 - aoa.FAST = 8.00 -- =16.5/2 + aoa.SLOW=9.50 + aoa.Slow=9.25 + aoa.OnSpeedMax=9.00 + aoa.OnSpeed=8.75 + aoa.OnSpeedMin=8.50 + aoa.Fast=8.25 + aoa.FAST=8.00 elseif harrier then - - -- AV-8B Harrier parameters. Tuning done on the Fast AoA to allow for abeam and ninety at Nozzles 55. Pene testing - aoa.SLOW = 16.0 - aoa.Slow = 13.5 - aoa.OnSpeedMax = 12.5 - aoa.OnSpeed = 10.0 - aoa.OnSpeedMin = 9.5 - aoa.Fast = 8.0 - aoa.FAST = 7.5 - + aoa.SLOW=16.0 + aoa.Slow=13.5 + aoa.OnSpeedMax=12.5 + aoa.OnSpeed=10.0 + aoa.OnSpeedMin=9.5 + aoa.Fast=8.0 + aoa.FAST=7.5 end - return aoa -end - ---- Convert AoA from arbitrary units to degrees. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. --- @param #number aoaunits AoA in arbitrary units. --- @return #number AoA in degrees. -function AIRBOSS:_AoAUnit2Deg( playerData, aoaunits ) - - -- Init. - local degrees = aoaunits - - -- Check aircraft type of player. - if playerData.actype == AIRBOSS.AircraftCarrier.F14A or playerData.actype == AIRBOSS.AircraftCarrier.F14B then - - ------------- - -- F-14A/B -- - ------------- - - -- NATOPS: - -- unit=0 ==> alpha=-10 degrees. - -- unit=30 ==> alpha=+40 degrees. - - -- Assuming a linear relationship between these to points of the graph. - -- However: AoA=15 Units ==> 15 degrees, which is too much. - degrees = -10 + 50 / 30 * aoaunits - - -- HB Facebook page https://www.facebook.com/heatblur/photos/a.683612385159716/754368278084126 - -- AoA=15 Units <==> AoA=10.359 degrees. - degrees = 0.918 * aoaunits - 3.411 - - elseif playerData.actype == AIRBOSS.AircraftCarrier.A4EC then - - ---------- - -- A-4E -- - ---------- - - -- A-4E-C source code suggests a simple factor of 1/2 for conversion. - degrees = 0.5 * aoaunits - end - + function AIRBOSS:_AoAUnit2Deg(playerData,aoaunits) + local degrees=aoaunits + if playerData.actype==AIRBOSS.AircraftCarrier.F14A or playerData.actype==AIRBOSS.AircraftCarrier.F14B then + degrees=-10+50/30*aoaunits + degrees=0.918*aoaunits-3.411 + elseif playerData.actype==AIRBOSS.AircraftCarrier.A4EC then + degrees=0.5*aoaunits + end return degrees -end - ---- Convert AoA from degrees to arbitrary units. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. --- @param #number degrees AoA in degrees. --- @return #number AoA in arbitrary units. -function AIRBOSS:_AoADeg2Units( playerData, degrees ) - - -- Init. - local aoaunits = degrees - - -- Check aircraft type of player. - if playerData.actype == AIRBOSS.AircraftCarrier.F14A or playerData.actype == AIRBOSS.AircraftCarrier.F14B then - - ------------- - -- F-14A/B -- - ------------- - - -- NATOPS: - -- unit=0 ==> alpha=-10 degrees. - -- unit=30 ==> alpha=+40 degrees. - - -- Assuming a linear relationship between these to points of the graph. - aoaunits = (degrees + 10) * 30 / 50 - - -- HB Facebook page https://www.facebook.com/heatblur/photos/a.683612385159716/754368278084126 - -- AoA=15 Units <==> AoA=10.359 degrees. - aoaunits = 1.089 * degrees + 3.715 - - elseif playerData.actype == AIRBOSS.AircraftCarrier.A4EC then - - ---------- - -- A-4E -- - ---------- - - -- A-4E source code suggests a simple factor of two as conversion. - aoaunits = 2 * degrees - end - + function AIRBOSS:_AoADeg2Units(playerData,degrees) + local aoaunits=degrees + if playerData.actype==AIRBOSS.AircraftCarrier.F14A or playerData.actype==AIRBOSS.AircraftCarrier.F14B then + aoaunits=(degrees+10)*30/50 + aoaunits=1.089*degrees+3.715 + elseif playerData.actype==AIRBOSS.AircraftCarrier.A4EC then + aoaunits=2*degrees + end return aoaunits -end - ---- Get optimal aircraft flight parameters at checkpoint. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. --- @param #string step Pattern step. --- @return #number Altitude in meters or nil. --- @return #number Angle of Attack or nil. --- @return #number Distance to carrier in meters or nil. --- @return #number Speed in m/s or nil. -function AIRBOSS:_GetAircraftParameters( playerData, step ) - - -- Get parameters depended on step. - step = step or playerData.step - - -- Get AC type. - local hornet = playerData.actype == AIRBOSS.AircraftCarrier.HORNET - or playerData.actype == AIRBOSS.AircraftCarrier.RHINOE - or playerData.actype == AIRBOSS.AircraftCarrier.RHINOF - or playerData.actype == AIRBOSS.AircraftCarrier.GROWLER - local skyhawk = playerData.actype == AIRBOSS.AircraftCarrier.A4EC - local tomcat = playerData.actype == AIRBOSS.AircraftCarrier.F14A or playerData.actype == AIRBOSS.AircraftCarrier.F14B - local harrier = playerData.actype == AIRBOSS.AircraftCarrier.AV8B - local goshawk = playerData.actype == AIRBOSS.AircraftCarrier.T45C - - -- Return values. + end + function AIRBOSS:_GetAircraftParameters(playerData,step) + step=step or playerData.step + local hornet=playerData.actype==AIRBOSS.AircraftCarrier.HORNET + or playerData.actype==AIRBOSS.AircraftCarrier.RHINOE + or playerData.actype==AIRBOSS.AircraftCarrier.RHINOF + or playerData.actype==AIRBOSS.AircraftCarrier.GROWLER + local skyhawk=playerData.actype==AIRBOSS.AircraftCarrier.A4EC + local tomcat=playerData.actype==AIRBOSS.AircraftCarrier.F14A or playerData.actype==AIRBOSS.AircraftCarrier.F14B + local harrier=playerData.actype==AIRBOSS.AircraftCarrier.AV8B + local goshawk=playerData.actype==AIRBOSS.AircraftCarrier.T45C local alt local aoa local dist local speed - - -- Aircraft specific AoA. - local aoaac = self:_GetAircraftAoA( playerData ) - - if step == AIRBOSS.PatternStep.PLATFORM then - - alt = UTILS.FeetToMeters( 5000 ) - - -- dist=UTILS.NMToMeters(20) - - speed = UTILS.KnotsToMps( 250 ) - - elseif step == AIRBOSS.PatternStep.ARCIN then - - if tomcat then - speed = UTILS.KnotsToMps( 150 ) - else - speed = UTILS.KnotsToMps( 250 ) - end - - elseif step == AIRBOSS.PatternStep.ARCOUT then - - if tomcat then - speed = UTILS.KnotsToMps( 150 ) - else - speed = UTILS.KnotsToMps( 250 ) - end - - elseif step == AIRBOSS.PatternStep.DIRTYUP then - - alt = UTILS.FeetToMeters( 1200 ) - - -- speed=UTILS.KnotsToMps(250) - - elseif step == AIRBOSS.PatternStep.BULLSEYE then - - alt = UTILS.FeetToMeters( 1200 ) - - dist = -UTILS.NMToMeters( 3 ) - - aoa = aoaac.OnSpeed - - elseif step == AIRBOSS.PatternStep.INITIAL then - - if hornet or tomcat or harrier then - alt = UTILS.FeetToMeters( 800 ) - speed = UTILS.KnotsToMps( 350 ) - elseif skyhawk then - alt = UTILS.FeetToMeters( 600 ) - speed = UTILS.KnotsToMps( 250 ) - elseif goshawk then - alt = UTILS.FeetToMeters( 800 ) - speed = UTILS.KnotsToMps( 300 ) - end - - elseif step == AIRBOSS.PatternStep.BREAKENTRY then - - if hornet or tomcat or harrier then - alt = UTILS.FeetToMeters( 800 ) - speed = UTILS.KnotsToMps( 350 ) - elseif skyhawk then - alt = UTILS.FeetToMeters( 600 ) - speed = UTILS.KnotsToMps( 250 ) - elseif goshawk then - alt = UTILS.FeetToMeters( 800 ) - speed = UTILS.KnotsToMps( 300 ) - end - - elseif step == AIRBOSS.PatternStep.EARLYBREAK then - - if hornet or tomcat or harrier or goshawk then - alt = UTILS.FeetToMeters( 800 ) - elseif skyhawk then - alt = UTILS.FeetToMeters( 600 ) - end - - elseif step == AIRBOSS.PatternStep.LATEBREAK then - - if hornet or tomcat or harrier or goshawk then - alt = UTILS.FeetToMeters( 800 ) - elseif skyhawk then - alt = UTILS.FeetToMeters( 600 ) - end - - elseif step == AIRBOSS.PatternStep.ABEAM then - - if hornet or tomcat or harrier or goshawk then - alt = UTILS.FeetToMeters( 600 ) - elseif skyhawk then - alt = UTILS.FeetToMeters( 500 ) - end - - aoa = aoaac.OnSpeed - - if goshawk then - -- 0.9 to 1.1 NM per natops ch.4 page 48 - dist = UTILS.NMToMeters( 0.9 ) - elseif harrier then - -- 0.8 to 1.0 NM - dist = UTILS.NMToMeters( 0.9 ) - else - dist = UTILS.NMToMeters( 1.1 ) - end - - elseif step == AIRBOSS.PatternStep.NINETY then - - if hornet or tomcat then - alt = UTILS.FeetToMeters( 500 ) - elseif goshawk then - alt = UTILS.FeetToMeters( 450 ) - elseif skyhawk then - alt = UTILS.FeetToMeters( 500 ) - elseif harrier then - alt = UTILS.FeetToMeters( 425 ) - end - - aoa = aoaac.OnSpeed - - elseif step == AIRBOSS.PatternStep.WAKE then - - if hornet or goshawk then - alt = UTILS.FeetToMeters( 370 ) - elseif tomcat then - alt = UTILS.FeetToMeters( 430 ) -- Tomcat should be a bit higher as it intercepts the GS a bit higher. - elseif skyhawk then - alt = UTILS.FeetToMeters( 370 ) -- ? - end - -- Harrier wont get into wake pos. Runway is not angled and it stays port. - - aoa = aoaac.OnSpeed - - elseif step == AIRBOSS.PatternStep.FINAL then - - if hornet or goshawk then - alt = UTILS.FeetToMeters( 300 ) - elseif tomcat then - alt = UTILS.FeetToMeters( 360 ) - elseif skyhawk then - alt = UTILS.FeetToMeters( 300 ) -- ? - elseif harrier then - alt=UTILS.FeetToMeters(312)-- 300-325 ft - end - - aoa = aoaac.OnSpeed - + local aoaac=self:_GetAircraftAoA(playerData) + if step==AIRBOSS.PatternStep.PLATFORM then + alt=UTILS.FeetToMeters(5000) + speed=UTILS.KnotsToMps(250) + elseif step==AIRBOSS.PatternStep.ARCIN then + if tomcat then + speed=UTILS.KnotsToMps(150) + else + speed=UTILS.KnotsToMps(250) end - - return alt, aoa, dist, speed -end - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- QUEUE Functions ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ---- Get next marshal flight which is ready to enter the landing pattern. --- @param #AIRBOSS self --- @return #AIRBOSS.FlightGroup Marshal flight next in line and ready to enter the pattern. Or nil if no flight is ready. -function AIRBOSS:_GetNextMarshalFight() - - -- Loop over all marshal flights. - for _, _flight in pairs( self.Qmarshal ) do - local flight = _flight -- #AIRBOSS.FlightGroup - - -- Current stack. - local stack = flight.flag - - -- Total marshal time in seconds. - local Tmarshal = timer.getAbsTime() - flight.time - - -- Min time in marshal stack. - local TmarshalMin = 2 * 60 -- Two minutes for human players. - if flight.ai then - TmarshalMin = 3 * 60 -- Three minutes for AI. - end - - -- Check if conditions are right. - if flight.holding ~= nil and Tmarshal >= TmarshalMin then - if flight.case == 1 and stack == 1 or flight.case > 1 then - if flight.ai then - -- Return AI flight. - return flight - else - -- Check for human player if they are already commencing. - if flight.step ~= AIRBOSS.PatternStep.COMMENCING then - return flight - end - end - end - end + elseif step==AIRBOSS.PatternStep.ARCOUT then + if tomcat then + speed=UTILS.KnotsToMps(150) + else + speed=UTILS.KnotsToMps(250) end - - return nil -end - ---- Check marshal and pattern queues. --- @param #AIRBOSS self -function AIRBOSS:_CheckQueue() - - -- Print queues. - if self.Debug then - self:_PrintQueue( self.flights, "All Flights" ) + elseif step==AIRBOSS.PatternStep.DIRTYUP then + alt=UTILS.FeetToMeters(1200) + elseif step==AIRBOSS.PatternStep.BULLSEYE then + alt=UTILS.FeetToMeters(1200) + dist=-UTILS.NMToMeters(3) + aoa=aoaac.OnSpeed + elseif step==AIRBOSS.PatternStep.INITIAL then + if hornet or tomcat or harrier then + alt=UTILS.FeetToMeters(800) + speed=UTILS.KnotsToMps(350) + elseif skyhawk then + alt=UTILS.FeetToMeters(600) + speed=UTILS.KnotsToMps(250) + elseif goshawk then + alt=UTILS.FeetToMeters(800) + speed=UTILS.KnotsToMps(300) end - self:_PrintQueue( self.Qmarshal, "Marshal" ) - self:_PrintQueue( self.Qpattern, "Pattern" ) - self:_PrintQueue( self.Qwaiting, "Waiting" ) - self:_PrintQueue( self.Qspinning, "Spinning" ) - - -- If flights are waiting outside 10 NM zone and carrier switches from Case I to Case II/III, they should be added to the Marshal stack as now there is no stack limit any more. - if self.case > 1 then - for _, _flight in pairs( self.Qwaiting ) do - local flight = _flight -- #AIRBOSS.FlightGroup - - -- Remove flight from waiting queue. - local removed = self:_RemoveFlightFromQueue( self.Qwaiting, flight ) - - if removed then - - -- Get free stack - local stack = self:_GetFreeStack( flight.ai ) - - -- Debug info. - self:T( self.lid .. string.format( "Moving flight %s onboard %s from Waiting queue to Case %d Marshal stack %d", flight.groupname, flight.onboard, self.case, stack ) ) - - -- Send flight to marshal stack. - if flight.ai then - self:_MarshalAI( flight, stack ) - else - self:_MarshalPlayer( flight, stack ) - end - - -- Break the loop so that only one flight per 30 seconds is removed. - break - end - - end + elseif step==AIRBOSS.PatternStep.BREAKENTRY then + if hornet or tomcat or harrier then + alt=UTILS.FeetToMeters(800) + speed=UTILS.KnotsToMps(350) + elseif skyhawk then + alt=UTILS.FeetToMeters(600) + speed=UTILS.KnotsToMps(250) + elseif goshawk then + alt=UTILS.FeetToMeters(800) + speed=UTILS.KnotsToMps(300) end - - -- Check if carrier is currently in recovery mode. - if not self:IsRecovering() then - - ----------------------------- - -- Switching Recovery Case -- - ----------------------------- - - -- Loop over all flights currently in the marshal queue. - for _, _flight in pairs( self.Qmarshal ) do - local flight = _flight -- #AIRBOSS.FlightGroup - - -- TODO: In principle this should be done/necessary only if case 1-->2/3 or 2/3-->1, right? - -- When recovery switches from 2->3 or 3-->2 nothing changes in the marshal stack. - - -- Check if a change of stack is necessary. - if (flight.case == 1 and self.case > 1) or (flight.case > 1 and self.case == 1) then - - -- Remove flight from marshal queue. - local removed = self:_RemoveFlightFromQueue( self.Qmarshal, flight ) - - if removed then - - -- Get free stack - local stack = self:_GetFreeStack( flight.ai ) - - -- Debug output. - self:T( self.lid .. string.format( "Moving flight %s onboard %s from Marshal Case %d ==> %d Marshal stack %d", flight.groupname, flight.onboard, flight.case, self.case, stack ) ) - - -- Send flight to marshal queue. - if flight.ai then - self:_MarshalAI( flight, stack ) - else - self:_MarshalPlayer( flight, stack ) - end - - -- Break the loop so that only one flight per 30 seconds is removed. No spam of messages, no conflict with the loop over queue entries. - break - - elseif flight.case ~= self.case then - - -- This should handle 2-->3 or 3-->2 - flight.case = self.case - - end - - end - end - - -- Not recovering ==> skip the rest! - return + elseif step==AIRBOSS.PatternStep.EARLYBREAK then + if hornet or tomcat or harrier or goshawk then + alt=UTILS.FeetToMeters(800) + elseif skyhawk then + alt=UTILS.FeetToMeters(600) end - - -- Get number of airborne aircraft units(!) currently in pattern. - local _, npattern = self:_GetQueueInfo( self.Qpattern ) - - -- Get number of aircraft units spinning. - local _, nspinning = self:_GetQueueInfo( self.Qspinning ) - - -- Get next marshal flight. - local marshalflight = self:_GetNextMarshalFight() - - -- Check if there are flights waiting in the Marshal stack and if the pattern is free. No one should be spinning. - if marshalflight and npattern < self.Nmaxpattern and nspinning == 0 then - - -- Time flight is marshaling. - local Tmarshal = timer.getAbsTime() - marshalflight.time - self:T( self.lid .. string.format( "Marshal time of next group %s = %d seconds", marshalflight.groupname, Tmarshal ) ) - - -- Time (last) flight has entered landing pattern. - local Tpattern = 9999 - local npunits = 1 - local pcase = 1 - if npattern > 0 then - - -- Last flight group send to pattern. - local patternflight = self.Qpattern[#self.Qpattern] -- #AIRBOSS.FlightGroup - - -- Recovery case of pattern flight. - pcase = patternflight.case - - -- Number of airborne aircraft in this group. Count includes section members. - local npunits = self:_GetFlightUnits( patternflight, false ) - - -- Get time in pattern. - Tpattern = timer.getAbsTime() - patternflight.time - self:T( self.lid .. string.format( "Pattern time of last group %s = %d seconds. # of units=%d.", patternflight.groupname, Tpattern, npunits ) ) - end - - -- Min time in pattern before next aircraft is allowed. - local TpatternMin - if pcase == 1 then - TpatternMin = 2 * 60 * npunits -- 45*npunits -- 45 seconds interval per plane! - else - TpatternMin = 2 * 60 * npunits -- 120*npunits -- 120 seconds interval per plane! - end - - -- Check interval to last pattern flight. - if Tpattern > TpatternMin then - self:T( self.lid .. string.format( "Sending marshal flight %s to pattern.", marshalflight.groupname ) ) - self:_ClearForLanding( marshalflight ) - end - + elseif step==AIRBOSS.PatternStep.LATEBREAK then + if hornet or tomcat or harrier or goshawk then + alt=UTILS.FeetToMeters(800) + elseif skyhawk then + alt=UTILS.FeetToMeters(600) end -end - ---- Clear flight for landing. AI are removed from Marshal queue and the Marshal stack is collapsed. --- If next in line is an AI flight, this is done. If human player is next, we wait for "Commence" via F10 radio menu command. --- @param #AIRBOSS self --- @param #AIRBOSS.FlightGroup flight Flight to go to pattern. -function AIRBOSS:_ClearForLanding( flight ) - - -- Check if flight is AI or human. If AI, we collapse the stack and commence. If human, we suggest to commence. + elseif step==AIRBOSS.PatternStep.ABEAM then + if hornet or tomcat or harrier or goshawk then + alt=UTILS.FeetToMeters(600) + elseif skyhawk then + alt=UTILS.FeetToMeters(500) + end + aoa=aoaac.OnSpeed + if goshawk then + dist=UTILS.NMToMeters(0.9) + elseif harrier then + dist=UTILS.NMToMeters(0.9) + else + dist=UTILS.NMToMeters(1.1) + end + elseif step==AIRBOSS.PatternStep.NINETY then + if hornet or tomcat then + alt=UTILS.FeetToMeters(500) + elseif goshawk then + alt=UTILS.FeetToMeters(450) + elseif skyhawk then + alt=UTILS.FeetToMeters(500) + elseif harrier then + alt=UTILS.FeetToMeters(425) + end + aoa=aoaac.OnSpeed + elseif step==AIRBOSS.PatternStep.WAKE then + if hornet or goshawk then + alt=UTILS.FeetToMeters(370) + elseif tomcat then + alt=UTILS.FeetToMeters(430) + elseif skyhawk then + alt=UTILS.FeetToMeters(370) + end + aoa=aoaac.OnSpeed + elseif step==AIRBOSS.PatternStep.FINAL then + if hornet or goshawk then + alt=UTILS.FeetToMeters(300) + elseif tomcat then + alt=UTILS.FeetToMeters(360) + elseif skyhawk then + alt=UTILS.FeetToMeters(300) + elseif harrier then + alt=UTILS.FeetToMeters(312) + end + aoa=aoaac.OnSpeed + end + return alt,aoa,dist,speed + end + function AIRBOSS:_GetNextMarshalFight() + for _,_flight in pairs(self.Qmarshal)do + local flight=_flight + local stack=flight.flag + local Tmarshal=timer.getAbsTime()-flight.time + local TmarshalMin=2*60 if flight.ai then - - -- Collapse stack and send AI to pattern. - self:_RemoveFlightFromMarshalQueue( flight, false ) - self:_LandAI( flight ) - - -- Cleared for Case X recovery. - self:_MarshalCallClearedForRecovery( flight.onboard, flight.case ) - - -- Voice over of the commencing simulated call from AI - if self.xtVoiceOversAI then - local leader = flight.group:GetUnits()[1] - self:_CommencingCall(leader, flight.onboard) - end - + TmarshalMin=3*60 + end + if flight.holding~=nil and Tmarshal>=TmarshalMin then + if flight.case==1 and stack==1 or flight.case>1 then + if flight.ai then + return flight else - - -- Cleared for Case X recovery. - if flight.step ~= AIRBOSS.PatternStep.COMMENCING then - self:_MarshalCallClearedForRecovery( flight.onboard, flight.case ) - flight.time = timer.getAbsTime() - end - - -- Set step to commencing. This will trigger the zone check until the player is in the right place. - self:_SetPlayerStep( flight, AIRBOSS.PatternStep.COMMENCING, 3 ) - + if flight.step~=AIRBOSS.PatternStep.COMMENCING then + return flight end - -end - ---- Set player step. Any warning is erased and next step hint shown. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. --- @param #string step Next step. --- @param #number delay (Optional) Set set after a delay in seconds. -function AIRBOSS:_SetPlayerStep( playerData, step, delay ) - - if delay and delay > 0 then - -- Delayed call. - -- SCHEDULER:New(nil, self._SetPlayerStep, {self, playerData, step}, delay) - self:ScheduleOnce( delay, self._SetPlayerStep, self, playerData, step ) - else - - -- Check if player still exists after possible delay. - if playerData then - - -- Set player step. - playerData.step = step - - -- Erase warning. - playerData.warning = nil - - -- Next step hint. - self:_StepHint( playerData ) - end - end - -end - ---- Scan carrier zone for (new) units. --- @param #AIRBOSS self -function AIRBOSS:_ScanCarrierZone() - - -- Carrier position. - local coord = self:GetCoordinate() - - -- Scan radius = radius of the CCA. - local RCCZ = self.zoneCCA:GetRadius() - - -- Debug info. - self:T( self.lid .. string.format( "Scanning Carrier Controlled Area. Radius=%.1f NM.", UTILS.MetersToNM( RCCZ ) ) ) - - -- Scan units in carrier zone. - local _, _, _, unitscan = coord:ScanObjects( RCCZ, true, false, false ) - - -- Make a table with all groups currently in the CCA zone. - local insideCCA = {} - for _, _unit in pairs( unitscan ) do - local unit = _unit -- Wrapper.Unit#UNIT - - -- Necessary conditions to be met: - local airborne = unit:IsAir() -- and unit:InAir() - local inzone = unit:IsInZone( self.zoneCCA ) - local friendly = self:GetCoalition() == unit:GetCoalition() - local carrierac = self:_IsCarrierAircraft( unit ) - - -- Check if this an aircraft and that it is airborne and closing in. - if airborne and inzone and friendly and carrierac then - - local group = unit:GetGroup() - local groupname = group:GetName() - - if insideCCA[groupname] == nil then - insideCCA[groupname] = group - end - - end end - - -- Find new flights that are inside CCA. - for groupname, _group in pairs( insideCCA ) do - local group = _group -- Wrapper.Group#GROUP - - -- Get flight group if possible. - local knownflight = self:_GetFlightFromGroupInQueue( group, self.flights ) - - -- Get aircraft type name. - local actype = group:GetTypeName() - - -- Create a new flight group - if knownflight then - - -- Debug output. - self:T2(self.lid..string.format("Known flight group %s of type %s in CCA.", groupname, actype)) - - -- Check if flight is AI and if we want to handle it at all. - if knownflight.ai and knownflight.flag == -100 and self.handleai then - - local putintomarshal = false - - -- Get flight group. - local flight = _DATABASE:GetOpsGroup( groupname ) - - if flight and flight:IsInbound() and flight.destbase:GetName() == self.carrier:GetName() then - if flight.ishelo then - else - putintomarshal = true - end - flight.airboss = self - end - - -- Send AI flight to marshal stack if group closes in more than 5 and has initial flag value. - if putintomarshal then - - - -- Get the next free stack for current recovery case. - local stack = self:_GetFreeStack( knownflight.ai ) - - -- Repawn. - local respawn = self.respawnAI - - if stack then - - -- Send AI to marshal stack. We respawn the group to clean possible departure and destination airbases. - self:_MarshalAI( knownflight, stack, respawn ) - - else - - -- Send AI to orbit outside 10 NM zone and wait until the next Marshal stack is available. - if not self:_InQueue( self.Qwaiting, knownflight.group ) then - self:_WaitAI( knownflight, respawn ) -- Group is respawned to clear any attached airfields. - end - - end - - -- Break the loop to not have all flights at once! Spams the message screen. - break - - end -- Closed in or tanker/AWACS - - end - - else - - -- Unknown new AI flight. Create a new flight group. - if not self:_IsHuman( group ) then - self:_CreateFlightGroup( group ) - end - end - end - - -- Find flights that are not in CCA. - local remove = {} - for _, _flight in pairs( self.flights ) do - local flight = _flight -- #AIRBOSS.FlightGroup - if insideCCA[flight.groupname] == nil then - -- Do not remove flights in marshal pattern. At least for case 2 & 3. If zone is set small, they might be outside in the holding pattern. - if flight.ai and not (self:_InQueue( self.Qmarshal, flight.group ) or self:_InQueue( self.Qpattern, flight.group )) then - table.insert( remove, flight ) - end - end end - - -- Remove flight groups outside CCA. - for _, flight in pairs( remove ) do - self:_RemoveFlightFromQueue( self.flights, flight ) + return nil end - -end - ---- Tell player to wait outside the 10 NM zone until a Marshal stack is available. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. -function AIRBOSS:_WaitPlayer( playerData ) - - -- Check if flight is known to the airboss already. - if playerData then - - -- Number of waiting flights - local nwaiting = #self.Qwaiting - - -- Radio message: Stack is full. - self:_MarshalCallStackFull( playerData.onboard, nwaiting ) - - -- Add player flight to waiting queue. - table.insert( self.Qwaiting, playerData ) - - -- Set time stamp. - playerData.time = timer.getAbsTime() - - -- Set step to waiting. - playerData.step = AIRBOSS.PatternStep.WAITING - playerData.warning = nil - - -- Set all flights in section to waiting. - for _, _flight in pairs( playerData.section ) do - local flight = _flight -- #AIRBOSS.PlayerData - flight.step = AIRBOSS.PatternStep.WAITING - flight.time = timer.getAbsTime() - flight.warning = nil - end - - end - -end - ---- Orbit at a specified position at a specified altitude with a specified speed. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. --- @param #number stack The Marshal stack the player gets. -function AIRBOSS:_MarshalPlayer( playerData, stack ) - - -- Check if flight is known to the airboss already. - if playerData then - - -- Add group to marshal stack. - self:_AddMarshalGroup( playerData, stack ) - - -- Set step to holding. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.HOLDING ) - - -- Holding switch to nil until player arrives in the holding zone. - playerData.holding = nil - - -- Set same stack for all flights in section. - for _, _flight in pairs( playerData.section ) do - local flight = _flight -- #AIRBOSS.PlayerData - - -- XXX: Inform player? Should be done by lead via radio? - - -- Set step. - self:_SetPlayerStep( flight, AIRBOSS.PatternStep.HOLDING ) - - -- Holding to nil, until arrived. - flight.holding = nil - - -- Set case to that of lead. - flight.case = playerData.case - - -- Set stack flag. - flight.flag = stack - - -- Trigger Marshal event. - self:Marshal( flight ) - end - - else - self:E( self.lid .. "ERROR: Could not add player to Marshal stack! playerData=nil" ) - end - -end - ---- Command AI flight to orbit outside the 10 NM zone and wait for a free Marshal stack. --- If the flight is not already holding in the Marshal stack, it is guided there first. --- @param #AIRBOSS self --- @param #AIRBOSS.FlightGroup flight Flight group. --- @param #boolean respawn If true respawn the group. Otherwise reset the mission task with new waypoints. -function AIRBOSS:_WaitAI( flight, respawn ) - - -- Set flag to something other than -100 and <0 - flight.flag = -99 - - -- Add AI flight to waiting queue. - table.insert( self.Qwaiting, flight ) - - -- Flight group name. - local group = flight.group - local groupname = flight.groupname - - -- Aircraft speed 274 knots TAS ~= 250 KIAS when orbiting the pattern. (Orbit expects m/s.) - local speedOrbitMps = UTILS.KnotsToMps( 274 ) - - -- Orbit speed in km/h for waypoints. - local speedOrbitKmh = UTILS.KnotsToKmph( 274 ) - - -- Aircraft speed 400 knots when transiting to holding zone. (Waypoint expects km/h.) - local speedTransit = UTILS.KnotsToKmph( 370 ) - - -- Carrier coordinate - local cv = self:GetCoordinate() - - -- Coordinate of flight group - local fc = group:GetCoordinate() - - -- Carrier heading - local hdg = self:GetHeading( false ) - - -- Heading from carrier to flight group - local hdgto = cv:HeadingTo( fc ) - - -- Holding altitude between angels 6 and 10 (random). - local angels = math.random( 6, 10 ) - local altitude = UTILS.FeetToMeters( angels * 1000 ) - - -- Point outsize 10 NM zone of the carrier. - local p0 = cv:Translate( UTILS.NMToMeters( 11 ), hdgto ):Translate( UTILS.NMToMeters( 5 ), hdg ):SetAltitude( altitude ) - - -- Waypoints array to be filled depending on case etc. - local wp = {} - - -- Current position. Always good for as the first waypoint. - wp[1] = group:GetCoordinate():WaypointAirTurningPoint( nil, speedTransit, {}, "Current Position" ) - - -- Set orbit task. - local taskorbit = group:TaskOrbit( p0, altitude, speedOrbitMps ) - - -- Orbit at waypoint. - wp[#wp + 1] = p0:WaypointAirTurningPoint( nil, speedOrbitKmh, { taskorbit }, string.format( "Waiting Orbit at Angels %d", angels ) ) - - -- Debug markers. + function AIRBOSS:_CheckQueue() if self.Debug then - p0:MarkToAll( string.format( "Waiting Orbit of flight %s at Angels %s", groupname, angels ) ) + self:_PrintQueue(self.flights,"All Flights") + end + self:_PrintQueue(self.Qmarshal,"Marshal") + self:_PrintQueue(self.Qpattern,"Pattern") + self:_PrintQueue(self.Qwaiting,"Waiting") + self:_PrintQueue(self.Qspinning,"Spinning") + if self.case>1 then + for _,_flight in pairs(self.Qwaiting)do + local flight=_flight + local removed=self:_RemoveFlightFromQueue(self.Qwaiting,flight) + if removed then + local stack=self:_GetFreeStack(flight.ai) + self:T(self.lid..string.format("Moving flight %s onboard %s from Waiting queue to Case %d Marshal stack %d",flight.groupname,flight.onboard,self.case,stack)) + if flight.ai then + self:_MarshalAI(flight,stack) + else + self:_MarshalPlayer(flight,stack) + end + break + end + end + end + if not self:IsRecovering()then + for _,_flight in pairs(self.Qmarshal)do + local flight=_flight + if(flight.case==1 and self.case>1)or(flight.case>1 and self.case==1)then + local removed=self:_RemoveFlightFromQueue(self.Qmarshal,flight) + if removed then + local stack=self:_GetFreeStack(flight.ai) + self:T(self.lid..string.format("Moving flight %s onboard %s from Marshal Case %d ==> %d Marshal stack %d",flight.groupname,flight.onboard,flight.case,self.case,stack)) + if flight.ai then + self:_MarshalAI(flight,stack) + else + self:_MarshalPlayer(flight,stack) + end + break + elseif flight.case~=self.case then + flight.case=self.case + end + end + end + return + end + local _,npattern=self:_GetQueueInfo(self.Qpattern) + local _,nspinning=self:_GetQueueInfo(self.Qspinning) + local marshalflight=self:_GetNextMarshalFight() + if marshalflight and npattern0 then + local patternflight=self.Qpattern[#self.Qpattern] + pcase=patternflight.case + local npunits=self:_GetFlightUnits(patternflight,false) + Tpattern=timer.getAbsTime()-patternflight.time + self:T(self.lid..string.format("Pattern time of last group %s = %d seconds. # of units=%d.",patternflight.groupname,Tpattern,npunits)) + end + local TpatternMin + if pcase==1 then + TpatternMin=2*60*npunits + else + TpatternMin=2*60*npunits + end + if Tpattern>TpatternMin then + self:T(self.lid..string.format("Sending marshal flight %s to pattern.",marshalflight.groupname)) + self:_ClearForLanding(marshalflight) + end + end + end + function AIRBOSS:_ClearForLanding(flight) + if flight.ai then + self:_RemoveFlightFromMarshalQueue(flight,false) + self:_LandAI(flight) + self:_MarshalCallClearedForRecovery(flight.onboard,flight.case) + if self.xtVoiceOversAI then + local leader=flight.group:GetUnits()[1] + self:_CommencingCall(leader,flight.onboard) + end + else + if flight.step~=AIRBOSS.PatternStep.COMMENCING then + self:_MarshalCallClearedForRecovery(flight.onboard,flight.case) + flight.time=timer.getAbsTime() + end + self:_SetPlayerStep(flight,AIRBOSS.PatternStep.COMMENCING,3) + end + end + function AIRBOSS:_SetPlayerStep(playerData,step,delay) + if delay and delay>0 then + self:ScheduleOnce(delay,self._SetPlayerStep,self,playerData,step) + else + if playerData then + playerData.step=step + playerData.warning=nil + self:_StepHint(playerData) + end + end + end + function AIRBOSS:_ScanCarrierZone() + local coord=self:GetCoordinate() + local RCCZ=self.zoneCCA:GetRadius() + self:T(self.lid..string.format("Scanning Carrier Controlled Area. Radius=%.1f NM.",UTILS.MetersToNM(RCCZ))) + local _,_,_,unitscan=coord:ScanObjects(RCCZ,true,false,false) + local insideCCA={} + for _,_unit in pairs(unitscan)do + local unit=_unit + local airborne=unit:IsAir() + local inzone=unit:IsInZone(self.zoneCCA) + local friendly=self:GetCoalition()==unit:GetCoalition() + local carrierac=self:_IsCarrierAircraft(unit) + if airborne and inzone and friendly and carrierac then + local group=unit:GetGroup() + local groupname=group:GetName() + if insideCCA[groupname]==nil then + insideCCA[groupname]=group + end + end + end + for groupname,_group in pairs(insideCCA)do + local group=_group + local knownflight=self:_GetFlightFromGroupInQueue(group,self.flights) + local actype=group:GetTypeName() + if knownflight then + self:T2(self.lid..string.format("Known flight group %s of type %s in CCA.",groupname,actype)) + if knownflight.ai and knownflight.flag==-100 and self.handleai then + local putintomarshal=false + local flight=_DATABASE:GetOpsGroup(groupname) + if flight and flight:IsInbound()and flight.destbase:GetName()==self.carrier:GetName()then + if flight.ishelo then + else + putintomarshal=true + end + flight.airboss=self + end + if putintomarshal then + local stack=self:_GetFreeStack(knownflight.ai) + local respawn=self.respawnAI + if stack then + self:_MarshalAI(knownflight,stack,respawn) + else + if not self:_InQueue(self.Qwaiting,knownflight.group)then + self:_WaitAI(knownflight,respawn) + end + end + break + end + end + else + if not self:_IsHuman(group)then + self:_CreateFlightGroup(group) + end + end + end + local remove={} + for _,_flight in pairs(self.flights)do + local flight=_flight + if insideCCA[flight.groupname]==nil then + if flight.ai and not(self:_InQueue(self.Qmarshal,flight.group)or self:_InQueue(self.Qpattern,flight.group))then + table.insert(remove,flight) + end + end + end + for _,flight in pairs(remove)do + self:_RemoveFlightFromQueue(self.flights,flight) + end + end + function AIRBOSS:_WaitPlayer(playerData) + if playerData then + local nwaiting=#self.Qwaiting + self:_MarshalCallStackFull(playerData.onboard,nwaiting) + table.insert(self.Qwaiting,playerData) + playerData.time=timer.getAbsTime() + playerData.step=AIRBOSS.PatternStep.WAITING + playerData.warning=nil + for _,_flight in pairs(playerData.section)do + local flight=_flight + flight.step=AIRBOSS.PatternStep.WAITING + flight.time=timer.getAbsTime() + flight.warning=nil + end + end + end + function AIRBOSS:_MarshalPlayer(playerData,stack) + if playerData then + self:_AddMarshalGroup(playerData,stack) + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.HOLDING) + playerData.holding=nil + for _,_flight in pairs(playerData.section)do + local flight=_flight + self:_SetPlayerStep(flight,AIRBOSS.PatternStep.HOLDING) + flight.holding=nil + flight.case=playerData.case + flight.flag=stack + self:Marshal(flight) + end + else + self:E(self.lid.."ERROR: Could not add player to Marshal stack! playerData=nil") + end + end + function AIRBOSS:_WaitAI(flight,respawn) + flight.flag=-99 + table.insert(self.Qwaiting,flight) + local group=flight.group + local groupname=flight.groupname + local speedOrbitMps=UTILS.KnotsToMps(274) + local speedOrbitKmh=UTILS.KnotsToKmph(274) + local speedTransit=UTILS.KnotsToKmph(370) + local cv=self:GetCoordinate() + local fc=group:GetCoordinate() + local hdg=self:GetHeading(false) + local hdgto=cv:HeadingTo(fc) + local angels=math.random(6,10) + local altitude=UTILS.FeetToMeters(angels*1000) + local p0=cv:Translate(UTILS.NMToMeters(11),hdgto):Translate(UTILS.NMToMeters(5),hdg):SetAltitude(altitude) + local wp={} + wp[1]=group:GetCoordinate():WaypointAirTurningPoint(nil,speedTransit,{},"Current Position") + local taskorbit=group:TaskOrbit(p0,altitude,speedOrbitMps) + wp[#wp+1]=p0:WaypointAirTurningPoint(nil,speedOrbitKmh,{taskorbit},string.format("Waiting Orbit at Angels %d",angels)) + if self.Debug then + p0:MarkToAll(string.format("Waiting Orbit of flight %s at Angels %s",groupname,angels)) end - if respawn then - - -- This should clear the landing waypoints. - -- Note: This resets the weapons and the fuel state. But not the units fortunately. - - -- Get group template. - local Template = group:GetTemplate() - - -- Set route points. - Template.route.points = wp - - -- Respawn the group. - group = group:Respawn( Template, true ) - + local Template=group:GetTemplate() + Template.route.points=wp + group=group:Respawn(Template,true) end - - -- Reinit waypoints. - group:WayPointInitialize( wp ) - - -- Route group. - group:Route( wp, 1 ) - -end - ---- Command AI flight to orbit at a specified position at a specified altitude with a specified speed. If flight is not in the Marshal queue yet, it is added. This fixes the recovery case. --- If the flight is not already holding in the Marshal stack, it is guided there first. --- @param #AIRBOSS self --- @param #AIRBOSS.FlightGroup flight Flight group. --- @param #number nstack Stack number of group. Can also be the current stack if AI position needs to be updated wrt to changed carrier position. --- @param #boolean respawn If true, respawn the flight otherwise update mission task with new waypoints. -function AIRBOSS:_MarshalAI( flight, nstack, respawn ) - self:F2( { flight = flight, nstack = nstack, respawn = respawn } ) - - -- Nil check. - if flight == nil or flight.group == nil then - self:E( self.lid .. "ERROR: flight or flight.group is nil." ) - return + group:WayPointInitialize(wp) + group:Route(wp,1) end - - -- Nil check. - if flight.group:GetCoordinate() == nil then - self:E( self.lid .. "ERROR: cannot get coordinate of flight group." ) - return + function AIRBOSS:_MarshalAI(flight,nstack,respawn) + self:F2({flight=flight,nstack=nstack,respawn=respawn}) + if flight==nil or flight.group==nil then + self:E(self.lid.."ERROR: flight or flight.group is nil.") + return end - - -- Check if flight is already in Marshal queue. - if not self:_InQueue(self.Qmarshal,flight.group) then - -- Simulate inbound call - if self.xtVoiceOversAI then - local leader = flight.group:GetUnits()[1] - self:_MarshallInboundCall(leader, flight.onboard) - end - -- Add group to marshal stack queue. - self:_AddMarshalGroup( flight, nstack ) + if flight.group:GetCoordinate()==nil then + self:E(self.lid.."ERROR: cannot get coordinate of flight group.") + return end - - -- Explode unit for testing. Worked! - -- local u1=flight.group:GetUnit(1) --Wrapper.Unit#UNIT - -- u1:Explode(500, 10) - - -- Recovery case. - local case = flight.case - - -- Get old/current stack. - local ostack = flight.flag - - -- Flight group name. - local group = flight.group - local groupname = flight.groupname - - -- Set new stack. - flight.flag = nstack - - -- Current carrier position. - local Carrier = self:GetCoordinate() - - -- Carrier heading. - local hdg = self:GetHeading() - - -- Aircraft speed 274 knots TAS ~= 250 KIAS when orbiting the pattern. (Orbit expects m/s.) - local speedOrbitMps = UTILS.KnotsToMps( 274 ) - - -- Orbit speed in km/h for waypoints. - local speedOrbitKmh = UTILS.KnotsToKmph( 274 ) - - -- Aircraft speed 400 knots when transiting to holding zone. (Waypoint expects km/h.) - local speedTransit = UTILS.KnotsToKmph( 370 ) - + if not self:_InQueue(self.Qmarshal,flight.group)then + if self.xtVoiceOversAI then + local leader=flight.group:GetUnits()[1] + self:_MarshallInboundCall(leader,flight.onboard) + end + self:_AddMarshalGroup(flight,nstack) + end + local case=flight.case + local ostack=flight.flag + local group=flight.group + local groupname=flight.groupname + flight.flag=nstack + local Carrier=self:GetCoordinate() + local hdg=self:GetHeading() + local speedOrbitMps=UTILS.KnotsToMps(274) + local speedOrbitKmh=UTILS.KnotsToKmph(274) + local speedTransit=UTILS.KnotsToKmph(370) local altitude - local p0 -- Core.Point#COORDINATE - local p1 -- Core.Point#COORDINATE - local p2 -- Core.Point#COORDINATE - - -- Get altitude and positions. - altitude, p1, p2 = self:_GetMarshalAltitude( nstack, case ) - - -- Waypoints array to be filled depending on case etc. - local wp = {} - - -- If flight has not arrived in the holding zone, we guide it there. + local p0 + local p1 + local p2 + altitude,p1,p2=self:_GetMarshalAltitude(nstack,case) + local wp={} if not flight.holding then - - ---------------------- - -- Route to Holding -- - ---------------------- - - -- Debug info. - self:T( self.lid .. string.format( "Guiding AI flight %s to marshal stack %d-->%d.", groupname, ostack, nstack ) ) - - -- Current position. Always good for as the first waypoint. - wp[1] = group:GetCoordinate():WaypointAirTurningPoint( nil, speedTransit, {}, "Current Position" ) - - -- Task function when arriving at the holding zone. This will set flight.holding=true. - local TaskArrivedHolding = flight.group:TaskFunction( "AIRBOSS._ReachedHoldingZone", self, flight ) - - -- Select case. - if case == 1 then - - -- Initial point 7 NM and a bit port of carrier. - local pE = Carrier:Translate( UTILS.NMToMeters( 7 ), hdg - 30 ):SetAltitude( altitude ) - - -- Entry point 5 NM port and slightly astern the boat. - p0 = Carrier:Translate( UTILS.NMToMeters( 5 ), hdg - 135 ):SetAltitude( altitude ) - - -- Waypoint ahead of carrier's holding zone. - wp[#wp + 1] = pE:WaypointAirTurningPoint( nil, speedTransit, { TaskArrivedHolding }, "Entering Case I Marshal Pattern" ) - - else - - -- Get correct radial depending on recovery case including offset. - local radial = self:GetRadial( case, false, true ) - - -- Point in the middle of the race track and a 5 NM more port perpendicular. - p0 = p2:Translate( UTILS.NMToMeters( 5 ), radial + 90, true ):Translate( UTILS.NMToMeters( 5 ), radial, true ) - - -- Entering Case II/III marshal pattern waypoint. - wp[#wp + 1] = p0:WaypointAirTurningPoint( nil, speedTransit, { TaskArrivedHolding }, "Entering Case II/III Marshal Pattern" ) - - end - + self:T(self.lid..string.format("Guiding AI flight %s to marshal stack %d-->%d.",groupname,ostack,nstack)) + wp[1]=group:GetCoordinate():WaypointAirTurningPoint(nil,speedTransit,{},"Current Position") + local TaskArrivedHolding=flight.group:TaskFunction("AIRBOSS._ReachedHoldingZone",self,flight) + if case==1 then + local pE=Carrier:Translate(UTILS.NMToMeters(7),hdg-30):SetAltitude(altitude) + p0=Carrier:Translate(UTILS.NMToMeters(5),hdg-135):SetAltitude(altitude) + wp[#wp+1]=pE:WaypointAirTurningPoint(nil,speedTransit,{TaskArrivedHolding},"Entering Case I Marshal Pattern") else - - ------------------------ - -- In Marshal Pattern -- - ------------------------ - - -- Debug info. - self:T( self.lid .. string.format( "Updating AI flight %s at marshal stack %d-->%d.", groupname, ostack, nstack ) ) - - -- Current position. Speed expected in km/h. - wp[1] = group:GetCoordinate():WaypointAirTurningPoint( nil, speedOrbitKmh, {}, "Current Position" ) - - -- Create new waypoint 0.2 Nm ahead of current positon. - p0 = group:GetCoordinate():Translate( UTILS.NMToMeters( 0.2 ), group:GetHeading(), true ) - + local radial=self:GetRadial(case,false,true) + p0=p2:Translate(UTILS.NMToMeters(5),radial+90,true):Translate(UTILS.NMToMeters(5),radial,true) + wp[#wp+1]=p0:WaypointAirTurningPoint(nil,speedTransit,{TaskArrivedHolding},"Entering Case II/III Marshal Pattern") end - - -- Set orbit task. - local taskorbit = group:TaskOrbit( p1, altitude, speedOrbitMps, p2 ) - - -- Orbit at waypoint. - wp[#wp + 1] = p0:WaypointAirTurningPoint( nil, speedOrbitKmh, { taskorbit }, string.format( "Marshal Orbit Stack %d", nstack ) ) - - -- Debug markers. + else + self:T(self.lid..string.format("Updating AI flight %s at marshal stack %d-->%d.",groupname,ostack,nstack)) + wp[1]=group:GetCoordinate():WaypointAirTurningPoint(nil,speedOrbitKmh,{},"Current Position") + p0=group:GetCoordinate():Translate(UTILS.NMToMeters(0.2),group:GetHeading(),true) + end + local taskorbit=group:TaskOrbit(p1,altitude,speedOrbitMps,p2) + wp[#wp+1]=p0:WaypointAirTurningPoint(nil,speedOrbitKmh,{taskorbit},string.format("Marshal Orbit Stack %d",nstack)) if self.Debug then - p0:MarkToAll( "WP P0 " .. groupname ) - p1:MarkToAll( "RT P1 " .. groupname ) - p2:MarkToAll( "RT P2 " .. groupname ) + p0:MarkToAll("WP P0 "..groupname) + p1:MarkToAll("RT P1 "..groupname) + p2:MarkToAll("RT P2 "..groupname) end - if respawn then - - -- This should clear the landing waypoints. - -- Note: This resets the weapons and the fuel state. But not the units fortunately. - - -- Get group template. - local Template = group:GetTemplate() - - -- Set route points. - Template.route.points = wp - - -- Respawn the group. - flight.group = group:Respawn( Template, true ) - + local Template=group:GetTemplate() + Template.route.points=wp + flight.group=group:Respawn(Template,true) end - - -- Reinit waypoints. - flight.group:WayPointInitialize( wp ) - - -- Route group. - flight.group:Route( wp, 1 ) - - -- Trigger Marshal event. - self:Marshal( flight ) - -end - ---- Tell AI to refuel. Either at the recovery tanker or at the nearest divert airfield. --- @param #AIRBOSS self --- @param #AIRBOSS.FlightGroup flight Flight group. -function AIRBOSS:_RefuelAI( flight ) - - -- Waypoints array. - local wp = {} - - -- Current speed. - local CurrentSpeed = flight.group:GetVelocityKMH() - - -- Current positon. - wp[#wp + 1] = flight.group:GetCoordinate():WaypointAirTurningPoint( nil, CurrentSpeed, {}, "Current position" ) - - -- Check if aircraft can be refueled. - -- TODO: This should also depend on the tanker type AC. + flight.group:WayPointInitialize(wp) + flight.group:Route(wp,1) + self:Marshal(flight) + end + function AIRBOSS:_RefuelAI(flight) + local wp={} + local CurrentSpeed=flight.group:GetVelocityKMH() + wp[#wp+1]=flight.group:GetCoordinate():WaypointAirTurningPoint(nil,CurrentSpeed,{},"Current position") local refuelac=false local actype=flight.group:GetTypeName() - if actype==AIRBOSS.AircraftCarrier.AV8B or - actype==AIRBOSS.AircraftCarrier.F14A or - actype==AIRBOSS.AircraftCarrier.F14B or - actype==AIRBOSS.AircraftCarrier.F14A_AI or - actype==AIRBOSS.AircraftCarrier.HORNET or - actype==AIRBOSS.AircraftCarrier.RHINOE or - actype==AIRBOSS.AircraftCarrier.RHINOF or - actype==AIRBOSS.AircraftCarrier.GROWLER or - actype==AIRBOSS.AircraftCarrier.FA18C or - actype==AIRBOSS.AircraftCarrier.S3B or - actype==AIRBOSS.AircraftCarrier.S3BTANKER then - refuelac=true + if actype==AIRBOSS.AircraftCarrier.AV8B or + actype==AIRBOSS.AircraftCarrier.F14A or + actype==AIRBOSS.AircraftCarrier.F14B or + actype==AIRBOSS.AircraftCarrier.F14A_AI or + actype==AIRBOSS.AircraftCarrier.HORNET or + actype==AIRBOSS.AircraftCarrier.RHINOE or + actype==AIRBOSS.AircraftCarrier.RHINOF or + actype==AIRBOSS.AircraftCarrier.GROWLER or + actype==AIRBOSS.AircraftCarrier.FA18C or + actype==AIRBOSS.AircraftCarrier.S3B or + actype==AIRBOSS.AircraftCarrier.S3BTANKER then + refuelac=true end - - -- Message. - local text = "" - - -- Refuel or divert? + local text="" if self.tanker and refuelac then - - -- Current Tanker position. - local tankerpos = self.tanker.tanker:GetCoordinate() - - -- Task refueling. - local TaskRefuel = flight.group:TaskRefueling() - - -- Task to go back to Marshal. - local TaskMarshal = flight.group:TaskFunction( "AIRBOSS._TaskFunctionMarshalAI", self, flight ) - - -- Waypoint with tasks. - wp[#wp + 1] = tankerpos:WaypointAirTurningPoint( nil, CurrentSpeed, { TaskRefuel, TaskMarshal }, "Refueling" ) - - -- Marshal Message. - self:_MarshalCallGasAtTanker( flight.onboard ) - + local tankerpos=self.tanker.tanker:GetCoordinate() + local TaskRefuel=flight.group:TaskRefueling() + local TaskMarshal=flight.group:TaskFunction("AIRBOSS._TaskFunctionMarshalAI",self,flight) + wp[#wp+1]=tankerpos:WaypointAirTurningPoint(nil,CurrentSpeed,{TaskRefuel,TaskMarshal},"Refueling") + self:_MarshalCallGasAtTanker(flight.onboard) else - - ------------------------------ - -- Guide AI to divert field -- - ------------------------------ - - -- Closest Airfield of the coalition. - local divertfield = self:GetCoordinate():GetClosestAirbase( Airbase.Category.AIRDROME, self:GetCoalition() ) - - -- Handle case where there is no divert field of the own coalition and try neutral instead. - if divertfield == nil then - divertfield = self:GetCoordinate():GetClosestAirbase( Airbase.Category.AIRDROME, 0 ) - end - - if divertfield then - - -- Coordinate. - local divertcoord = divertfield:GetCoordinate() - - -- Landing waypoint. - wp[#wp + 1] = divertcoord:WaypointAirLanding( UTILS.KnotsToKmph( 300 ), divertfield, {}, "Divert Field" ) - - -- Marshal Message. - self:_MarshalCallGasAtDivert( flight.onboard, divertfield:GetName() ) - - -- Respawn! - - -- Get group template. - local Template = flight.group:GetTemplate() - - -- Set route points. - Template.route.points = wp - - -- Respawn the group. - flight.group = flight.group:Respawn( Template, true ) - - else - -- Set flight to refueling so this is not called again. - self:E( self.lid .. string.format( "WARNING: No recovery tanker or divert field available for group %s.", flight.groupname ) ) - flight.refueling = true - return - end - + local divertfield=self:GetCoordinate():GetClosestAirbase(Airbase.Category.AIRDROME,self:GetCoalition()) + if divertfield==nil then + divertfield=self:GetCoordinate():GetClosestAirbase(Airbase.Category.AIRDROME,0) end - - -- Reinit waypoints. - flight.group:WayPointInitialize( wp ) - - -- Route group. - flight.group:Route( wp, 1 ) - - -- Set refueling switch. - flight.refueling = true - -end - ---- Tell AI to land on the carrier. --- @param #AIRBOSS self --- @param #AIRBOSS.FlightGroup flight Flight group. -function AIRBOSS:_LandAI( flight ) - - -- Debug info. - self:T( self.lid .. string.format( "Landing AI flight %s.", flight.groupname ) ) - - -- NOTE: Looks like the AI needs to approach at the "correct" speed. If they are too fast, they fly an unnecessary circle to bleed of speed first. - -- Unfortunately, the correct speed depends on the aircraft type! - - -- Aircraft speed when flying the pattern. - local Speed = UTILS.KnotsToKmph( 200 ) - - if flight.actype == AIRBOSS.AircraftCarrier.HORNET - or flight.actype == AIRBOSS.AircraftCarrier.FA18C - or flight.actype == AIRBOSS.AircraftCarrier.RHINOE - or flight.actype == AIRBOSS.AircraftCarrier.RHINOF - or flight.actype == AIRBOSS.AircraftCarrier.GROWLER then - Speed = UTILS.KnotsToKmph( 200 ) - elseif flight.actype == AIRBOSS.AircraftCarrier.E2D then - Speed = UTILS.KnotsToKmph( 150 ) - elseif flight.actype == AIRBOSS.AircraftCarrier.F14A_AI or flight.actype == AIRBOSS.AircraftCarrier.F14A or flight.actype == AIRBOSS.AircraftCarrier.F14B then - Speed = UTILS.KnotsToKmph( 175 ) - elseif flight.actype == AIRBOSS.AircraftCarrier.S3B or flight.actype == AIRBOSS.AircraftCarrier.S3BTANKER then - Speed = UTILS.KnotsToKmph( 140 ) + if divertfield then + local divertcoord=divertfield:GetCoordinate() + wp[#wp+1]=divertcoord:WaypointAirLanding(UTILS.KnotsToKmph(300),divertfield,{},"Divert Field") + self:_MarshalCallGasAtDivert(flight.onboard,divertfield:GetName()) + local Template=flight.group:GetTemplate() + Template.route.points=wp + flight.group=flight.group:Respawn(Template,true) + else + self:E(self.lid..string.format("WARNING: No recovery tanker or divert field available for group %s.",flight.groupname)) + flight.refueling=true + return end - - -- Carrier position. - local Carrier = self:GetCoordinate() - - -- Carrier heading. - local hdg = self:GetHeading() - - -- Waypoints array. - local wp = {} - - local CurrentSpeed = flight.group:GetVelocityKMH() - - -- Current positon. - wp[#wp + 1] = flight.group:GetCoordinate():WaypointAirTurningPoint( nil, CurrentSpeed, {}, "Current position" ) - - -- Altitude 800 ft. Looks like this works best. - local alt = UTILS.FeetToMeters( 800 ) - - -- Landing waypoint 5 NM behind carrier at 2000 ft = 610 meters ASL. - wp[#wp + 1] = Carrier:Translate( UTILS.NMToMeters( 4 ), hdg - 160 ):SetAltitude( alt ):WaypointAirLanding( Speed, self.airbase, nil, "Landing" ) - -- wp[#wp+1]=Carrier:Translate(UTILS.NMToMeters(4), hdg-160):SetAltitude(alt):WaypointAirLandingReFu(Speed, self.airbase, nil, "Landing") - - -- wp[#wp+1]=self:GetCoordinate():Translate(UTILS.NMToMeters(3), hdg-160):SetAltitude(alt):WaypointAirTurningPoint(nil,Speed, {}, "Before Initial") ---WaypointAirLanding(Speed, self.airbase, nil, "Landing") - -- wp[#wp+1]=self:GetCoordinate():WaypointAirLanding(Speed, self.airbase, nil, "Landing") - - -- Reinit waypoints. - flight.group:WayPointInitialize( wp ) - - -- Route group. - flight.group:Route( wp, 0 ) -end - ---- Get marshal altitude and two positions of a counter-clockwise race track pattern. --- @param #AIRBOSS self --- @param #number stack Assigned stack number. Counting starts at one, i.e. stack=1 is the first stack. --- @param #number case Recovery case. Default is self.case. --- @return #number Holding altitude in meters. --- @return Core.Point#COORDINATE First race track coordinate. --- @return Core.Point#COORDINATE Second race track coordinate. -function AIRBOSS:_GetMarshalAltitude( stack, case ) - - -- Stack <= 0. - if stack <= 0 then - return 0, nil, nil end - - -- Recovery case. - case = case or self.case - - -- Carrier position. - local Carrier = self:GetCoordinate() - - -- Altitude of first stack. Depends on recovery case. + flight.group:WayPointInitialize(wp) + flight.group:Route(wp,1) + flight.refueling=true + end + function AIRBOSS:_LandAI(flight) + self:T(self.lid..string.format("Landing AI flight %s.",flight.groupname)) + local Speed=UTILS.KnotsToKmph(200) + if flight.actype==AIRBOSS.AircraftCarrier.HORNET + or flight.actype==AIRBOSS.AircraftCarrier.FA18C + or flight.actype==AIRBOSS.AircraftCarrier.RHINOE + or flight.actype==AIRBOSS.AircraftCarrier.RHINOF + or flight.actype==AIRBOSS.AircraftCarrier.GROWLER then + Speed=UTILS.KnotsToKmph(200) + elseif flight.actype==AIRBOSS.AircraftCarrier.E2D or flight.actype==AIRBOSS.AircraftCarrier.C2A then + Speed=UTILS.KnotsToKmph(150) + elseif flight.actype==AIRBOSS.AircraftCarrier.F14A_AI or flight.actype==AIRBOSS.AircraftCarrier.F14A or flight.actype==AIRBOSS.AircraftCarrier.F14B then + Speed=UTILS.KnotsToKmph(175) + elseif flight.actype==AIRBOSS.AircraftCarrier.S3B or flight.actype==AIRBOSS.AircraftCarrier.S3BTANKER then + Speed=UTILS.KnotsToKmph(140) + end + local Carrier=self:GetCoordinate() + local hdg=self:GetHeading() + local wp={} + local CurrentSpeed=flight.group:GetVelocityKMH() + wp[#wp+1]=flight.group:GetCoordinate():WaypointAirTurningPoint(nil,CurrentSpeed,{},"Current position") + local alt=UTILS.FeetToMeters(800) + wp[#wp+1]=Carrier:Translate(UTILS.NMToMeters(4),hdg-160):SetAltitude(alt):WaypointAirLanding(Speed,self.airbase,nil,"Landing") + flight.group:WayPointInitialize(wp) + flight.group:Route(wp,0) + end + function AIRBOSS:_GetMarshalAltitude(stack,case) + if stack<=0 then + return 0,nil,nil + end + case=case or self.case + local Carrier=self:GetCoordinate() local angels0 local Dist - local p1 = nil -- Core.Point#COORDINATE - local p2 = nil -- Core.Point#COORDINATE - - -- Stack number. - local nstack = stack - 1 - - if case == 1 then - - -- CASE I: Holding at 2000 ft on a circular pattern port of the carrier. Interval +1000 ft for next stack. - angels0 = 2 - - -- Get true heading of carrier. - local hdg = self.carrier:GetHeading() - - -- For CCW pattern: First point astern, second ahead of the carrier. - - -- First point over carrier. - p1 = Carrier - - -- Second point 1.5 NM ahead. - p2 = Carrier:Translate( UTILS.NMToMeters( 1.5 ), hdg ) - - -- Tarawa,LHA,LHD Delta patterns. - if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then - - -- Pattern is directly overhead the carrier. - p1 = Carrier:Translate( UTILS.NMToMeters( 1.0 ), hdg + 90 ) - p2 = p1:Translate( 2.5, hdg ) - - end - + local p1=nil + local p2=nil + local nstack=stack-1 + if case==1 then + angels0=2 + local hdg=self.carrier:GetHeading() + p1=Carrier + p2=Carrier:Translate(UTILS.NMToMeters(1.5),hdg) + if self.carriertype==AIRBOSS.CarrierType.INVINCIBLE or self.carriertype==AIRBOSS.CarrierType.HERMES or self.carriertype==AIRBOSS.CarrierType.TARAWA or self.carriertype==AIRBOSS.CarrierType.AMERICA or self.carriertype==AIRBOSS.CarrierType.JCARLOS or self.carriertype==AIRBOSS.CarrierType.CANBERRA then + p1=Carrier:Translate(UTILS.NMToMeters(1.0),hdg+90) + p2=p1:Translate(2.5,hdg) + end else - - -- CASE II/III: Holding at 6000 ft on a racetrack pattern astern the carrier. - angels0 = 6 - - -- Distance: d=n*angels0+15 NM, so first stack is at 15+6=21 NM - Dist = UTILS.NMToMeters( nstack + angels0 + 15 ) - - -- Get correct radial depending on recovery case including offset. - local radial = self:GetRadial( case, false, true ) - - -- For CCW pattern: p1 further astern than p2. - - -- Length of the race track pattern. - local l = UTILS.NMToMeters( 10 ) - - -- First point of race track pattern. - p1 = Carrier:Translate( Dist + l, radial ) - - -- Second point. - p2 = Carrier:Translate( Dist, radial ) - + angels0=6 + Dist=UTILS.NMToMeters(nstack+angels0+15) + local radial=self:GetRadial(case,false,true) + local l=UTILS.NMToMeters(10) + p1=Carrier:Translate(Dist+l,radial) + p2=Carrier:Translate(Dist,radial) end - - -- Pattern altitude. - local altitude = UTILS.FeetToMeters( (nstack + angels0) * 1000 ) - - -- Set altitude of coordinate. - p1:SetAltitude( altitude, true ) - p2:SetAltitude( altitude, true ) - - return altitude, p1, p2 -end - ---- Calculate an estimate of the charlie time of the player based on how many other aircraft are in the marshal or pattern queue before him. --- @param #AIRBOSS self --- @param #AIRBOSS.FlightGroup flightgroup Flight data. --- @return #number Charlie (abs) time in seconds. Or nil, if stack<0 or no recovery window will open. -function AIRBOSS:_GetCharlieTime( flightgroup ) - - -- Get current stack of player. - local stack = flightgroup.flag - - -- Flight is not in marshal stack. - if stack <= 0 then - return nil + local altitude=UTILS.FeetToMeters((nstack+angels0)*1000) + p1:SetAltitude(altitude,true) + p2:SetAltitude(altitude,true) + return altitude,p1,p2 end - - -- Current abs time. - local Tnow = timer.getAbsTime() - - -- Time the player has to spend in marshal stack until all lower stacks are emptied. - local Tcharlie = 0 - - local Trecovery = 0 - if self.recoverywindow then - -- Time in seconds until the next recovery starts or 0 if window is already open. - Trecovery = math.max( self.recoverywindow.START - Tnow, 0 ) - else - -- Set ~7 min if no future recovery window is defined. Otherwise radio call function crashes. - Trecovery = 7 * 60 - end - - -- Loop over flights currently in the marshal queue. - for _, _flight in pairs( self.Qmarshal ) do - local flight = _flight -- #AIRBOSS.FlightGroup - - -- Stack of marshal flight. - local mstack = flight.flag - - -- Time to get to the marshal stack if not holding already. - local Tarrive = 0 - - -- Minimum holding time per stack. - local Tholding = 3 * 60 - - if stack > 0 and mstack > 0 and mstack <= stack then - - -- Check if flight is already holding or just on its way. - if flight.holding == nil then - -- Flight is on its way to the marshal stack. - - -- Coordinate of the holding zone. - local holdingzone = self:_GetZoneHolding( flight.case, 1 ):GetCoordinate() - - -- Distance to holding zone. - local d0 = holdingzone:Get2DDistance( flight.group:GetCoordinate() ) - - -- Current velocity. - local v0 = flight.group:GetVelocityMPS() - - -- Time to get to the carrier. - Tarrive = d0 / v0 - - self:T3( self.lid .. string.format( "Tarrive=%.1f seconds, Clock %s", Tarrive, UTILS.SecondsToClock( Tnow + Tarrive ) ) ) - - else - -- Flight is already holding. - - -- Next in line. - if mstack == 1 then - - -- Current holding time. flight.time stamp should be when entering holding or last time the stack collapsed. - local tholding = timer.getAbsTime() - flight.time - - -- Deduce current holding time. Ensure that is >=0. - Tholding = math.max( 3 * 60 - tholding, 0 ) - end - - end - - -- This is the approx time needed to get to the pattern. If we are already there, it is the time until the recovery window opens or 0 if it is already open. - local Tmin = math.max( Tarrive, Trecovery ) - - -- Charlie time + 2 min holding in stack 1. - Tcharlie = math.max( Tmin, Tcharlie ) + Tholding - end - - end - - -- Convert to abs time. - Tcharlie = Tcharlie + Tnow - - -- Debug info. - local text = string.format( "Charlie time for flight %s (%s) %s", flightgroup.onboard, flightgroup.groupname, UTILS.SecondsToClock( Tcharlie ) ) - MESSAGE:New( text, 10, "DEBUG" ):ToAllIf( self.Debug ) - self:T( self.lid .. text ) - - return Tcharlie -end - ---- Add a flight group to the Marshal queue at a specific stack. Flight is informed via message. This fixes the recovery case to the current case ops in progress self.case). --- @param #AIRBOSS self --- @param #AIRBOSS.FlightGroup flight Flight group. --- @param #number stack Marshal stack. This (re-)sets the flag value. -function AIRBOSS:_AddMarshalGroup( flight, stack ) - - -- Set flag value. This corresponds to the stack number which starts at 1. - flight.flag = stack - - -- Set recovery case. - flight.case = self.case - - -- Add to marshal queue. - table.insert( self.Qmarshal, flight ) - - -- Pressure. - local P = UTILS.hPa2inHg( self:GetCoordinate():GetPressure() ) - - -- Stack altitude. - -- local alt=UTILS.MetersToFeet(self:_GetMarshalAltitude(stack, flight.case)) - local alt = self:_GetMarshalAltitude( stack, flight.case ) - - -- Current BRC. - local brc = self:GetBRC() - - -- If the carrier is supposed to turn into the wind, we take the wind coordinate. - if self.recoverywindow and self.recoverywindow.WIND then - brc = self:GetBRCintoWind(self.recoverywindow.SPEED) - end - - -- Get charlie time estimate. - flight.Tcharlie = self:_GetCharlieTime( flight ) - - -- Convert to clock string. - local Ccharlie = UTILS.SecondsToClock( flight.Tcharlie ) - - -- Combined marshal call. - self:_MarshalCallArrived( flight.onboard, flight.case, brc, alt, Ccharlie, P ) - - -- Hint about TACAN bearing. - if self.TACANon and (not flight.ai) and flight.difficulty == AIRBOSS.Difficulty.EASY then - -- Get inverse magnetic radial potential offset. - local radial = self:GetRadial( flight.case, true, true, true ) - if flight.case == 1 then - -- For case 1 we want the BRC but above routine return FB. - radial = self:GetBRC() - end - -- local text = string.format( "Select TACAN %03d°, channel %d%s (%s)", radial, self.TACANchannel, self.TACANmode, self.TACANmorse ) - local text = string.format( "设置塔康 %03d°, 频道 %d%s (%s)", radial, self.TACANchannel, self.TACANmode, self.TACANmorse ) - self:MessageToPlayer( flight, text, nil, "" ) - end - -end - ---- Collapse marshal stack. --- @param #AIRBOSS self --- @param #AIRBOSS.FlightGroup flight Flight that left the marshal stack. --- @param #boolean nopattern If true, flight does not go to pattern. -function AIRBOSS:_CollapseMarshalStack( flight, nopattern ) - self:F2( { flight = flight, nopattern = nopattern } ) - - -- Recovery case of flight. - local case = flight.case - - -- Stack of flight. - local stack = flight.flag - - -- Check that stack > 0. - if stack <= 0 then - self:E( self.lid .. string.format( "ERROR: Flight %s is has stack value %d<0. Cannot collapse stack!", flight.groupname, stack ) ) - return - end - - -- Memorize time when stack collapsed. Should better depend on case but for now we assume there are no two different stacks Case I or II/III. - self.Tcollapse = timer.getTime() - - -- Decrease flag values of all flight groups in marshal stack. - for _, _flight in pairs( self.Qmarshal ) do - local mflight = _flight -- #AIRBOSS.PlayerData - - -- Only collapse stack of which the flight left. CASE II/III stacks are not collapsed. - if (case == 1 and mflight.case == 1) then -- or (case>1 and mflight.case>1) then - - -- Get current flag/stack value. - local mstack = mflight.flag - - -- Only collapse stacks above the new pattern flight. - if mstack > stack then - - -- TODO: Is this now right as we allow more flights per stack? - -- Question is, does the stack collapse if the lower stack is completely empty or do aircraft descent if just one flight leaves. - -- For now, assuming that the stack must be completely empty before the next higher AC are allowed to descent. - local newstack = self:_GetFreeStack( mflight.ai, mflight.case, true ) - - -- Free stack has to be below. - if newstack and newstack < mstack then - - -- Debug info. - self:T( self.lid .. string.format( "Collapse Marshal: Flight %s (case %d) is changing marshal stack %d --> %d.", mflight.groupname, mflight.case, mstack, newstack ) ) - - if mflight.ai then - - -- Command AI to decrease stack. Flag is set in the routine. - self:_MarshalAI( mflight, newstack ) - - else - - -- Decrease stack/flag. Human player needs to take care himself. - mflight.flag = newstack - - -- Angels of new stack. - local angels = self:_GetAngels( self:_GetMarshalAltitude( newstack, case ) ) - - -- Inform players. - if mflight.difficulty ~= AIRBOSS.Difficulty.HARD then - - -- Send message to all non-pros that they can descent. - -- local text = string.format( "descent to stack at Angels %d.", angels ) - local text = string.format( "下降到指定高度 %d.", angels ) - self:MessageToPlayer( mflight, text, "MARSHAL" ) - - end - - -- Set time stamp. - mflight.time = timer.getAbsTime() - - -- Loop over section members. - for _, _sec in pairs( mflight.section ) do - local sec = _sec -- #AIRBOSS.PlayerData - - -- Also decrease flag for section members of flight. - sec.flag = newstack - - -- Set new time stamp. - sec.time = timer.getAbsTime() - - -- Inform section member. - if sec.difficulty ~= AIRBOSS.Difficulty.HARD then - -- local text = string.format( "descent to stack at Angels %d.", angels ) - local text = string.format( "下降到指定高度 %d.", angels ) - self:MessageToPlayer( sec, text, "MARSHAL" ) - end - - end - - end - - end - end - end - end - - if nopattern then - - -- Debug message. - self:T( self.lid .. string.format( "Flight %s is leaving stack but not going to pattern.", flight.groupname ) ) - - else - - -- Debug message. - local Tmarshal = UTILS.SecondsToClock( timer.getAbsTime() - flight.time ) - self:T( self.lid .. string.format( "Flight %s is leaving marshal after %s and going pattern.", flight.groupname, Tmarshal ) ) - - -- Add flight to pattern queue. - self:_AddFlightToPatternQueue( flight ) - - end - - -- Set flag to -1 (-1 is rather arbitrary but it should not be positive or -100 or -42). - flight.flag = -1 - - -- New time stamp for time in pattern. - flight.time = timer.getAbsTime() - -end - ---- Get next free Marshal stack. Depending on AI/human and recovery case. --- @param #AIRBOSS self --- @param #boolean ai If true, get a free stack for an AI flight group. --- @param #number case Recovery case. Default current (self) case in progress. --- @param #boolean empty Return lowest stack that is completely empty. --- @return #number Lowest free stack available for the given case or nil if all Case I stacks are taken. -function AIRBOSS:_GetFreeStack( ai, case, empty ) - - -- Recovery case. - case = case or self.case - - if case == 1 then - return self:_GetFreeStack_Old( ai, case, empty ) - end - - -- Max number of stacks available. - local nmaxstacks = 100 - if case == 1 then - nmaxstacks = self.Nmaxmarshal - end - - -- Assume up to two (human) flights per stack. All are free. - local stack = {} - for i = 1, nmaxstacks do - stack[i] = self.NmaxStack -- Number of human flights per stack. - end - - local nmax = 1 - - -- Loop over all flights in marshal stack. - for _, _flight in pairs( self.Qmarshal ) do - local flight = _flight -- #AIRBOSS.FlightGroup - - -- Check that the case is right. - if flight.case == case then - - -- Get stack of flight. - local n = flight.flag - - if n > nmax then - nmax = n - end - - if n > 0 then - if flight.ai or flight.case > 1 then - stack[n] = 0 -- AI get one stack on their own. Also CASE II/III get one stack each. - else - stack[n] = stack[n] - 1 - end - else - self:E( string.format( "ERROR: Flight %s in marshal stack has stack value <= 0. Stack value is %d.", flight.groupname, n ) ) - end - - end - end - - local nfree = nil - if stack[nmax] == 0 then - -- Max occupied stack is completely full! - if case == 1 then - if nmax >= nmaxstacks then - -- Already all Case I stacks are occupied ==> wait outside 10 NM zone. - nfree = nil - else - -- Return next free stack. - nfree = nmax + 1 - end - else - -- Case II/III return next stack - nfree = nmax + 1 - end - - elseif stack[nmax] == self.NmaxStack then - -- Max occupied stack is completely empty! This should happen only when there is no other flight in the marshal queue. - self:E( self.lid .. string.format( "ERROR: Max occupied stack is empty. Should not happen! Nmax=%d, stack[nmax]=%d", nmax, stack[nmax] ) ) - nfree = nmax - else - -- Max occupied stack is partly full. - if ai or empty or case > 1 then - nfree = nmax + 1 - else - nfree = nmax - end - - end - - self:T( self.lid .. string.format( "Returning free stack %s", tostring( nfree ) ) ) - return nfree -end - ---- Get next free Marshal stack. Depending on AI/human and recovery case. --- @param #AIRBOSS self --- @param #boolean ai If true, get a free stack for an AI flight group. --- @param #number case Recovery case. Default current (self) case in progress. --- @param #boolean empty Return lowest stack that is completely empty. --- @return #number Lowest free stack available for the given case or nil if all Case I stacks are taken. -function AIRBOSS:_GetFreeStack_Old( ai, case, empty ) - - -- Recovery case. - case = case or self.case - - -- Max number of stacks available. - local nmaxstacks = 100 - if case == 1 then - nmaxstacks = self.Nmaxmarshal - end - - -- Assume up to two (human) flights per stack. All are free. - local stack = {} - for i = 1, nmaxstacks do - stack[i] = self.NmaxStack -- Number of human flights per stack. - end - - -- Loop over all flights in marshal stack. - for _, _flight in pairs( self.Qmarshal ) do - local flight = _flight -- #AIRBOSS.FlightGroup - - -- Check that the case is right. - if flight.case == case then - - -- Get stack of flight. - local n = flight.flag - - if n > 0 then - if flight.ai or flight.case > 1 then - stack[n] = 0 -- AI get one stack on their own. Also CASE II/III get one stack each. - else - stack[n] = stack[n] - 1 - end - else - self:E( string.format( "ERROR: Flight %s in marshal stack has stack value <= 0. Stack value is %d.", flight.groupname, n ) ) - end - - end - end - - -- Loop over stacks and check which one has a place left. - local nfree = nil - for i = 1, nmaxstacks do - self:T2( self.lid .. string.format( "FF Stack[%d]=%d", i, stack[i] ) ) - if ai or empty or case > 1 then - -- AI need the whole stack. - if stack[i] == self.NmaxStack then - nfree = i - return i - end - else - -- Human players only need one free spot. - if stack[i] > 0 then - nfree = i - return i - end - end - end - - return nfree -end - ---- Get number of (airborne) units in a flight. --- @param #AIRBOSS self --- @param #AIRBOSS.FlightGroup flight The flight group. --- @param #boolean onground If true, include units on the ground. By default only airborne units are counted. --- @return #number Number of units in flight including section members. --- @return #number Number of units in flight excluding section members. --- @return #number Number of section members. -function AIRBOSS:_GetFlightUnits( flight, onground ) - - -- Default is only airborne. - local inair = true - if onground == true then - inair = false - end - - --- Count units of a group which are alive and in the air. - local function countunits( _group, inair ) - local group = _group -- Wrapper.Group#GROUP - local units = group:GetUnits() - local n = 0 - if units then - for _, _unit in pairs( units ) do - local unit = _unit -- Wrapper.Unit#UNIT - if unit and unit:IsAlive() then - if inair then - -- Only count units in air. - if unit:InAir() then - self:T2( self.lid .. string.format( "Unit %s is in AIR", unit:GetName() ) ) - n = n + 1 - end - else - -- Count units in air or on the ground. - n = n + 1 - end - end - end - end - return n - end - - -- Count units of the group itself (alive units in air). - local nunits = countunits( flight.group, inair ) - - -- Count section members. - local nsection = 0 - for _, sec in pairs( flight.section ) do - local secflight = sec -- #AIRBOSS.PlayerData - -- Count alive units in air. - nsection = nsection + countunits( secflight.group, inair ) - end - - return nunits + nsection, nunits, nsection -end - ---- Get number of groups and units in queue, which are alive and airborne. In units we count the section members as well. --- @param #AIRBOSS self --- @param #table queue The queue. Can be self.flights, self.Qmarshal or self.Qpattern. --- @param #number case (Optional) Only count flights, which are in a specific recovery case. Note that you can use case=23 for flights that are either in Case II or III. By default all groups/units regardless of case are counted. --- @return #number Total number of flight groups in queue. --- @return #number Total number of aircraft in queue since each flight group can contain multiple aircraft. -function AIRBOSS:_GetQueueInfo( queue, case ) - - local ngroup = 0 - local Nunits = 0 - - -- Loop over flight groups. - for _, _flight in pairs( queue ) do - local flight = _flight -- #AIRBOSS.FlightGroup - - -- Check if a specific case was requested. - if case then - - ------------------------------------------------------------------------ - -- Only count specific case with special 23 = CASE II and III combined. - ------------------------------------------------------------------------ - - if (flight.case == case) or (case == 23 and (flight.case == 2 or flight.case == 3)) then - - -- Number of total units, units in flight and section members ALIVE and AIRBORNE. - local ntot, nunits, nsection = self:_GetFlightUnits( flight ) - - -- Add up total unit number. - Nunits = Nunits + ntot - - -- Increase group count. - if ntot > 0 then - ngroup = ngroup + 1 - end - - end - - else - - --------------------------------------------------------------------------- - -- No specific case requested. Count all groups & units in selected queue. - --------------------------------------------------------------------------- - - -- Number of total units, units in flight and section members ALIVE and AIRBORNE. - local ntot, nunits, nsection = self:_GetFlightUnits( flight ) - - -- Add up total unit number. - Nunits = Nunits + ntot - - -- Increase group count. - if ntot > 0 then - ngroup = ngroup + 1 - end - - end - - end - - return ngroup, Nunits -end - ---- Print holding queue. --- @param #AIRBOSS self --- @param #table queue Queue to print. --- @param #string name Queue name. -function AIRBOSS:_PrintQueue( queue, name ) - - -- local nqueue=#queue - local Nqueue, nqueue = self:_GetQueueInfo( queue ) - - local text = string.format( "%s Queue N=%d (#%d), n=%d:", name, Nqueue, #queue, nqueue ) - if #queue == 0 then - -- text = text .. " empty." - text = text .. " 空队列." - else - for i, _flight in pairs( queue ) do - local flight = _flight -- #AIRBOSS.FlightGroup - - local clock = UTILS.SecondsToClock( timer.getAbsTime() - flight.time ) - local case = flight.case - local stack = flight.flag - local fuel = flight.group:GetFuelMin() * 100 - local ai = tostring( flight.ai ) - local lead = flight.seclead - local Nsec = #flight.section - local actype = self:_GetACNickname( flight.actype ) - local onboard = flight.onboard - local holding = tostring( flight.holding ) - - -- Airborne units. - local _, nunits, nsec = self:_GetFlightUnits( flight, false ) - - -- Text. - -- text = text .. string.format( "\n[%d] %s*%d (%s): lead=%s (%d/%d), onboard=%s, flag=%d, case=%d, time=%s, fuel=%d, ai=%s, holding=%s", i, flight.groupname, nunits, actype, lead, nsec, Nsec, onboard, stack, case, clock, fuel, ai, holding ) - text = text .. string.format( "\n[%d] %s*%d (%s): 长机=%s (%d/%d), 在甲板上=%s, flag=%d, case=%d, 时间=%s, 油量=%d, ai=%s, 等待=%s", i, flight.groupname, nunits, actype, lead, nsec, Nsec, onboard, stack, case, clock, fuel, ai, holding ) - if stack > 0 then - local alt = UTILS.MetersToFeet( self:_GetMarshalAltitude( stack, case ) ) - -- text = text .. string.format( " stackalt=%d ft", alt ) - text = text .. string.format( " 等待高度=%d ft", alt ) - end - for j, _element in pairs( flight.elements ) do - local element = _element -- #AIRBOSS.FlightElement - -- text = text .. string.format( "\n (%d) %s (%s): ai=%s, ballcall=%s, recovered=%s", j, element.onboard, element.unitname, tostring( element.ai ), tostring( element.ballcall ), tostring( element.recovered ) ) - text = text .. string.format( "\n (%d) %s (%s): ai=%s, 最终进近=%s, 已回收=%s", j, element.onboard, element.unitname, tostring( element.ai ), tostring( element.ballcall ), tostring( element.recovered ) ) - end - end - end - self:T( self.lid .. text ) -end - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- FLIGHT & PLAYER functions ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ---- Create a new flight group. Usually when a flight appears in the CCA. --- @param #AIRBOSS self --- @param Wrapper.Group#GROUP group Aircraft group. --- @return #AIRBOSS.FlightGroup Flight group. -function AIRBOSS:_CreateFlightGroup( group ) - - -- Debug info. - self:T( self.lid .. string.format( "Creating new flight for group %s of aircraft type %s.", group:GetName(), group:GetTypeName() ) ) - - -- New flight. - local flight = {} -- #AIRBOSS.FlightGroup - - -- Check if not already in flights - if not self:_InQueue( self.flights, group ) then - - -- Flight group name - local groupname = group:GetName() - local human, playername = self:_IsHuman( group ) - - -- Queue table item. - flight.group = group - flight.groupname = group:GetName() - flight.nunits = #group:GetUnits() - flight.time = timer.getAbsTime() - flight.dist0 = group:GetCoordinate():Get2DDistance( self:GetCoordinate() ) - flight.flag = -100 - flight.ai = not human - flight.actype = group:GetTypeName() - flight.onboardnumbers = self:_GetOnboardNumbers( group ) - flight.seclead = flight.group:GetUnit( 1 ):GetName() -- Sec lead is first unitname of group but player name for players. - flight.section = {} - flight.ballcall = false - flight.refueling = false - flight.holding = nil - flight.name = flight.group:GetUnit( 1 ):GetName() -- Will be overwritten in _Newplayer with player name if human player in the group. - - -- Note, this should be re-set elsewhere! - flight.case = self.case - - -- Flight elements. - local text = string.format( "Flight elements of group %s:", flight.groupname ) - flight.elements = {} - local units = group:GetUnits() - for i, _unit in pairs( units ) do - local unit = _unit -- Wrapper.Unit#UNIT - local element = {} -- #AIRBOSS.FlightElement - element.unit = unit - element.unitname = unit:GetName() - element.onboard = flight.onboardnumbers[element.unitname] - element.ballcall = false - element.ai = not self:_IsHumanUnit( unit ) - element.recovered = nil - text = text .. string.format( "\n[%d] %s onboard #%s, AI=%s", i, element.unitname, tostring( element.onboard ), tostring( element.ai ) ) - table.insert( flight.elements, element ) - end - self:T( self.lid .. text ) - - -- Onboard - if flight.ai then - local onboard = flight.onboardnumbers[flight.seclead] - flight.onboard = onboard - else - flight.onboard = self:_GetOnboardNumberPlayer( group ) - end - - -- Add to known flights. - table.insert( self.flights, flight ) - - else - self:E( self.lid .. string.format( "ERROR: Flight group %s already exists in self.flights!", group:GetName() ) ) - return nil - end - - return flight -end - ---- Initialize player data after birth event of player unit. --- @param #AIRBOSS self --- @param #string unitname Name of the player unit. --- @return #AIRBOSS.PlayerData Player data. -function AIRBOSS:_NewPlayer( unitname ) - - -- Get player unit and name. - local playerunit, playername = self:_GetPlayerUnitAndName( unitname ) - - if playerunit and playername then - - -- Get group. - local group = playerunit:GetGroup() - - -- Player data. - local playerData -- #AIRBOSS.PlayerData - - -- Create a flight group for the player. - playerData = self:_CreateFlightGroup( group ) - - -- Nil check. - if playerData then - - -- Player unit, client and callsign. - playerData.unit = playerunit - playerData.unitname = unitname - playerData.name = playername - playerData.callsign = playerData.unit:GetCallsign() - playerData.client = CLIENT:FindByName( unitname, nil, true ) - playerData.seclead = playername - - -- Number of passes done by player in this slot. - playerData.passes = 0 -- playerData.passes or 0 - - -- Messages for player. - playerData.messages = {} - - -- Debriefing tables. - playerData.lastdebrief = playerData.lastdebrief or {} - - -- Attitude monitor. - playerData.attitudemonitor = false - - -- Trap sheet save. - if playerData.trapon == nil then - playerData.trapon = self.trapsheet - end - - -- Set difficulty level. - playerData.difficulty = playerData.difficulty or self.defaultskill - - -- Subtitles of player. - if playerData.subtitles == nil then - playerData.subtitles = true - end - - -- Show step hints. - if playerData.showhints == nil then - if playerData.difficulty == AIRBOSS.Difficulty.HARD then - playerData.showhints = false - else - playerData.showhints = true - end - end - - -- Points rewarded. - playerData.points = {} - - -- Init stuff for this round. - playerData = self:_InitPlayer( playerData ) - - -- Init player data. - self.players[playername] = playerData - - -- Init player grades table if necessary. - self.playerscores[playername] = self.playerscores[playername] or {} - - -- Welcome player message. - if self.welcome then - -- self:MessageToPlayer( playerData, string.format( "Welcome, %s %s!", playerData.difficulty, playerData.name ), string.format( "AIRBOSS %s", self.alias ), "", 5 ) - self:MessageToPlayer( playerData, string.format( "欢迎登舰, %s %s!", playerData.difficulty, playerData.name ), string.format( "AIRBOSS %s", self.alias ), "", 5 ) - end - - end - - -- Return player data table. - return playerData - end - + function AIRBOSS:_GetCharlieTime(flightgroup) + local stack=flightgroup.flag + if stack<=0 then return nil -end - ---- Initialize player data by (re-)setting parmeters to initial values. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. --- @param #string step (Optional) New player step. Default UNDEFINED. --- @return #AIRBOSS.PlayerData Initialized player data. -function AIRBOSS:_InitPlayer( playerData, step ) - self:T( self.lid .. string.format( "Initializing player data for %s callsign %s.", playerData.name, playerData.callsign ) ) - - playerData.step = step or AIRBOSS.PatternStep.UNDEFINED - playerData.groove = {} - playerData.debrief = {} - playerData.trapsheet = {} - playerData.warning = nil - playerData.holding = nil - playerData.refueling = false - playerData.valid = false - playerData.lig = false - playerData.wop = false - playerData.waveoff = false - playerData.wofd = false - playerData.owo = false - playerData.boltered = false - playerData.hover = false - playerData.stable = false - playerData.landed = false - playerData.Tlso = timer.getTime() - playerData.Tgroove = nil - playerData.TIG0 = nil - playerData.wire = nil - playerData.flag = -100 - playerData.debriefschedulerID = nil - - -- Set us up on final if group name contains "Groove". But only for the first pass. - if playerData.group:GetName():match( "Groove" ) and playerData.passes == 0 then - -- self:MessageToPlayer( playerData, "Group name contains \"Groove\". Happy groove testing." ) - self:MessageToPlayer( playerData, "群组名包含 \"Groove\". 祝您 groove 测试愉快." ) - playerData.attitudemonitor = true - playerData.step = AIRBOSS.PatternStep.FINAL - self:_AddFlightToPatternQueue( playerData ) - self.dTstatus = 0.1 end - - return playerData -end - ---- Get flight from group in a queue. --- @param #AIRBOSS self --- @param Wrapper.Group#GROUP group Group that will be removed from queue. --- @param #table queue The queue from which the group will be removed. --- @return #AIRBOSS.FlightGroup Flight group or nil. --- @return #number Queue index or nil. -function AIRBOSS:_GetFlightFromGroupInQueue( group, queue ) - - if group then - - -- Group name - local name = group:GetName() - - -- Loop over all flight groups in queue - for i, _flight in pairs( queue ) do - local flight = _flight -- #AIRBOSS.FlightGroup - - if flight.groupname == name then - return flight, i - end - end - - self:T2( self.lid .. string.format( "WARNING: Flight group %s could not be found in queue.", name ) ) - end - - self:T2( self.lid .. string.format( "WARNING: Flight group could not be found in queue. Group is nil!" ) ) - return nil, nil -end - ---- Get element in flight. --- @param #AIRBOSS self --- @param #string unitname Name of the unit. --- @return #AIRBOSS.FlightElement Element of the flight or nil. --- @return #number Element index or nil. --- @return #AIRBOSS.FlightGroup The Flight group or nil -function AIRBOSS:_GetFlightElement( unitname ) - - -- Get the unit. - local unit = UNIT:FindByName( unitname ) - - -- Check if unit exists. - if unit then - - -- Get flight element from all flights. - local flight = self:_GetFlightFromGroupInQueue( unit:GetGroup(), self.flights ) - - -- Check if fight exists. - if flight then - - -- Loop over all elements in flight group. - for i, _element in pairs( flight.elements ) do - local element = _element -- #AIRBOSS.FlightElement - - if element.unit:GetName() == unitname then - return element, i, flight - end - end - - self:T2( self.lid .. string.format( "WARNING: Flight element %s could not be found in flight group.", unitname, flight.groupname ) ) - end - end - - return nil, nil, nil -end - ---- Get element in flight. --- @param #AIRBOSS self --- @param #string unitname Name of the unit. --- @return #boolean If true, element could be removed or nil otherwise. -function AIRBOSS:_RemoveFlightElement( unitname ) - - -- Get table index. - local element, idx, flight = self:_GetFlightElement( unitname ) - - if idx then - table.remove( flight.elements, idx ) - return true + local Tnow=timer.getAbsTime() + local Tcharlie=0 + local Trecovery=0 + if self.recoverywindow then + Trecovery=math.max(self.recoverywindow.START-Tnow,0) else - self:T( "WARNING: Flight element could not be removed from flight group. Index=nil!" ) - return nil + Trecovery=7*60 end -end - ---- Check if a group is in a queue. --- @param #AIRBOSS self --- @param #table queue The queue to check. --- @param Wrapper.Group#GROUP group The group to be checked. --- @return #boolean If true, group is in the queue. False otherwise. -function AIRBOSS:_InQueue( queue, group ) - local name = group:GetName() - for _, _flight in pairs( queue ) do - local flight = _flight -- #AIRBOSS.FlightGroup - if name == flight.groupname then - return true - end - end - return false -end - ---- Remove dead flight groups from all queues. --- @param #AIRBOSS self --- @param Wrapper.Group#GROUP group Aircraft group. --- @return #AIRBOSS.FlightGroup Flight group. -function AIRBOSS:_RemoveDeadFlightGroups() - - -- Remove dead flights from all flights table. - for i = #self.flight, 1, -1 do - local flight = self.flights[i] -- #AIRBOSS.FlightGroup - if not flight.group:IsAlive() then - self:T( string.format( "Removing dead flight group %s from ALL flights table.", flight.groupname ) ) - table.remove( self.flights, i ) - end - end - - -- Remove dead flights from Marhal queue table. - for i = #self.Qmarshal, 1, -1 do - local flight = self.Qmarshal[i] -- #AIRBOSS.FlightGroup - if not flight.group:IsAlive() then - self:T( string.format( "Removing dead flight group %s from Marshal Queue table.", flight.groupname ) ) - table.remove( self.Qmarshal, i ) - end - end - - -- Remove dead flights from Pattern queue table. - for i = #self.Qpattern, 1, -1 do - local flight = self.Qpattern[i] -- #AIRBOSS.FlightGroup - if not flight.group:IsAlive() then - self:T( string.format( "Removing dead flight group %s from Pattern Queue table.", flight.groupname ) ) - table.remove( self.Qpattern, i ) - end - end - -end - ---- Get the lead flight group of a flight group. --- @param #AIRBOSS self --- @param #AIRBOSS.FlightGroup flight Flight group to check. --- @return #AIRBOSS.FlightGroup Flight group of the leader or flight itself if no other leader. -function AIRBOSS:_GetLeadFlight( flight ) - - -- Init. - local lead = flight - - -- Only human players can be section leads of other players. - if flight.name ~= flight.seclead then - lead = self.players[flight.seclead] - end - - return lead -end - ---- Check if all elements of a flight were recovered. This also checks potential section members. --- If so, flight is removed from the queue. --- @param #AIRBOSS self --- @param #AIRBOSS.FlightGroup flight Flight group to check. --- @return #boolean If true, all elements landed. -function AIRBOSS:_CheckSectionRecovered( flight ) - - -- Nil check. - if flight == nil then - return true - end - - -- Get the lead flight first, so that we can also check all section members. - local lead = self:_GetLeadFlight( flight ) - - -- Check all elements of the lead flight group. - for _, _element in pairs( lead.elements ) do - local element = _element -- #AIRBOSS.FlightElement - if not element.recovered then - return false - end - end - - -- Now check all section members, if any. - for _, _section in pairs( lead.section ) do - local sectionmember = _section -- #AIRBOSS.FlightGroup - - -- Check all elements of the secmember flight group. - for _, _element in pairs( sectionmember.elements ) do - local element = _element -- #AIRBOSS.FlightElement - if not element.recovered then - return false - end - end - end - - -- Remove lead flight from pattern queue. It is this flight who is added to the queue. - self:_RemoveFlightFromQueue( self.Qpattern, lead ) - - -- Just for now, check if it is in other queues as well. - if self:_InQueue( self.Qmarshal, lead.group ) then - self:E( self.lid .. string.format( "ERROR: lead flight group %s should not be in marshal queue", lead.groupname ) ) - self:_RemoveFlightFromMarshalQueue( lead, true ) - end - -- Just for now, check if it is in other queues as well. - if self:_InQueue( self.Qwaiting, lead.group ) then - self:E( self.lid .. string.format( "ERROR: lead flight group %s should not be in pattern queue", lead.groupname ) ) - self:_RemoveFlightFromQueue( self.Qwaiting, lead ) - end - - return true -end - ---- Add flight to pattern queue and set recoverd to false for all elements of the flight and its section members. --- @param #AIRBOSS self --- @param #AIRBOSS.FlightGroup Flight group of element. -function AIRBOSS:_AddFlightToPatternQueue( flight ) - - -- Add flight to table. - table.insert( self.Qpattern, flight ) - - -- Set flag to -1 (-1 is rather arbitrary but it should not be positive or -100 or -42). - flight.flag = -1 - -- New time stamp for time in pattern. - flight.time = timer.getAbsTime() - - -- Init recovered switch. - flight.recovered = false - for _, elem in pairs( flight.elements ) do - elem.recoverd = false - end - - -- Set recovered for all section members. - for _, sec in pairs( flight.section ) do - -- Set flag and timestamp for section members - sec.flag = -1 - sec.time = timer.getAbsTime() - for _, elem in pairs( sec.elements ) do - elem.recoverd = false - end - end -end - ---- Sets flag recovered=true for a flight element, which was successfully recovered (landed). --- @param #AIRBOSS self --- @param Wrapper.Unit#UNIT unit The aircraft unit that was recovered. --- @return #AIRBOSS.FlightGroup Flight group of element. -function AIRBOSS:_RecoveredElement( unit ) - - -- Get element of flight. - local element, idx, flight = self:_GetFlightElement( unit:GetName() ) -- #AIRBOSS.FlightElement - - -- Nil check. Could be if a helo landed or something else we dont know! - if element then - element.recovered = true - end - - return flight -end - ---- Remove a flight group from the Marshal queue. Marshal stack is collapsed, too, if flight was in the queue. Waiting flights are send to marshal. --- @param #AIRBOSS self --- @param #AIRBOSS.FlightGroup flight Flight group that will be removed from queue. --- @param #boolean nopattern If true, flight is NOT going to landing pattern. --- @return #boolean True, flight was removed or false otherwise. --- @return #number Table index of the flight in the Marshal queue. -function AIRBOSS:_RemoveFlightFromMarshalQueue( flight, nopattern ) - - -- Remove flight from marshal queue if it is in. - local removed, idx = self:_RemoveFlightFromQueue( self.Qmarshal, flight ) - - -- Collapse marshal stack if flight was removed. - if removed then - - -- Flight is not holding any more. - flight.holding = nil - - -- Collapse marshal stack if flight was removed. - self:_CollapseMarshalStack( flight, nopattern ) - - -- Stacks are only limited for Case I. - if flight.case == 1 and #self.Qwaiting > 0 then - - -- Next flight in line waiting. - local nextflight = self.Qwaiting[1] -- #AIRBOSS.FlightGroup - - -- Get free stack. - local freestack = self:_GetFreeStack( nextflight.ai ) - - -- Send next flight to marshal stack. - if nextflight.ai then - - -- Send AI to Marshal Stack. - self:_MarshalAI( nextflight, freestack ) - - else - - -- Send player to Marshal stack. - self:_MarshalPlayer( nextflight, freestack ) - - end - - -- Remove flight from waiting queue. - self:_RemoveFlightFromQueue( self.Qwaiting, nextflight ) - - end - end - - return removed, idx -end - ---- Remove a flight group from a queue. --- @param #AIRBOSS self --- @param #table queue The queue from which the group will be removed. --- @param #AIRBOSS.FlightGroup flight Flight group that will be removed from queue. --- @return #boolean True, flight was in Queue and removed. False otherwise. --- @return #number Table index of removed queue element or nil. -function AIRBOSS:_RemoveFlightFromQueue( queue, flight ) - - -- Loop over all flights in group. - for i, _flight in pairs( queue ) do - local qflight = _flight -- #AIRBOSS.FlightGroup - - -- Check for name. - if qflight.groupname == flight.groupname then - self:T( self.lid .. string.format( "Removing flight group %s from queue.", flight.groupname ) ) - table.remove( queue, i ) - return true, i - end - end - - return false, nil -end - ---- Remove a unit and its element from a flight group (e.g. when landed) and update all queues if the whole flight group is gone. --- @param #AIRBOSS self --- @param Wrapper.Unit#UNIT unit The unit to be removed. -function AIRBOSS:_RemoveUnitFromFlight( unit ) - - -- Check if unit exists. - if unit and unit:IsInstanceOf( "UNIT" ) then - - -- Get group. - local group = unit:GetGroup() - - -- Check if group exists. - if group then - - -- Get flight. - local flight = self:_GetFlightFromGroupInQueue( group, self.flights ) - - -- Check if flight exists. - if flight then - - -- Remove element from flight group. - local removed = self:_RemoveFlightElement( unit:GetName() ) - - if removed then - - -- Get number of units (excluding section members). For AI only those that are still in air as we assume once they landed, they are out of the game. - local _, nunits = self:_GetFlightUnits( flight, not flight.ai ) - - -- Number of flight elements still left. - local nelements = #flight.elements - - -- Debug info. - self:T( self.lid .. string.format( "Removed unit %s: nunits=%d, nelements=%d", unit:GetName(), nunits, nelements ) ) - - -- Check if no units are left. - if nunits == 0 or nelements == 0 then - -- Remove flight from all queues. - self:_RemoveFlight( flight ) - end - - end - end - end - end - -end - ---- Remove a flight, which is a member of a section, from this section. --- @param #AIRBOSS self --- @param #AIRBOSS.FlightGroup flight The flight to be removed from the section -function AIRBOSS:_RemoveFlightFromSection( flight ) - - -- First check if player is not the lead. - if flight.name ~= flight.seclead then - - -- Remove this flight group from the section of the leader. - local lead = self.players[flight.seclead] -- #AIRBOSS.FlightGroup - if lead then - for i, sec in pairs( lead.section ) do - local sectionmember = sec -- #AIRBOSS.FlightGroup - if sectionmember.name == flight.name then - table.remove( lead.section, i ) - break - end - end - end - end - -end - ---- Update section if a flight is removed. --- If removed flight is member of a section, he is removed for the leaders section. --- If removed flight is the section lead, we try to find a new leader. --- @param #AIRBOSS self --- @param #AIRBOSS.FlightGroup flight The flight to be removed. -function AIRBOSS:_UpdateFlightSection( flight ) - - -- Check if this player is the leader of a section. - if flight.seclead == flight.name then - - -------------------- - -- Section Leader -- - -------------------- - - -- This player is the leader ==> We need a new one. - if #flight.section >= 1 then - - -- New leader. - local newlead = flight.section[1] -- #AIRBOSS.FlightGroup - newlead.seclead = newlead.name - - -- Adjust new section members. - for i = 2, #flight.section do - local member = flight.section[i] -- #AIRBOSS.FlightGroup - - -- Add remaining members new leaders table. - table.insert( newlead.section, member ) - - -- Set new section lead of member. - member.seclead = newlead.name - end - - end - - -- Flight section empty - flight.section = {} - + for _,_flight in pairs(self.Qmarshal)do + local flight=_flight + local mstack=flight.flag + local Tarrive=0 + local Tholding=3*60 + if stack>0 and mstack>0 and mstack<=stack then + if flight.holding==nil then + local holdingzone=self:_GetZoneHolding(flight.case,1):GetCoordinate() + local d0=holdingzone:Get2DDistance(flight.group:GetCoordinate()) + local v0=flight.group:GetVelocityMPS() + Tarrive=d0/v0 + self:T3(self.lid..string.format("Tarrive=%.1f seconds, Clock %s",Tarrive,UTILS.SecondsToClock(Tnow+Tarrive))) else - - -------------------- - -- Section Member -- - -------------------- - - -- Remove flight from its leaders section. - self:_RemoveFlightFromSection( flight ) - + if mstack==1 then + local tholding=timer.getAbsTime()-flight.time + Tholding=math.max(3*60-tholding,0) end - -end - ---- Remove a flight from Marshal, Pattern and Waiting queues. If flight is in Marhal queue, the above stack is collapsed. --- Also set player step to undefined if applicable or remove human flight if option *completely* is true. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData flight The flight to be removed. --- @param #boolean completely If true, also remove human flight from all flights table. -function AIRBOSS:_RemoveFlight( flight, completely ) - self:F( self.lid .. string.format( "Removing flight %s, ai=%s completely=%s.", tostring( flight.groupname ), tostring( flight.ai ), tostring( completely ) ) ) - - -- Remove flight from all queues. - self:_RemoveFlightFromMarshalQueue( flight, true ) - self:_RemoveFlightFromQueue( self.Qpattern, flight ) - self:_RemoveFlightFromQueue( self.Qwaiting, flight ) - self:_RemoveFlightFromQueue( self.Qspinning, flight ) - - -- Check if player or AI + end + local Tmin=math.max(Tarrive,Trecovery) + Tcharlie=math.max(Tmin,Tcharlie)+Tholding + end + end + Tcharlie=Tcharlie+Tnow + local text=string.format("Charlie time for flight %s (%s) %s",flightgroup.onboard,flightgroup.groupname,UTILS.SecondsToClock(Tcharlie)) + MESSAGE:New(text,10,"DEBUG"):ToAllIf(self.Debug) + self:T(self.lid..text) + return Tcharlie + end + function AIRBOSS:_AddMarshalGroup(flight,stack) + flight.flag=stack + flight.case=self.case + table.insert(self.Qmarshal,flight) + local P=UTILS.hPa2inHg(self:GetCoordinate():GetPressure()) + local alt=self:_GetMarshalAltitude(stack,flight.case) + local brc=self:GetBRC() + if self.recoverywindow and self.recoverywindow.WIND then + brc=self:GetBRCintoWind(self.recoverywindow.SPEED) + end + flight.Tcharlie=self:_GetCharlieTime(flight) + local Ccharlie=UTILS.SecondsToClock(flight.Tcharlie) + self:_MarshalCallArrived(flight.onboard,flight.case,brc,alt,Ccharlie,P) + if self.TACANon and(not flight.ai)and flight.difficulty==AIRBOSS.Difficulty.EASY then + local radial=self:GetRadial(flight.case,true,true,true) + if flight.case==1 then + radial=self:GetBRC() + end + -- local text=string.format("Select TACAN %03d°, channel %d%s (%s)",radial,self.TACANchannel,self.TACANmode,self.TACANmorse) + -- self:MessageToPlayer(flight,text,nil,"") + local text=string.format("设置 TACAN %03d°, 频道 %d%s (%s)",radial,self.TACANchannel,self.TACANmode,self.TACANmorse) + self:MessageToPlayer(flight,text,nil,"") + end + end + function AIRBOSS:_CollapseMarshalStack(flight,nopattern) + self:F2({flight=flight,nopattern=nopattern}) + local case=flight.case + local stack=flight.flag + if stack<=0 then + self:E(self.lid..string.format("ERROR: Flight %s is has stack value %d<0. Cannot collapse stack!",flight.groupname,stack)) + return + end + self.Tcollapse=timer.getTime() + for _,_flight in pairs(self.Qmarshal)do + local mflight=_flight + if(case==1 and mflight.case==1)then + local mstack=mflight.flag + if mstack>stack then + local newstack=self:_GetFreeStack(mflight.ai,mflight.case,true) + if newstack and newstack %d.",mflight.groupname,mflight.case,mstack,newstack)) + if mflight.ai then + self:_MarshalAI(mflight,newstack) + else + mflight.flag=newstack + local angels=self:_GetAngels(self:_GetMarshalAltitude(newstack,case)) + if mflight.difficulty~=AIRBOSS.Difficulty.HARD then + -- local text=string.format("descent to stack at Angels %d.",angels) + -- self:MessageToPlayer(mflight,text,"MARSHAL") + local text=string.format("下降到等待位置, 高度 %d.",angels) + self:MessageToPlayer(mflight,text,"MARSHAL") + end + mflight.time=timer.getAbsTime() + for _,_sec in pairs(mflight.section)do + local sec=_sec + sec.flag=newstack + sec.time=timer.getAbsTime() + if sec.difficulty~=AIRBOSS.Difficulty.HARD then + -- local text=string.format("descent to stack at Angels %d.",angels) + -- self:MessageToPlayer(sec,text,"MARSHAL") + local text=string.format("下降到等待位置, 高度 %d.",angels) + self:MessageToPlayer(mflight,text,"MARSHAL") + end + end + end + end + end + end + end + if nopattern then + self:T(self.lid..string.format("Flight %s is leaving stack but not going to pattern.",flight.groupname)) + else + local Tmarshal=UTILS.SecondsToClock(timer.getAbsTime()-flight.time) + self:T(self.lid..string.format("Flight %s is leaving marshal after %s and going pattern.",flight.groupname,Tmarshal)) + self:_AddFlightToPatternQueue(flight) + end + flight.flag=-1 + flight.time=timer.getAbsTime() + end + function AIRBOSS:_GetFreeStack(ai,case,empty) + case=case or self.case + if case==1 then + return self:_GetFreeStack_Old(ai,case,empty) + end + local nmaxstacks=100 + if case==1 then + nmaxstacks=self.Nmaxmarshal + end + local stack={} + for i=1,nmaxstacks do + stack[i]=self.NmaxStack + end + local nmax=1 + for _,_flight in pairs(self.Qmarshal)do + local flight=_flight + if flight.case==case then + local n=flight.flag + if n>nmax then + nmax=n + end + if n>0 then + if flight.ai or flight.case>1 then + stack[n]=0 + else + stack[n]=stack[n]-1 + end + else + self:E(string.format("ERROR: Flight %s in marshal stack has stack value <= 0. Stack value is %d.",flight.groupname,n)) + end + end + end + local nfree=nil + if stack[nmax]==0 then + if case==1 then + if nmax>=nmaxstacks then + nfree=nil + else + nfree=nmax+1 + end + else + nfree=nmax+1 + end + elseif stack[nmax]==self.NmaxStack then + self:E(self.lid..string.format("ERROR: Max occupied stack is empty. Should not happen! Nmax=%d, stack[nmax]=%d",nmax,stack[nmax])) + nfree=nmax + else + if ai or empty or case>1 then + nfree=nmax+1 + else + nfree=nmax + end + end + self:T(self.lid..string.format("Returning free stack %s",tostring(nfree))) + return nfree + end + function AIRBOSS:_GetFreeStack_Old(ai,case,empty) + case=case or self.case + local nmaxstacks=100 + if case==1 then + nmaxstacks=self.Nmaxmarshal + end + local stack={} + for i=1,nmaxstacks do + stack[i]=self.NmaxStack + end + for _,_flight in pairs(self.Qmarshal)do + local flight=_flight + if flight.case==case then + local n=flight.flag + if n>0 then + if flight.ai or flight.case>1 then + stack[n]=0 + else + stack[n]=stack[n]-1 + end + else + self:E(string.format("ERROR: Flight %s in marshal stack has stack value <= 0. Stack value is %d.",flight.groupname,n)) + end + end + end + local nfree=nil + for i=1,nmaxstacks do + self:T2(self.lid..string.format("FF Stack[%d]=%d",i,stack[i])) + if ai or empty or case>1 then + if stack[i]==self.NmaxStack then + nfree=i + return i + end + else + if stack[i]>0 then + nfree=i + return i + end + end + end + return nfree + end + function AIRBOSS:_GetFlightUnits(flight,onground) + local inair=true + if onground==true then + inair=false + end + local function countunits(_group,inair) + local group=_group + local units=group:GetUnits() + local n=0 + if units then + for _,_unit in pairs(units)do + local unit=_unit + if unit and unit:IsAlive()then + if inair then + if unit:InAir()then + self:T2(self.lid..string.format("Unit %s is in AIR",unit:GetName())) + n=n+1 + end + else + n=n+1 + end + end + end + end + return n + end + local nunits=countunits(flight.group,inair) + local nsection=0 + for _,sec in pairs(flight.section)do + local secflight=sec + nsection=nsection+countunits(secflight.group,inair) + end + return nunits+nsection,nunits,nsection + end + function AIRBOSS:_GetQueueInfo(queue,case) + local ngroup=0 + local Nunits=0 + for _,_flight in pairs(queue)do + local flight=_flight + if case then + if(flight.case==case)or(case==23 and(flight.case==2 or flight.case==3))then + local ntot,nunits,nsection=self:_GetFlightUnits(flight) + Nunits=Nunits+ntot + if ntot>0 then + ngroup=ngroup+1 + end + end + else + local ntot,nunits,nsection=self:_GetFlightUnits(flight) + Nunits=Nunits+ntot + if ntot>0 then + ngroup=ngroup+1 + end + end + end + return ngroup,Nunits + end + function AIRBOSS:_PrintQueue(queue,name) + local Nqueue,nqueue=self:_GetQueueInfo(queue) + local text=string.format("%s Queue N=%d (#%d), n=%d:",name,Nqueue,#queue,nqueue) + if#queue==0 then + text=text.." empty." + else + for i,_flight in pairs(queue)do + local flight=_flight + local clock=UTILS.SecondsToClock(timer.getAbsTime()-flight.time) + local case=flight.case + local stack=flight.flag + local fuel=flight.group:GetFuelMin()*100 + local ai=tostring(flight.ai) + local lead=flight.seclead + local Nsec=#flight.section + local actype=self:_GetACNickname(flight.actype) + local onboard=flight.onboard + local holding=tostring(flight.holding) + local _,nunits,nsec=self:_GetFlightUnits(flight,false) + text=text..string.format("\n[%d] %s*%d (%s): lead=%s (%d/%d), onboard=%s, flag=%d, case=%d, time=%s, fuel=%d, ai=%s, holding=%s",i,flight.groupname,nunits,actype,lead,nsec,Nsec,onboard,stack,case,clock,fuel,ai,holding) + if stack>0 then + local alt=UTILS.MetersToFeet(self:_GetMarshalAltitude(stack,case)) + text=text..string.format(" stackalt=%d ft",alt) + end + for j,_element in pairs(flight.elements)do + local element=_element + text=text..string.format("\n (%d) %s (%s): ai=%s, ballcall=%s, recovered=%s",j,element.onboard,element.unitname,tostring(element.ai),tostring(element.ballcall),tostring(element.recovered)) + end + end + end + self:T(self.lid..text) + end + function AIRBOSS:_CreateFlightGroup(group) + self:T(self.lid..string.format("Creating new flight for group %s of aircraft type %s.",group:GetName(),group:GetTypeName())) + local flight={} + if not self:_InQueue(self.flights,group)then + local groupname=group:GetName() + local human,playername=self:_IsHuman(group) + flight.group=group + flight.groupname=group:GetName() + flight.nunits=#group:GetUnits() + flight.time=timer.getAbsTime() + flight.dist0=group:GetCoordinate():Get2DDistance(self:GetCoordinate()) + flight.flag=-100 + flight.ai=not human + flight.actype=group:GetTypeName() + flight.onboardnumbers=self:_GetOnboardNumbers(group) + flight.seclead=flight.group:GetUnit(1):GetName() + flight.section={} + flight.ballcall=false + flight.refueling=false + flight.holding=nil + flight.name=flight.group:GetUnit(1):GetName() + flight.case=self.case + local text=string.format("Flight elements of group %s:",flight.groupname) + flight.elements={} + local units=group:GetUnits() + for i,_unit in pairs(units)do + local unit=_unit + local element={} + element.unit=unit + element.unitname=unit:GetName() + element.onboard=flight.onboardnumbers[element.unitname] + element.ballcall=false + element.ai=not self:_IsHumanUnit(unit) + element.recovered=nil + text=text..string.format("\n[%d] %s onboard #%s, AI=%s",i,element.unitname,tostring(element.onboard),tostring(element.ai)) + table.insert(flight.elements,element) + end + self:T(self.lid..text) if flight.ai then - - -- Remove AI flight completely. Pure AI flights have no sections and cannot be members. - self:_RemoveFlightFromQueue( self.flights, flight ) - + local onboard=flight.onboardnumbers[flight.seclead] + flight.onboard=onboard else - - -- Remove all grades until a final grade is reached. - local grades = self.playerscores[flight.name] - if grades and #grades > 0 then - while #grades > 0 and grades[#grades].finalscore == nil do - table.remove( grades, #grades ) - end - end - - -- Check if flight should be completely removed, e.g. after the player died or simply left the slot. - if completely then - - -- Update flight section. Remove flight from section or find new section leader if flight was the lead. - self:_UpdateFlightSection( flight ) - - -- Remove completely. - self:_RemoveFlightFromQueue( self.flights, flight ) - - -- Remove player from players table. - local playerdata = self.players[flight.name] - if playerdata then - self:T( self.lid .. string.format( "Removing player %s completely.", flight.name ) ) - self.players[flight.name] = nil - end - - -- Remove flight. - flight = nil - - else - - -- Set player step to undefined. - self:_SetPlayerStep( flight, AIRBOSS.PatternStep.UNDEFINED ) - - -- Also set this for the section members as they are in the same boat. - for _, sectionmember in pairs( flight.section ) do - self:_SetPlayerStep( sectionmember, AIRBOSS.PatternStep.UNDEFINED ) - -- Also remove section member in case they are in the spinning queue. - self:_RemoveFlightFromQueue( self.Qspinning, sectionmember ) - end - - -- What if flight is member of a section. His status is now undefined. Should he be removed from the section? - -- I think yes, if he pulls the trigger. - self:_RemoveFlightFromSection( flight ) - - end + flight.onboard=self:_GetOnboardNumberPlayer(group) end - -end - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- Player Status ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ---- Check current player status. --- @param #AIRBOSS self -function AIRBOSS:_CheckPlayerStatus() - - -- Loop over all players. - for _playerName, _playerData in pairs( self.players ) do - local playerData = _playerData -- #AIRBOSS.PlayerData - - if playerData then - - -- Player unit. - local unit = playerData.unit - - -- Check if unit is alive. - if unit and unit:IsAlive() then - - -- Check if player is in carrier controlled area (zone with R=50 NM around the carrier). - -- TODO: This might cause problems if the CCA is set to be very small! - if unit:IsInZone( self.zoneCCA ) then - - -- Display aircraft attitude and other parameters as message text. - if playerData.attitudemonitor then - self:_AttitudeMonitor( playerData ) - end - - -- Check distance to other flights. - self:_CheckPlayerPatternDistance( playerData ) - - -- Foul deck check. - self:_CheckFoulDeck( playerData ) - - -- Check current step. - if playerData.step == AIRBOSS.PatternStep.UNDEFINED then - - -- Status undefined. - -- local time=timer.getAbsTime() - -- local clock=UTILS.SecondsToClock(time) - -- self:T3(string.format("Player status undefined. Waiting for next step. Time %s", clock)) - - elseif playerData.step == AIRBOSS.PatternStep.REFUELING then - - -- Nothing to do here at the moment. - - elseif playerData.step == AIRBOSS.PatternStep.SPINNING then - - -- Player is spinning. - self:_Spinning( playerData ) - - elseif playerData.step == AIRBOSS.PatternStep.HOLDING then - - -- CASE I/II/III: In holding pattern. - self:_Holding( playerData ) - - elseif playerData.step == AIRBOSS.PatternStep.WAITING then - - -- CASE I: Waiting outside 10 NM zone for next free Marshal stack. - self:_Waiting( playerData ) - - elseif playerData.step == AIRBOSS.PatternStep.COMMENCING then - - -- CASE I/II/III: New approach. - self:_Commencing( playerData, true ) - - elseif playerData.step == AIRBOSS.PatternStep.BOLTER then - - -- CASE I/II/III: Bolter pattern. - self:_BolterPattern( playerData ) - - elseif playerData.step == AIRBOSS.PatternStep.PLATFORM then - - -- CASE II/III: Player has reached 5k "Platform". - self:_Platform( playerData ) - - elseif playerData.step == AIRBOSS.PatternStep.ARCIN then - - -- Case II/III if offset. - self:_ArcInTurn( playerData ) - - elseif playerData.step == AIRBOSS.PatternStep.ARCOUT then - - -- Case II/III if offset. - self:_ArcOutTurn( playerData ) - - elseif playerData.step == AIRBOSS.PatternStep.DIRTYUP then - - -- CASE III: Player has descended to 1200 ft and is going level from now on. - self:_DirtyUp( playerData ) - - elseif playerData.step == AIRBOSS.PatternStep.BULLSEYE then - - -- CASE III: Player has intercepted the glide slope and should follow "Bullseye" (ICLS). - self:_Bullseye( playerData ) - - elseif playerData.step == AIRBOSS.PatternStep.INITIAL then - - -- CASE I/II: Player is at the initial position entering the landing pattern. - self:_Initial( playerData ) - - elseif playerData.step == AIRBOSS.PatternStep.BREAKENTRY then - - -- CASE I/II: Break entry. - self:_BreakEntry( playerData ) - - elseif playerData.step == AIRBOSS.PatternStep.EARLYBREAK then - - -- CASE I/II: Early break. - self:_Break( playerData, AIRBOSS.PatternStep.EARLYBREAK ) - - elseif playerData.step == AIRBOSS.PatternStep.LATEBREAK then - - -- CASE I/II: Late break. - self:_Break( playerData, AIRBOSS.PatternStep.LATEBREAK ) - - elseif playerData.step == AIRBOSS.PatternStep.ABEAM then - - -- CASE I/II: Abeam position. - self:_Abeam( playerData ) - - elseif playerData.step == AIRBOSS.PatternStep.NINETY then - - -- CASE:I/II: Check long down wind leg. - self:_CheckForLongDownwind( playerData ) - - -- At the ninety. - self:_Ninety( playerData ) - - elseif playerData.step == AIRBOSS.PatternStep.WAKE then - - -- CASE I/II: In the wake. - self:_Wake( playerData ) - - elseif playerData.step == AIRBOSS.PatternStep.EMERGENCY then - - -- Emergency landing. Player pos is not checked. - self:_Final( playerData, true ) - - elseif playerData.step == AIRBOSS.PatternStep.FINAL then - - -- CASE I/II: Turn to final and enter the groove. - self:_Final( playerData ) - - elseif playerData.step == AIRBOSS.PatternStep.GROOVE_XX or - playerData.step == AIRBOSS.PatternStep.GROOVE_IM or - playerData.step == AIRBOSS.PatternStep.GROOVE_IC or - playerData.step == AIRBOSS.PatternStep.GROOVE_AR or - playerData.step == AIRBOSS.PatternStep.GROOVE_AL or - playerData.step == AIRBOSS.PatternStep.GROOVE_LC or - playerData.step == AIRBOSS.PatternStep.GROOVE_IW then - - -- CASE I/II: In the groove. - self:_Groove( playerData ) - - elseif playerData.step == AIRBOSS.PatternStep.DEBRIEF then - - -- Debriefing in 5 seconds. - -- SCHEDULER:New(nil, self._Debrief, {self, playerData}, 5) - playerData.debriefschedulerID = self:ScheduleOnce( 5, self._Debrief, self, playerData ) - - -- Undefined status. - playerData.step = AIRBOSS.PatternStep.UNDEFINED - - else - - -- Error, unknown step! - self:E( self.lid .. string.format( "ERROR: Unknown player step %s. Please report!", tostring( playerData.step ) ) ) - - end - - -- Check if player missed a step during Case II/III and allow him to enter the landing pattern. - self:_CheckMissedStepOnEntry( playerData ) - - else - self:T2( self.lid .. "WARNING: Player unit not inside the CCA!" ) - end - - else - -- Unit not alive. - self:T( self.lid .. "WARNING: Player unit is not alive!" ) - end - end - end - -end - ---- Checks if a player is in the pattern queue and has missed a step in Case II/III approach. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. -function AIRBOSS:_CheckMissedStepOnEntry( playerData ) - - -- Conditions to be met: Case II/III, in pattern queue, flag!=42 (will be set to 42 at the end if player missed a step). - local rightcase = playerData.case > 1 - local rightqueue = self:_InQueue( self.Qpattern, playerData.group ) - local rightflag = playerData.flag ~= -42 - - -- Steps that the player could have missed during Case II/III. - local step = playerData.step - local missedstep = step == AIRBOSS.PatternStep.PLATFORM or step == AIRBOSS.PatternStep.ARCIN or step == AIRBOSS.PatternStep.ARCOUT or step == AIRBOSS.PatternStep.DIRTYUP - - -- Check if player is about to enter the initial or bullseye zones and maybe has missed a step in the pattern. - if rightcase and rightqueue and rightflag then - - -- Get right zone. - local zone = nil - if playerData.case == 2 and missedstep then - - zone = self:_GetZoneInitial( playerData.case ) - - elseif playerData.case == 3 and missedstep then - - zone = self:_GetZoneBullseye( playerData.case ) - - end - - -- Zone only exists if player is not at the initial or bullseye step. - if zone then - - -- Check if player is in initial or bullseye zone. - local inzone = playerData.unit:IsInZone( zone ) - - -- Relative heading to carrier direction. - local relheading = self:_GetRelativeHeading( playerData.unit, false ) - - -- Check if player is in zone and flying roughly in the right direction. - if inzone and math.abs( relheading ) < 60 then - - -- Player is in one of the initial zones short before the landing pattern. - -- local text = string.format( "you missed an important step in the pattern!\nYour next step would have been %s.", playerData.step ) - local text = string.format( "你漏掉了程序中的一个重要步骤! \n你的下一步应该是 %s.", playerData.step ) - self:MessageToPlayer( playerData, text, "AIRBOSS", nil, 5 ) - - if playerData.case == 2 then - -- Set next step to initial. - playerData.step = AIRBOSS.PatternStep.INITIAL - elseif playerData.case == 3 then - -- Set next step to bullseye. - playerData.step = AIRBOSS.PatternStep.BULLSEYE - end - - -- Set flag value to -42. This is the value to ensure that this routine is not called again! - playerData.flag = -42 - end - end - end -end - ---- Set time in the groove for player. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. -function AIRBOSS:_SetTimeInGroove( playerData ) - - -- Set time in the groove - if playerData.TIG0 then - playerData.Tgroove = timer.getTime() - playerData.TIG0 + table.insert(self.flights,flight) else - playerData.Tgroove = 999 + self:E(self.lid..string.format("ERROR: Flight group %s already exists in self.flights!",group:GetName())) + return nil end - -end - ---- Get time in the groove of player. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. --- @return #number Player's time in groove in seconds. -function AIRBOSS:_GetTimeInGroove( playerData ) - - local Tgroove = 999 - - -- Get time in the groove. - if playerData.TIG0 then - Tgroove = timer.getTime() - playerData.TIG0 + return flight end - - return Tgroove -end - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- EVENT functions -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ---- Airboss event handler for event birth. --- @param #AIRBOSS self --- @param Core.Event#EVENTDATA EventData -function AIRBOSS:OnEventBirth( EventData ) - self:F3( { eventbirth = EventData } ) - - -- Nil checks. - if EventData == nil then - self:E( self.lid .. "ERROR: EventData=nil in event BIRTH!" ) - self:E( EventData ) - return + function AIRBOSS:_NewPlayer(unitname) + local playerunit,playername=self:_GetPlayerUnitAndName(unitname) + if playerunit and playername then + local group=playerunit:GetGroup() + local playerData + playerData=self:_CreateFlightGroup(group) + if playerData then + playerData.unit=playerunit + playerData.unitname=unitname + playerData.name=playername + playerData.callsign=playerData.unit:GetCallsign() + playerData.client=CLIENT:FindByName(unitname,nil,true) + playerData.seclead=playername + playerData.passes=0 + playerData.messages={} + playerData.lastdebrief=playerData.lastdebrief or{} + playerData.attitudemonitor=false + if playerData.trapon==nil then + playerData.trapon=self.trapsheet end - if EventData.IniUnit == nil and (not EventData.IniObjectCategory == Object.Category.STATIC) then - self:E( self.lid .. "ERROR: EventData.IniUnit=nil in event BIRTH!" ) - self:E( EventData ) - return + playerData.difficulty=playerData.difficulty or self.defaultskill + if playerData.subtitles==nil then + playerData.subtitles=true end - - if EventData.IniObjectCategory ~= Object.Category.UNIT then return end - - local _unitName = EventData.IniUnitName - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - self:T( self.lid .. "BIRTH: unit = " .. tostring( EventData.IniUnitName ) ) - self:T( self.lid .. "BIRTH: group = " .. tostring( EventData.IniGroupName ) ) - self:T( self.lid .. "BIRTH: player = " .. tostring( _playername ) ) - - if _unit and _playername then - - local _uid = _unit:GetID() - local _group = _unit:GetGroup() - local _callsign = _unit:GetCallsign() - - -- Debug output. - local text = string.format( "Pilot %s, callsign %s entered unit %s of group %s.", _playername, _callsign, _unitName, _group:GetName() ) - self:T( self.lid .. text ) - MESSAGE:New( text, 5 ):ToAllIf( self.Debug ) - - -- Check if aircraft type the player occupies is carrier capable. - local rightaircraft = self:_IsCarrierAircraft( _unit ) - if rightaircraft == false then - local text = string.format( "Player aircraft type %s not supported by AIRBOSS class.", _unit:GetTypeName() ) - MESSAGE:New( text, 30 ):ToAllIf( self.Debug ) - self:T2( self.lid .. text ) - return - end - - -- Check that coalition of the carrier and aircraft match. - if self:GetCoalition() ~= _unit:GetCoalition() then - local text = string.format( "Player entered aircraft of other coalition." ) - MESSAGE:New( text, 30 ):ToAllIf( self.Debug ) - self:T( self.lid .. text ) - return - end - - -- Add Menu commands. - self:_AddF10Commands( _unitName ) - - -- Delaying the new player for a second, because AI units of the flight would not be registered correctly. - -- SCHEDULER:New(nil, self._NewPlayer, {self, _unitName}, 1) - self:ScheduleOnce( 1, self._NewPlayer, self, _unitName ) - - end -end - ---- Airboss event handler for event land. --- @param #AIRBOSS self --- @param Core.Event#EVENTDATA EventData -function AIRBOSS:OnEventLand( EventData ) - self:F3( { eventland = EventData } ) - - -- Nil checks. - if EventData == nil then - self:E( self.lid .. "ERROR: EventData=nil in event LAND!" ) - self:E( EventData ) - return - end - if EventData.IniUnit == nil then - self:E( self.lid .. "ERROR: EventData.IniUnit=nil in event LAND!" ) - self:E( EventData ) - return - end - - -- Get unit name that landed. - local _unitName = EventData.IniUnitName - - -- Check if this was a player. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Debug output. - self:T( self.lid .. "LAND: unit = " .. tostring( EventData.IniUnitName ) ) - self:T( self.lid .. "LAND: group = " .. tostring( EventData.IniGroupName ) ) - self:T( self.lid .. "LAND: player = " .. tostring( _playername ) ) - - -- This would be the closest airbase. - local airbase = EventData.Place - - -- Nil check for airbase. Crashed as player gave me no airbase. - if airbase == nil then - return - end - - -- Get airbase name. - local airbasename = tostring( airbase:GetName() ) - - -- Check if aircraft landed on the right airbase. - if airbasename == self.airbase:GetName() then - - -- Stern coordinate at the rundown. - local stern = self:_GetSternCoord() - - -- Polygon zone close around the carrier. - local zoneCarrier = self:_GetZoneCarrierBox() - - -- Check if player or AI landed. - if _unit and _playername then - - ------------------------- - -- Human Player landed -- - ------------------------- - - -- Get info. - local _uid = _unit:GetID() - local _group = _unit:GetGroup() - local _callsign = _unit:GetCallsign() - - -- Debug output. - local text = string.format( "Player %s, callsign %s unit %s (ID=%d) of group %s landed at airbase %s", _playername, _callsign, _unitName, _uid, _group:GetName(), airbasename ) - self:T( self.lid .. text ) - MESSAGE:New( text, 5, "DEBUG" ):ToAllIf( self.Debug ) - - -- Player data. - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - - -- Check if playerData is okay. - if playerData == nil then - self:E( self.lid .. string.format( "ERROR: playerData nil in landing event. unit=%s player=%s", tostring( _unitName ), tostring( _playername ) ) ) - return - end - - -- Check that player landed on the carrier. - if _unit:IsInZone( zoneCarrier ) then - - -- Check if this was a valid approach. - if not playerData.valid then - -- Player missed at least one step in the pattern. - -- local text = string.format( "you missed at least one important step in the pattern!\nYour next step would have been %s.\nThis pass is INVALID.", playerData.step ) - local text = string.format( "你漏掉了至少一个关键步骤!\n你本应该执行 %s.\n此次考核无效.", playerData.step ) - self:MessageToPlayer( playerData, text, "AIRBOSS", nil, 30, true, 5 ) - - -- Clear queues just in case. - self:_RemoveFlightFromMarshalQueue( playerData, true ) - self:_RemoveFlightFromQueue( self.Qpattern, playerData ) - self:_RemoveFlightFromQueue( self.Qwaiting, playerData ) - self:_RemoveFlightFromQueue( self.Qspinning, playerData ) - - -- Reinitialize player data. - self:_InitPlayer( playerData ) - - return - end - - -- Check if player already landed. We dont need a second time. - if playerData.landed then - - self:E( self.lid .. string.format( "Player %s just landed a second time.", _playername ) ) - - else - - -- We did land. - playerData.landed = true - - -- Switch attitude monitor off if on. - playerData.attitudemonitor = false - - -- Coordinate at landing event. - local coord = playerData.unit:GetCoordinate() - - -- Get distances relative to - local X, Z, rho, phi = self:_GetDistances( _unit ) - - -- Landing distance wrt to stern position. - local dist = coord:Get2DDistance( stern ) - - -- Debug mark of player landing coord. - if self.Debug and false then - -- Debug mark of player landing coord. - local lp = coord:MarkToAll( "Landing coord." ) - coord:SmokeGreen() - end - - -- Set time in the groove of player. - self:_SetTimeInGroove( playerData ) - - -- Debug text. - local text = string.format( "Player %s AC type %s landed at dist=%.1f m. Tgroove=%.1f sec.", playerData.name, playerData.actype, dist, self:_GetTimeInGroove( playerData ) ) - text = text .. string.format( " X=%.1f m, Z=%.1f m, rho=%.1f m.", X, Z, rho ) - self:T( self.lid .. text ) - - -- Check carrier type. - if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then - - -- Power "Idle". - self:RadioTransmission( self.LSORadio, self.LSOCall.IDLE, false, 1, nil, true ) - - -- Next step debrief. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.DEBRIEF ) - - else - - -- Next step undefined until we know more. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.UNDEFINED ) - - -- Call trapped function in 1 second to make sure we did not bolter. - -- SCHEDULER:New(nil, self._Trapped, {self, playerData}, 1) - self:ScheduleOnce( 1, self._Trapped, self, playerData ) - - end - - end - - else - -- Handle case where player did not land on the carrier. - -- Well, I guess, he leaves the slot or ejects. Both should be handled. - if playerData then - self:E( self.lid .. string.format( "Player %s did not land in carrier box zone. Maybe in the water near the carrier?", playerData.name ) ) - end - end - - else - - -------------------- - -- AI unit landed -- - -------------------- - - if self.carriertype ~= AIRBOSS.CarrierType.INVINCIBLE or self.carriertype ~= AIRBOSS.CarrierType.HERMES or self.carriertype ~= AIRBOSS.CarrierType.TARAWA or self.carriertype ~= AIRBOSS.CarrierType.AMERICA or self.carriertype ~= AIRBOSS.CarrierType.JCARLOS or self.carriertype ~= AIRBOSS.CarrierType.CANBERRA then - - -- Coordinate at landing event - local coord = EventData.IniUnit:GetCoordinate() - - -- Debug mark of player landing coord. - local dist = coord:Get2DDistance( self:GetCoordinate() ) - - -- Get wire - local wire = self:_GetWire( coord, 0 ) - - -- Aircraft type. - local _type = EventData.IniUnit:GetTypeName() - - -- Debug text. - local text = string.format( "AI unit %s of type %s landed at dist=%.1f m. Trapped wire=%d.", _unitName, _type, dist, wire ) - self:T( self.lid .. text ) - - end - - -- AI always lands ==> remove unit from flight group and queues. - local flight = self:_RecoveredElement( EventData.IniUnit ) - - -- Check if all were recovered. If so update pattern queue. - self:_CheckSectionRecovered( flight ) - - end - end -end - ---- Airboss event handler for event that a unit shuts down its engines. --- @param #AIRBOSS self --- @param Core.Event#EVENTDATA EventData -function AIRBOSS:OnEventEngineShutdown( EventData ) - self:F3( { eventengineshutdown = EventData } ) - - -- Nil checks. - if EventData == nil then - self:E( self.lid .. "ERROR: EventData=nil in event ENGINESHUTDOWN!" ) - self:E( EventData ) - return - end - if EventData.IniUnit == nil then - self:E( self.lid .. "ERROR: EventData.IniUnit=nil in event ENGINESHUTDOWN!" ) - self:E( EventData ) - return - end - - local _unitName = EventData.IniUnitName - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - self:T3( self.lid .. "ENGINESHUTDOWN: unit = " .. tostring( EventData.IniUnitName ) ) - self:T3( self.lid .. "ENGINESHUTDOWN: group = " .. tostring( EventData.IniGroupName ) ) - self:T3( self.lid .. "ENGINESHUTDOWN: player = " .. tostring( _playername ) ) - - if _unit and _playername then - - -- Debug message. - self:T( self.lid .. string.format( "Player %s shut down its engines!", _playername ) ) - + if playerData.showhints==nil then + if playerData.difficulty==AIRBOSS.Difficulty.HARD then + playerData.showhints=false else - - -- Debug message. - self:T( self.lid .. string.format( "AI unit %s shut down its engines!", _unitName ) ) - - -- Get flight. - local flight = self:_GetFlightFromGroupInQueue( EventData.IniGroup, self.flights ) - - -- Only AI flights. - if flight and flight.ai then - - -- Check if all elements were recovered. - local recovered = self:_CheckSectionRecovered( flight ) - - -- Despawn group and completely remove flight. - if recovered then - self:T( self.lid .. string.format( "AI group %s completely recovered. Despawning group after engine shutdown event as requested in 5 seconds.", tostring( EventData.IniGroupName ) ) ) - - -- Remove flight. - self:_RemoveFlight( flight ) - - -- Check if this is a tanker or AWACS associated with the carrier. - local istanker = self.tanker and self.tanker.tanker:GetName() == EventData.IniGroupName - local isawacs = self.awacs and self.awacs.tanker:GetName() == EventData.IniGroupName - - -- Destroy group if desired. Recovery tankers have their own logic for despawning. - if self.despawnshutdown and not (istanker or isawacs) then - EventData.IniGroup:Destroy( nil, 5 ) - end - - end - - end + playerData.showhints=true end -end - ---- Airboss event handler for event that a unit takes off. --- @param #AIRBOSS self --- @param Core.Event#EVENTDATA EventData -function AIRBOSS:OnEventTakeoff( EventData ) - self:F3( { eventtakeoff = EventData } ) - - -- Nil checks. - if EventData == nil then - self:E( self.lid .. "ERROR: EventData=nil in event TAKEOFF!" ) - self:E( EventData ) - return end - if EventData.IniUnit == nil then - self:E( self.lid .. "ERROR: EventData.IniUnit=nil in event TAKEOFF!" ) - self:E( EventData ) - return + playerData.points={} + playerData=self:_InitPlayer(playerData) + self.players[playername]=playerData + self.playerscores[playername]=self.playerscores[playername]or{} + if self.welcome then + -- self:MessageToPlayer(playerData,string.format("Welcome, %s %s!",playerData.difficulty,playerData.name),string.format("AIRBOSS %s",self.alias),"",5) + self:MessageToPlayer(playerData,string.format("欢迎登舰, %s %s!",playerData.difficulty,playerData.name),string.format("航空长 %s",self.alias),"",5) end - - local _unitName = EventData.IniUnitName - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - self:T3( self.lid .. "TAKEOFF: unit = " .. tostring( EventData.IniUnitName ) ) - self:T3( self.lid .. "TAKEOFF: group = " .. tostring( EventData.IniGroupName ) ) - self:T3( self.lid .. "TAKEOFF: player = " .. tostring( _playername ) ) - - -- Airbase. - local airbase = EventData.Place - - -- Airbase name. - local airbasename = "unknown" - if airbase then - airbasename = airbase:GetName() end - - -- Check right airbase. - if airbasename == self.airbase:GetName() then - - if _unit and _playername then - - -- Debug message. - self:T( self.lid .. string.format( "Player %s took off at %s!", _playername, airbasename ) ) - - else - - -- Debug message. - self:T2( self.lid .. string.format( "AI unit %s took off at %s!", _unitName, airbasename ) ) - - -- Get flight. - local flight = self:_GetFlightFromGroupInQueue( EventData.IniGroup, self.flights ) - - if flight then - - -- Set ballcall and recoverd status. - for _, elem in pairs( flight.elements ) do - local element = elem -- #AIRBOSS.FlightElement - element.ballcall = false - element.recovered = nil - end - end - end - + return playerData end -end - ---- Airboss event handler for event crash. --- @param #AIRBOSS self --- @param Core.Event#EVENTDATA EventData -function AIRBOSS:OnEventCrash( EventData ) - self:F3( { eventcrash = EventData } ) - - -- Nil checks. - if EventData == nil then - self:E( self.lid .. "ERROR: EventData=nil in event CRASH!" ) - self:E( EventData ) - return + return nil end - if EventData.IniUnit == nil then - self:E( self.lid .. "ERROR: EventData.IniUnit=nil in event CRASH!" ) - self:E( EventData ) - return + function AIRBOSS:_InitPlayer(playerData,step) + self:T(self.lid..string.format("Initializing player data for %s callsign %s.",playerData.name,playerData.callsign)) + playerData.step=step or AIRBOSS.PatternStep.UNDEFINED + playerData.groove={} + playerData.debrief={} + playerData.trapsheet={} + playerData.warning=nil + playerData.holding=nil + playerData.refueling=false + playerData.valid=false + playerData.lig=false + playerData.wop=false + playerData.waveoff=false + playerData.wofd=false + playerData.owo=false + playerData.boltered=false + playerData.hover=false + playerData.stable=false + playerData.landed=false + playerData.Tlso=timer.getTime() + playerData.Tgroove=nil + playerData.TIG0=nil + playerData.wire=nil + playerData.flag=-100 + playerData.debriefschedulerID=nil + if playerData.group:GetName():match("Groove")and playerData.passes==0 then + -- self:MessageToPlayer(playerData,"Group name contains \"Groove\". Happy groove testing.") + self:MessageToPlayer(playerData,"群组名称包含 \"Groove\". 祝五边训练愉快.") + playerData.attitudemonitor=true + playerData.step=AIRBOSS.PatternStep.FINAL + self:_AddFlightToPatternQueue(playerData) + self.dTstatus=0.1 end - - local _unitName = EventData.IniUnitName - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - self:T3( self.lid .. "CRASH: unit = " .. tostring( EventData.IniUnitName ) ) - self:T3( self.lid .. "CRASH: group = " .. tostring( EventData.IniGroupName ) ) - self:T3( self.lid .. "CARSH: player = " .. tostring( _playername ) ) - - if _unit and _playername then - -- Debug message. - self:T( self.lid .. string.format( "Player %s crashed!", _playername ) ) - - -- Get player flight. - local flight = self.players[_playername] - - -- Remove flight completely from all queues and collapse marshal if necessary. - -- This also updates the section, if any and removes any unfinished gradings of the player. - if flight then - self:_RemoveFlight( flight, true ) - end - + return playerData + end + function AIRBOSS:_GetFlightFromGroupInQueue(group,queue) + if group then + local name=group:GetName() + for i,_flight in pairs(queue)do + local flight=_flight + if flight.groupname==name then + return flight,i + end + end + self:T2(self.lid..string.format("WARNING: Flight group %s could not be found in queue.",name)) + end + self:T2(self.lid..string.format("WARNING: Flight group could not be found in queue. Group is nil!")) + return nil,nil + end + function AIRBOSS:_GetFlightElement(unitname) + local unit=UNIT:FindByName(unitname) + if unit then + local flight=self:_GetFlightFromGroupInQueue(unit:GetGroup(),self.flights) + if flight then + for i,_element in pairs(flight.elements)do + local element=_element + if element.unit:GetName()==unitname then + return element,i,flight + end + end + self:T2(self.lid..string.format("WARNING: Flight element %s could not be found in flight group.",unitname,flight.groupname)) + end + end + return nil,nil,nil + end + function AIRBOSS:_RemoveFlightElement(unitname) + local element,idx,flight=self:_GetFlightElement(unitname) + if idx then + table.remove(flight.elements,idx) + return true else - -- Debug message. - self:T2( self.lid .. string.format( "AI unit %s crashed!", EventData.IniUnitName ) ) - - -- Remove unit from flight and queues. - self:_RemoveUnitFromFlight( EventData.IniUnit ) + self:T("WARNING: Flight element could not be removed from flight group. Index=nil!") + return nil end - -end - ---- Airboss event handler for event Ejection. --- @param #AIRBOSS self --- @param Core.Event#EVENTDATA EventData -function AIRBOSS:OnEventEjection( EventData ) - self:F3( { eventland = EventData } ) - - -- Nil checks. - if EventData == nil then - self:E( self.lid .. "ERROR: EventData=nil in event EJECTION!" ) - self:E( EventData ) - return end - if EventData.IniUnit == nil then - self:E( self.lid .. "ERROR: EventData.IniUnit=nil in event EJECTION!" ) - self:E( EventData ) - return + function AIRBOSS:_InQueue(queue,group) + local name=group:GetName() + for _,_flight in pairs(queue)do + local flight=_flight + if name==flight.groupname then + return true end - - local _unitName = EventData.IniUnitName - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - self:T3( self.lid .. "EJECT: unit = " .. tostring( EventData.IniUnitName ) ) - self:T3( self.lid .. "EJECT: group = " .. tostring( EventData.IniGroupName ) ) - self:T3( self.lid .. "EJECT: player = " .. tostring( _playername ) ) - - if _unit and _playername then - self:T( self.lid .. string.format( "Player %s ejected!", _playername ) ) - - -- Get player flight. - local flight = self.players[_playername] - - -- Remove flight completely from all queues and collapse marshal if necessary. - if flight then - self:_RemoveFlight( flight, true ) - end - - else - -- Debug message. - self:T( self.lid .. string.format( "AI unit %s ejected!", EventData.IniUnitName ) ) - - -- Remove element/unit from flight group and from all queues if no elements alive. - self:_RemoveUnitFromFlight( EventData.IniUnit ) - - -- What could happen is, that another element has landed (recovered) already and this one crashes. - -- This would mean that the flight would not be deleted from the queue ==> Check if section recovered. - local flight = self:_GetFlightFromGroupInQueue( EventData.IniGroup, self.flights ) - self:_CheckSectionRecovered( flight ) end - -end - ---- Airboss event handler for event REMOVEUNIT. --- @param #AIRBOSS self --- @param Core.Event#EVENTDATA EventData -function AIRBOSS:OnEventRemoveUnit( EventData ) - self:F3( { eventland = EventData } ) - - -- Nil checks. - if EventData == nil then - self:E( self.lid .. "ERROR: EventData=nil in event REMOVEUNIT!" ) - self:E( EventData ) - return - end - if EventData.IniUnit == nil then - self:E( self.lid .. "ERROR: EventData.IniUnit=nil in event REMOVEUNIT!" ) - self:E( EventData ) - return - end - - local _unitName = EventData.IniUnitName - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - self:T3( self.lid .. "EJECT: unit = " .. tostring( EventData.IniUnitName ) ) - self:T3( self.lid .. "EJECT: group = " .. tostring( EventData.IniGroupName ) ) - self:T3( self.lid .. "EJECT: player = " .. tostring( _playername ) ) - - if _unit and _playername then - self:T( self.lid .. string.format( "Player %s removed!", _playername ) ) - - -- Get player flight. - local flight = self.players[_playername] - - -- Remove flight completely from all queues and collapse marshal if necessary. - if flight then - self:_RemoveFlight( flight, true ) - end - - else - -- Debug message. - self:T( self.lid .. string.format( "AI unit %s removed!", EventData.IniUnitName ) ) - - -- Remove element/unit from flight group and from all queues if no elements alive. - self:_RemoveUnitFromFlight( EventData.IniUnit ) - - -- What could happen is, that another element has landed (recovered) already and this one crashes. - -- This would mean that the flight would not be deleted from the queue ==> Check if section recovered. - local flight = self:_GetFlightFromGroupInQueue( EventData.IniGroup, self.flights ) - self:_CheckSectionRecovered( flight ) - end - -end - ---- Airboss event handler for event player leave unit. --- @param #AIRBOSS self --- @param Core.Event#EVENTDATA EventData --- function AIRBOSS:OnEventPlayerLeaveUnit(EventData) -function AIRBOSS:_PlayerLeft( EventData ) - self:F3( { eventleave = EventData } ) - - -- Nil checks. - if EventData == nil then - self:E( self.lid .. "ERROR: EventData=nil in event PLAYERLEFTUNIT!" ) - self:E( EventData ) - return - end - if EventData.IniUnit == nil then - self:E( self.lid .. "ERROR: EventData.IniUnit=nil in event PLAYERLEFTUNIT!" ) - self:E( EventData ) - return - end - - local _unitName = EventData.IniUnitName - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - self:T3( self.lid .. "PLAYERLEAVEUNIT: unit = " .. tostring( EventData.IniUnitName ) ) - self:T3( self.lid .. "PLAYERLEAVEUNIT: group = " .. tostring( EventData.IniGroupName ) ) - self:T3( self.lid .. "PLAYERLEAVEUNIT: player = " .. tostring( _playername ) ) - - if _unit and _playername then - - -- Debug info. - self:T( self.lid .. string.format( "Player %s left unit %s!", _playername, _unitName ) ) - - -- Get player flight. - local flight = self.players[_playername] - - -- Remove flight completely from all queues and collapse marshal if necessary. - if flight then - self:_RemoveFlight( flight, true ) - end - - end - -end - ---- Airboss event function handling the mission end event. --- Handles the case when the mission is ended. --- @param #AIRBOSS self --- @param Core.Event#EVENTDATA EventData Event data. -function AIRBOSS:OnEventMissionEnd( EventData ) - self:T3( self.lid .. "Mission Ended" ) -end - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- PATTERN functions -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ---- Spinning --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. -function AIRBOSS:_Spinning( playerData ) - - -- Early break. - local SpinIt = {} - SpinIt.name = "Spinning" - SpinIt.Xmin = -UTILS.NMToMeters( 6 ) -- Not more than 5 NM behind the boat. - SpinIt.Xmax = UTILS.NMToMeters( 5 ) -- Not more than 5 NM in front of the boat. - SpinIt.Zmin = -UTILS.NMToMeters( 6 ) -- Not more than 5 NM port. - SpinIt.Zmax = UTILS.NMToMeters( 2 ) -- Not more than 3 NM starboard. - SpinIt.LimitXmin = -100 -- 100 meters behind the boat - SpinIt.LimitXmax = nil - SpinIt.LimitZmin = -UTILS.NMToMeters( 1 ) -- 1 NM port - SpinIt.LimitZmax = nil - - -- Get distances between carrier and player unit (parallel and perpendicular to direction of movement of carrier) - local X, Z, rho, phi = self:_GetDistances( playerData.unit ) - - -- Check if we are in front of the boat (diffX > 0). - if self:_CheckLimits( X, Z, SpinIt ) then - - -- Player is "de-spinned". Should go to initial again. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.INITIAL ) - - -- Remove player from spinning queue. - self:_RemoveFlightFromQueue( self.Qspinning, playerData ) - - end - -end - ---- Waiting outside 10 NM zone for free Marshal stack. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. -function AIRBOSS:_Waiting( playerData ) - - -- Create 10 NM zone around the carrier. - local radius = UTILS.NMToMeters( 10 ) - local zone = ZONE_RADIUS:New( "Carrier 10 NM Zone", self.carrier:GetVec2(), radius ) - -- local zone = ZONE_RADIUS:New( "航母 10NM 区域", self.carrier:GetVec2(), radius ) - - -- Check if player is inside 10 NM radius of the carrier. - local inzone = playerData.unit:IsInZone( zone ) - - -- Time player is waiting. - local Twaiting = timer.getAbsTime() - playerData.time - - -- Warning if player is inside the zone. - if inzone and Twaiting > 3 * 60 and not playerData.warning then - -- local text = string.format( "You are supposed to wait outside the 10 NM zone." ) - local text = string.format( "你应该在 10海里 外区域等待." ) - self:MessageToPlayer( playerData, text, "AIRBOSS" ) - playerData.warning = true - end - - -- Reset warning. - if inzone == false and playerData.warning == true then - playerData.warning = nil - end - -end - ---- Holding. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. -function AIRBOSS:_Holding( playerData ) - - -- Player unit and flight. - local unit = playerData.unit - - -- Current stack. - local stack = playerData.flag - - -- Check for reported error. - if stack <= 0 then - local text = string.format( "ERROR: player %s in step %s is holding but has stack=%s (<=0)", playerData.name, playerData.step, tostring( stack ) ) - self:E( self.lid .. text ) - end - - --------------------------- - -- Holding Pattern Check -- - --------------------------- - - -- Pattern altitude. - local patternalt = self:_GetMarshalAltitude( stack, playerData.case ) - - -- Player altitude. - local playeralt = unit:GetAltitude() - - -- Get holding zone of player. - local zoneHolding = self:_GetZoneHolding( playerData.case, stack ) - - -- Nil check. - if zoneHolding == nil then - self:E( self.lid .. "ERROR: zoneHolding is nil!" ) - self:E( { playerData = playerData } ) - return - end - - -- Check if player is in holding zone. - local inholdingzone = unit:IsInZone( zoneHolding ) - - -- Altitude difference between player and assigned stack. - local altdiff = playeralt - patternalt - - -- Acceptable altitude depending on player skill. - local altgood = UTILS.FeetToMeters( 500 ) - if playerData.difficulty == AIRBOSS.Difficulty.HARD then - -- Pros can be expected to be within +-200 ft. - altgood = UTILS.FeetToMeters( 200 ) - elseif playerData.difficulty == AIRBOSS.Difficulty.NORMAL then - -- Normal guys should be within +-350 ft. - altgood = UTILS.FeetToMeters( 350 ) - elseif playerData.difficulty == AIRBOSS.Difficulty.EASY then - -- Students should be within +-500 ft. - altgood = UTILS.FeetToMeters( 500 ) - end - - -- When back to good altitude = 50%. - local altback = altgood * 0.5 - - -- Check if stack just collapsed and give the player one minute to change the altitude. - local justcollapsed = false - if self.Tcollapse then - -- Time since last stack change. - local dT = timer.getTime() - self.Tcollapse - - -- TODO: check if this works. - -- local dT=timer.getAbsTime()-playerData.time - - -- Check if less then 90 seconds. - if dT <= 90 then - justcollapsed = true - end - end - - -- Check if altitude is acceptable. - local goodalt = math.abs( altdiff ) < altgood - - -- Angels. - local angels = self:_GetAngels( patternalt ) - - -- XXX: Check if player is flying counter clockwise. AOB<0. - - -- Message text. - local text = "" - - -- Different cases - if playerData.holding == true then - -- Player was in holding zone last time we checked. - - if inholdingzone then - -- Player is still in holding zone. - self:T3( "Player is still in the holding zone. Good job." ) - else - -- Player left the holding zone. - -- text = text .. string.format( "You just left the holding zone. Watch your numbers!" ) - text = text .. string.format( "你已经偏离等待区域. 注意你的顺序!" ) - playerData.holding = false - end - - -- Altitude check if stack not just collapsed. - if not justcollapsed then - - if altdiff > altgood then - - -- Issue warning for being too high. - if not playerData.warning then - -- text = text .. string.format( "You left your assigned altitude. Descent to angels %d.", angels ) - text = text .. string.format( "你已经偏离了给定高度. 下降到高度 %d.", angels ) - playerData.warning = true - end - - elseif altdiff < -altgood then - - -- Issue warning for being too low. - if not playerData.warning then - -- text = text .. string.format( "You left your assigned altitude. Climb to angels %d.", angels ) - text = text .. string.format( "你已经偏离了给定高度. 爬升到高度 %d.", angels ) - playerData.warning = true - end - - end - - end - - -- Back to assigned altitude. - if playerData.warning and math.abs( altdiff ) <= altback then - -- text = text .. string.format( "Altitude is looking good again." ) - text = text .. string.format( "高度保持得不错." ) - playerData.warning = nil - end - - elseif playerData.holding == false then - - -- Player left holding zone - if inholdingzone then - -- Player is back in the holding zone. - -- text = text .. string.format( "You are back in the holding zone. Now stay there!" ) - text = text .. string.format( "已返回等待区域. 注意保持!" ) - playerData.holding = true - else - -- Player is still outside the holding zone. - self:T3( "Player still outside the holding zone. What are you doing man?!" ) - end - - elseif playerData.holding == nil then - -- Player did not entered the holding zone yet. - - if inholdingzone then - - -- Player arrived in holding zone. - playerData.holding = true - - -- Inform player. - -- text = text .. string.format( "You arrived at the holding zone." ) - text = text .. string.format( "你已经到达等待区域." ) - - -- Feedback on altitude. - if goodalt then - -- text = text .. string.format( " Altitude is good." ) - text = text .. string.format( " 高度不错,处在预定高度." ) - else - if altdiff < 0 then - -- text = text .. string.format( " But you're too low." ) - text = text .. string.format( " 你现在高度偏低." ) - else - -- text = text .. string.format( " But you're too high." ) - text = text .. string.format( " 你现在高度偏高." ) - end - -- text = text .. string.format( "\nCurrently assigned altitude is %d ft.", UTILS.MetersToFeet( patternalt ) ) - text = text .. string.format( "\n目前分配给你的高度是 %d ft.", UTILS.MetersToFeet( patternalt ) ) - playerData.warning = true - end - - else - -- Player did not yet arrive in holding zone. - self:T3( "Waiting for player to arrive in the holding zone." ) - end - - end - - -- Send message. - if playerData.showhints then - self:MessageToPlayer( playerData, text, "MARSHAL" ) - end - -end - ---- Commence approach. This step initializes the player data. Section members are also set to commence. Next step depends on recovery case: --- --- * Case 1: Initial --- * Case 2/3: Platform --- --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. --- @param #boolean zonecheck If true, zone is checked before player is released. -function AIRBOSS:_Commencing( playerData, zonecheck ) - - -- Check for auto commence - if zonecheck then - - -- Get auto commence zone. - local zoneCommence = self:_GetZoneCommence( playerData.case, playerData.flag ) - - -- Check if unit is in the zone. - local inzone = playerData.unit:IsInZone( zoneCommence ) - - -- Skip the rest if not in the zone yet. - if not inzone then - - -- Friendly reminder. - if timer.getAbsTime() - playerData.time > 180 then - self:_MarshalCallClearedForRecovery( playerData.onboard, playerData.case ) - playerData.time = timer.getAbsTime() - end - - -- Skip the rest. - return - end - - end - - -- Remove flight from Marshal queue. If flight was in queue, stack is collapsed and flight added to the pattern queue. - self:_RemoveFlightFromMarshalQueue( playerData ) - - -- Initialize player data for new approach. - self:_InitPlayer( playerData ) - - -- Commencing message to player only. - if playerData.difficulty ~= AIRBOSS.Difficulty.HARD then - - -- Text - local text = "" - - -- Positive response. - if playerData.case == 1 then - -- text = text .. "Proceed to initial." - text = text .. "继续到 initial 阶段." - else - -- text = text .. "Descent to platform." - text = text .. "下降高度到达\"平台\"[platform]." - if playerData.difficulty == AIRBOSS.Difficulty.EASY and playerData.showhints then - -- text = text .. " VSI 4000 ft/min until you reach 5000 ft." - text = text .. " 保持下降率 4000 ft/min 直到你到达 5000 ft." - end - end - - -- Message to player. - self:MessageToPlayer( playerData, text, "MARSHAL" ) - end - - -- Next step: depends on case recovery. - local nextstep - if playerData.case == 1 then - -- CASE I: Player has to fly to the initial which is 3 NM DME astern of the boat. - nextstep = AIRBOSS.PatternStep.INITIAL - else - -- CASE II/III: Player has to start the descent at 4000 ft/min to the platform at 5k ft. - nextstep = AIRBOSS.PatternStep.PLATFORM - end - - -- Next step hint. - self:_SetPlayerStep( playerData, nextstep ) - - -- Commence section members as well but dont check the zone. - for i, _flight in pairs( playerData.section ) do - local flight = _flight -- #AIRBOSS.PlayerData - self:_Commencing( flight, false ) - end - -end - ---- Start pattern when player enters the initial zone in case I/II recoveries. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. --- @return #boolean True if player is in the initial zone. -function AIRBOSS:_Initial( playerData ) - - -- Check if player is in initial zone and entering the CASE I pattern. - local inzone = playerData.unit:IsInZone( self:_GetZoneInitial( playerData.case ) ) - - -- Relative heading to carrier direction. - local relheading = self:_GetRelativeHeading( playerData.unit, false ) - - -- altitude of player in feet. - local altitude = playerData.unit:GetAltitude() - - -- Check if player is in zone and flying roughly in the right direction. - if inzone and math.abs( relheading ) < 60 and altitude <= self.initialmaxalt then - - -- Send message for normal and easy difficulty. - if playerData.showhints then - - -- Inform player. - local hint = string.format( "Initial" ) - - -- Hook down for students. - if playerData.difficulty == AIRBOSS.Difficulty.EASY and playerData.actype ~= AIRBOSS.AircraftCarrier.AV8B then - if playerData.actype == AIRBOSS.AircraftCarrier.F14A or playerData.actype == AIRBOSS.AircraftCarrier.F14B then - -- hint = hint .. " - Hook down, SAS on, Wing Sweep 68°!" - hint = hint .. " - 放尾勾, SAS 开, 机翼角度 68°!" - else - -- hint = hint .. " - Hook down!" - hint = hint .. " - 放尾勾!" - end - end - - self:MessageToPlayer( playerData, hint, "MARSHAL" ) - end - - -- Next step: Break entry. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.BREAKENTRY ) - - return true - end - return false -end - ---- Check if player is in CASE II/III approach corridor. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. -function AIRBOSS:_CheckCorridor( playerData ) - - -- Check if player is in valid zone - local validzone = self:_GetZoneCorridor( playerData.case ) - - -- Check if we are inside the moving zone. - local invalid = playerData.unit:IsNotInZone( validzone ) - - -- Issue warning. - if invalid and (not playerData.warning) then - -- self:MessageToPlayer( playerData, "you left the approach corridor!", "AIRBOSS" ) - self:MessageToPlayer( playerData, "你已偏离接近航道!", "AIRBOSS" ) - playerData.warning = true end - - -- Back in zone. - if (not invalid) and playerData.warning then - -- self:MessageToPlayer( playerData, "you're back in the approach corridor.", "AIRBOSS" ) - self:MessageToPlayer( playerData, "你已回到接近航道.", "AIRBOSS" ) - playerData.warning = false + function AIRBOSS:_RemoveDeadFlightGroups() + for i=#self.flight,1,-1 do + local flight=self.flights[i] + if not flight.group:IsAlive()then + self:T(string.format("Removing dead flight group %s from ALL flights table.",flight.groupname)) + table.remove(self.flights,i) end - -end - ---- Platform at 5k ft for case II/III recoveries. Descent at 2000 ft/min. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. -function AIRBOSS:_Platform( playerData ) - - -- Check if player left or got back to the approach corridor. - self:_CheckCorridor( playerData ) - - -- Check if we are inside the moving zone. - local inzone = playerData.unit:IsInZone( self:_GetZonePlatform( playerData.case ) ) - - -- Check if we are in zone. + end + for i=#self.Qmarshal,1,-1 do + local flight=self.Qmarshal[i] + if not flight.group:IsAlive()then + self:T(string.format("Removing dead flight group %s from Marshal Queue table.",flight.groupname)) + table.remove(self.Qmarshal,i) + end + end + for i=#self.Qpattern,1,-1 do + local flight=self.Qpattern[i] + if not flight.group:IsAlive()then + self:T(string.format("Removing dead flight group %s from Pattern Queue table.",flight.groupname)) + table.remove(self.Qpattern,i) + end + end + end + function AIRBOSS:_GetLeadFlight(flight) + local lead=flight + if flight.name~=flight.seclead then + lead=self.players[flight.seclead] + end + return lead + end + function AIRBOSS:_CheckSectionRecovered(flight) + if flight==nil then + return true + end + local lead=self:_GetLeadFlight(flight) + for _,_element in pairs(lead.elements)do + local element=_element + if not element.recovered then + return false + end + end + for _,_section in pairs(lead.section)do + local sectionmember=_section + for _,_element in pairs(sectionmember.elements)do + local element=_element + if not element.recovered then + return false + end + end + end + self:_RemoveFlightFromQueue(self.Qpattern,lead) + if self:_InQueue(self.Qmarshal,lead.group)then + self:E(self.lid..string.format("ERROR: lead flight group %s should not be in marshal queue",lead.groupname)) + self:_RemoveFlightFromMarshalQueue(lead,true) + end + if self:_InQueue(self.Qwaiting,lead.group)then + self:E(self.lid..string.format("ERROR: lead flight group %s should not be in pattern queue",lead.groupname)) + self:_RemoveFlightFromQueue(self.Qwaiting,lead) + end + return true + end + function AIRBOSS:_AddFlightToPatternQueue(flight) + table.insert(self.Qpattern,flight) + flight.flag=-1 + flight.time=timer.getAbsTime() + flight.recovered=false + for _,elem in pairs(flight.elements)do + elem.recoverd=false + end + for _,sec in pairs(flight.section)do + sec.flag=-1 + sec.time=timer.getAbsTime() + for _,elem in pairs(sec.elements)do + elem.recoverd=false + end + end + end + function AIRBOSS:_RecoveredElement(unit) + local element,idx,flight=self:_GetFlightElement(unit:GetName()) + if element then + element.recovered=true + end + return flight + end + function AIRBOSS:_RemoveFlightFromMarshalQueue(flight,nopattern) + local removed,idx=self:_RemoveFlightFromQueue(self.Qmarshal,flight) + if removed then + flight.holding=nil + self:_CollapseMarshalStack(flight,nopattern) + if flight.case==1 and#self.Qwaiting>0 then + local nextflight=self.Qwaiting[1] + local freestack=self:_GetFreeStack(nextflight.ai) + if nextflight.ai then + self:_MarshalAI(nextflight,freestack) + else + self:_MarshalPlayer(nextflight,freestack) + end + self:_RemoveFlightFromQueue(self.Qwaiting,nextflight) + end + end + return removed,idx + end + function AIRBOSS:_RemoveFlightFromQueue(queue,flight) + for i,_flight in pairs(queue)do + local qflight=_flight + if qflight.groupname==flight.groupname then + self:T(self.lid..string.format("Removing flight group %s from queue.",flight.groupname)) + table.remove(queue,i) + return true,i + end + end + return false,nil + end + function AIRBOSS:_RemoveUnitFromFlight(unit) + if unit and unit:IsInstanceOf("UNIT")then + local group=unit:GetGroup() + if group then + local flight=self:_GetFlightFromGroupInQueue(group,self.flights) + if flight then + local removed=self:_RemoveFlightElement(unit:GetName()) + if removed then + local _,nunits=self:_GetFlightUnits(flight,not flight.ai) + local nelements=#flight.elements + self:T(self.lid..string.format("Removed unit %s: nunits=%d, nelements=%d",unit:GetName(),nunits,nelements)) + if nunits==0 or nelements==0 then + self:_RemoveFlight(flight) + end + end + end + end + end + end + function AIRBOSS:_RemoveFlightFromSection(flight) + if flight.name~=flight.seclead then + local lead=self.players[flight.seclead] + if lead then + for i,sec in pairs(lead.section)do + local sectionmember=sec + if sectionmember.name==flight.name then + table.remove(lead.section,i) + break + end + end + end + end + end + function AIRBOSS:_UpdateFlightSection(flight) + if flight.seclead==flight.name then + if#flight.section>=1 then + local newlead=flight.section[1] + newlead.seclead=newlead.name + for i=2,#flight.section do + local member=flight.section[i] + table.insert(newlead.section,member) + member.seclead=newlead.name + end + end + flight.section={} + else + self:_RemoveFlightFromSection(flight) + end + end + function AIRBOSS:_RemoveFlight(flight,completely) + self:F(self.lid..string.format("Removing flight %s, ai=%s completely=%s.",tostring(flight.groupname),tostring(flight.ai),tostring(completely))) + self:_RemoveFlightFromMarshalQueue(flight,true) + self:_RemoveFlightFromQueue(self.Qpattern,flight) + self:_RemoveFlightFromQueue(self.Qwaiting,flight) + self:_RemoveFlightFromQueue(self.Qspinning,flight) + if flight.ai then + self:_RemoveFlightFromQueue(self.flights,flight) + else + local grades=self.playerscores[flight.name] + if grades and#grades>0 then + while#grades>0 and grades[#grades].finalscore==nil do + table.remove(grades,#grades) + end + end + if completely then + self:_UpdateFlightSection(flight) + self:_RemoveFlightFromQueue(self.flights,flight) + local playerdata=self.players[flight.name] + if playerdata then + self:T(self.lid..string.format("Removing player %s completely.",flight.name)) + self.players[flight.name]=nil + end + flight=nil + else + self:_SetPlayerStep(flight,AIRBOSS.PatternStep.UNDEFINED) + for _,sectionmember in pairs(flight.section)do + self:_SetPlayerStep(sectionmember,AIRBOSS.PatternStep.UNDEFINED) + self:_RemoveFlightFromQueue(self.Qspinning,sectionmember) + end + self:_RemoveFlightFromSection(flight) + end + end + end + function AIRBOSS:_CheckPlayerStatus() + for _playerName,_playerData in pairs(self.players)do + local playerData=_playerData + if playerData then + local unit=playerData.unit + if unit and unit:IsAlive()then + if unit:IsInZone(self.zoneCCA)then + if playerData.attitudemonitor then + self:_AttitudeMonitor(playerData) + end + self:_CheckPlayerPatternDistance(playerData) + self:_CheckFoulDeck(playerData) + if playerData.step==AIRBOSS.PatternStep.UNDEFINED then + elseif playerData.step==AIRBOSS.PatternStep.REFUELING then + elseif playerData.step==AIRBOSS.PatternStep.SPINNING then + self:_Spinning(playerData) + elseif playerData.step==AIRBOSS.PatternStep.HOLDING then + self:_Holding(playerData) + elseif playerData.step==AIRBOSS.PatternStep.WAITING then + self:_Waiting(playerData) + elseif playerData.step==AIRBOSS.PatternStep.COMMENCING then + self:_Commencing(playerData,true) + elseif playerData.step==AIRBOSS.PatternStep.BOLTER then + self:_BolterPattern(playerData) + elseif playerData.step==AIRBOSS.PatternStep.PLATFORM then + self:_Platform(playerData) + elseif playerData.step==AIRBOSS.PatternStep.ARCIN then + self:_ArcInTurn(playerData) + elseif playerData.step==AIRBOSS.PatternStep.ARCOUT then + self:_ArcOutTurn(playerData) + elseif playerData.step==AIRBOSS.PatternStep.DIRTYUP then + self:_DirtyUp(playerData) + elseif playerData.step==AIRBOSS.PatternStep.BULLSEYE then + self:_Bullseye(playerData) + elseif playerData.step==AIRBOSS.PatternStep.INITIAL then + self:_Initial(playerData) + elseif playerData.step==AIRBOSS.PatternStep.BREAKENTRY then + self:_BreakEntry(playerData) + elseif playerData.step==AIRBOSS.PatternStep.EARLYBREAK then + self:_Break(playerData,AIRBOSS.PatternStep.EARLYBREAK) + elseif playerData.step==AIRBOSS.PatternStep.LATEBREAK then + self:_Break(playerData,AIRBOSS.PatternStep.LATEBREAK) + elseif playerData.step==AIRBOSS.PatternStep.ABEAM then + self:_Abeam(playerData) + elseif playerData.step==AIRBOSS.PatternStep.NINETY then + self:_CheckForLongDownwind(playerData) + self:_Ninety(playerData) + elseif playerData.step==AIRBOSS.PatternStep.WAKE then + self:_Wake(playerData) + elseif playerData.step==AIRBOSS.PatternStep.EMERGENCY then + self:_Final(playerData,true) + elseif playerData.step==AIRBOSS.PatternStep.FINAL then + self:_Final(playerData) + elseif playerData.step==AIRBOSS.PatternStep.GROOVE_XX or + playerData.step==AIRBOSS.PatternStep.GROOVE_IM or + playerData.step==AIRBOSS.PatternStep.GROOVE_IC or + playerData.step==AIRBOSS.PatternStep.GROOVE_AR or + playerData.step==AIRBOSS.PatternStep.GROOVE_AL or + playerData.step==AIRBOSS.PatternStep.GROOVE_LC or + playerData.step==AIRBOSS.PatternStep.GROOVE_IW then + self:_Groove(playerData) + elseif playerData.step==AIRBOSS.PatternStep.DEBRIEF then + playerData.debriefschedulerID=self:ScheduleOnce(5,self._Debrief,self,playerData) + playerData.step=AIRBOSS.PatternStep.UNDEFINED + else + self:E(self.lid..string.format("ERROR: Unknown player step %s. Please report!",tostring(playerData.step))) + end + self:_CheckMissedStepOnEntry(playerData) + else + self:T2(self.lid.."WARNING: Player unit not inside the CCA!") + end + else + self:T(self.lid.."WARNING: Player unit is not alive!") + end + end + end + end + function AIRBOSS:_CheckMissedStepOnEntry(playerData) + local rightcase=playerData.case>1 + local rightqueue=self:_InQueue(self.Qpattern,playerData.group) + local rightflag=playerData.flag~=-42 + local step=playerData.step + local missedstep=step==AIRBOSS.PatternStep.PLATFORM or step==AIRBOSS.PatternStep.ARCIN or step==AIRBOSS.PatternStep.ARCOUT or step==AIRBOSS.PatternStep.DIRTYUP + if rightcase and rightqueue and rightflag then + local zone=nil + if playerData.case==2 and missedstep then + zone=self:_GetZoneInitial(playerData.case) + elseif playerData.case==3 and missedstep then + zone=self:_GetZoneBullseye(playerData.case) + end + if zone then + local inzone=playerData.unit:IsInZone(zone) + local relheading=self:_GetRelativeHeading(playerData.unit,false) + if inzone and math.abs(relheading)<60 then + -- local text=string.format("you missed an important step in the pattern!\nYour next step would have been %s.",playerData.step) + -- self:MessageToPlayer(playerData,text,"AIRBOSS",nil,5) + local text=string.format("你错过了一个航降的关键步骤!\n你的下一个环节本来应该是 %s.",playerData.step) + self:MessageToPlayer(playerData,text,"航空长",nil,5) + if playerData.case==2 then + playerData.step=AIRBOSS.PatternStep.INITIAL + elseif playerData.case==3 then + playerData.step=AIRBOSS.PatternStep.BULLSEYE + end + playerData.flag=-42 + end + end + end + end + function AIRBOSS:_SetTimeInGroove(playerData) + if playerData.TIG0 then + playerData.Tgroove=timer.getTime()-playerData.TIG0 + else + playerData.Tgroove=999 + end + end + function AIRBOSS:_GetTimeInGroove(playerData) + local Tgroove=999 + if playerData.TIG0 then + Tgroove=timer.getTime()-playerData.TIG0 + end + return Tgroove + end + function AIRBOSS:OnEventBirth(EventData) + self:F3({eventbirth=EventData}) + if EventData==nil then + self:E(self.lid.."ERROR: EventData=nil in event BIRTH!") + self:E(EventData) + return + end + if EventData.IniUnit==nil and(not EventData.IniObjectCategory==Object.Category.STATIC)then + self:E(self.lid.."ERROR: EventData.IniUnit=nil in event BIRTH!") + self:E(EventData) + return + end + if EventData.IniObjectCategory~=Object.Category.UNIT then return end + local _unitName=EventData.IniUnitName + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + self:T(self.lid.."BIRTH: unit = "..tostring(EventData.IniUnitName)) + self:T(self.lid.."BIRTH: group = "..tostring(EventData.IniGroupName)) + self:T(self.lid.."BIRTH: player = "..tostring(_playername)) + if _unit and _playername then + local _uid=_unit:GetID() + local _group=_unit:GetGroup() + local _callsign=_unit:GetCallsign() + local text=string.format("Pilot %s, callsign %s entered unit %s of group %s.",_playername,_callsign,_unitName,_group:GetName()) + self:T(self.lid..text) + MESSAGE:New(text,5):ToAllIf(self.Debug) + local rightaircraft=self:_IsCarrierAircraft(_unit) + if rightaircraft==false then + local text=string.format("Player aircraft type %s not supported by AIRBOSS class.",_unit:GetTypeName()) + MESSAGE:New(text,30):ToAllIf(self.Debug) + self:T2(self.lid..text) + return + end + if self:GetCoalition()~=_unit:GetCoalition()then + local text=string.format("Player entered aircraft of other coalition.") + MESSAGE:New(text,30):ToAllIf(self.Debug) + self:T(self.lid..text) + return + end + self:_AddF10Commands(_unitName) + self:ScheduleOnce(1,self._NewPlayer,self,_unitName) + end + end + function AIRBOSS:OnEventLand(EventData) + self:F3({eventland=EventData}) + if EventData==nil then + self:E(self.lid.."ERROR: EventData=nil in event LAND!") + self:E(EventData) + return + end + if EventData.IniUnit==nil then + self:E(self.lid.."ERROR: EventData.IniUnit=nil in event LAND!") + self:E(EventData) + return + end + local _unitName=EventData.IniUnitName + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + self:T(self.lid.."LAND: unit = "..tostring(EventData.IniUnitName)) + self:T(self.lid.."LAND: group = "..tostring(EventData.IniGroupName)) + self:T(self.lid.."LAND: player = "..tostring(_playername)) + local airbase=EventData.Place + if airbase==nil then + return + end + local airbasename=tostring(airbase:GetName()) + if airbasename==self.airbase:GetName()then + local stern=self:_GetSternCoord() + local zoneCarrier=self:_GetZoneCarrierBox() + if _unit and _playername then + local _uid=_unit:GetID() + local _group=_unit:GetGroup() + local _callsign=_unit:GetCallsign() + local text=string.format("Player %s, callsign %s unit %s (ID=%d) of group %s landed at airbase %s",_playername,_callsign,_unitName,_uid,_group:GetName(),airbasename) + self:T(self.lid..text) + MESSAGE:New(text,5,"DEBUG"):ToAllIf(self.Debug) + local playerData=self.players[_playername] + if playerData==nil then + self:E(self.lid..string.format("ERROR: playerData nil in landing event. unit=%s player=%s",tostring(_unitName),tostring(_playername))) + return + end + if _unit:IsInZone(zoneCarrier)then + if not playerData.valid then + -- local text=string.format("you missed at least one important step in the pattern!\nYour next step would have been %s.\nThis pass is INVALID.",playerData.step) + -- self:MessageToPlayer(playerData,text,"AIRBOSS",nil,30,true,5) + local text=string.format("你错过了航降中一个关键的步骤!\n你的下一步本应该是 %s.\n此次成绩无效.",playerData.step) + self:MessageToPlayer(playerData,text,"航空长",nil,30,true,5) + self:_RemoveFlightFromMarshalQueue(playerData,true) + self:_RemoveFlightFromQueue(self.Qpattern,playerData) + self:_RemoveFlightFromQueue(self.Qwaiting,playerData) + self:_RemoveFlightFromQueue(self.Qspinning,playerData) + self:_InitPlayer(playerData) + return + end + if playerData.landed then + self:E(self.lid..string.format("Player %s just landed a second time.",_playername)) + else + playerData.landed=true + playerData.attitudemonitor=false + local coord=playerData.unit:GetCoordinate() + local X,Z,rho,phi=self:_GetDistances(_unit) + local dist=coord:Get2DDistance(stern) + if self.Debug and false then + local lp=coord:MarkToAll("Landing coord.") + coord:SmokeGreen() + end + self:_SetTimeInGroove(playerData) + local text=string.format("Player %s AC type %s landed at dist=%.1f m. Tgroove=%.1f sec.",playerData.name,playerData.actype,dist,self:_GetTimeInGroove(playerData)) + text=text..string.format(" X=%.1f m, Z=%.1f m, rho=%.1f m.",X,Z,rho) + self:T(self.lid..text) + if self.carriertype==AIRBOSS.CarrierType.INVINCIBLE or self.carriertype==AIRBOSS.CarrierType.HERMES or self.carriertype==AIRBOSS.CarrierType.TARAWA or self.carriertype==AIRBOSS.CarrierType.AMERICA or self.carriertype==AIRBOSS.CarrierType.JCARLOS or self.carriertype==AIRBOSS.CarrierType.CANBERRA then + self:RadioTransmission(self.LSORadio,self.LSOCall.IDLE,false,1,nil,true) + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.DEBRIEF) + else + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.UNDEFINED) + self:ScheduleOnce(1,self._Trapped,self,playerData) + end + end + else + if playerData then + self:E(self.lid..string.format("Player %s did not land in carrier box zone. Maybe in the water near the carrier?",playerData.name)) + end + end + else + if self.carriertype~=AIRBOSS.CarrierType.INVINCIBLE or self.carriertype~=AIRBOSS.CarrierType.HERMES or self.carriertype~=AIRBOSS.CarrierType.TARAWA or self.carriertype~=AIRBOSS.CarrierType.AMERICA or self.carriertype~=AIRBOSS.CarrierType.JCARLOS or self.carriertype~=AIRBOSS.CarrierType.CANBERRA then + local coord=EventData.IniUnit:GetCoordinate() + local dist=coord:Get2DDistance(self:GetCoordinate()) + local wire=self:_GetWire(coord,0) + local _type=EventData.IniUnit:GetTypeName() + local text=string.format("AI unit %s of type %s landed at dist=%.1f m. Trapped wire=%d.",_unitName,_type,dist,wire) + self:T(self.lid..text) + end + local flight=self:_RecoveredElement(EventData.IniUnit) + self:_CheckSectionRecovered(flight) + end + end + end + function AIRBOSS:OnEventEngineShutdown(EventData) + self:F3({eventengineshutdown=EventData}) + if EventData==nil then + self:E(self.lid.."ERROR: EventData=nil in event ENGINESHUTDOWN!") + self:E(EventData) + return + end + if EventData.IniUnit==nil then + self:E(self.lid.."ERROR: EventData.IniUnit=nil in event ENGINESHUTDOWN!") + self:E(EventData) + return + end + local _unitName=EventData.IniUnitName + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + self:T3(self.lid.."ENGINESHUTDOWN: unit = "..tostring(EventData.IniUnitName)) + self:T3(self.lid.."ENGINESHUTDOWN: group = "..tostring(EventData.IniGroupName)) + self:T3(self.lid.."ENGINESHUTDOWN: player = "..tostring(_playername)) + if _unit and _playername then + self:T(self.lid..string.format("Player %s shut down its engines!",_playername)) + else + self:T(self.lid..string.format("AI unit %s shut down its engines!",_unitName)) + local flight=self:_GetFlightFromGroupInQueue(EventData.IniGroup,self.flights) + if flight and flight.ai then + local recovered=self:_CheckSectionRecovered(flight) + if recovered then + self:T(self.lid..string.format("AI group %s completely recovered. Despawning group after engine shutdown event as requested in 5 seconds.",tostring(EventData.IniGroupName))) + self:_RemoveFlight(flight) + local istanker=self.tanker and self.tanker.tanker:GetName()==EventData.IniGroupName + local isawacs=self.awacs and self.awacs.tanker:GetName()==EventData.IniGroupName + if self.despawnshutdown and not(istanker or isawacs)then + EventData.IniGroup:Destroy(nil,5) + end + end + end + end + end + function AIRBOSS:OnEventTakeoff(EventData) + self:F3({eventtakeoff=EventData}) + if EventData==nil then + self:E(self.lid.."ERROR: EventData=nil in event TAKEOFF!") + self:E(EventData) + return + end + if EventData.IniUnit==nil then + self:E(self.lid.."ERROR: EventData.IniUnit=nil in event TAKEOFF!") + self:E(EventData) + return + end + local _unitName=EventData.IniUnitName + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + self:T3(self.lid.."TAKEOFF: unit = "..tostring(EventData.IniUnitName)) + self:T3(self.lid.."TAKEOFF: group = "..tostring(EventData.IniGroupName)) + self:T3(self.lid.."TAKEOFF: player = "..tostring(_playername)) + local airbase=EventData.Place + local airbasename="unknown" + if airbase then + airbasename=airbase:GetName() + end + if airbasename==self.airbase:GetName()then + if _unit and _playername then + self:T(self.lid..string.format("Player %s took off at %s!",_playername,airbasename)) + else + self:T2(self.lid..string.format("AI unit %s took off at %s!",_unitName,airbasename)) + local flight=self:_GetFlightFromGroupInQueue(EventData.IniGroup,self.flights) + if flight then + for _,elem in pairs(flight.elements)do + local element=elem + element.ballcall=false + element.recovered=nil + end + end + end + end + end + function AIRBOSS:OnEventCrash(EventData) + self:F3({eventcrash=EventData}) + if EventData==nil then + self:E(self.lid.."ERROR: EventData=nil in event CRASH!") + self:E(EventData) + return + end + if EventData.IniUnit==nil then + self:E(self.lid.."ERROR: EventData.IniUnit=nil in event CRASH!") + self:E(EventData) + return + end + local _unitName=EventData.IniUnitName + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + self:T3(self.lid.."CRASH: unit = "..tostring(EventData.IniUnitName)) + self:T3(self.lid.."CRASH: group = "..tostring(EventData.IniGroupName)) + self:T3(self.lid.."CARSH: player = "..tostring(_playername)) + if _unit and _playername then + self:T(self.lid..string.format("Player %s crashed!",_playername)) + local flight=self.players[_playername] + if flight then + self:_RemoveFlight(flight,true) + end + else + self:T2(self.lid..string.format("AI unit %s crashed!",EventData.IniUnitName)) + self:_RemoveUnitFromFlight(EventData.IniUnit) + end + end + function AIRBOSS:OnEventEjection(EventData) + self:F3({eventland=EventData}) + if EventData==nil then + self:E(self.lid.."ERROR: EventData=nil in event EJECTION!") + self:E(EventData) + return + end + if EventData.IniUnit==nil then + self:E(self.lid.."ERROR: EventData.IniUnit=nil in event EJECTION!") + self:E(EventData) + return + end + local _unitName=EventData.IniUnitName + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + self:T3(self.lid.."EJECT: unit = "..tostring(EventData.IniUnitName)) + self:T3(self.lid.."EJECT: group = "..tostring(EventData.IniGroupName)) + self:T3(self.lid.."EJECT: player = "..tostring(_playername)) + if _unit and _playername then + self:T(self.lid..string.format("Player %s ejected!",_playername)) + local flight=self.players[_playername] + if flight then + self:_RemoveFlight(flight,true) + end + else + self:T(self.lid..string.format("AI unit %s ejected!",EventData.IniUnitName)) + self:_RemoveUnitFromFlight(EventData.IniUnit) + local flight=self:_GetFlightFromGroupInQueue(EventData.IniGroup,self.flights) + self:_CheckSectionRecovered(flight) + end + end + function AIRBOSS:OnEventRemoveUnit(EventData) + self:F3({eventland=EventData}) + if EventData==nil then + self:E(self.lid.."ERROR: EventData=nil in event REMOVEUNIT!") + self:E(EventData) + return + end + if EventData.IniUnit==nil then + self:E(self.lid.."ERROR: EventData.IniUnit=nil in event REMOVEUNIT!") + self:E(EventData) + return + end + local _unitName=EventData.IniUnitName + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + self:T3(self.lid.."EJECT: unit = "..tostring(EventData.IniUnitName)) + self:T3(self.lid.."EJECT: group = "..tostring(EventData.IniGroupName)) + self:T3(self.lid.."EJECT: player = "..tostring(_playername)) + if _unit and _playername then + self:T(self.lid..string.format("Player %s removed!",_playername)) + local flight=self.players[_playername] + if flight then + self:_RemoveFlight(flight,true) + end + else + self:T(self.lid..string.format("AI unit %s removed!",EventData.IniUnitName)) + self:_RemoveUnitFromFlight(EventData.IniUnit) + local flight=self:_GetFlightFromGroupInQueue(EventData.IniGroup,self.flights) + self:_CheckSectionRecovered(flight) + end + end + function AIRBOSS:_PlayerLeft(EventData) + self:F3({eventleave=EventData}) + if EventData==nil then + self:E(self.lid.."ERROR: EventData=nil in event PLAYERLEFTUNIT!") + self:E(EventData) + return + end + if EventData.IniUnit==nil then + self:E(self.lid.."ERROR: EventData.IniUnit=nil in event PLAYERLEFTUNIT!") + self:E(EventData) + return + end + local _unitName=EventData.IniUnitName + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + self:T3(self.lid.."PLAYERLEAVEUNIT: unit = "..tostring(EventData.IniUnitName)) + self:T3(self.lid.."PLAYERLEAVEUNIT: group = "..tostring(EventData.IniGroupName)) + self:T3(self.lid.."PLAYERLEAVEUNIT: player = "..tostring(_playername)) + if _unit and _playername then + self:T(self.lid..string.format("Player %s left unit %s!",_playername,_unitName)) + local flight=self.players[_playername] + if flight then + self:_RemoveFlight(flight,true) + end + end + end + function AIRBOSS:OnEventMissionEnd(EventData) + self:T3(self.lid.."Mission Ended") + end + function AIRBOSS:_Spinning(playerData) + local SpinIt={} + SpinIt.name="Spinning" + SpinIt.Xmin=-UTILS.NMToMeters(6) + SpinIt.Xmax=UTILS.NMToMeters(5) + SpinIt.Zmin=-UTILS.NMToMeters(6) + SpinIt.Zmax=UTILS.NMToMeters(2) + SpinIt.LimitXmin=-100 + SpinIt.LimitXmax=nil + SpinIt.LimitZmin=-UTILS.NMToMeters(1) + SpinIt.LimitZmax=nil + local X,Z,rho,phi=self:_GetDistances(playerData.unit) + if self:_CheckLimits(X,Z,SpinIt)then + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.INITIAL) + self:_RemoveFlightFromQueue(self.Qspinning,playerData) + end + end + function AIRBOSS:_Waiting(playerData) + local radius=UTILS.NMToMeters(10) + local zone=ZONE_RADIUS:New("Carrier 10 NM Zone",self.carrier:GetVec2(),radius) + local inzone=playerData.unit:IsInZone(zone) + local Twaiting=timer.getAbsTime()-playerData.time + if inzone and Twaiting>3*60 and not playerData.warning then + -- local text=string.format("You are supposed to wait outside the 10 NM zone.") + -- self:MessageToPlayer(playerData,text,"AIRBOSS") + local text=string.format("你应该在10海里区域外等待.") + self:MessageToPlayer(playerData,text,"航空长") + playerData.warning=true + end + if inzone==false and playerData.warning==true then + playerData.warning=nil + end + end + function AIRBOSS:_Holding(playerData) + local unit=playerData.unit + local stack=playerData.flag + if stack<=0 then + local text=string.format("ERROR: player %s in step %s is holding but has stack=%s (<=0)",playerData.name,playerData.step,tostring(stack)) + self:E(self.lid..text) + end + local patternalt=self:_GetMarshalAltitude(stack,playerData.case) + local playeralt=unit:GetAltitude() + local zoneHolding=self:_GetZoneHolding(playerData.case,stack) + if zoneHolding==nil then + self:E(self.lid.."ERROR: zoneHolding is nil!") + self:E({playerData=playerData}) + return + end + local inholdingzone=unit:IsInZone(zoneHolding) + local altdiff=playeralt-patternalt + local altgood=UTILS.FeetToMeters(500) + if playerData.difficulty==AIRBOSS.Difficulty.HARD then + altgood=UTILS.FeetToMeters(200) + elseif playerData.difficulty==AIRBOSS.Difficulty.NORMAL then + altgood=UTILS.FeetToMeters(350) + elseif playerData.difficulty==AIRBOSS.Difficulty.EASY then + altgood=UTILS.FeetToMeters(500) + end + local altback=altgood*0.5 + local justcollapsed=false + if self.Tcollapse then + local dT=timer.getTime()-self.Tcollapse + if dT<=90 then + justcollapsed=true + end + end + local goodalt=math.abs(altdiff)altgood then + if not playerData.warning then + -- text=text..string.format("You left your assigned altitude. Descent to angels %d.",angels) + text=text..string.format("你偏离了分配的高度. 下降至高度 %d.",angels) + playerData.warning=true + end + elseif altdiff<-altgood then + if not playerData.warning then + -- text=text..string.format("You left your assigned altitude. Climb to angels %d.",angels) + text=text..string.format("你偏离了分配的高度. 爬升至高度 %d.",angels) + playerData.warning=true + end + end + end + if playerData.warning and math.abs(altdiff)<=altback then + -- text=text..string.format("Altitude is looking good again.") + text=text..string.format("高度保持完美.") + playerData.warning=nil + end + elseif playerData.holding==false then + if inholdingzone then + -- text=text..string.format("You are back in the holding zone. Now stay there!") + text=text..string.format("你回到了等待区域. 尽量保持好位置!") + playerData.holding=true + else + self:T3("Player still outside the holding zone. What are you doing man?!") + end + elseif playerData.holding==nil then + if inholdingzone then + playerData.holding=true + -- text=text..string.format("You arrived at the holding zone.") + text=text..string.format("你到达了等待区域.") + if goodalt then + -- text=text..string.format(" Altitude is good.") + text=text..string.format(" 高度完美.") + else + if altdiff<0 then + -- text=text..string.format(" But you're too low.") + text=text..string.format(" 但是你太低了.") + else + -- text=text..string.format(" But you're too high.") + text=text..string.format(" 但是你高度过高了.") + end + -- text=text..string.format("\nCurrently assigned altitude is %d ft.",UTILS.MetersToFeet(patternalt)) + text=text..string.format("\n目前分配给你的高度是 %d 英尺(ft).",UTILS.MetersToFeet(patternalt)) + playerData.warning=true + end + else + self:T3("Waiting for player to arrive in the holding zone.") + end + end + if playerData.showhints then + self:MessageToPlayer(playerData,text,"MARSHAL") + end + end + function AIRBOSS:_Commencing(playerData,zonecheck) + if zonecheck then + local zoneCommence=self:_GetZoneCommence(playerData.case,playerData.flag) + local inzone=playerData.unit:IsInZone(zoneCommence) + if not inzone then + if timer.getAbsTime()-playerData.time>180 then + self:_MarshalCallClearedForRecovery(playerData.onboard,playerData.case) + playerData.time=timer.getAbsTime() + end + return + end + end + self:_RemoveFlightFromMarshalQueue(playerData) + self:_InitPlayer(playerData) + if playerData.difficulty~=AIRBOSS.Difficulty.HARD then + local text="" + if playerData.case==1 then + -- text=text.."Proceed to initial." + text=text.."前进至起始点." + else + -- text=text.."Descent to platform." + text=text.."下降到 平台." + if playerData.difficulty==AIRBOSS.Difficulty.EASY and playerData.showhints then + -- text=text.." VSI 4000 ft/min until you reach 5000 ft." + text=text.." 在你到达 5000 ft前保持下降率 4000ft/min." + end + end + self:MessageToPlayer(playerData,text,"MARSHAL") + end + local nextstep + if playerData.case==1 then + nextstep=AIRBOSS.PatternStep.INITIAL + else + nextstep=AIRBOSS.PatternStep.PLATFORM + end + self:_SetPlayerStep(playerData,nextstep) + for i,_flight in pairs(playerData.section)do + local flight=_flight + self:_Commencing(flight,false) + end + end + function AIRBOSS:_Initial(playerData) + local inzone=playerData.unit:IsInZone(self:_GetZoneInitial(playerData.case)) + local relheading=self:_GetRelativeHeading(playerData.unit,false) + local altitude=playerData.unit:GetAltitude() + if inzone and math.abs(relheading)<60 and altitude<=self.initialmaxalt then + if playerData.showhints then + local hint=string.format("Initial") + if playerData.difficulty==AIRBOSS.Difficulty.EASY and playerData.actype~=AIRBOSS.AircraftCarrier.AV8B then + if playerData.actype==AIRBOSS.AircraftCarrier.F14A or playerData.actype==AIRBOSS.AircraftCarrier.F14B then + -- hint=hint.." - Hook down, SAS on, Wing Sweep 68°!" + hint=hint.." - 放尾勾, SAS 开, 机翼角度 68°!" + else + -- hint=hint.." - Hook down!" + hint=hint.." - 放尾勾!" + end + end + self:MessageToPlayer(playerData,hint,"MARSHAL") + end + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.BREAKENTRY) + return true + end + return false + end + function AIRBOSS:_CheckCorridor(playerData) + local validzone=self:_GetZoneCorridor(playerData.case) + local invalid=playerData.unit:IsNotInZone(validzone) + if invalid and(not playerData.warning)then + -- self:MessageToPlayer(playerData,"you left the approach corridor!","AIRBOSS") + self:MessageToPlayer(playerData,"你偏离了降落航道!","AIRBOSS") + playerData.warning=true + end + if(not invalid)and playerData.warning then + -- self:MessageToPlayer(playerData,"you're back in the approach corridor.","AIRBOSS") + self:MessageToPlayer(playerData,"你重新回到了了降落航道.","AIRBOSS") + playerData.warning=false + end + end + function AIRBOSS:_Platform(playerData) + self:_CheckCorridor(playerData) + local inzone=playerData.unit:IsInZone(self:_GetZonePlatform(playerData.case)) if inzone then - - -- Hint for player about altitude, AoA etc. - self:_PlayerHint( playerData ) - - -- Next step: depends. - local nextstep - if math.abs( self.holdingoffset ) > 0 and playerData.case > 1 then - -- Turn to BRC (case II) or FB (case III). - nextstep = AIRBOSS.PatternStep.ARCIN - else - if playerData.case == 2 then - -- Case II: Initial zone then Case I recovery. - nextstep = AIRBOSS.PatternStep.INITIAL - elseif playerData.case == 3 then - -- CASE III: Dirty up. - nextstep = AIRBOSS.PatternStep.DIRTYUP - end - end - - -- Next step hint. - self:_SetPlayerStep( playerData, nextstep ) - + self:_PlayerHint(playerData) + local nextstep + if math.abs(self.holdingoffset)>0 and playerData.case>1 then + nextstep=AIRBOSS.PatternStep.ARCIN + else + if playerData.case==2 then + nextstep=AIRBOSS.PatternStep.INITIAL + elseif playerData.case==3 then + nextstep=AIRBOSS.PatternStep.DIRTYUP end -end - ---- Arc in turn for case II/III recoveries. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. -function AIRBOSS:_ArcInTurn( playerData ) - - -- Check if player left or got back to the approach corridor. - self:_CheckCorridor( playerData ) - - -- Check if we are inside the moving zone. - local inzone = playerData.unit:IsInZone( self:_GetZoneArcIn( playerData.case ) ) - + end + self:_SetPlayerStep(playerData,nextstep) + end + end + function AIRBOSS:_ArcInTurn(playerData) + self:_CheckCorridor(playerData) + local inzone=playerData.unit:IsInZone(self:_GetZoneArcIn(playerData.case)) if inzone then - - -- Hint for player about altitude, AoA etc. - self:_PlayerHint( playerData ) - - -- Next step: Arc Out Turn. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.ARCOUT ) - + self:_PlayerHint(playerData) + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.ARCOUT) end -end - ---- Arc out turn for case II/III recoveries. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. -function AIRBOSS:_ArcOutTurn( playerData ) - - -- Check if player left or got back to the approach corridor. - self:_CheckCorridor( playerData ) - - -- Check if we are inside the moving zone. - local inzone = playerData.unit:IsInZone( self:_GetZoneArcOut( playerData.case ) ) - + end + function AIRBOSS:_ArcOutTurn(playerData) + self:_CheckCorridor(playerData) + local inzone=playerData.unit:IsInZone(self:_GetZoneArcOut(playerData.case)) if inzone then - - -- Hint for player about altitude, AoA etc. - self:_PlayerHint( playerData ) - - -- Next step: - local nextstep - if playerData.case == 3 then - -- Case III: Dirty up. - nextstep = AIRBOSS.PatternStep.DIRTYUP - else - -- Case II: Initial. - nextstep = AIRBOSS.PatternStep.INITIAL - end - - -- Next step hint. - self:_SetPlayerStep( playerData, nextstep ) + self:_PlayerHint(playerData) + local nextstep + if playerData.case==3 then + nextstep=AIRBOSS.PatternStep.DIRTYUP + else + nextstep=AIRBOSS.PatternStep.INITIAL end -end - ---- Dirty up and level out at 1200 ft for case III recovery. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. -function AIRBOSS:_DirtyUp( playerData ) - - -- Check if player left or got back to the approach corridor. - self:_CheckCorridor( playerData ) - - -- Check if we are inside the moving zone. - local inzone = playerData.unit:IsInZone( self:_GetZoneDirtyUp( playerData.case ) ) - + self:_SetPlayerStep(playerData,nextstep) + end + end + function AIRBOSS:_DirtyUp(playerData) + self:_CheckCorridor(playerData) + local inzone=playerData.unit:IsInZone(self:_GetZoneDirtyUp(playerData.case)) if inzone then - - -- Hint for player about altitude, AoA etc. - self:_PlayerHint( playerData ) - - -- Radio call "Say/Fly needles". Delayed by 10/15 seconds. - if playerData.actype == AIRBOSS.AircraftCarrier.HORNET - or playerData.actype == AIRBOSS.AircraftCarrier.F14A - or playerData.actype == AIRBOSS.AircraftCarrier.F14B - or playerData.actype == AIRBOSS.AircraftCarrier.RHINOE - or playerData.actype == AIRBOSS.AircraftCarrier.RHINOF - or playerData.actype == AIRBOSS.AircraftCarrier.GROWLER - then - local callsay = self:_NewRadioCall( self.MarshalCall.SAYNEEDLES, nil, nil, 5, playerData.onboard ) - local callfly = self:_NewRadioCall( self.MarshalCall.FLYNEEDLES, nil, nil, 5, playerData.onboard ) - self:RadioTransmission( self.MarshalRadio, callsay, false, 55, nil, true ) - self:RadioTransmission( self.MarshalRadio, callfly, false, 60, nil, true ) - end - - -- TODO: Make Fly Bullseye call if no automatic ICLS is active. - - -- Next step: CASE III: Intercept glide slope and follow bullseye (ICLS). - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.BULLSEYE ) - + self:_PlayerHint(playerData) + if playerData.actype==AIRBOSS.AircraftCarrier.HORNET + or playerData.actype==AIRBOSS.AircraftCarrier.F14A + or playerData.actype==AIRBOSS.AircraftCarrier.F14B + or playerData.actype==AIRBOSS.AircraftCarrier.RHINOE + or playerData.actype==AIRBOSS.AircraftCarrier.RHINOF + or playerData.actype==AIRBOSS.AircraftCarrier.GROWLER + then + local callsay=self:_NewRadioCall(self.MarshalCall.SAYNEEDLES,nil,nil,5,playerData.onboard) + local callfly=self:_NewRadioCall(self.MarshalCall.FLYNEEDLES,nil,nil,5,playerData.onboard) + self:RadioTransmission(self.MarshalRadio,callsay,false,55,nil,true) + self:RadioTransmission(self.MarshalRadio,callfly,false,60,nil,true) end -end - ---- Intercept glide slop and follow ICLS, aka Bullseye for case III recovery. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. --- @return #boolean If true, player is in bullseye zone. -function AIRBOSS:_Bullseye( playerData ) - - -- Check if player left or got back to the approach corridor. - self:_CheckCorridor( playerData ) - - -- Check if we are inside the moving zone. - local inzone = playerData.unit:IsInZone( self:_GetZoneBullseye( playerData.case ) ) - - -- Relative heading to carrier direction of the runway. - local relheading = self:_GetRelativeHeading( playerData.unit, true ) - - -- Check if player is in zone and flying roughly in the right direction. - if inzone and math.abs( relheading ) < 60 then - - -- Hint for player about altitude, AoA etc. - self:_PlayerHint( playerData ) - - -- LSO expect spot 5 or 7.5 call - if playerData.actype == AIRBOSS.AircraftCarrier.AV8B and self.carriertype == AIRBOSS.CarrierType.JCARLOS then - self:RadioTransmission( self.LSORadio, self.LSOCall.EXPECTSPOT5, nil, nil, nil, true ) - elseif playerData.actype == AIRBOSS.AircraftCarrier.AV8B and self.carriertype == AIRBOSS.CarrierType.CANBERRA then - self:RadioTransmission( self.LSORadio, self.LSOCall.EXPECTSPOT5, nil, nil, nil, true ) - elseif playerData.actype == AIRBOSS.AircraftCarrier.AV8B then - self:RadioTransmission( self.LSORadio, self.LSOCall.EXPECTSPOT75, nil, nil, nil, true ) - end - - -- Next step: Groove Call the ball. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.GROOVE_XX ) - + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.BULLSEYE) end -end - ---- Bolter pattern. Sends player to abeam for Case I/II or Bullseye for Case III ops. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. -function AIRBOSS:_BolterPattern( playerData ) - - -- Get distances between carrier and player unit (parallel and perpendicular to direction of movement of carrier) - local X, Z, rho, phi = self:_GetDistances( playerData.unit ) - - -- Bolter Pattern thresholds. - local Bolter = {} - Bolter.name = "Bolter Pattern" - Bolter.Xmin = -UTILS.NMToMeters( 5 ) -- Not more then 5 NM astern of boat. - Bolter.Xmax = UTILS.NMToMeters( 3 ) -- Not more then 3 NM ahead of boat. - Bolter.Zmin = -UTILS.NMToMeters( 5 ) -- Not more than 2 NM port. - Bolter.Zmax = UTILS.NMToMeters( 1 ) -- Not more than 1 NM starboard. - Bolter.LimitXmin = 100 -- Check that 100 meter ahead and port - Bolter.LimitXmax = nil - Bolter.LimitZmin = nil - Bolter.LimitZmax = nil - - -- Check if we are in front of the boat (diffX > 0). - if self:_CheckLimits( X, Z, Bolter ) then - local nextstep - if playerData.case < 3 then - nextstep = AIRBOSS.PatternStep.ABEAM - else - nextstep = AIRBOSS.PatternStep.BULLSEYE - end - self:_SetPlayerStep( playerData, nextstep ) end -end - ---- Break entry for case I/II recoveries. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. -function AIRBOSS:_BreakEntry( playerData ) - - -- Get distances between carrier and player unit (parallel and perpendicular to direction of movement of carrier) - local X, Z = self:_GetDistances( playerData.unit ) - - -- Abort condition check. - if self:_CheckAbort( X, Z, self.BreakEntry ) then - self:_AbortPattern( playerData, X, Z, self.BreakEntry, true ) - return + function AIRBOSS:_Bullseye(playerData) + self:_CheckCorridor(playerData) + local inzone=playerData.unit:IsInZone(self:_GetZoneBullseye(playerData.case)) + local relheading=self:_GetRelativeHeading(playerData.unit,true) + if inzone and math.abs(relheading)<60 then + self:_PlayerHint(playerData) + if playerData.actype==AIRBOSS.AircraftCarrier.AV8B and self.carriertype==AIRBOSS.CarrierType.JCARLOS then + self:RadioTransmission(self.LSORadio,self.LSOCall.EXPECTSPOT5,nil,nil,nil,true) + elseif playerData.actype==AIRBOSS.AircraftCarrier.AV8B and self.carriertype==AIRBOSS.CarrierType.CANBERRA then + self:RadioTransmission(self.LSORadio,self.LSOCall.EXPECTSPOT5,nil,nil,nil,true) + elseif playerData.actype==AIRBOSS.AircraftCarrier.AV8B then + self:RadioTransmission(self.LSORadio,self.LSOCall.EXPECTSPOT75,nil,nil,nil,true) end - - -- Check if we are in front of the boat (diffX > 0). - if self:_CheckLimits( X, Z, self.BreakEntry ) then - - -- Hint for player about altitude, AoA etc. - self:_PlayerHint( playerData ) - - -- Next step: Early Break. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.EARLYBREAK ) - + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.GROOVE_XX) end -end - ---- Break. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. --- @param #string part Part of the break. -function AIRBOSS:_Break( playerData, part ) - - -- Get distances between carrier and player unit (parallel and perpendicular to direction of movement of carrier) - local X, Z = self:_GetDistances( playerData.unit ) - - -- Early or late break. - local breakpoint = self.BreakEarly - if part == AIRBOSS.PatternStep.LATEBREAK then - breakpoint = self.BreakLate end - - -- Check abort conditions. - if self:_CheckAbort( X, Z, breakpoint ) then - self:_AbortPattern( playerData, X, Z, breakpoint, true ) - return + function AIRBOSS:_BolterPattern(playerData) + local X,Z,rho,phi=self:_GetDistances(playerData.unit) + local Bolter={} + Bolter.name="Bolter Pattern" + Bolter.Xmin=-UTILS.NMToMeters(5) + Bolter.Xmax=UTILS.NMToMeters(3) + Bolter.Zmin=-UTILS.NMToMeters(5) + Bolter.Zmax=UTILS.NMToMeters(1) + Bolter.LimitXmin=100 + Bolter.LimitXmax=nil + Bolter.LimitZmin=nil + Bolter.LimitZmax=nil + if self:_CheckLimits(X,Z,Bolter)then + local nextstep + if playerData.case<3 then + nextstep=AIRBOSS.PatternStep.ABEAM + else + nextstep=AIRBOSS.PatternStep.BULLSEYE end - - -- Player made a very tight turn and did not trigger the latebreak threshold at 0.8 NM. - local tooclose = false - if part == AIRBOSS.PatternStep.LATEBREAK then - local close = 0.8 - if playerData.actype == AIRBOSS.AircraftCarrier.AV8B then - close = 0.5 - end - if X < 0 and Z < UTILS.NMToMeters( close ) then - if playerData.difficulty == AIRBOSS.Difficulty.EASY and playerData.showhints then - -- self:MessageToPlayer( playerData, "your turn was too tight! Allow for more distance to the boat next time.", "LSO" ) - self:MessageToPlayer( playerData, "你转向转得有点小猛! 下次转的时候离航母再远点.", "LSO" ) - end - tooclose = true - end + self:_SetPlayerStep(playerData,nextstep) end - - -- Check limits. - if self:_CheckLimits( X, Z, breakpoint ) or tooclose then - - -- Hint for player about altitude, AoA etc. - self:_PlayerHint( playerData ) - - -- Next step: Late Break or Abeam. - local nextstep - if part == AIRBOSS.PatternStep.EARLYBREAK then - nextstep = AIRBOSS.PatternStep.LATEBREAK - else - nextstep = AIRBOSS.PatternStep.ABEAM - end - - self:_SetPlayerStep( playerData, nextstep ) end -end - ---- Long downwind leg check. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. -function AIRBOSS:_CheckForLongDownwind( playerData ) - - -- Get distances between carrier and player unit (parallel and perpendicular to direction of movement of carrier) - local X, Z = self:_GetDistances( playerData.unit ) - - -- 1.6 NM from carrier is too far. - local limit = UTILS.NMToMeters( -1.6 ) - - -- For the tarawa, other LHA and LHD we give a bit more space. - if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then - limit = UTILS.NMToMeters( -2.0 ) + function AIRBOSS:_BreakEntry(playerData) + local X,Z=self:_GetDistances(playerData.unit) + if self:_CheckAbort(X,Z,self.BreakEntry)then + self:_AbortPattern(playerData,X,Z,self.BreakEntry,true) + return end - - -- Check we are not too far out w.r.t back of the boat. - if X < limit then -- and relhead<45 then - - -- Sound output. - self:RadioTransmission( self.LSORadio, self.LSOCall.LONGINGROOVE ) - self:RadioTransmission( self.LSORadio, self.LSOCall.DEPARTANDREENTER, nil, nil, nil, true ) - - -- Debrief. - self:_AddToDebrief( playerData, "Long in the groove - Pattern Waveoff!" ) - - -- grade="LIG PATTERN WAVE OFF - CUT 1 PT" - playerData.lig = true - playerData.wop = true - - -- Next step: Debriefing. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.DEBRIEF ) - + if self:_CheckLimits(X,Z,self.BreakEntry)then + self:_PlayerHint(playerData) + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.EARLYBREAK) end - -end - ---- Abeam position. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. -function AIRBOSS:_Abeam( playerData ) - - -- Get distances between carrier and player unit (parallel and perpendicular to direction of movement of carrier) - local X, Z = self:_GetDistances( playerData.unit ) - - -- Check abort conditions. - if self:_CheckAbort( X, Z, self.Abeam ) then - self:_AbortPattern( playerData, X, Z, self.Abeam, true ) - return end - - -- Check nest step threshold. - if self:_CheckLimits( X, Z, self.Abeam ) then - - -- Paddles contact. - self:RadioTransmission( self.LSORadio, self.LSOCall.PADDLESCONTACT, nil, nil, nil, true ) - - -- LSO expect spot 5 or 7.5 call - if playerData.actype == AIRBOSS.AircraftCarrier.AV8B and self.carriertype == AIRBOSS.CarrierType.JCARLOS then - self:RadioTransmission( self.LSORadio, self.LSOCall.EXPECTSPOT5, false, 5, nil, true ) - elseif playerData.actype == AIRBOSS.AircraftCarrier.AV8B and self.carriertype == AIRBOSS.CarrierType.CANBERRA then - self:RadioTransmission( self.LSORadio, self.LSOCall.EXPECTSPOT5, false, 5, nil, true ) - elseif playerData.actype == AIRBOSS.AircraftCarrier.AV8B then - self:RadioTransmission( self.LSORadio, self.LSOCall.EXPECTSPOT75, false, 5, nil, true ) - end - - -- Hint for player about altitude, AoA etc. - self:_PlayerHint( playerData, 3 ) - - -- Next step: ninety. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.NINETY ) - + function AIRBOSS:_Break(playerData,part) + local X,Z=self:_GetDistances(playerData.unit) + local breakpoint=self.BreakEarly + if part==AIRBOSS.PatternStep.LATEBREAK then + breakpoint=self.BreakLate end -end - ---- At the Ninety. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. -function AIRBOSS:_Ninety( playerData ) - - -- Get distances between carrier and player unit (parallel and perpendicular to direction of movement of carrier) - local X, Z = self:_GetDistances( playerData.unit ) - - -- Check abort conditions. - if self:_CheckAbort( X, Z, self.Ninety ) then - self:_AbortPattern( playerData, X, Z, self.Ninety, true ) - return + if self:_CheckAbort(X,Z,breakpoint)then + self:_AbortPattern(playerData,X,Z,breakpoint,true) + return end - - -- Get Realtive heading player to carrier. - local relheading = self:_GetRelativeHeading( playerData.unit, false ) - - -- At the 90, i.e. 90 degrees between player heading and BRC of carrier. - if relheading <= 90 then - - -- Hint for player about altitude, AoA etc. - self:_PlayerHint( playerData ) - - -- Next step: wake. - if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then - -- Harrier has no wake stop. It stays port of the boat. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.FINAL ) - else - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.WAKE ) - end - - elseif relheading > 90 and self:_CheckLimits( X, Z, self.Wake ) then - -- Message to player. - -- self:MessageToPlayer( playerData, "you are already at the wake and have not passed the 90. Turn faster next time!", "LSO" ) - self:MessageToPlayer( playerData, "三转五到达航母尾部的时候机头还没转过90度. 下次转得快些!", "LSO" ) - self:RadioTransmission( self.LSORadio, self.LSOCall.DEPARTANDREENTER, nil, nil, nil, true ) - playerData.wop = true - -- Debrief. - self:_AddToDebrief( playerData, "Overshoot at wake - Pattern Waveoff!" ) - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.DEBRIEF ) + local tooclose=false + if part==AIRBOSS.PatternStep.LATEBREAK then + local close=0.8 + if playerData.actype==AIRBOSS.AircraftCarrier.AV8B then + close=0.5 end -end - ---- At the Wake. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. -function AIRBOSS:_Wake( playerData ) - - -- Get distances between carrier and player unit (parallel and perpendicular to direction of movement of carrier) - local X, Z = self:_GetDistances( playerData.unit ) - - -- Check abort conditions. - if self:_CheckAbort( X, Z, self.Wake ) then - self:_AbortPattern( playerData, X, Z, self.Wake, true ) - return + if X<0 and Z0. - if self:_CheckLimits( X, Z, self.Wake ) then - - -- Hint for player about altitude, AoA etc. - self:_PlayerHint( playerData ) - - -- Next step: Final. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.FINAL ) - + tooclose=true end -end - ---- Get groove data. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. --- @return #AIRBOSS.GrooveData Groove data table. -function AIRBOSS:_GetGrooveData( playerData ) - - -- Get distances between carrier and player unit (parallel and perpendicular to direction of movement of carrier). - local X, Z = self:_GetDistances( playerData.unit ) - - -- Stern position at the rundown. - local stern = self:_GetSternCoord() - - -- Distance from rundown to player aircraft. - local rho = stern:Get2DDistance( playerData.unit:GetCoordinate() ) - - -- Aircraft is behind the carrier. - local astern = X < self.carrierparam.sterndist - - -- Correct sign. Negative if passed rundown. - if astern == false then - rho = -rho end - - -- Velocity vector. - local vel = playerData.unit:GetVelocityVec3() - - -- Grade, points, details - local Gg, Gp, Gd = self:_LSOgrade( playerData ) - - -- Gather pilot data. - local groovedata = {} -- #AIRBOSS.GrooveData - groovedata.Step = playerData.step - groovedata.Time = timer.getTime() - groovedata.Rho = rho - groovedata.X = X - groovedata.Z = Z - groovedata.Alt = self:_GetAltCarrier( playerData.unit ) - groovedata.AoA = playerData.unit:GetAoA() - groovedata.GSE = self:_Glideslope( playerData.unit ) - groovedata.LUE = self:_Lineup( playerData.unit, true ) - groovedata.Roll = playerData.unit:GetRoll() - groovedata.Pitch = playerData.unit:GetPitch() - groovedata.Yaw = playerData.unit:GetYaw() - groovedata.Vel = UTILS.VecNorm( vel ) - groovedata.Vy = vel.y - groovedata.Gamma = self:_GetRelativeHeading( playerData.unit, true ) - groovedata.Grade = Gg - groovedata.GradePoints = Gp - groovedata.GradeDetail = Gd - - -- env.info(string.format(", %.6f, %.6f, %.6f, %.6f, %.6f, %.6f, %.6f", groovedata.Time, groovedata.Rho, groovedata.X, groovedata.Alt, groovedata.GSE, groovedata.LUE, groovedata.AoA)) - + if self:_CheckLimits(X,Z,breakpoint)or tooclose then + self:_PlayerHint(playerData) + local nextstep + if part==AIRBOSS.PatternStep.EARLYBREAK then + nextstep=AIRBOSS.PatternStep.LATEBREAK + else + nextstep=AIRBOSS.PatternStep.ABEAM + end + self:_SetPlayerStep(playerData,nextstep) + end + end + function AIRBOSS:_CheckForLongDownwind(playerData) + local X,Z=self:_GetDistances(playerData.unit) + local limit=UTILS.NMToMeters(-1.6) + if self.carriertype==AIRBOSS.CarrierType.INVINCIBLE or self.carriertype==AIRBOSS.CarrierType.HERMES or self.carriertype==AIRBOSS.CarrierType.TARAWA or self.carriertype==AIRBOSS.CarrierType.AMERICA or self.carriertype==AIRBOSS.CarrierType.JCARLOS or self.carriertype==AIRBOSS.CarrierType.CANBERRA then + limit=UTILS.NMToMeters(-2.0) + end + if X90 and self:_CheckLimits(X,Z,self.Wake)then + -- self:MessageToPlayer(playerData,"you are already at the wake and have not passed the 90. Turn faster next time!","LSO") + self:MessageToPlayer(playerData,"你已经到了尾流区域但还没飞过 90°. 下次转弯速度要更快些!","LSO") + self:RadioTransmission(self.LSORadio,self.LSOCall.DEPARTANDREENTER,nil,nil,nil,true) + playerData.wop=true + -- self:_AddToDebrief(playerData,"Overshoot at wake - Pattern Waveoff!") + self:_AddToDebrief(playerData,"在尾流处飞过了 - 复飞!") + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.DEBRIEF) + end + end + function AIRBOSS:_Wake(playerData) + local X,Z=self:_GetDistances(playerData.unit) + if self:_CheckAbort(X,Z,self.Wake)then + self:_AbortPattern(playerData,X,Z,self.Wake,true) + return + end + if self:_CheckLimits(X,Z,self.Wake)then + self:_PlayerHint(playerData) + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.FINAL) + end + end + function AIRBOSS:_GetGrooveData(playerData) + local X,Z=self:_GetDistances(playerData.unit) + local stern=self:_GetSternCoord() + local rho=stern:Get2DDistance(playerData.unit:GetCoordinate()) + local astern=X5. This would mean the player has not turned in correctly! - - -- Groove data. - playerData.groove.X0 = UTILS.DeepCopy( groovedata ) - - -- Set time stamp. Next call in 4 seconds. - playerData.Tlso = timer.getTime() - - -- Next step: X start. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.GROOVE_XX ) end - - -- Groovedata step. - groovedata.Step = playerData.step - -end - ---- In the groove. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. -function AIRBOSS:_Groove( playerData ) - - -- Ranges in the groove. - local RX0 = UTILS.NMToMeters( 1.000 ) -- Everything before X 1.00 = 1852 m - local RXX = UTILS.NMToMeters( 0.750 ) -- Start of groove. 0.75 = 1389 m - local RIM = UTILS.NMToMeters( 0.500 ) -- In the Middle 0.50 = 926 m (middle one third of the glideslope) - local RIC = UTILS.NMToMeters( 0.250 ) -- In Close 0.25 = 463 m (last one third of the glideslope) - local RAR = UTILS.NMToMeters( 0.040 ) -- At the Ramp. 0.04 = 75 m - - -- Groove data. - local groovedata = self:_GetGrooveData( playerData ) - - -- Add data to trapsheet. - table.insert( playerData.trapsheet, groovedata ) - - -- Coords. - local X = groovedata.X - local Z = groovedata.Z - - -- Check abort conditions. - if self:_CheckAbort( groovedata.X, groovedata.Z, self.Groove ) then - self:_AbortPattern( playerData, groovedata.X, groovedata.Z, self.Groove, true ) - return + local groovedata=self:_GetGrooveData(playerData) + table.insert(playerData.trapsheet,groovedata) + local zone=self:_GetZoneGroove() + local inzone=playerData.unit:IsInZone(zone) + if inzone then + self:_PlayerHint(playerData,nil,true) + groovedata.FlyThrough=nil + playerData.groove.X0=UTILS.DeepCopy(groovedata) + playerData.Tlso=timer.getTime() + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.GROOVE_XX) end - - -- Shortcuts. - local rho = groovedata.Rho - local lineupError = groovedata.LUE - local glideslopeError = groovedata.GSE - local AoA = groovedata.AoA - - if rho <= RXX and playerData.step == AIRBOSS.PatternStep.GROOVE_XX and (math.abs( groovedata.Roll ) <= 4.0 or playerData.unit:IsInZone( self:_GetZoneLineup() )) then - - -- Start time in groove - playerData.TIG0 = timer.getTime() - - -- LSO "Call the ball" call. - self:RadioTransmission( self.LSORadio, self.LSOCall.CALLTHEBALL, nil, nil, nil, true ) - playerData.Tlso = timer.getTime() - - -- Pilot "405, Hornet Ball, 3.2". - - -- LSO "Roger ball" call in three seconds. - self:RadioTransmission( self.LSORadio, self.LSOCall.ROGERBALL, false, nil, 2, true ) - - -- Store data. - playerData.groove.XX = UTILS.DeepCopy( groovedata ) - - -- This is a valid approach and player did not miss any important steps in the pattern. - playerData.valid = true - - -- Next step: in the middle. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.GROOVE_IM ) - - elseif rho <= RIM and playerData.step == AIRBOSS.PatternStep.GROOVE_IM then - - -- Store data. - playerData.groove.IM = UTILS.DeepCopy( groovedata ) - - -- Next step: in close. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.GROOVE_IC ) - - elseif rho <= RIC and playerData.step == AIRBOSS.PatternStep.GROOVE_IC then - - -- Store data. - playerData.groove.IC = UTILS.DeepCopy( groovedata ) - - -- Next step: AR at the ramp. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.GROOVE_AR ) - - elseif rho <= RAR and playerData.step == AIRBOSS.PatternStep.GROOVE_AR then - - -- Store data. - playerData.groove.AR = UTILS.DeepCopy( groovedata ) - - -- Next step: in the wires. - if playerData.actype == AIRBOSS.AircraftCarrier.AV8B then - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.GROOVE_AL ) - else - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.GROOVE_IW ) - end - - elseif rho <= RAR and playerData.step == AIRBOSS.PatternStep.GROOVE_AL then - - -- Store data. - playerData.groove.AL = UTILS.DeepCopy( groovedata ) - - -- Get zone abeam LDG spot. - local ZoneALS = self:_GetZoneAbeamLandingSpot() - - -- Get player velocity in km/h. - local vplayer = playerData.unit:GetVelocityKMH() - - -- Get carrier velocity in km/h. - local vcarrier = self.carrier:GetVelocityKMH() - - -- Speed difference. - local dv = math.abs( vplayer - vcarrier ) - - - -- Stable when speed difference < 30 km/h.(16 Kts)Pene Testing - local stable=dv<30 - - -- Check if player is inside the zone. - if playerData.unit:IsInZone( ZoneALS ) and stable then - - -- Radio Transmission "Cleared to land" once the aircraft is inside the zone. - self:RadioTransmission( self.LSORadio, self.LSOCall.CLEAREDTOLAND, nil, nil, nil, true ) - - -- Next step: Level cross. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.GROOVE_LC ) - -- Set Stable Hover - playerData.stable = true - playerData.hover = true - end - - elseif rho <= RAR and playerData.step == AIRBOSS.PatternStep.GROOVE_LC then - - -- Store data. - playerData.groove.LC = UTILS.DeepCopy( groovedata ) - - -- Get zone primary LDG spot. - local ZoneLS = self:_GetZoneLandingSpot() - - -- Get player velocity in km/h. - local vplayer = playerData.unit:GetVelocityKMH() - - -- Get carrier velocity in km/h. - local vcarrier = self.carrier:GetVelocityKMH() - - -- Speed difference. - local dv = math.abs( vplayer - vcarrier ) - - -- Stable when v<15 km/h. - local stable=dv<15 - - -- Radio Transmission "Stabilized" once the aircraft has been cleared to cross and is over the Landing Spot and stable. - if playerData.unit:IsInZone( ZoneLS ) and stable and playerData.stable == true then - self:RadioTransmission( self.LSORadio, self.LSOCall.STABILIZED, nil, nil, nil, false ) - playerData.stable = false - playerData.warning = true - end - - -- We keep it in this step until landed. - + groovedata.Step=playerData.step end - - -------------- - -- Wave Off -- - -------------- - - -- Between IC and AR check for wave off. - if rho >= RAR and rho <= RIC and not playerData.waveoff then - - -- Check if player should wave off. - local waveoff = self:_CheckWaveOff( glideslopeError, lineupError, AoA, playerData ) - - -- Let's see.. - if waveoff then - - -- Debug info. - self:T3( self.lid .. string.format( "Waveoff distance rho=%.1f m", rho ) ) - - -- LSO Wave off! - self:RadioTransmission( self.LSORadio, self.LSOCall.WAVEOFF, nil, nil, nil, true ) - playerData.Tlso = timer.getTime() - - -- Player was waved off! - playerData.waveoff = true - - -- Nothing else necessary. - return - end - - end - - -- Long V/STOL groove time Wave Off over 75 seconds to IC - TOPGUN level Only. --pene testing (WIP)--- Need to think more about this. - - --if rho>=RAR and rho<=RIC and not playerData.waveoff and playerData.difficulty==AIRBOSS.Difficulty.HARD and playerData.actype== AIRBOSS.AircraftCarrier.AV8B then - -- Get groove time - --local vSlow=groovedata.time - -- If too slow wave off. - --if vSlow >75 then - - -- LSO Wave off! - --self:RadioTransmission(self.LSORadio, self.LSOCall.WAVEOFF, nil, nil, nil, true) - --playerData.Tlso=timer.getTime() - - -- Player was waved Off - --playerData.waveoff=true - --return - --end - --end - - -- Groovedata step. - groovedata.Step = playerData.step - - ----------------- - -- Groove Data -- - ----------------- - - -- Check if we are beween 3/4 NM and end of ship. - if rho >= RAR and rho < RX0 and playerData.waveoff == false then - - -- Get groove step short hand of the previous step. - local gs = self:_GS( playerData.step, -1 ) - - -- Get current groove data. - local gd = playerData.groove[gs] -- #AIRBOSS.GrooveData - - if gd then - self:T3( gd ) - - -- Distance in NM. - local d = UTILS.MetersToNM( rho ) - - -- Drift on lineup. - if rho >= RAR and rho <= RIM then - if gd.LUE > 0.22 and lineupError < -0.22 then - env.info " Drift Right across centre ==> DR-" - gd.Drift = " DR" - self:T( self.lid .. string.format( "Got Drift Right across centre step %s, d=%.3f: Max LUE=%.3f, lower LUE=%.3f", gs, d, gd.LUE, lineupError ) ) - elseif gd.LUE < -0.22 and lineupError > 0.22 then - env.info " Drift Left ==> DL-" - gd.Drift = " DL" - self:T( self.lid .. string.format( "Got Drift Left across centre at step %s, d=%.3f: Min LUE=%.3f, lower LUE=%.3f", gs, d, gd.LUE, lineupError ) ) - elseif gd.LUE > 0.13 and lineupError < -0.14 then - env.info " Little Drift Right across centre ==> (DR-)" - gd.Drift = " (DR)" - self:T( self.lid .. string.format( "Got Little Drift Right across centre at step %s, d=%.3f: Max LUE=%.3f, lower LUE=%.3f", gs, d, gd.LUE, lineupError ) ) - elseif gd.LUE < -0.13 and lineupError > 0.14 then - env.info " Little Drift Left across centre ==> (DL-)" - gd.Drift = " (DL)" - self:E( self.lid .. string.format( "Got Little Drift Left across centre at step %s, d=%.3f: Min LUE=%.3f, lower LUE=%.3f", gs, d, gd.LUE, lineupError ) ) - end - end - - -- Update max deviation of line up error. - if math.abs( lineupError ) > math.abs( gd.LUE ) then - self:T( self.lid .. string.format( "Got bigger LUE at step %s, d=%.3f: LUE %.3f>%.3f", gs, d, lineupError, gd.LUE ) ) - gd.LUE = lineupError - end - - -- Fly through good window of glideslope. - if gd.GSE > 0.4 and glideslopeError < -0.3 then - -- Fly through down ==> "\" - gd.FlyThrough = "\\" - self:T( self.lid .. string.format( "Got Fly through DOWN at step %s, d=%.3f: Max GSE=%.3f, lower GSE=%.3f", gs, d, gd.GSE, glideslopeError ) ) - elseif gd.GSE < -0.3 and glideslopeError > 0.4 then - -- Fly through up ==> "/" - gd.FlyThrough = "/" - self:E( self.lid .. string.format( "Got Fly through UP at step %s, d=%.3f: Min GSE=%.3f, lower GSE=%.3f", gs, d, gd.GSE, glideslopeError ) ) - end - - -- Update max deviation of glideslope error. - if math.abs( glideslopeError ) > math.abs( gd.GSE ) then - self:T( self.lid .. string.format( "Got bigger GSE at step %s, d=%.3f: GSE |%.3f|>|%.3f|", gs, d, glideslopeError, gd.GSE ) ) - gd.GSE = glideslopeError - end - - -- Get aircraft AoA parameters. - local aircraftaoa = self:_GetAircraftAoA( playerData ) - - -- On Speed AoA. - local aoaopt = aircraftaoa.OnSpeed - - -- Compare AoAs wrt on speed AoA and update max deviation. - if math.abs( AoA - aoaopt ) > math.abs( gd.AoA - aoaopt ) then - self:T( self.lid .. string.format( "Got bigger AoA error at step %s, d=%.3f: AoA %.3f>%.3f.", gs, d, AoA, gd.AoA ) ) - gd.AoA = AoA - end - - -- local gs2=self:_GS(groovedata.Step, -1) - -- env.info(string.format("groovestep %s %s d=%.3f NM: GSE=%.3f %.3f, LUE=%.3f %.3f, AoA=%.3f %.3f", gs, gs2, d, groovedata.GSE, gd.GSE, groovedata.LUE, gd.LUE, groovedata.AoA, gd.AoA)) - - end - - --------------- - -- LSO Calls -- - --------------- - - -- Time since last LSO call. - local deltaT = timer.getTime() - playerData.Tlso - - -- Wait until player passed the 0.75 NM distance. - local _advice = true - if playerData.TIG0 == nil and playerData.difficulty ~= AIRBOSS.Difficulty.EASY then -- rho>RXX - _advice = false - end - - -- LSO call if necessary. - if deltaT >= self.LSOdT and _advice then - self:_LSOadvice( playerData, glideslopeError, lineupError ) - end - + function AIRBOSS:_Groove(playerData) + local RX0=UTILS.NMToMeters(1.000) + local RXX=UTILS.NMToMeters(0.750) + local RIM=UTILS.NMToMeters(0.500) + local RIC=UTILS.NMToMeters(0.250) + local RAR=UTILS.NMToMeters(0.040) + local groovedata=self:_GetGrooveData(playerData) + table.insert(playerData.trapsheet,groovedata) + local X=groovedata.X + local Z=groovedata.Z + if self:_CheckAbort(groovedata.X,groovedata.Z,self.Groove)then + self:_AbortPattern(playerData,groovedata.X,groovedata.Z,self.Groove,true) + return end - - ---------------------------------------------------------- - --- Some time here the landing event MIGHT be triggered -- - ---------------------------------------------------------- - - -- Player infront of the carrier X>~77 m. - if X > self.carrierparam.totlength + self.carrierparam.sterndist then - - if playerData.waveoff then - - if playerData.landed then - -- This should not happen because landing event was triggered. - -- self:_AddToDebrief( playerData, "You were waved off but landed anyway. Airboss wants to talk to you!" ) - self:_AddToDebrief( playerData, "喊你复飞但是你还是落了. Airboss 喊你喝茶!" ) - else - -- self:_AddToDebrief( playerData, "You were waved off." ) - self:_AddToDebrief( playerData, "你已执行复飞." ) - end - - elseif playerData.boltered then - - -- This should not happen because landing event was triggered. - -- self:_AddToDebrief( playerData, "You boltered." ) - self:_AddToDebrief( playerData, "你脱钩了." ) - - else - - -- This should not happen. - self:T( "Player was not waved off but flew past the carrier without landing ==> Own wave off!" ) - - -- We count this as OWO. - -- self:_AddToDebrief( playerData, "Own waveoff." ) - self:_AddToDebrief( playerData, "自主执行复飞." ) - - -- Set Owo - playerData.owo = true - - end - - -- Next step: debrief. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.DEBRIEF ) - + local rho=groovedata.Rho + local lineupError=groovedata.LUE + local glideslopeError=groovedata.GSE + local AoA=groovedata.AoA + if rho<=RXX and playerData.step==AIRBOSS.PatternStep.GROOVE_XX and(math.abs(groovedata.Roll)<=4.0 and playerData.unit:IsInZone(self:_GetZoneLineup()))then + playerData.TIG0=timer.getTime() + self:RadioTransmission(self.LSORadio,self.LSOCall.CALLTHEBALL,nil,nil,nil,true) + playerData.Tlso=timer.getTime() + self:RadioTransmission(self.LSORadio,self.LSOCall.ROGERBALL,false,nil,2,true) + playerData.groove.XX=UTILS.DeepCopy(groovedata) + playerData.valid=true + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.GROOVE_IM) + elseif rho<=RIM and playerData.step==AIRBOSS.PatternStep.GROOVE_IM then + playerData.groove.IM=UTILS.DeepCopy(groovedata) + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.GROOVE_IC) + elseif rho<=RIC and playerData.step==AIRBOSS.PatternStep.GROOVE_IC then + playerData.groove.IC=UTILS.DeepCopy(groovedata) + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.GROOVE_AR) + elseif rho<=RAR and playerData.step==AIRBOSS.PatternStep.GROOVE_AR then + playerData.groove.AR=UTILS.DeepCopy(groovedata) + if playerData.actype==AIRBOSS.AircraftCarrier.AV8B then + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.GROOVE_AL) + else + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.GROOVE_IW) end - -end - ---- LSO check if player needs to wave off. --- Wave off conditions are: --- --- * Glideslope error <1.2 or >1.8 degrees. --- * |Line up error| > 3 degrees. --- * AoA check but only for TOPGUN graduates. --- @param #AIRBOSS self --- @param #number glideslopeError Glideslope error in degrees. --- @param #number lineupError Line up error in degrees. --- @param #number AoA Angle of attack of player aircraft. --- @param #AIRBOSS.PlayerData playerData Player data. --- @return #boolean If true, player should wave off! -function AIRBOSS:_CheckWaveOff( glideslopeError, lineupError, AoA, playerData ) - - -- Assume we're all good. - local waveoff = false - - -- Parameters - local glMax = 1.8 - local glMin = -1.2 - local luAbs = 3.0 - - -- For the harrier, we allow a bit more room. - if playerData.actype == AIRBOSS.AircraftCarrier.AV8B then - glMax = 2.6 - glMin = -2.2 -- Testing, @Engines may be just dragging it in on Hermes, or the carrier parameters need adjusting. - luAbs = 4.1 -- Testing Pene. - + elseif rho<=RAR and playerData.step==AIRBOSS.PatternStep.GROOVE_AL then + playerData.groove.AL=UTILS.DeepCopy(groovedata) + local ZoneALS=self:_GetZoneAbeamLandingSpot() + local vplayer=playerData.unit:GetVelocityKMH() + local vcarrier=self.carrier:GetVelocityKMH() + local dv=math.abs(vplayer-vcarrier) + local stable=dv<30 + if playerData.unit:IsInZone(ZoneALS)and stable then + self:RadioTransmission(self.LSORadio,self.LSOCall.CLEAREDTOLAND,nil,nil,nil,true) + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.GROOVE_LC) + playerData.stable=true + playerData.hover=true end - - -- Too high or too low? - if glideslopeError > glMax then - -- local text = string.format( "\n- Waveoff due to glideslope error %.2f > %.1f degrees!", glideslopeError, glMax ) - local text = string.format( "\n- 复飞 - 由于下滑道 偏离 %.2f > %.1f 度!", glideslopeError, glMax ) - self:T( self.lid .. string.format( "%s: %s", playerData.name, text ) ) - self:_AddToDebrief( playerData, text ) - waveoff = true - elseif glideslopeError < glMin then - -- local text = string.format( "\n- Waveoff due to glideslope error %.2f < %.1f degrees!", glideslopeError, glMin ) - local text = string.format( "\n- 复飞 - 由于下滑道 偏离 %.2f < %.1f 度!", glideslopeError, glMin ) - self:T( self.lid .. string.format( "%s: %s", playerData.name, text ) ) - self:_AddToDebrief( playerData, text ) - waveoff = true + elseif rho<=RAR and playerData.step==AIRBOSS.PatternStep.GROOVE_LC then + playerData.groove.LC=UTILS.DeepCopy(groovedata) + local ZoneLS=self:_GetZoneLandingSpot() + local vplayer=playerData.unit:GetVelocityKMH() + local vcarrier=self.carrier:GetVelocityKMH() + local dv=math.abs(vplayer-vcarrier) + local stable=dv<15 + if playerData.unit:IsInZone(ZoneLS)and stable and playerData.stable==true then + self:RadioTransmission(self.LSORadio,self.LSOCall.STABILIZED,nil,nil,nil,false) + playerData.stable=false + playerData.warning=true end - - -- Too far from centerline? - if math.abs( lineupError ) > luAbs then - -- local text = string.format( "\n- Waveoff due to line up error |%.1f| > %.1f degrees!", lineupError, luAbs ) - local text = string.format( "\n- 复飞 - 由于没有对正甲板 偏离 |%.1f| > %.1f 度!", lineupError, luAbs ) - self:T( self.lid .. string.format( "%s: %s", playerData.name, text ) ) - self:_AddToDebrief( playerData, text ) - waveoff = true end - - -- Too slow or too fast? Only for pros. - - if playerData.difficulty == AIRBOSS.Difficulty.HARD and playerData.actype ~= AIRBOSS.AircraftCarrier.AV8B then - -- Get aircraft specific AoA values. Not for AV-8B due to transition to Stable Hover. - local aoaac = self:_GetAircraftAoA( playerData ) - -- Check too slow or too fast. - if AoA < aoaac.FAST then - -- local text = string.format( "\n- Waveoff due to AoA %.1f < %.1f!", AoA, aoaac.FAST ) - local text = string.format( "\n- 复飞 - 由于 AoA %.1f < %.1f!", AoA, aoaac.FAST ) - self:T( self.lid .. string.format( "%s: %s", playerData.name, text ) ) - self:_AddToDebrief( playerData, text ) - waveoff = true - elseif AoA > aoaac.SLOW then - -- local text = string.format( "\n- Waveoff due to AoA %.1f > %.1f!", AoA, aoaac.SLOW ) - local text = string.format( "\n- 复飞 - 由于 AoA %.1f > %.1f!", AoA, aoaac.SLOW ) - self:T( self.lid .. string.format( "%s: %s", playerData.name, text ) ) - self:_AddToDebrief( playerData, text ) - waveoff = true - - end + if rho>=RAR and rho<=RIC and not playerData.waveoff then + local waveoff=self:_CheckWaveOff(glideslopeError,lineupError,AoA,playerData) + if waveoff then + self:T3(self.lid..string.format("Waveoff distance rho=%.1f m",rho)) + self:RadioTransmission(self.LSORadio,self.LSOCall.WAVEOFF,nil,nil,nil,true) + playerData.Tlso=timer.getTime() + playerData.waveoff=true + return + end + end + groovedata.Step=playerData.step + if rho>=RAR and rho=RAR and rho<=RIM then + if gd.LUE>0.22 and lineupError<-0.22 then + env.info" Drift Right across centre ==> DR-" + gd.Drift=" DR" + self:T(self.lid..string.format("Got Drift Right across centre step %s, d=%.3f: Max LUE=%.3f, lower LUE=%.3f",gs,d,gd.LUE,lineupError)) + elseif gd.LUE<-0.22 and lineupError>0.22 then + env.info" Drift Left ==> DL-" + gd.Drift=" DL" + self:T(self.lid..string.format("Got Drift Left across centre at step %s, d=%.3f: Min LUE=%.3f, lower LUE=%.3f",gs,d,gd.LUE,lineupError)) + elseif gd.LUE>0.13 and lineupError<-0.14 then + env.info" Little Drift Right across centre ==> (DR-)" + gd.Drift=" (DR)" + self:T(self.lid..string.format("Got Little Drift Right across centre at step %s, d=%.3f: Max LUE=%.3f, lower LUE=%.3f",gs,d,gd.LUE,lineupError)) + elseif gd.LUE<-0.13 and lineupError>0.14 then + env.info" Little Drift Left across centre ==> (DL-)" + gd.Drift=" (DL)" + self:E(self.lid..string.format("Got Little Drift Left across centre at step %s, d=%.3f: Min LUE=%.3f, lower LUE=%.3f",gs,d,gd.LUE,lineupError)) + end + end + if math.abs(lineupError)>math.abs(gd.LUE)then + self:T(self.lid..string.format("Got bigger LUE at step %s, d=%.3f: LUE %.3f>%.3f",gs,d,lineupError,gd.LUE)) + gd.LUE=lineupError + end + if gd.GSE>0.4 and glideslopeError<-0.3 then + gd.FlyThrough="\\" + self:T(self.lid..string.format("Got Fly through DOWN at step %s, d=%.3f: Max GSE=%.3f, lower GSE=%.3f",gs,d,gd.GSE,glideslopeError)) + elseif gd.GSE<-0.3 and glideslopeError>0.4 then + gd.FlyThrough="/" + self:E(self.lid..string.format("Got Fly through UP at step %s, d=%.3f: Min GSE=%.3f, lower GSE=%.3f",gs,d,gd.GSE,glideslopeError)) + end + if math.abs(glideslopeError)>math.abs(gd.GSE)then + self:T(self.lid..string.format("Got bigger GSE at step %s, d=%.3f: GSE |%.3f|>|%.3f|",gs,d,glideslopeError,gd.GSE)) + gd.GSE=glideslopeError + end + local aircraftaoa=self:_GetAircraftAoA(playerData) + local aoaopt=aircraftaoa.OnSpeed + if math.abs(AoA-aoaopt)>math.abs(gd.AoA-aoaopt)then + self:T(self.lid..string.format("Got bigger AoA error at step %s, d=%.3f: AoA %.3f>%.3f.",gs,d,AoA,gd.AoA)) + gd.AoA=AoA + end + end + local deltaT=timer.getTime()-playerData.Tlso + local _advice=true + if playerData.TIG0==nil and playerData.difficulty~=AIRBOSS.Difficulty.EASY then + _advice=false + end + if deltaT>=self.LSOdT and _advice then + self:_LSOadvice(playerData,glideslopeError,lineupError) + end + end + if X>self.carrierparam.totlength+self.carrierparam.sterndist then + if playerData.waveoff then + if playerData.landed then + self:_AddToDebrief(playerData,"You were waved off but landed anyway. Airboss wants to talk to you!") + else + self:_AddToDebrief(playerData,"You were waved off.") + end + elseif playerData.boltered then + self:_AddToDebrief(playerData,"You boltered.") + else + self:T("Player was not waved off but flew past the carrier without landing ==> Own wave off!") + self:_AddToDebrief(playerData,"Own waveoff.") + playerData.owo=true + end + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.DEBRIEF) + end + end + function AIRBOSS:_CheckWaveOff(glideslopeError,lineupError,AoA,playerData) + local waveoff=false + local glMax=1.8 + local glMin=-1.2 + local luAbs=3.0 + if playerData.actype==AIRBOSS.AircraftCarrier.AV8B then + glMax=2.6 + glMin=-2.2 + luAbs=4.1 + end + if glideslopeError>glMax then + local text=string.format("\n- Waveoff due to glideslope error %.2f > %.1f degrees!",glideslopeError,glMax) + self:T(self.lid..string.format("%s: %s",playerData.name,text)) + self:_AddToDebrief(playerData,text) + waveoff=true + elseif glideslopeErrorluAbs then + local text=string.format("\n- Waveoff due to line up error |%.1f| > %.1f degrees!",lineupError,luAbs) + self:T(self.lid..string.format("%s: %s",playerData.name,text)) + self:_AddToDebrief(playerData,text) + waveoff=true + end + if playerData.difficulty==AIRBOSS.Difficulty.HARD and playerData.actype~=AIRBOSS.AircraftCarrier.AV8B then + local aoaac=self:_GetAircraftAoA(playerData) + if AoAaoaac.SLOW then + local text=string.format("\n- Waveoff due to AoA %.1f > %.1f!",AoA,aoaac.SLOW) + self:T(self.lid..string.format("%s: %s",playerData.name,text)) + self:_AddToDebrief(playerData,text) + waveoff=true + end end - return waveoff -end - ---- Check if other aircraft are currently on the landing runway. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. --- @return boolean If true, we have a foul deck. -function AIRBOSS:_CheckFoulDeck( playerData ) - - -- Assume no check necessary. - local check = false - - -- CVN: Check at IM and IC. - if playerData.step == AIRBOSS.PatternStep.GROOVE_IM or playerData.step == AIRBOSS.PatternStep.GROOVE_IC then - check = true end - - -- AV-8B check until - if playerData.actype == AIRBOSS.AircraftCarrier.AV8B then - if playerData.step == AIRBOSS.PatternStep.GROOVE_AR or playerData.step == AIRBOSS.PatternStep.GROOVE_AL then - check = true - end + function AIRBOSS:_CheckFoulDeck(playerData) + local check=false + if playerData.step==AIRBOSS.PatternStep.GROOVE_IM or playerData.step==AIRBOSS.PatternStep.GROOVE_IC then + check=true end - - -- Check if player was already waved off. Should not be necessary as player step is set to debrief afterwards! - if playerData.wofd == true or check == false then - -- Player was already waved off. - return + if playerData.actype==AIRBOSS.AircraftCarrier.AV8B then + if playerData.step==AIRBOSS.PatternStep.GROOVE_AR or playerData.step==AIRBOSS.PatternStep.GROOVE_AL then + check=true end - - -- Landing runway zone. - local runway = self:_GetZoneRunwayBox() - - -- For AB-8B we just check the primary landing spot. - if playerData.actype == AIRBOSS.AircraftCarrier.AV8B then - runway = self:_GetZoneLandingSpot() end - - -- Scan radius. - local R = 250 - - -- Debug info. - self:T( self.lid .. string.format( "Foul deck check: Scanning Carrier Runway Area. Radius=%.1f m.", R ) ) - - -- Scan units in carrier zone. - local _, _, _, unitscan = self:GetCoordinate():ScanObjects( R, true, false, false ) - - -- Loop over all scanned units and check if they are on the runway. - local fouldeck = false - local foulunit = nil -- Wrapper.Unit#UNIT - for _, _unit in pairs( unitscan ) do - local unit = _unit -- Wrapper.Unit#UNIT - - -- Check if unit is in zone. - local inzone = unit:IsInZone( runway ) - - -- Check if aircraft and in air. - local isaircraft = unit:IsAir() - local isairborn = unit:InAir() - - if inzone and isaircraft and not isairborn then - local text = string.format( "Unit %s on landing runway ==> Foul deck!", unit:GetName() ) - self:T( self.lid .. text ) - MESSAGE:New( text, 10 ):ToAllIf( self.Debug ) - if self.Debug then - runway:FlareZone( FLARECOLOR.Red, 30 ) - end - fouldeck = true - foulunit = unit - end + if playerData.wofd==true or check==false then + return + end + local runway=self:_GetZoneRunwayBox() + if playerData.actype==AIRBOSS.AircraftCarrier.AV8B then + runway=self:_GetZoneLandingSpot() + end + local R=250 + self:T(self.lid..string.format("Foul deck check: Scanning Carrier Runway Area. Radius=%.1f m.",R)) + local _,_,_,unitscan=self:GetCoordinate():ScanObjects(R,true,false,false) + local fouldeck=false + local foulunit=nil + for _,_unit in pairs(unitscan)do + local unit=_unit + local inzone=unit:IsInZone(runway) + local isaircraft=unit:IsAir() + local isairborn=unit:InAir() + if inzone and isaircraft and not isairborn then + local text=string.format("载具单位 %s 在降落甲板上 ==> 甲板被占用!",unit:GetName()) + self:T(self.lid..text) + MESSAGE:New(text,10):ToAllIf(self.Debug) + if self.Debug then + runway:FlareZone(FLARECOLOR.Red,30) + end + fouldeck=true + foulunit=unit + end end - - -- Add to debrief and if playerData and fouldeck then - - -- Debrief text. - -- local text = string.format( "Foul deck waveoff due to aircraft %s!", foulunit:GetName() ) - local text = string.format( "复飞 - 由于甲板被航空器 %s 阻塞!", foulunit:GetName() ) - self:T( self.lid .. string.format( "%s: %s", playerData.name, text ) ) - self:_AddToDebrief( playerData, text ) - - -- Foul deck + wave off radio message. - self:RadioTransmission( self.LSORadio, self.LSOCall.FOULDECK, false, 1 ) - self:RadioTransmission( self.LSORadio, self.LSOCall.WAVEOFF, false, 1.2, nil, true ) - - -- Player hint for flight students. - if playerData.showhints then - -- local text = string.format( "overfly landing area and enter bolter pattern." ) - local text = string.format( "飞跃降落区域并进入 脱钩[bolter]程序." ) - self:MessageToPlayer( playerData, text, "LSO", nil, nil, false, 3 ) - end - - -- Set player parameters for foul deck. - playerData.wofd = true - - -- Debrief. - playerData.step = AIRBOSS.PatternStep.DEBRIEF - playerData.warning = nil - - -- Pass would be invalid if the player lands. - playerData.valid = false - - -- Send a message to the player that blocks the runway. - if foulunit then - local foulflight = self:_GetFlightFromGroupInQueue( foulunit:GetGroup(), self.flights ) - if foulflight and not foulflight.ai then - -- self:MessageToPlayer( foulflight, "move your ass from my runway. NOW!", "AIRBOSS" ) - self:MessageToPlayer( foulflight, "麻溜从降落区域滚出克!", "AIRBOSS" ) - end - end + -- local text=string.format("Foul deck waveoff due to aircraft %s!",foulunit:GetName()) + local text=string.format("因为 %s 占用甲板导致复飞!",foulunit:GetName()) + self:T(self.lid..string.format("%s: %s",playerData.name,text)) + self:_AddToDebrief(playerData,text) + self:RadioTransmission(self.LSORadio,self.LSOCall.FOULDECK,false,1) + self:RadioTransmission(self.LSORadio,self.LSOCall.WAVEOFF,false,1.2,nil,true) + if playerData.showhints then + -- local text=string.format("overfly landing area and enter bolter pattern.") + local text=string.format("飞越着陆区,进入复飞航线.") + self:MessageToPlayer(playerData,text,"LSO",nil,nil,false,3) + end + playerData.wofd=true + playerData.step=AIRBOSS.PatternStep.DEBRIEF + playerData.warning=nil + playerData.valid=false + if foulunit then + local foulflight=self:_GetFlightFromGroupInQueue(foulunit:GetGroup(),self.flights) + if foulflight and not foulflight.ai then + -- self:MessageToPlayer(foulflight,"move your ass from my runway. NOW!","AIRBOSS") + self:MessageToPlayer(foulflight,"赶紧离开降落区域. 搞快点!","航空长") + end + end end - return fouldeck -end - ---- Get "stern" coordinate. --- @param #AIRBOSS self --- @return Core.Point#COORDINATE Coordinate at the rundown of the carrier. -function AIRBOSS:_GetSternCoord() - - -- Heading of carrier (true). - local hdg = self.carrier:GetHeading() - - -- Final bearing (true). + end + function AIRBOSS:_GetSternCoord() + local hdg=self.carrier:GetHeading() local FB=self:GetFinalBearing() local case=self.case - - -- Stern coordinate (sterndist<0). Also translate 10 meters starboard wrt Final bearing. - self.sterncoord:UpdateFromCoordinate( self:GetCoordinate() ) - -- local stern=self:GetCoordinate() - - -- Stern coordinate (sterndist<0). --Pene testing Case III + self.sterncoord:UpdateFromCoordinate(self:GetCoordinate()) if self.carriertype==AIRBOSS.CarrierType.INVINCIBLE or self.carriertype==AIRBOSS.CarrierType.HERMES or self.carriertype==AIRBOSS.CarrierType.TARAWA or self.carriertype==AIRBOSS.CarrierType.AMERICA or self.carriertype==AIRBOSS.CarrierType.JCARLOS or self.carriertype==AIRBOSS.CarrierType.CANBERRA then - if case==3 then - -- CASE III V/STOL translation Due over deck approach if needed. - self.sterncoord:Translate(self.carrierparam.sterndist, hdg, true, true):Translate(8, FB-90, true, true) - elseif case==2 or case==1 then - -- V/Stol: Translate 8 meters port. - self.sterncoord:Translate(self.carrierparam.sterndist, hdg, true, true):Translate(8, FB-90, true, true) + if case==3 then + self.sterncoord:Translate(self.carrierparam.sterndist,hdg,true,true):Translate(8,FB-90,true,true) + elseif case==2 or case==1 then + self.sterncoord:Translate(self.carrierparam.sterndist,hdg,true,true):Translate(8,FB-90,true,true) end elseif self.carriertype==AIRBOSS.CarrierType.STENNIS then - -- Stennis: translate 7 meters starboard wrt Final bearing. - self.sterncoord:Translate( self.carrierparam.sterndist, hdg, true, true ):Translate( 7, FB + 90, true, true ) - elseif self.carriertype == AIRBOSS.CarrierType.FORRESTAL then - -- Forrestal - self.sterncoord:Translate( self.carrierparam.sterndist, hdg, true, true ):Translate( 7.5, FB + 90, true, true ) + self.sterncoord:Translate(self.carrierparam.sterndist,hdg,true,true):Translate(7,FB+90,true,true) + elseif self.carriertype==AIRBOSS.CarrierType.FORRESTAL then + self.sterncoord:Translate(self.carrierparam.sterndist,hdg,true,true):Translate(7.5,FB+90,true,true) else - -- Nimitz SC: translate 8 meters starboard wrt Final bearing. - self.sterncoord:Translate( self.carrierparam.sterndist, hdg, true, true ):Translate( 9.5, FB + 90, true, true ) + self.sterncoord:Translate(self.carrierparam.sterndist,hdg,true,true):Translate(9.5,FB+90,true,true) end - - -- Set altitude. - self.sterncoord:SetAltitude( self.carrierparam.deckheight ) - + self.sterncoord:SetAltitude(self.carrierparam.deckheight) return self.sterncoord -end - ---- Get wire from draw argument. --- @param #AIRBOSS self --- @param Core.Point#COORDINATE Lcoord Landing position. --- @return #number Trapped wire (1-4) or 99 if no wire was trapped. -function AIRBOSS:_GetWireFromDrawArg() - + end + function AIRBOSS:_GetWireFromDrawArg() local wireArgs={} wireArgs[1]=141 wireArgs[2]=142 wireArgs[3]=143 wireArgs[4]=144 - - for wire,drawArg in pairs(wireArgs) do - local value=self.carrier:GetDrawArgumentValue(drawArg) - if math.abs(value)>0.001 then - return wire - end - end - - return 99 -end - ---- Get wire from landing position. --- @param #AIRBOSS self --- @param Core.Point#COORDINATE Lcoord Landing position. --- @param #number dc Distance correction. Shift the landing coord back if dc>0 and forward if dc<0. --- @return #number Trapped wire (1-4) or 99 if no wire was trapped. -function AIRBOSS:_GetWire( Lcoord, dc ) - - -- Final bearing (true). - local FB = self:GetFinalBearing() - - -- Stern coordinate (sterndist<0). Also translate 10 meters starboard wrt Final bearing. - local Scoord = self:_GetSternCoord() - - -- Distance to landing coord. - local Ldist = Lcoord:Get2DDistance( Scoord ) - - -- For human (not AI) the lading event is delayed unfortunately. Therefore, we need another correction factor. - dc = dc or 65 - - -- Corrected landing distance wrt to stern. Landing distance needs to be reduced due to delayed landing event for human players. - local d = Ldist - dc - - -- Multiplayer wire correction. - if self.mpWireCorrection then - d = d - self.mpWireCorrection - end - - -- Shift wires from stern to their correct position. - local w1 = self.carrierparam.wire1 - local w2 = self.carrierparam.wire2 - local w3 = self.carrierparam.wire3 - local w4 = self.carrierparam.wire4 - - -- Which wire was caught? - local wire - if d < w1 then -- 46 - wire = 1 - elseif d < w2 then -- 46+12 - wire = 2 - elseif d < w3 then -- 46+24 - wire = 3 - elseif d < w4 then -- 46+35 - wire = 4 - else - wire = 99 - end - - if self.Debug and false then - - -- Wire position coordinates. - local wp1 = Scoord:Translate( w1, FB ) - local wp2 = Scoord:Translate( w2, FB ) - local wp3 = Scoord:Translate( w3, FB ) - local wp4 = Scoord:Translate( w4, FB ) - - -- Debug marks. - wp1:MarkToAll( "Wire 1" ) - wp2:MarkToAll( "Wire 2" ) - wp3:MarkToAll( "Wire 3" ) - wp4:MarkToAll( "Wire 4" ) - - -- Mark stern. - Scoord:MarkToAll( "Stern" ) - - -- Mark at landing position. - Lcoord:MarkToAll( string.format( "Landing Point wire=%s", wire ) ) - - -- Smoke landing position. - Lcoord:SmokeGreen() - - -- Corrected landing position. - local Dcoord = Lcoord:Translate( -dc, FB ) - - -- Smoke corrected landing pos red. - Dcoord:SmokeRed() - - end - - -- Debug output. - self:T( string.format( "GetWire: L=%.1f, L-dc=%.1f ==> wire=%d (dc=%.1f)", Ldist, Ldist - dc, wire, dc ) ) - + for wire,drawArg in pairs(wireArgs)do + local value=self.carrier:GetDrawArgumentValue(drawArg) + if math.abs(value)>0.001 then return wire -end - ---- Trapped? Check if in air or not after landing event. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. -function AIRBOSS:_Trapped( playerData ) - - if playerData.unit:InAir() == false then - -- Seems we have successfully landed. - - -- Lets see if we can get a good wire. - local unit = playerData.unit - - -- Coordinate of player aircraft. - local coord = unit:GetCoordinate() - - -- Get velocity in km/h. We need to substrackt the carrier velocity. - local v = unit:GetVelocityKMH() - self.carrier:GetVelocityKMH() - - -- Stern coordinate. - local stern = self:_GetSternCoord() - - -- Distance to stern pos. - local s = stern:Get2DDistance( coord ) - - -- Get current wire (estimate). This now based on the position where the player comes to a standstill which should reflect the trapped wire better. - local dcorr = 100 - if playerData.actype == AIRBOSS.AircraftCarrier.HORNET - or playerData.actype == AIRBOSS.AircraftCarrier.RHINOE - or playerData.actype == AIRBOSS.AircraftCarrier.RHINOF - or playerData.actype == AIRBOSS.AircraftCarrier.GROWLER then - dcorr = 100 - elseif playerData.actype == AIRBOSS.AircraftCarrier.F14A or playerData.actype == AIRBOSS.AircraftCarrier.F14B then - -- TODO: Check Tomcat. - dcorr = 100 - elseif playerData.actype == AIRBOSS.AircraftCarrier.A4EC then - -- A-4E gets slowed down much faster the the F/A-18C! - dcorr = 56 - elseif playerData.actype == AIRBOSS.AircraftCarrier.T45C then - -- T-45 also gets slowed down much faster the the F/A-18C. - dcorr = 56 - end - - -- Get wire. - local wire = self:_GetWire( coord, dcorr ) - - -- Debug. - local text = string.format( "Player %s _Trapped: v=%.1f km/h, s-dcorr=%.1f m ==> wire=%d (dcorr=%d)", playerData.name, v, s - dcorr, wire, dcorr ) - self:T( self.lid .. text ) - - -- Call this function again until v < threshold. Player comes to a standstill ==> Get wire! - if v > 5 then - - -- Check if we passed all wires. - if wire > 4 and v > 10 and not playerData.warning then - -- Looks like we missed the wires ==> Bolter! - self:RadioTransmission( self.LSORadio, self.LSOCall.BOLTER, nil, nil, nil, true ) - playerData.warning = true - end - - -- Call function again and check if converged or back in air. - -- SCHEDULER:New(nil, self._Trapped, {self, playerData}, 0.1) - self:ScheduleOnce( 0.1, self._Trapped, self, playerData ) - return - end - - ---------------------------------------- - --- Form this point on we have converged - ---------------------------------------- - - -- Put some smoke and a mark. - if self.Debug then - coord:SmokeBlue() - coord:MarkToAll( text ) - stern:MarkToAll( "Stern" ) - end - - -- Set player wire. - playerData.wire = wire - - -- Message to player. - -- local text = string.format( "Trapped %d-wire.", wire ) - local text = string.format( "钩住 %d-wire.", wire ) - if wire == 3 then - -- text = text .. " Well done!" - local threeWireText = { - [1] = '第三根!不错不错.', - [2] = '非常好!', - [3] = '第三根!大师级别的降落水平.', - [4] = '甭看飞咋样,咱钩的第三根.', - } - text = text .. threeWireText[math.random(1,#threeWireText)] - elseif wire == 2 then - -- text = text .. " Not bad, maybe you even get the 3rd next time." - local twoWireText = { - [1] = '不错,说不定下次就钩上第三根了.', - [2] = '不错,第二根!', - [3] = '不错!', - } - text = text .. twoWireText[math.random(1,#twoWireText)] - elseif wire == 4 then - -- text = text .. " That was scary. You can do better than this!" - local fourWireText = { - [1] = '第四根,你应该庆幸你还活着.', - [2] = '差点进机库兄弟!', - [3] = '太哈人了. 下次要落得比这好才行!', - } - text = text .. fourWireText[math.random(1,#fourWireText)] - elseif wire == 1 then - -- text = text .. " Try harder next time!" - local oneWireText = { - [1] = '继续努力吧.', - [2] = '哦豁,差点bolter.', - [3] = '第一根,海航降落不用拉飘!', - } - text = text .. oneWireText[math.random(1,#oneWireText)] - end - - -- Message to player. - self:MessageToPlayer( playerData, text, "LSO", "" ) - - -- Debrief. - -- local hint = string.format( "Trapped %d-wire.", wire ) - local hint = string.format( "钩住 %d-wire.", wire ) - self:_AddToDebrief( playerData, hint, "Groove: IW" ) - + end + end + return 99 + end + function AIRBOSS:_GetWire(Lcoord,dc) + local FB=self:GetFinalBearing() + local Scoord=self:_GetSternCoord() + local Ldist=Lcoord:Get2DDistance(Scoord) + dc=dc or 65 + local d=Ldist-dc + if self.mpWireCorrection then + d=d-self.mpWireCorrection + end + local w1=self.carrierparam.wire1 + local w2=self.carrierparam.wire2 + local w3=self.carrierparam.wire3 + local w4=self.carrierparam.wire4 + local wire + if d Boltered! - local text = string.format( "Player %s boltered in trapped function.", playerData.name ) - self:T( self.lid .. text ) - MESSAGE:New( text, 5, "DEBUG" ):ToAllIf( self.debug ) - - -- Bolter switch on. - playerData.boltered = true - + wire=99 end - - -- Next step: debriefing. - playerData.step = AIRBOSS.PatternStep.DEBRIEF - playerData.warning = nil -end - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- ZONE functions ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ---- Get Initial zone for Case I or II. --- @param #AIRBOSS self --- @param #number case Recovery Case. --- @return Core.Zone#ZONE_POLYGON_BASE Initial zone. -function AIRBOSS:_GetZoneInitial( case ) - - self.zoneInitial = self.zoneInitial or ZONE_POLYGON_BASE:New( "Zone CASE I/II Initial" ) - - -- Get radial, i.e. inverse of BRC. - local radial = self:GetRadial( 2, false, false ) - - -- Carrier coordinate. - local cv = self:GetCoordinate() - - -- Vec2 array. - local vec2 = {} - - if case == 1 then - -- Case I - - local c1 = cv:Translate( UTILS.NMToMeters( 0.5 ), radial - 90 ) -- 0.0 0.5 starboard - local c2 = cv:Translate( UTILS.NMToMeters( 1.3 ), radial - 90 ):Translate( UTILS.NMToMeters( 3 ), radial ) -- -3.0 1.3 starboard, astern - local c3 = cv:Translate( UTILS.NMToMeters( 0.4 ), radial + 90 ):Translate( UTILS.NMToMeters( 3 ), radial ) -- -3.0 -0.4 port, astern - local c4 = cv:Translate( UTILS.NMToMeters( 1.0 ), radial ) - local c5 = cv - - -- Vec2 array. - vec2 = { c1:GetVec2(), c2:GetVec2(), c3:GetVec2(), c4:GetVec2(), c5:GetVec2() } - - else - -- Case II - - -- Funnel. - local c1 = cv:Translate( UTILS.NMToMeters( 0.5 ), radial - 90 ) -- 0.0, 0.5 - local c2 = c1:Translate( UTILS.NMToMeters( 0.5 ), radial ) -- 0.5, 0.5 - local c3 = cv:Translate( UTILS.NMToMeters( 1.2 ), radial - 90 ):Translate( UTILS.NMToMeters( 3 ), radial ) -- 3.0, 1.2 - local c4 = cv:Translate( UTILS.NMToMeters( 1.2 ), radial + 90 ):Translate( UTILS.NMToMeters( 3 ), radial ) -- 3.0,-1.2 - local c5 = cv:Translate( UTILS.NMToMeters( 0.5 ), radial ) - local c6 = cv - - -- Vec2 array. - vec2 = { c1:GetVec2(), c2:GetVec2(), c3:GetVec2(), c4:GetVec2(), c5:GetVec2(), c6:GetVec2() } - + if self.Debug and false then + local wp1=Scoord:Translate(w1,FB) + local wp2=Scoord:Translate(w2,FB) + local wp3=Scoord:Translate(w3,FB) + local wp4=Scoord:Translate(w4,FB) + wp1:MarkToAll("Wire 1") + wp2:MarkToAll("Wire 2") + wp3:MarkToAll("Wire 3") + wp4:MarkToAll("Wire 4") + Scoord:MarkToAll("Stern") + Lcoord:MarkToAll(string.format("Landing Point wire=%s",wire)) + Lcoord:SmokeGreen() + local Dcoord=Lcoord:Translate(-dc,FB) + Dcoord:SmokeRed() end - - -- Polygon zone. - -- local zone=ZONE_POLYGON_BASE:New("Zone CASE I/II Initial", vec2) - - self.zoneInitial:UpdateFromVec2( vec2 ) - - -- return zone - return self.zoneInitial -end - ---- Get lineup groove zone. --- @param #AIRBOSS self --- @return Core.Zone#ZONE_POLYGON_BASE Lineup zone. -function AIRBOSS:_GetZoneLineup() - - self.zoneLineup = self.zoneLineup or ZONE_POLYGON_BASE:New( "Zone Lineup" ) - - -- Get radial, i.e. inverse of BRC. - local fbi = self:GetRadial( 1, false, false ) - - -- Stern coordinate. - local st = self:_GetOptLandingCoordinate() - - -- Zone points. - local c1 = st - local c2 = st:Translate( UTILS.NMToMeters( 0.50 ), fbi + 15 ) - local c3 = st:Translate( UTILS.NMToMeters( 0.50 ), fbi + self.lue._max - 0.05 ) - local c4 = st:Translate( UTILS.NMToMeters( 0.77 ), fbi + self.lue._max - 0.05 ) - local c5 = c4:Translate( UTILS.NMToMeters( 0.25 ), fbi - 90 ) - - -- Vec2 array. - local vec2 = { c1:GetVec2(), c2:GetVec2(), c3:GetVec2(), c4:GetVec2(), c5:GetVec2() } - - self.zoneLineup:UpdateFromVec2( vec2 ) - - -- Polygon zone. - -- local zone=ZONE_POLYGON_BASE:New("Zone Lineup", vec2) - -- return zone - - return self.zoneLineup -end - ---- Get groove zone. --- @param #AIRBOSS self --- @param #number l Length of the groove in NM. Default 1.5 NM. --- @param #number w Width of the groove in NM. Default 0.25 NM. --- @param #number b Width of the beginning in NM. Default 0.10 NM. --- @return Core.Zone#ZONE_POLYGON_BASE Groove zone. -function AIRBOSS:_GetZoneGroove( l, w, b ) - - self.zoneGroove = self.zoneGroove or ZONE_POLYGON_BASE:New( "Zone Groove" ) - - l = l or 1.50 - w = w or 0.25 - b = b or 0.10 - - -- Get radial, i.e. inverse of BRC. - local fbi = self:GetRadial( 1, false, false ) - - -- Stern coordinate. - local st = self:_GetSternCoord() - - -- Zone points. - local c1 = st:Translate( self.carrierparam.totwidthstarboard, fbi - 90 ) - local c2 = st:Translate( UTILS.NMToMeters( 0.10 ), fbi - 90 ):Translate( UTILS.NMToMeters( 0.3 ), fbi ) - local c3 = st:Translate( UTILS.NMToMeters( 0.25 ), fbi - 90 ):Translate( UTILS.NMToMeters( l ), fbi ) - local c4 = st:Translate( UTILS.NMToMeters( w / 2 ), fbi + 90 ):Translate( UTILS.NMToMeters( l ), fbi ) - local c5 = st:Translate( UTILS.NMToMeters( b ), fbi + 90 ):Translate( UTILS.NMToMeters( 0.3 ), fbi ) - local c6 = st:Translate( self.carrierparam.totwidthport, fbi + 90 ) - - -- Vec2 array. - local vec2 = { c1:GetVec2(), c2:GetVec2(), c3:GetVec2(), c4:GetVec2(), c5:GetVec2(), c6:GetVec2() } - - self.zoneGroove:UpdateFromVec2( vec2 ) - - -- Polygon zone. - -- local zone=ZONE_POLYGON_BASE:New("Zone Groove", vec2) - -- return zone - - return self.zoneGroove -end - ---- Get Bullseye zone with radius 1 NM and DME 3 NM from the carrier. Radial depends on recovery case. --- @param #AIRBOSS self --- @param #number case Recovery case. --- @return Core.Zone#ZONE_RADIUS Arc in zone. -function AIRBOSS:_GetZoneBullseye( case ) - - -- Radius = 1 NM. - local radius = UTILS.NMToMeters( 1 ) - - -- Distance = 3 NM - local distance = UTILS.NMToMeters( 3 ) - - -- Zone depends on Case recovery. - local radial = self:GetRadial( case, false, false ) - - -- Get coordinate and vec2. - local coord = self:GetCoordinate():Translate( distance, radial ) - local vec2 = coord:GetVec2() - - -- Create zone. - local zone = ZONE_RADIUS:New( "Zone Bullseye", vec2, radius ) - return zone - - -- self.zoneBullseye=self.zoneBullseye or ZONE_RADIUS:New("Zone Bullseye", vec2, radius) -end - ---- Get dirty up zone with radius 1 NM and DME 9 NM from the carrier. Radial depends on recovery case. --- @param #AIRBOSS self --- @param #number case Recovery case. --- @return Core.Zone#ZONE_RADIUS Dirty up zone. -function AIRBOSS:_GetZoneDirtyUp( case ) - - -- Radius = 1 NM. - local radius = UTILS.NMToMeters( 1 ) - - -- Distance = 9 NM - local distance = UTILS.NMToMeters( 9 ) - - -- Zone depends on Case recovery. - local radial = self:GetRadial( case, false, false ) - - -- Get coordinate and vec2. - local coord = self:GetCoordinate():Translate( distance, radial ) - local vec2 = coord:GetVec2() - - -- Create zone. - local zone = ZONE_RADIUS:New( "Zone Dirty Up", vec2, radius ) - - return zone -end - ---- Get arc out zone with radius 1 NM and DME 12 NM from the carrier. Radial depends on recovery case. --- @param #AIRBOSS self --- @param #number case Recovery case. --- @return Core.Zone#ZONE_RADIUS Arc in zone. -function AIRBOSS:_GetZoneArcOut( case ) - - -- Radius = 1.25 NM. - local radius = UTILS.NMToMeters( 1.25 ) - - -- Distance = 12 NM - local distance = UTILS.NMToMeters( 11.75 ) - - -- Zone depends on Case recovery. - local radial = self:GetRadial( case, false, false ) - - -- Get coordinate of carrier and translate. - local coord = self:GetCoordinate():Translate( distance, radial ) - - -- Create zone. - local zone = ZONE_RADIUS:New( "Zone Arc Out", coord:GetVec2(), radius ) - - return zone -end - ---- Get arc in zone with radius 1 NM and DME 14 NM from the carrier. Radial depends on recovery case. --- @param #AIRBOSS self --- @param #number case Recovery case. --- @return Core.Zone#ZONE_RADIUS Arc in zone. -function AIRBOSS:_GetZoneArcIn( case ) - - -- Radius = 1.25 NM. - local radius = UTILS.NMToMeters( 1.25 ) - - -- Zone depends on Case recovery. - local radial = self:GetRadial( case, false, true ) - - -- Angle between FB/BRC and holding zone. - local alpha = math.rad( self.holdingoffset ) - - -- 14+x NM from carrier - local x = 14 -- /math.cos(alpha) - - -- Distance = 14 NM - local distance = UTILS.NMToMeters( x ) - - -- Get coordinate. - local coord = self:GetCoordinate():Translate( distance, radial ) - - -- Create zone. - local zone = ZONE_RADIUS:New( "Zone Arc In", coord:GetVec2(), radius ) - - return zone -end - ---- Get platform zone with radius 1 NM and DME 19 NM from the carrier. Radial depends on recovery case. --- @param #AIRBOSS self --- @param #number case Recovery case. --- @return Core.Zone#ZONE_RADIUS Circular platform zone. -function AIRBOSS:_GetZonePlatform( case ) - - -- Radius = 1 NM. - local radius = UTILS.NMToMeters( 1 ) - - -- Zone depends on Case recovery. - local radial = self:GetRadial( case, false, true ) - - -- Angle between FB/BRC and holding zone. - local alpha = math.rad( self.holdingoffset ) - - -- Distance = 19 NM - local distance = UTILS.NMToMeters( 19 ) -- /math.cos(alpha) - - -- Get coordinate. - local coord = self:GetCoordinate():Translate( distance, radial ) - - -- Create zone. - local zone = ZONE_RADIUS:New( "Zone Platform", coord:GetVec2(), radius ) - - return zone -end - ---- Get approach corridor zone. Shape depends on recovery case. --- @param #AIRBOSS self --- @param #number case Recovery case. --- @param #number l Length of the zone in NM. Default 31 (=21+10) NM. --- @return Core.Zone#ZONE_POLYGON_BASE Box zone. -function AIRBOSS:_GetZoneCorridor( case, l ) - - -- Total length. - l = l or 31 - - -- Radial and offset. - local radial = self:GetRadial( case, false, false ) - local offset = self:GetRadial( case, false, true ) - - -- Distance shift ahead of carrier to allow for some space to bolter. - local dx = 5 - - -- Width of the box in NM. - local w = 2 - local w2 = w / 2 - - -- Distance from carrier to arc out zone. - local d = 12 - - -- Carrier position. - local cv = self:GetCoordinate() - - -- Polygon points. - local c = {} - - -- First point. Carrier coordinate translated 5 NM in direction of travel to allow for bolter space. - c[1] = cv:Translate( -UTILS.NMToMeters( dx ), radial ) - - if math.abs( self.holdingoffset ) >= 5 then - - ----------------- - -- Angled Case -- - ----------------- - - c[2] = c[1]:Translate( UTILS.NMToMeters( w2 ), radial - 90 ) -- 1 Right of carrier, dx ahead. - c[3] = c[2]:Translate( UTILS.NMToMeters( d + dx + w2 ), radial ) -- 13 "south" @ 1 right - - c[4] = cv:Translate( UTILS.NMToMeters( 15 ), offset ):Translate( UTILS.NMToMeters( 1 ), offset - 90 ) - c[5] = cv:Translate( UTILS.NMToMeters( l ), offset ):Translate( UTILS.NMToMeters( 1 ), offset - 90 ) - c[6] = cv:Translate( UTILS.NMToMeters( l ), offset ):Translate( UTILS.NMToMeters( 1 ), offset + 90 ) - c[7] = cv:Translate( UTILS.NMToMeters( 13 ), offset ):Translate( UTILS.NMToMeters( 1 ), offset + 90 ) - c[8] = cv:Translate( UTILS.NMToMeters( 11 ), radial ):Translate( UTILS.NMToMeters( 1 ), radial + 90 ) - - c[9] = c[1]:Translate( UTILS.NMToMeters( w2 ), radial + 90 ) - - else - - ----------------------------- - -- Easy case of a long box -- - ----------------------------- - - c[2] = c[1]:Translate( UTILS.NMToMeters( w2 ), radial - 90 ) - c[3] = c[2]:Translate( UTILS.NMToMeters( dx + l ), radial ) -- Stack 1 starts at 21 and is 7 NM. - c[4] = c[3]:Translate( UTILS.NMToMeters( w ), radial + 90 ) - c[5] = c[1]:Translate( UTILS.NMToMeters( w2 ), radial + 90 ) - + self:T(string.format("GetWire: L=%.1f, L-dc=%.1f ==> wire=%d (dc=%.1f)",Ldist,Ldist-dc,wire,dc)) + return wire end - - -- Create an array of a square! - local p = {} - for _i, _c in ipairs( c ) do - if self.Debug then - -- _c:SmokeBlue() - end - p[_i] = _c:GetVec2() + function AIRBOSS:_Trapped(playerData) + if playerData.unit:InAir()==false then + local unit=playerData.unit + local coord=unit:GetCoordinate() + local v=unit:GetVelocityKMH()-self.carrier:GetVelocityKMH() + local stern=self:_GetSternCoord() + local s=stern:Get2DDistance(coord) + local dcorr=100 + if playerData.actype==AIRBOSS.AircraftCarrier.HORNET + or playerData.actype==AIRBOSS.AircraftCarrier.RHINOE + or playerData.actype==AIRBOSS.AircraftCarrier.RHINOF + or playerData.actype==AIRBOSS.AircraftCarrier.GROWLER then + dcorr=100 + elseif playerData.actype==AIRBOSS.AircraftCarrier.F14A or playerData.actype==AIRBOSS.AircraftCarrier.F14B then + dcorr=100 + elseif playerData.actype==AIRBOSS.AircraftCarrier.A4EC then + dcorr=56 + elseif playerData.actype==AIRBOSS.AircraftCarrier.T45C then + dcorr=56 end - - -- Square zone length=10NM width=6 NM behind the carrier starting at angels+15 NM behind the carrier. - -- So stay 0-5 NM (+1 NM error margin) port of carrier. - local zone = ZONE_POLYGON_BASE:New( "CASE II/III Approach Corridor", p ) - - return zone -end - ---- Get zone of carrier. Carrier is approximated as rectangle. --- @param #AIRBOSS self --- @return Core.Zone#ZONE Zone surrounding the carrier. -function AIRBOSS:_GetZoneCarrierBox() - - self.zoneCarrierbox = self.zoneCarrierbox or ZONE_POLYGON_BASE:New( "Carrier Box Zone" ) - - -- Stern coordinate. - local S = self:_GetSternCoord() - - -- Current carrier heading. - local hdg = self:GetHeading( false ) - - -- Coordinate array. - local p = {} - - -- Starboard stern point. - p[1] = S:Translate( self.carrierparam.totwidthstarboard, hdg + 90 ) - - -- Starboard bow point. - p[2] = p[1]:Translate( self.carrierparam.totlength, hdg ) - - -- Port bow point. - p[3] = p[2]:Translate( self.carrierparam.totwidthstarboard + self.carrierparam.totwidthport, hdg - 90 ) - - -- Port stern point. - p[4] = p[3]:Translate( self.carrierparam.totlength, hdg - 180 ) - - -- Convert to vec2. - local vec2 = {} - for _, coord in ipairs( p ) do - table.insert( vec2, coord:GetVec2() ) + local wire=self:_GetWire(coord,dcorr) + local text=string.format("Player %s _Trapped: v=%.1f km/h, s-dcorr=%.1f m ==> wire=%d (dcorr=%d)",playerData.name,v,s-dcorr,wire,dcorr) + self:T(self.lid..text) + if v>5 then + if wire>4 and v>10 and not playerData.warning then + self:RadioTransmission(self.LSORadio,self.LSOCall.BOLTER,nil,nil,nil,true) + playerData.warning=true end - - -- Create polygon zone. - -- local zone=ZONE_POLYGON_BASE:New("Carrier Box Zone", vec2) - -- return zone - - self.zoneCarrierbox:UpdateFromVec2( vec2 ) - - return self.zoneCarrierbox -end - ---- Get zone of landing runway. --- @param #AIRBOSS self --- @return Core.Zone#ZONE_POLYGON Zone surrounding landing runway. -function AIRBOSS:_GetZoneRunwayBox() - - self.zoneRunwaybox = self.zoneRunwaybox or ZONE_POLYGON_BASE:New( "Landing Runway Zone" ) - - -- Stern coordinate. - local S = self:_GetSternCoord() - - -- Current carrier heading. - local FB = self:GetFinalBearing( false ) - - -- Coordinate array. - local p = {} - - -- Points. - p[1] = S:Translate( self.carrierparam.rwywidth * 0.5, FB + 90 ) - p[2] = p[1]:Translate( self.carrierparam.rwylength, FB ) - p[3] = p[2]:Translate( self.carrierparam.rwywidth, FB - 90 ) - p[4] = p[3]:Translate( self.carrierparam.rwylength, FB - 180 ) - - -- Convert to vec2. - local vec2 = {} - for _, coord in ipairs( p ) do - table.insert( vec2, coord:GetVec2() ) + self:ScheduleOnce(0.1,self._Trapped,self,playerData) + return end - - -- Create polygon zone. - -- local zone=ZONE_POLYGON_BASE:New("Landing Runway Zone", vec2) - -- return zone - - self.zoneRunwaybox:UpdateFromVec2( vec2 ) - - return self.zoneRunwaybox -end - ---- Get zone of primary abeam landing position of HMS Hermes, HMS Invincible, USS Tarawa, USS America and Juan Carlos. Box length 50 meters and width 30 meters. - ---- Allow for Clear to land call from LSO approaching abeam the landing spot if stable as per NATOPS 00-80T --- @param #AIRBOSS self --- @return Core.Zone#ZONE_POLYGON Zone surrounding landing runway. -function AIRBOSS:_GetZoneAbeamLandingSpot() - - -- Primary landing Spot coordinate. - local S = self:_GetOptLandingCoordinate() - - -- Current carrier heading. - local FB = self:GetFinalBearing( false ) - - -- Coordinate array. Pene Testing extended Abeam landing spot V/STOL. - local p={} - - -- Points. - p[1] = S:Translate( 15, FB ):Translate( 15, FB + 90 ) -- Top-Right - p[2] = S:Translate( -45, FB ):Translate( 15, FB + 90 ) -- Bottom-Right - p[3] = S:Translate( -45, FB ):Translate( 15, FB - 90 ) -- Bottom-Left - p[4] = S:Translate( 15, FB ):Translate( 15, FB - 90 ) -- Top-Left - - -- Convert to vec2. - local vec2 = {} - for _, coord in ipairs( p ) do - table.insert( vec2, coord:GetVec2() ) - end - - -- Create polygon zone. - local zone = ZONE_POLYGON_BASE:New( "Abeam Landing Spot Zone", vec2 ) - - return zone -end - ---- Get zone of the primary landing spot of the USS Tarawa. --- @param #AIRBOSS self --- @return Core.Zone#ZONE_POLYGON Zone surrounding landing runway. -function AIRBOSS:_GetZoneLandingSpot() - - -- Primary landing Spot coordinate. - local S = self:_GetLandingSpotCoordinate() - - -- Current carrier heading. - local FB = self:GetFinalBearing( false ) - - -- Coordinate array. - local p = {} - - -- Points. - p[1] = S:Translate( 10, FB ):Translate( 10, FB + 90 ) -- Top-Right - p[2] = S:Translate( -10, FB ):Translate( 10, FB + 90 ) -- Bottom-Right - p[3] = S:Translate( -10, FB ):Translate( 10, FB - 90 ) -- Bottom-Left - p[4] = S:Translate( 10, FB ):Translate( 10, FB - 90 ) -- Top-left - - -- Convert to vec2. - local vec2 = {} - for _, coord in ipairs( p ) do - table.insert( vec2, coord:GetVec2() ) - end - - -- Create polygon zone. - local zone = ZONE_POLYGON_BASE:New( "Landing Spot Zone", vec2 ) - - return zone -end - ---- Get holding zone of player. --- @param #AIRBOSS self --- @param #number case Recovery case. --- @param #number stack Marshal stack number. --- @return Core.Zone#ZONE Holding zone. -function AIRBOSS:_GetZoneHolding( case, stack ) - - -- Holding zone. - local zoneHolding = nil -- Core.Zone#ZONE - - -- Stack is <= 0 ==> no marshal zone. - if stack <= 0 then - self:E( self.lid .. "ERROR: Stack <= 0 in _GetZoneHolding!" ) - self:E( { case = case, stack = stack } ) - return nil - end - - -- Pattern altitude. - local patternalt, c1, c2 = self:_GetMarshalAltitude( stack, case ) - - -- Select case. - if case == 1 then - -- CASE I - - -- Get current carrier heading. - local hdg = self:GetHeading() - - -- Distance to the post. - local D = UTILS.NMToMeters( 2.5 ) - - -- Post 2.5 NM port of carrier. - local Post = self:GetCoordinate():Translate( D, hdg + 270 ) - - -- TODO: update zone not creating a new one. - - -- Create holding zone. - self.zoneHolding = ZONE_RADIUS:New( "CASE I Holding Zone", Post:GetVec2(), self.marshalradius ) - - -- Delta pattern. - if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then - self.zoneHolding = ZONE_RADIUS:New( "CASE I Holding Zone", self.carrier:GetVec2(), UTILS.NMToMeters( 5 ) ) - end - - else - -- CASE II/II - - -- Get radial. - local radial = self:GetRadial( case, false, true ) - - -- Create an array of a rectangle. Length is 7 NM, width is 8 NM. One NM starboard to line up with the approach corridor. - local p = {} - p[1] = c2:Translate( UTILS.NMToMeters( 1 ), radial - 90 ):GetVec2() -- c2 is at (angels+15) NM directly behind the carrier. We translate it 1 NM starboard. - p[2] = c1:Translate( UTILS.NMToMeters( 1 ), radial - 90 ):GetVec2() -- c1 is 7 NM further behind. Also translated 1 NM starboard. - p[3] = c1:Translate( UTILS.NMToMeters( 7 ), radial + 90 ):GetVec2() -- p3 7 NM port of carrier. - p[4] = c2:Translate( UTILS.NMToMeters( 7 ), radial + 90 ):GetVec2() -- p4 7 NM port of carrier. - - -- Square zone length=7NM width=6 NM behind the carrier starting at angels+15 NM behind the carrier. - -- So stay 0-5 NM (+1 NM error margin) port of carrier. - self.zoneHolding = self.zoneHolding or ZONE_POLYGON_BASE:New( "CASE II/III Holding Zone" ) - - self.zoneHolding:UpdateFromVec2( p ) - end - - return self.zoneHolding -end - ---- Get zone where player are automatically commence when enter. --- @param #AIRBOSS self --- @param #number case Recovery case. --- @param #number stack Stack for Case II/III as we commence from stack>=1. --- @return Core.Zone#ZONE Holding zone. -function AIRBOSS:_GetZoneCommence( case, stack ) - - -- Commence zone. - local zone - - if case == 1 then - -- Case I - - -- Get current carrier heading. - local hdg = self:GetHeading() - - -- Distance to the zone. - local D = UTILS.NMToMeters( 4.75 ) - - -- Zone radius. - local R = UTILS.NMToMeters( 1 ) - - -- Three position - local Three = self:GetCoordinate():Translate( D, hdg + 275 ) - - if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then - local Dx = UTILS.NMToMeters( 2.25 ) - - local Dz = UTILS.NMToMeters( 2.25 ) - - R = UTILS.NMToMeters( 1 ) - - Three = self:GetCoordinate():Translate( Dz, hdg - 90 ):Translate( Dx, hdg - 180 ) - - end - - -- Create holding zone. - self.zoneCommence = self.zoneCommence or ZONE_RADIUS:New( "CASE I Commence Zone" ) - - self.zoneCommence:UpdateFromVec2( Three:GetVec2(), R ) - - else - -- Case II/III - - stack = stack or 1 - - -- Start point at 21 NM for stack=1. - local l = 20 + stack - - -- Offset angle - local offset = self:GetRadial( case, false, true ) - - -- Carrier position. - local cv = self:GetCoordinate() - - -- Polygon points. - local c = {} - - c[1] = cv:Translate( UTILS.NMToMeters( l ), offset ):Translate( UTILS.NMToMeters( 1 ), offset - 90 ) - c[2] = cv:Translate( UTILS.NMToMeters( l + 2.5 ), offset ):Translate( UTILS.NMToMeters( 1 ), offset - 90 ) - c[3] = cv:Translate( UTILS.NMToMeters( l + 2.5 ), offset ):Translate( UTILS.NMToMeters( 1 ), offset + 90 ) - c[4] = cv:Translate( UTILS.NMToMeters( l ), offset ):Translate( UTILS.NMToMeters( 1 ), offset + 90 ) - - -- Create an array of a square! - local p = {} - for _i, _c in ipairs( c ) do - p[_i] = _c:GetVec2() - end - - -- Zone polygon. - self.zoneCommence = self.zoneCommence or ZONE_POLYGON_BASE:New( "CASE II/III Commence Zone" ) - - self.zoneCommence:UpdateFromVec2( p ) - - end - - return self.zoneCommence -end - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- ORIENTATION functions ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ---- Provide info about player status on the fly. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. -function AIRBOSS:_AttitudeMonitor( playerData ) - - -- Player unit. - local unit = playerData.unit - - -- Aircraft attitude. - local aoa = unit:GetAoA() - local yaw = unit:GetYaw() - local roll = unit:GetRoll() - local pitch = unit:GetPitch() - - -- Distance to the boat. - local dist = playerData.unit:GetCoordinate():Get2DDistance( self:GetCoordinate() ) - local dx, dz, rho, phi = self:_GetDistances( unit ) - - -- Wind vector. - local wind = unit:GetCoordinate():GetWindWithTurbulenceVec3() - - -- Aircraft veloecity vector. - local velo = unit:GetVelocityVec3() - local vabs = UTILS.VecNorm( velo ) - - local rwy = false - local step = playerData.step - if playerData.step == AIRBOSS.PatternStep.FINAL or - playerData.step == AIRBOSS.PatternStep.GROOVE_XX or - playerData.step == AIRBOSS.PatternStep.GROOVE_IM or - playerData.step == AIRBOSS.PatternStep.GROOVE_IC or - playerData.step == AIRBOSS.PatternStep.GROOVE_AR or - playerData.step == AIRBOSS.PatternStep.GROOVE_AL or - playerData.step == AIRBOSS.PatternStep.GROOVE_LC or - playerData.step == AIRBOSS.PatternStep.GROOVE_IW then - step = self:_GS( step, -1 ) - rwy = true - end - - -- Relative heading Aircraft to Carrier. - local relhead = self:_GetRelativeHeading( playerData.unit, rwy ) - - -- local lc=self:_GetOptLandingCoordinate() - -- lc:FlareRed() - - -- Output - -- local text = string.format( "Pattern step: %s", step ) - local text = string.format( "阶段: %s", step ) - -- text = text .. string.format( "\nAoA=%.1f° = %.1f Units | |V|=%.1f knots", aoa, self:_AoADeg2Units( playerData, aoa ), UTILS.MpsToKnots( vabs ) ) - text = text .. string.format( "\nAoA=%.1f° = %.1f 单位 | |V|=%.1f knots", aoa, self:_AoADeg2Units( playerData, aoa ), UTILS.MpsToKnots( vabs ) ) if self.Debug then - -- Velocity vector. - text = text .. string.format( "\nVx=%.1f Vy=%.1f Vz=%.1f m/s", velo.x, velo.y, velo.z ) - -- Wind vector. - -- text = text .. string.format( "\nWind Vx=%.1f Vy=%.1f Vz=%.1f m/s", wind.x, wind.y, wind.z ) - text = text .. string.format( "\n风 Vx=%.1f Vy=%.1f Vz=%.1f m/s", wind.x, wind.y, wind.z ) + coord:SmokeBlue() + coord:MarkToAll(text) + stern:MarkToAll("Stern") end - -- text = text .. string.format( "\nPitch=%.1f° | Roll=%.1f° | Yaw=%.1f°", pitch, roll, yaw ) - text = text .. string.format( "\n俯仰=%.1f° | 滚转=%.1f° | 偏航=%.1f°", pitch, roll, yaw ) - -- text = text .. string.format( "\nClimb Angle=%.1f° | Rate=%d ft/min", unit:GetClimbAngle(), velo.y * 196.85 ) - text = text .. string.format( "\n爬升角度=%.1f° | 速率=%d ft/min", unit:GetClimbAngle(), velo.y * 196.85 ) - local dist = self:_GetOptLandingCoordinate():Get3DDistance( playerData.unit:GetVec3() ) - -- Get player velocity in km/h. - local vplayer = playerData.unit:GetVelocityKMH() - -- Get carrier velocity in km/h. - local vcarrier = self.carrier:GetVelocityKMH() - -- Speed difference. - local dv = math.abs( vplayer - vcarrier ) - local alt = self:_GetAltCarrier( playerData.unit ) - -- text = text .. string.format( "\nDist=%.1f m Alt=%.1f m delta|V|=%.1f km/h", dist, alt, dv ) - text = text .. string.format( "\n距离=%.1f m 高度=%.1f m delta|V|=%.1f km/h", dist, alt, dv ) - -- If in the groove, provide line up and glide slope error. - if playerData.step == AIRBOSS.PatternStep.FINAL or - playerData.step == AIRBOSS.PatternStep.GROOVE_XX or - playerData.step == AIRBOSS.PatternStep.GROOVE_IM or - playerData.step == AIRBOSS.PatternStep.GROOVE_IC or - playerData.step == AIRBOSS.PatternStep.GROOVE_AR or - playerData.step == AIRBOSS.PatternStep.GROOVE_AL or - playerData.step == AIRBOSS.PatternStep.GROOVE_LC or - playerData.step == AIRBOSS.PatternStep.GROOVE_IW then - local lue = self:_Lineup( playerData.unit, true ) - local gle = self:_Glideslope( playerData.unit ) - text = text .. string.format( "\nGamma=%.1f° | Rho=%.1f°", relhead, phi ) - -- text = text .. string.format( "\nLineUp=%.2f° | GlideSlope=%.2f° | AoA=%.1f Units", lue, gle, self:_AoADeg2Units( playerData, aoa ) ) - text = text .. string.format( "\n相对中线=%.2f° | 下滑道=%.2f° | AoA=%.1f Units", lue, gle, self:_AoADeg2Units( playerData, aoa ) ) - local grade, points, analysis = self:_LSOgrade( playerData ) - text = text .. string.format( "\nTgroove=%.1f sec", self:_GetTimeInGroove( playerData ) ) - -- text = text .. string.format( "\nGrade: %s %.1f PT - %s", grade, points, analysis ) - text = text .. string.format( "\n成绩: %s %.1f PT - %s", grade, points, analysis ) + playerData.wire=wire + local text=string.format("Trapped %d-wire.",wire) + if wire==3 then + -- text=text.." Well done!" + text=text.." 完美!" + elseif wire==2 then + -- text=text.." Not bad, maybe you even get the 3rd next time." + text=text.." 不错, 说不定你下次就能钩到第三根." + elseif wire==4 then + -- text=text.." That was scary. You can do better than this!" + text=text.." 太哈人了. 希望你下次飞好点!" + elseif wire==1 then + -- text=text.." Try harder next time!" + text=text.." 下次努力吧bro!" + end + self:MessageToPlayer(playerData,text,"LSO","") + -- local hint=string.format("Trapped %d-wire.",wire) + local hint=string.format("钩中 %d-wire.",wire) + -- self:_AddToDebrief(playerData,hint,"Groove: IW") + self:_AddToDebrief(playerData,hint,"第五边(Groove): IW") else - text = text .. string.format( "\nR=%.2f NM | X=%d Z=%d m", UTILS.MetersToNM( rho ), dx, dz ) - text = text .. string.format( "\nGamma=%.1f° | Rho=%.1f°", relhead, phi ) + local text=string.format("Player %s boltered in trapped function.",playerData.name) + self:T(self.lid..text) + MESSAGE:New(text,5,"DEBUG"):ToAllIf(self.debug) + playerData.boltered=true end - - MESSAGE:New( text, 1, nil, true ):ToClient( playerData.client ) -end - ---- Get glide slope of aircraft unit. --- @param #AIRBOSS self --- @param Wrapper.Unit#UNIT unit Aircraft unit. --- @param #number optangle (Optional) Return glide slope relative to this angle, i.e. the error from the optimal glide slope ~3.5 degrees. --- @return #number Glide slope angle in degrees measured from the deck of the carrier and third wire. -function AIRBOSS:_Glideslope( unit, optangle ) - - if optangle == nil then - if unit:GetTypeName() == AIRBOSS.AircraftCarrier.AV8B then - optangle = 3.0 - else - optangle = 3.5 - end + playerData.step=AIRBOSS.PatternStep.DEBRIEF + playerData.warning=nil end - -- Landing coordinate - local landingcoord = self:_GetOptLandingCoordinate() - - -- Distance from stern to aircraft. - local x = unit:GetCoordinate():Get2DDistance( landingcoord ) - - -- Altitude of unit corrected by the deck height of the carrier. - local h = self:_GetAltCarrier( unit ) - - -- Harrier should be 40-50 ft above the deck. - if unit:GetTypeName() == AIRBOSS.AircraftCarrier.AV8B then - h = unit:GetAltitude() - (UTILS.FeetToMeters( 50 ) + self.carrierparam.deckheight + 2) + function AIRBOSS:_GetZoneInitial(case) + self.zoneInitial=self.zoneInitial or ZONE_POLYGON_BASE:New("Zone CASE I/II Initial") + local radial=self:GetRadial(2,false,false) + local cv=self:GetCoordinate() + local vec2={} + if case==1 then + local c1=cv:Translate(UTILS.NMToMeters(0.5),radial-90) + local c2=cv:Translate(UTILS.NMToMeters(1.3),radial-90):Translate(UTILS.NMToMeters(3),radial) + local c3=cv:Translate(UTILS.NMToMeters(0.4),radial+90):Translate(UTILS.NMToMeters(3),radial) + local c4=cv:Translate(UTILS.NMToMeters(1.0),radial) + local c5=cv + vec2={c1:GetVec2(),c2:GetVec2(),c3:GetVec2(),c4:GetVec2(),c5:GetVec2()} + else + local c1=cv:Translate(UTILS.NMToMeters(0.5),radial-90) + local c2=c1:Translate(UTILS.NMToMeters(0.5),radial) + local c3=cv:Translate(UTILS.NMToMeters(1.2),radial-90):Translate(UTILS.NMToMeters(3),radial) + local c4=cv:Translate(UTILS.NMToMeters(1.2),radial+90):Translate(UTILS.NMToMeters(3),radial) + local c5=cv:Translate(UTILS.NMToMeters(0.5),radial) + local c6=cv + vec2={c1:GetVec2(),c2:GetVec2(),c3:GetVec2(),c4:GetVec2(),c5:GetVec2(),c6:GetVec2()} end - - -- Glide slope. - local glideslope = math.atan( h / x ) - - -- Glide slope (error) in degrees. - local gs = math.deg( glideslope ) - optangle - - return gs -end - ---- Get glide slope of aircraft unit. --- @param #AIRBOSS self --- @param Wrapper.Unit#UNIT unit Aircraft unit. --- @param #number optangle (Optional) Return glide slope relative to this angle, i.e. the error from the optimal glide slope ~3.5 degrees. --- @return #number Glide slope angle in degrees measured from the deck of the carrier and third wire. -function AIRBOSS:_Glideslope2( unit, optangle ) - - if optangle == nil then - if unit:GetTypeName() == AIRBOSS.AircraftCarrier.AV8B then - optangle = 3.0 - else - optangle = 3.5 - end + self.zoneInitial:UpdateFromVec2(vec2) + return self.zoneInitial end - -- Landing coordinate - local landingcoord = self:_GetOptLandingCoordinate() - - -- Distance from stern to aircraft. - local x = unit:GetCoordinate():Get3DDistance( landingcoord ) - - -- Altitude of unit corrected by the deck height of the carrier. - local h = self:_GetAltCarrier( unit ) - - -- Harrier should be 40-50 ft above the deck. - if unit:GetTypeName() == AIRBOSS.AircraftCarrier.AV8B then - h = unit:GetAltitude() - (UTILS.FeetToMeters( 50 ) + self.carrierparam.deckheight + 2) + function AIRBOSS:_GetZoneLineup() + self.zoneLineup=self.zoneLineup or ZONE_POLYGON_BASE:New("Zone Lineup") + local fbi=self:GetRadial(1,false,false) + local st=self:_GetOptLandingCoordinate() + local c1=st + local c2=st:Translate(UTILS.NMToMeters(0.50),fbi+15) + local c3=st:Translate(UTILS.NMToMeters(0.50),fbi+self.lue._max-0.05) + local c4=st:Translate(UTILS.NMToMeters(0.77),fbi+self.lue._max-0.05) + local c5=c4:Translate(UTILS.NMToMeters(0.25),fbi-90) + local vec2={c1:GetVec2(),c2:GetVec2(),c3:GetVec2(),c4:GetVec2(),c5:GetVec2()} + self.zoneLineup:UpdateFromVec2(vec2) + return self.zoneLineup end - - -- Glide slope. - local glideslope = math.asin( h / x ) - - -- Glide slope (error) in degrees. - local gs = math.deg( glideslope ) - optangle - - -- Debug. - self:T3( self.lid .. string.format( "Glide slope error = %.1f, x=%.1f h=%.1f", gs, x, h ) ) - - return gs -end - ---- Get line up of player wrt to carrier. --- @param #AIRBOSS self --- @param Wrapper.Unit#UNIT unit Aircraft unit. --- @param #boolean runway If true, include angled runway. --- @return #number Line up with runway heading in degrees. 0 degrees = perfect line up. +1 too far left. -1 too far right. -function AIRBOSS:_Lineup( unit, runway ) - - -- Landing coordinate - local landingcoord = self:_GetOptLandingCoordinate() - - -- Vector to landing coord. - local A = landingcoord:GetVec3() - - -- Vector to player. - local B = unit:GetVec3() - - -- Vector from player to carrier. - local C = UTILS.VecSubstract( A, B ) - - -- Only in 2D plane. - C.y = 0.0 - - -- Orientation of carrier. - local X = self.carrier:GetOrientationX() - X.y = 0.0 - - -- Rotate orientation to angled runway. - if runway then - X = UTILS.Rotate2D( X, -self.carrierparam.rwyangle ) + function AIRBOSS:_GetZoneGroove(l,w,b) + self.zoneGroove=self.zoneGroove or ZONE_POLYGON_BASE:New("Zone Groove") + l=l or 1.50 + w=w or 0.25 + b=b or 0.10 + local fbi=self:GetRadial(1,false,false) + local st=self:_GetSternCoord() + local c1=st:Translate(self.carrierparam.totwidthstarboard,fbi-90) + local c2=st:Translate(UTILS.NMToMeters(0.10),fbi-90):Translate(UTILS.NMToMeters(0.3),fbi) + local c3=st:Translate(UTILS.NMToMeters(0.25),fbi-90):Translate(UTILS.NMToMeters(l),fbi) + local c4=st:Translate(UTILS.NMToMeters(w/2),fbi+90):Translate(UTILS.NMToMeters(l),fbi) + local c5=st:Translate(UTILS.NMToMeters(b),fbi+90):Translate(UTILS.NMToMeters(0.3),fbi) + local c6=st:Translate(self.carrierparam.totwidthport,fbi+90) + local vec2={c1:GetVec2(),c2:GetVec2(),c3:GetVec2(),c4:GetVec2(),c5:GetVec2(),c6:GetVec2()} + self.zoneGroove:UpdateFromVec2(vec2) + return self.zoneGroove end - - -- Projection of player pos on x component. - local x = UTILS.VecDot( X, C ) - - -- Orientation of carrier. - local Z = self.carrier:GetOrientationZ() - Z.y = 0.0 - - -- Rotate orientation to angled runway. - if runway then - Z = UTILS.Rotate2D( Z, -self.carrierparam.rwyangle ) + function AIRBOSS:_GetZoneBullseye(case) + local radius=UTILS.NMToMeters(1) + local distance=UTILS.NMToMeters(3) + local radial=self:GetRadial(case,false,false) + local coord=self:GetCoordinate():Translate(distance,radial) + local vec2=coord:GetVec2() + local zone=ZONE_RADIUS:New("Zone Bullseye",vec2,radius) + return zone end - - -- Projection of player pos on z component. - local z = UTILS.VecDot( Z, C ) - - --- - local lineup = math.deg( math.atan2( z, x ) ) - - return lineup -end - ---- Get altitude of aircraft wrt carrier deck. Should give zero when the aircraft touched down. --- @param #AIRBOSS self --- @param Wrapper.Unit#UNIT unit Aircraft unit. --- @return #number Altitude in meters wrt carrier height. -function AIRBOSS:_GetAltCarrier( unit ) - - -- TODO: Value 4 meters is for the Hornet. Adjust for Harrier, A4E and - - -- Altitude of unit corrected by the deck height of the carrier. - local h = unit:GetAltitude() - self.carrierparam.deckheight - 2 - - return h -end - ---- Get optimal landing position of the aircraft. Usually between second and third wire. In case of Tarawa, Canberrra, Juan Carlos and America we take the abeam landing spot 120 ft above and 21 ft abeam the 7.5 position, for the Juan Carlos I, HMS Invincible, and HMS Hermes and Invincible it is 120 ft above and 21 ft abeam the 5 position. For CASE III it is 120ft directly above the landing spot. --- @param #AIRBOSS self --- @return Core.Point#COORDINATE Optimal landing coordinate. -function AIRBOSS:_GetOptLandingCoordinate() - - -- Start with stern coordiante. - self.landingcoord:UpdateFromCoordinate( self:_GetSternCoord() ) - - -- Final bearing. + function AIRBOSS:_GetZoneDirtyUp(case) + local radius=UTILS.NMToMeters(1) + local distance=UTILS.NMToMeters(9) + local radial=self:GetRadial(case,false,false) + local coord=self:GetCoordinate():Translate(distance,radial) + local vec2=coord:GetVec2() + local zone=ZONE_RADIUS:New("Zone Dirty Up",vec2,radius) + return zone + end + function AIRBOSS:_GetZoneArcOut(case) + local radius=UTILS.NMToMeters(1.25) + local distance=UTILS.NMToMeters(11.75) + local radial=self:GetRadial(case,false,false) + local coord=self:GetCoordinate():Translate(distance,radial) + local zone=ZONE_RADIUS:New("Zone Arc Out",coord:GetVec2(),radius) + return zone + end + function AIRBOSS:_GetZoneArcIn(case) + local radius=UTILS.NMToMeters(1.25) + local radial=self:GetRadial(case,false,true) + local alpha=math.rad(self.holdingoffset) + local x=14 + local distance=UTILS.NMToMeters(x) + local coord=self:GetCoordinate():Translate(distance,radial) + local zone=ZONE_RADIUS:New("Zone Arc In",coord:GetVec2(),radius) + return zone + end + function AIRBOSS:_GetZonePlatform(case) + local radius=UTILS.NMToMeters(1) + local radial=self:GetRadial(case,false,true) + local alpha=math.rad(self.holdingoffset) + local distance=UTILS.NMToMeters(19) + local coord=self:GetCoordinate():Translate(distance,radial) + local zone=ZONE_RADIUS:New("Zone Platform",coord:GetVec2(),radius) + return zone + end + function AIRBOSS:_GetZoneCorridor(case,l) + l=l or 31 + local radial=self:GetRadial(case,false,false) + local offset=self:GetRadial(case,false,true) + local dx=5 + local w=2 + local w2=w/2 + local d=12 + local cv=self:GetCoordinate() + local c={} + c[1]=cv:Translate(-UTILS.NMToMeters(dx),radial) + if math.abs(self.holdingoffset)>=5 then + c[2]=c[1]:Translate(UTILS.NMToMeters(w2),radial-90) + c[3]=c[2]:Translate(UTILS.NMToMeters(d+dx+w2),radial) + c[4]=cv:Translate(UTILS.NMToMeters(15),offset):Translate(UTILS.NMToMeters(1),offset-90) + c[5]=cv:Translate(UTILS.NMToMeters(l),offset):Translate(UTILS.NMToMeters(1),offset-90) + c[6]=cv:Translate(UTILS.NMToMeters(l),offset):Translate(UTILS.NMToMeters(1),offset+90) + c[7]=cv:Translate(UTILS.NMToMeters(13),offset):Translate(UTILS.NMToMeters(1),offset+90) + c[8]=cv:Translate(UTILS.NMToMeters(11),radial):Translate(UTILS.NMToMeters(1),radial+90) + c[9]=c[1]:Translate(UTILS.NMToMeters(w2),radial+90) + else + c[2]=c[1]:Translate(UTILS.NMToMeters(w2),radial-90) + c[3]=c[2]:Translate(UTILS.NMToMeters(dx+l),radial) + c[4]=c[3]:Translate(UTILS.NMToMeters(w),radial+90) + c[5]=c[1]:Translate(UTILS.NMToMeters(w2),radial+90) + end + local p={} + for _i,_c in ipairs(c)do + if self.Debug then + end + p[_i]=_c:GetVec2() + end + local zone=ZONE_POLYGON_BASE:New("CASE II/III Approach Corridor",p) + return zone + end + function AIRBOSS:_GetZoneCarrierBox() + self.zoneCarrierbox=self.zoneCarrierbox or ZONE_POLYGON_BASE:New("Carrier Box Zone") + local S=self:_GetSternCoord() + local hdg=self:GetHeading(false) + local p={} + p[1]=S:Translate(self.carrierparam.totwidthstarboard,hdg+90) + p[2]=p[1]:Translate(self.carrierparam.totlength,hdg) + p[3]=p[2]:Translate(self.carrierparam.totwidthstarboard+self.carrierparam.totwidthport,hdg-90) + p[4]=p[3]:Translate(self.carrierparam.totlength,hdg-180) + local vec2={} + for _,coord in ipairs(p)do + table.insert(vec2,coord:GetVec2()) + end + self.zoneCarrierbox:UpdateFromVec2(vec2) + return self.zoneCarrierbox + end + function AIRBOSS:_GetZoneRunwayBox() + self.zoneRunwaybox=self.zoneRunwaybox or ZONE_POLYGON_BASE:New("Landing Runway Zone") + local S=self:_GetSternCoord() local FB=self:GetFinalBearing(false) - - -- Cse - local case=self.case - - -- set Case III V/STOL abeam landing spot over deck -- Pene Testing + local p={} + p[1]=S:Translate(self.carrierparam.rwywidth*0.5,FB+90) + p[2]=p[1]:Translate(self.carrierparam.rwylength,FB) + p[3]=p[2]:Translate(self.carrierparam.rwywidth,FB-90) + p[4]=p[3]:Translate(self.carrierparam.rwylength,FB-180) + local vec2={} + for _,coord in ipairs(p)do + table.insert(vec2,coord:GetVec2()) + end + self.zoneRunwaybox:UpdateFromVec2(vec2) + return self.zoneRunwaybox + end + function AIRBOSS:_GetZoneAbeamLandingSpot() + local S=self:_GetOptLandingCoordinate() + local FB=self:GetFinalBearing(false) + local p={} + p[1]=S:Translate(15,FB):Translate(15,FB+90) + p[2]=S:Translate(-45,FB):Translate(15,FB+90) + p[3]=S:Translate(-45,FB):Translate(15,FB-90) + p[4]=S:Translate(15,FB):Translate(15,FB-90) + local vec2={} + for _,coord in ipairs(p)do + table.insert(vec2,coord:GetVec2()) + end + local zone=ZONE_POLYGON_BASE:New("Abeam Landing Spot Zone",vec2) + return zone + end + function AIRBOSS:_GetZoneLandingSpot() + local S=self:_GetLandingSpotCoordinate() + local FB=self:GetFinalBearing(false) + local p={} + p[1]=S:Translate(10,FB):Translate(10,FB+90) + p[2]=S:Translate(-10,FB):Translate(10,FB+90) + p[3]=S:Translate(-10,FB):Translate(10,FB-90) + p[4]=S:Translate(10,FB):Translate(10,FB-90) + local vec2={} + for _,coord in ipairs(p)do + table.insert(vec2,coord:GetVec2()) + end + local zone=ZONE_POLYGON_BASE:New("Landing Spot Zone",vec2) + return zone + end + function AIRBOSS:_GetZoneHolding(case,stack) + local zoneHolding=nil + if stack<=0 then + self:E(self.lid.."ERROR: Stack <= 0 in _GetZoneHolding!") + self:E({case=case,stack=stack}) + return nil + end + local patternalt,c1,c2=self:_GetMarshalAltitude(stack,case) + if case==1 then + local hdg=self:GetHeading() + local D=UTILS.NMToMeters(2.5) + local Post=self:GetCoordinate():Translate(D,hdg+270) + self.zoneHolding=ZONE_RADIUS:New("CASE I Holding Zone",Post:GetVec2(),self.marshalradius) if self.carriertype==AIRBOSS.CarrierType.INVINCIBLE or self.carriertype==AIRBOSS.CarrierType.HERMES or self.carriertype==AIRBOSS.CarrierType.TARAWA or self.carriertype==AIRBOSS.CarrierType.AMERICA or self.carriertype==AIRBOSS.CarrierType.JCARLOS or self.carriertype==AIRBOSS.CarrierType.CANBERRA then - - if case==3 then - - -- Landing coordinate. - self.landingcoord:UpdateFromCoordinate(self:_GetLandingSpotCoordinate()) - - -- Altitude 120ft -- is this corect for Case III? - self.landingcoord:SetAltitude(UTILS.FeetToMeters(120)) - - elseif case==2 or case==1 then - - -- Landing 100 ft abeam, 120 ft alt. - self.landingcoord:UpdateFromCoordinate(self:_GetLandingSpotCoordinate()):Translate(35, FB-90, true, true) - - -- Alitude 120 ft. - self.landingcoord:SetAltitude(UTILS.FeetToMeters(120)) - - end - + self.zoneHolding=ZONE_RADIUS:New("CASE I Holding Zone",self.carrier:GetVec2(),UTILS.NMToMeters(5)) + end else - - -- Ideally we want to land between 2nd and 3rd wire. - if self.carrierparam.wire3 then - -- We take the position of the 3rd wire to approximately account for the length of the aircraft. - self.landingcoord:Translate( self.carrierparam.wire3, FB, true, true ) - end - - -- Add 2 meters to account for aircraft height. - self.landingcoord.y = self.landingcoord.y + 2 - + local radial=self:GetRadial(case,false,true) + local p={} + p[1]=c2:Translate(UTILS.NMToMeters(1),radial-90):GetVec2() + p[2]=c1:Translate(UTILS.NMToMeters(1),radial-90):GetVec2() + p[3]=c1:Translate(UTILS.NMToMeters(7),radial+90):GetVec2() + p[4]=c2:Translate(UTILS.NMToMeters(7),radial+90):GetVec2() + self.zoneHolding=self.zoneHolding or ZONE_POLYGON_BASE:New("CASE II/III Holding Zone") + self.zoneHolding:UpdateFromVec2(p) + end + return self.zoneHolding + end + function AIRBOSS:_GetZoneCommence(case,stack) + local zone + if case==1 then + local hdg=self:GetHeading() + local D=UTILS.NMToMeters(4.75) + local R=UTILS.NMToMeters(1) + local Three=self:GetCoordinate():Translate(D,hdg+275) + if self.carriertype==AIRBOSS.CarrierType.INVINCIBLE or self.carriertype==AIRBOSS.CarrierType.HERMES or self.carriertype==AIRBOSS.CarrierType.TARAWA or self.carriertype==AIRBOSS.CarrierType.AMERICA or self.carriertype==AIRBOSS.CarrierType.JCARLOS or self.carriertype==AIRBOSS.CarrierType.CANBERRA then + local Dx=UTILS.NMToMeters(2.25) + local Dz=UTILS.NMToMeters(2.25) + R=UTILS.NMToMeters(1) + Three=self:GetCoordinate():Translate(Dz,hdg-90):Translate(Dx,hdg-180) + end + self.zoneCommence=self.zoneCommence or ZONE_RADIUS:New("CASE I Commence Zone") + self.zoneCommence:UpdateFromVec2(Three:GetVec2(),R) + else + stack=stack or 1 + local l=20+stack + local offset=self:GetRadial(case,false,true) + local cv=self:GetCoordinate() + local c={} + c[1]=cv:Translate(UTILS.NMToMeters(l),offset):Translate(UTILS.NMToMeters(1),offset-90) + c[2]=cv:Translate(UTILS.NMToMeters(l+2.5),offset):Translate(UTILS.NMToMeters(1),offset-90) + c[3]=cv:Translate(UTILS.NMToMeters(l+2.5),offset):Translate(UTILS.NMToMeters(1),offset+90) + c[4]=cv:Translate(UTILS.NMToMeters(l),offset):Translate(UTILS.NMToMeters(1),offset+90) + local p={} + for _i,_c in ipairs(c)do + p[_i]=_c:GetVec2() + end + self.zoneCommence=self.zoneCommence or ZONE_POLYGON_BASE:New("CASE II/III Commence Zone") + self.zoneCommence:UpdateFromVec2(p) + end + return self.zoneCommence + end + function AIRBOSS:_AttitudeMonitor(playerData) + local unit=playerData.unit + local aoa=unit:GetAoA() + local yaw=unit:GetYaw() + local roll=unit:GetRoll() + local pitch=unit:GetPitch() + local dist=playerData.unit:GetCoordinate():Get2DDistance(self:GetCoordinate()) + local dx,dz,rho,phi=self:_GetDistances(unit) + local wind=unit:GetCoordinate():GetWindWithTurbulenceVec3() + local velo=unit:GetVelocityVec3() + local vabs=UTILS.VecNorm(velo) + local rwy=false + local step=playerData.step + if playerData.step==AIRBOSS.PatternStep.FINAL or + playerData.step==AIRBOSS.PatternStep.GROOVE_XX or + playerData.step==AIRBOSS.PatternStep.GROOVE_IM or + playerData.step==AIRBOSS.PatternStep.GROOVE_IC or + playerData.step==AIRBOSS.PatternStep.GROOVE_AR or + playerData.step==AIRBOSS.PatternStep.GROOVE_AL or + playerData.step==AIRBOSS.PatternStep.GROOVE_LC or + playerData.step==AIRBOSS.PatternStep.GROOVE_IW then + step=self:_GS(step,-1) + rwy=true + end + local relhead=self:_GetRelativeHeading(playerData.unit,rwy) + -- local text=string.format("Pattern step: %s",step) + local text=string.format("降落阶段: %s",step) + -- text=text..string.format("\nAoA=%.1f° = %.1f Units | |V|=%.1f knots",aoa,self:_AoADeg2Units(playerData,aoa),UTILS.MpsToKnots(vabs)) + text=text..string.format("\nAoA=%.1f° = %.1f 单位 | |V|=%.1f 节",aoa,self:_AoADeg2Units(playerData,aoa),UTILS.MpsToKnots(vabs)) + if self.Debug then + text=text..string.format("\nVx=%.1f Vy=%.1f Vz=%.1f m/s",velo.x,velo.y,velo.z) + text=text..string.format("\nWind Vx=%.1f Vy=%.1f Vz=%.1f m/s",wind.x,wind.y,wind.z) + end + -- text=text..string.format("\nPitch=%.1f° | Roll=%.1f° | Yaw=%.1f°",pitch,roll,yaw) + -- text=text..string.format("\nClimb Angle=%.1f° | Rate=%d ft/min",unit:GetClimbAngle(),velo.y*196.85) + text=text..string.format("\n俯仰=%.1f° | 滚转=%.1f° | 偏航=%.1f°",pitch,roll,yaw) + text=text..string.format("\n爬升角=%.1f° | 速率=%d ft/min",unit:GetClimbAngle(),velo.y*196.85) + local dist=self:_GetOptLandingCoordinate():Get3DDistance(playerData.unit:GetVec3()) + local vplayer=playerData.unit:GetVelocityKMH() + local vcarrier=self.carrier:GetVelocityKMH() + local dv=math.abs(vplayer-vcarrier) + local alt=self:_GetAltCarrier(playerData.unit) + -- text=text..string.format("\nDist=%.1f m Alt=%.1f m delta|V|=%.1f km/h",dist,alt,dv) + text=text..string.format("\n距离=%.1f m 高度=%.1f m delta|V|=%.1f km/h",dist,alt,dv) + if playerData.step==AIRBOSS.PatternStep.FINAL or + playerData.step==AIRBOSS.PatternStep.GROOVE_XX or + playerData.step==AIRBOSS.PatternStep.GROOVE_IM or + playerData.step==AIRBOSS.PatternStep.GROOVE_IC or + playerData.step==AIRBOSS.PatternStep.GROOVE_AR or + playerData.step==AIRBOSS.PatternStep.GROOVE_AL or + playerData.step==AIRBOSS.PatternStep.GROOVE_LC or + playerData.step==AIRBOSS.PatternStep.GROOVE_IW then + local lue=self:_Lineup(playerData.unit,true) + local gle=self:_Glideslope(playerData.unit) + -- text=text..string.format("\nGamma=%.1f° | Rho=%.1f°",relhead,phi) + -- text=text..string.format("\nLineUp=%.2f° | GlideSlope=%.2f° | AoA=%.1f Units",lue,gle,self:_AoADeg2Units(playerData,aoa)) + text=text..string.format("\nGamma=%.1f° | Rho=%.1f°",relhead,phi) + text=text..string.format("\n对齐=%.2f° | 下滑道=%.2f° | AoA=%.1f 单位",lue,gle,self:_AoADeg2Units(playerData,aoa)) + local grade,points,analysis=self:_LSOgrade(playerData) + -- text=text..string.format("\nTgroove=%.1f sec",self:_GetTimeInGroove(playerData)) + -- text=text..string.format("\nGrade: %s %.1f PT - %s",grade,points,analysis) + text=text..string.format("\n第五边(groove)时间=%.1f 秒",self:_GetTimeInGroove(playerData)) + text=text..string.format("\n成绩: %s %.1f PT - %s",grade,points,analysis) + else + -- text=text..string.format("\nR=%.2f NM | X=%d Z=%d m",UTILS.MetersToNM(rho),dx,dz) + -- text=text..string.format("\nGamma=%.1f° | Rho=%.1f°",relhead,phi) + text=text..string.format("\nR=%.2f NM | X=%d Z=%d m",UTILS.MetersToNM(rho),dx,dz) + text=text..string.format("\nGamma=%.1f° | Rho=%.1f°",relhead,phi) + end + MESSAGE:New(text,1,nil,true):ToClient(playerData.client) + end + function AIRBOSS:_Glideslope(unit,optangle) + if optangle==nil then + if unit:GetTypeName()==AIRBOSS.AircraftCarrier.AV8B then + optangle=3.0 + else + optangle=3.5 + end + end + local landingcoord=self:_GetOptLandingCoordinate() + local x=unit:GetCoordinate():Get2DDistance(landingcoord) + local h=self:_GetAltCarrier(unit) + if unit:GetTypeName()==AIRBOSS.AircraftCarrier.AV8B then + h=unit:GetAltitude()-(UTILS.FeetToMeters(50)+self.carrierparam.deckheight+2) + end + local glideslope=math.atan(h/x) + local gs=math.deg(glideslope)-optangle + return gs + end + function AIRBOSS:_Glideslope2(unit,optangle) + if optangle==nil then + if unit:GetTypeName()==AIRBOSS.AircraftCarrier.AV8B then + optangle=3.0 + else + optangle=3.5 + end + end + local landingcoord=self:_GetOptLandingCoordinate() + local x=unit:GetCoordinate():Get3DDistance(landingcoord) + local h=self:_GetAltCarrier(unit) + if unit:GetTypeName()==AIRBOSS.AircraftCarrier.AV8B then + h=unit:GetAltitude()-(UTILS.FeetToMeters(50)+self.carrierparam.deckheight+2) + end + local glideslope=math.asin(h/x) + local gs=math.deg(glideslope)-optangle + self:T3(self.lid..string.format("Glide slope error = %.1f, x=%.1f h=%.1f",gs,x,h)) + return gs + end + function AIRBOSS:_Lineup(unit,runway) + local landingcoord=self:_GetOptLandingCoordinate() + local A=landingcoord:GetVec3() + local B=unit:GetVec3() + local C=UTILS.VecSubstract(A,B) + C.y=0.0 + local X=self.carrier:GetOrientationX() + X.y=0.0 + if runway then + X=UTILS.Rotate2D(X,-self.carrierparam.rwyangle) + end + local x=UTILS.VecDot(X,C) + local Z=self.carrier:GetOrientationZ() + Z.y=0.0 + if runway then + Z=UTILS.Rotate2D(Z,-self.carrierparam.rwyangle) + end + local z=UTILS.VecDot(Z,C) + local lineup=math.deg(math.atan2(z,x)) + return lineup + end + function AIRBOSS:_GetAltCarrier(unit) + local h=unit:GetAltitude()-self.carrierparam.deckheight-2 + return h + end + function AIRBOSS:_GetOptLandingCoordinate() + self.landingcoord:UpdateFromCoordinate(self:_GetSternCoord()) + local FB=self:GetFinalBearing(false) + local case=self.case + if self.carriertype==AIRBOSS.CarrierType.INVINCIBLE or self.carriertype==AIRBOSS.CarrierType.HERMES or self.carriertype==AIRBOSS.CarrierType.TARAWA or self.carriertype==AIRBOSS.CarrierType.AMERICA or self.carriertype==AIRBOSS.CarrierType.JCARLOS or self.carriertype==AIRBOSS.CarrierType.CANBERRA then + if case==3 then + self.landingcoord:UpdateFromCoordinate(self:_GetLandingSpotCoordinate()) + self.landingcoord:SetAltitude(UTILS.FeetToMeters(120)) + elseif case==2 or case==1 then + self.landingcoord:UpdateFromCoordinate(self:_GetLandingSpotCoordinate()):Translate(35,FB-90,true,true) + self.landingcoord:SetAltitude(UTILS.FeetToMeters(120)) + end + else + if self.carrierparam.wire3 then + self.landingcoord:Translate(self.carrierparam.wire3,FB,true,true) + end + self.landingcoord.y=self.landingcoord.y+2 end - return self.landingcoord -end - ---- Get landing spot on Tarawa and others. --- @param #AIRBOSS self --- @return Core.Point#COORDINATE Primary landing spot coordinate. -function AIRBOSS:_GetLandingSpotCoordinate() - - -- Start at stern coordinate. - self.landingspotcoord:UpdateFromCoordinate( self:_GetSternCoord() ) - - -- Landing 100 ft abeam, 100 alt. - local hdg = self:GetHeading() - - -- Primary landing spot. Different carriers handled via carrier parameter landingspot now. - self.landingspotcoord:Translate( self.carrierparam.landingspot, hdg, true, true ):SetAltitude( self.carrierparam.deckheight ) - + end + function AIRBOSS:_GetLandingSpotCoordinate() + self.landingspotcoord:UpdateFromCoordinate(self:_GetSternCoord()) + local hdg=self:GetHeading() + self.landingspotcoord:Translate(self.carrierparam.landingspot,hdg,true,true):SetAltitude(self.carrierparam.deckheight) return self.landingspotcoord -end - ---- Get true (or magnetic) heading of carrier. --- @param #AIRBOSS self --- @param #boolean magnetic If true, calculate magnetic heading. By default true heading is returned. --- @return #number Carrier heading in degrees. -function AIRBOSS:GetHeading( magnetic ) - self:F3( { magnetic = magnetic } ) - - -- Carrier heading - local hdg = self.carrier:GetHeading() - - -- Include magnetic declination. + end + function AIRBOSS:GetHeading(magnetic) + self:F3({magnetic=magnetic}) + local hdg=self.carrier:GetHeading() if magnetic then - hdg = hdg - self.magvar + hdg=hdg-self.magvar end - - -- Adjust negative values. - if hdg < 0 then - hdg = hdg + 360 + if hdg<0 then + hdg=hdg+360 end - return hdg -end - ---- Get base recovery course (BRC) of carrier. --- The is the magnetic heading of the carrier. --- @param #AIRBOSS self --- @return #number BRC in degrees. -function AIRBOSS:GetBRC() - return self:GetHeading( true ) -end - ---- Get wind direction and speed at carrier position. --- @param #AIRBOSS self --- @param #number alt Altitude ASL in meters. Default 15 m. --- @param #boolean magnetic Direction including magnetic declination. --- @param Core.Point#COORDINATE coord (Optional) Coordinate at which to get the wind. Default is current carrier position. --- @return #number Direction the wind is blowing **from** in degrees. --- @return #number Wind speed in m/s. -function AIRBOSS:GetWind( alt, magnetic, coord ) - - -- Current position of the carrier or input. - local cv = coord or self:GetCoordinate() - - -- Wind direction and speed. By default at 18 meters ASL. - local Wdir, Wspeed = cv:GetWind( alt or 18 ) - - -- Include magnetic declination. - if magnetic then - Wdir = Wdir - self.magvar - -- Adjust negative values. - if Wdir < 0 then - Wdir = Wdir + 360 - end end - - return Wdir, Wspeed -end - ---- Get wind speed on carrier deck parallel and perpendicular to runway. --- @param #AIRBOSS self --- @param #number alt Altitude in meters. Default 18 m. --- @return #number Wind component parallel to runway im m/s. --- @return #number Wind component perpendicular to runway in m/s. --- @return #number Total wind strength in m/s. -function AIRBOSS:GetWindOnDeck( alt ) - - -- Position of carrier. - local cv = self:GetCoordinate() - - -- Velocity vector of carrier. - local vc = self.carrier:GetVelocityVec3() - - -- Carrier orientation X. - local xc = self.carrier:GetOrientationX() - - -- Carrier orientation Z. - local zc = self.carrier:GetOrientationZ() - - -- Rotate back so that angled deck points to wind. - xc = UTILS.Rotate2D( xc, -self.carrierparam.rwyangle ) - zc = UTILS.Rotate2D( zc, -self.carrierparam.rwyangle ) - - -- Wind (from) vector - local vw = cv:GetWindWithTurbulenceVec3( alt or 18 ) --(change made from 50m to 15m from Discord discussion from Sickdog, next change to 18m due to SC higher deck discord) - - -- Total wind velocity vector. - -- Carrier velocity has to be negative. If carrier drives in the direction the wind is blowing from, we have less wind in total. - local vT = UTILS.VecSubstract( vw, vc ) - - -- || Parallel component. - local vpa = UTILS.VecDot( vT, xc ) - - -- == Perpendicular component. - local vpp = UTILS.VecDot( vT, zc ) - - -- Strength. - local vabs = UTILS.VecNorm( vT ) - - -- We return positive values as head wind and negative values as tail wind. - -- TODO: Check minus sign. - return -vpa, vpp, vabs -end - ---- Get true (or magnetic) heading of carrier into the wind. This accounts for the angled runway. --- @param #AIRBOSS self --- @param #boolean magnetic If true, calculate magnetic heading. By default true heading is returned. --- @param Core.Point#COORDINATE coord (Optional) Coordinate from which heading is calculated. Default is current carrier position. --- @return #number Carrier heading in degrees. -function AIRBOSS:GetHeadingIntoWind_old( magnetic, coord ) - + function AIRBOSS:GetBRC() + return self:GetHeading(true) + end + function AIRBOSS:GetWind(alt,magnetic,coord) + local cv=coord or self:GetCoordinate() + local Wdir,Wspeed=cv:GetWind(alt or 18) + if magnetic then + Wdir=Wdir-self.magvar + if Wdir<0 then + Wdir=Wdir+360 + end + end + return Wdir,Wspeed + end + function AIRBOSS:GetWindOnDeck(alt) + local cv=self:GetCoordinate() + local vc=self.carrier:GetVelocityVec3() + local xc=self.carrier:GetOrientationX() + local zc=self.carrier:GetOrientationZ() + xc=UTILS.Rotate2D(xc,-self.carrierparam.rwyangle) + zc=UTILS.Rotate2D(zc,-self.carrierparam.rwyangle) + local vw=cv:GetWindWithTurbulenceVec3(alt or 18) + local vT=UTILS.VecSubstract(vw,vc) + local vpa=UTILS.VecDot(vT,xc) + local vpp=UTILS.VecDot(vT,zc) + local vabs=UTILS.VecNorm(vT) + return-vpa,vpp,vabs + end + function AIRBOSS:GetHeadingIntoWind(vdeck,magnetic,coord) + if self.intowindold then + return self:GetHeadingIntoWind_old(vdeck,magnetic,coord) + else + return self:GetHeadingIntoWind_new(vdeck,magnetic,coord) + end + end + function AIRBOSS:GetHeadingIntoWind_old(vdeck,magnetic,coord) local function adjustDegreesForWindSpeed(windSpeed) - local degreesAdjustment = 0 - -- the windspeeds are in m/s - - -- +0 degrees at 15m/s = 37kts - -- +0 degrees at 14m/s = 35kts - -- +0 degrees at 13m/s = 33kts - -- +4 degrees at 12m/s = 31kts - -- +4 degrees at 11m/s = 29kts - -- +4 degrees at 10m/s = 27kts - -- +4 degrees at 9m/s = 27kts - -- +4 degrees at 8m/s = 27kts - -- +8 degrees at 7m/s = 27kts - -- +8 degrees at 6m/s = 27kts - -- +8 degrees at 5m/s = 26kts - -- +20 degrees at 4m/s = 26kts - -- +20 degrees at 3m/s = 26kts - -- +30 degrees at 2m/s = 26kts 1s - - if windSpeed > 0 and windSpeed < 3 then - degreesAdjustment = 30 - elseif windSpeed >= 3 and windSpeed < 5 then - degreesAdjustment = 20 - elseif windSpeed >= 5 and windSpeed < 8 then - degreesAdjustment = 8 - elseif windSpeed >= 8 and windSpeed < 13 then - degreesAdjustment = 4 - elseif windSpeed >= 13 then - degreesAdjustment = 0 - end - - return degreesAdjustment + local degreesAdjustment=0 + if windSpeed>0 and windSpeed<3 then + degreesAdjustment=30 + elseif windSpeed>=3 and windSpeed<5 then + degreesAdjustment=20 + elseif windSpeed>=5 and windSpeed<8 then + degreesAdjustment=8 + elseif windSpeed>=8 and windSpeed<13 then + degreesAdjustment=4 + elseif windSpeed>=13 then + degreesAdjustment=0 end - - -- Get direction the wind is blowing from. This is where we want to go. - local windfrom, vwind = self:GetWind( nil, nil, coord ) - - -- Actually, we want the runway in the wind. - local intowind = windfrom - self.carrierparam.rwyangle + adjustDegreesForWindSpeed(vwind) - - -- If no wind, take current heading. - if vwind < 0.1 then - intowind = self:GetHeading() + return degreesAdjustment + end + local windfrom,vwind=self:GetWind(nil,nil,coord) + local intowind=windfrom-self.carrierparam.rwyangle+adjustDegreesForWindSpeed(vwind) + if vwind<0.1 then + intowind=self:GetHeading() end - - -- Magnetic heading. if magnetic then - intowind = intowind - self.magvar + intowind=intowind-self.magvar end - - -- Adjust negative values. - if intowind < 0 then - intowind = intowind + 360 + if intowind<0 then + intowind=intowind+360 end - - return intowind -end - ---- Get true (or magnetic) heading of carrier into the wind. This accounts for the angled runway. --- Implementation based on [Mags & Bambi](https://magwo.github.io/carrier-cruise/). --- @param #AIRBOSS self --- @param #number vdeck Desired wind velocity over deck in knots. --- @param #boolean magnetic If true, calculate magnetic heading. By default true heading is returned. --- @param Core.Point#COORDINATE coord (Optional) Coordinate from which heading is calculated. Default is current carrier position. --- @return #number Carrier heading in degrees. --- @return #number Carrier speed in knots to reach desired wind speed on deck. -function AIRBOSS:GetHeadingIntoWind( vdeck, magnetic, coord ) - - -- Default offset angle. + local vtot=math.max(vdeck-UTILS.MpsToKnots(vwind),4) + return intowind,vtot + end + function AIRBOSS:GetHeadingIntoWind_new(vdeck,magnetic,coord) local Offset=self.carrierparam.rwyangle or 0 - - -- Get direction the wind is blowing from. - local windfrom, vwind=self:GetWind(18, nil ,coord) - - -- Ships min/max speed. + local windfrom,vwind=self:GetWind(18,nil,coord) local Vmin=4 local Vmax=UTILS.KmphToKnots(self.carrier:GetSpeedMax()) - - -- No wind. will stay on current heading. if vwind<0.1 then - local h=self:GetHeading(magnetic) - return h, math.min(vdeck, Vmax) + local h=self:GetHeading(magnetic) + return h,math.min(vdeck,Vmax) end - - -- Convert wind speed to knots. vwind=UTILS.MpsToKnots(vwind) - - -- Wind to in knots. local windto=(windfrom+180)%360 - - -- Offset angle in rad. We also define the rotation to be clock-wise, which requires a minus sign. local alpha=math.rad(-Offset) - - -- Constant. - local C = math.sqrt(math.cos(alpha)^2 / math.sin(alpha)^2 + 1) - - - -- Upper limit of desired speed due to max boat speed. - local vdeckMax=vwind + math.cos(alpha) * Vmax - - -- Lower limit of desired speed due to min boat speed. - local vdeckMin=vwind + math.cos(alpha) * Vmin - - - -- Speed of ship so it matches the desired speed. + local C=math.sqrt(math.cos(alpha)^2/math.sin(alpha)^2+1) + local vdeckMax=vwind+math.cos(alpha)*Vmax + local vdeckMin=vwind+math.cos(alpha)*Vmin local v=0 - - -- Angle wrt. to wind TO-direction local theta=0 - if vdeck>vdeckMax then - -- Boat cannot go fast enough - - -- Set max speed. - v=Vmax - - -- Calculate theta. - theta = math.asin(v/(vwind*C)) - math.asin(-1/C) - + v=Vmax + theta=math.asin(v/(vwind*C))-math.asin(-1/C) elseif vdeckvwind then - -- Too little wind - - -- Set theta to 90° - theta=math.pi/2 - - -- Set speed. - v = math.sqrt(vdeck^2 - vwind^2) - + theta=math.pi/2 + v=math.sqrt(vdeck^2-vwind^2) else - -- Normal case - theta = math.asin(vdeck * math.sin(alpha) / vwind) - v = vdeck * math.cos(alpha) - vwind * math.cos(theta) + theta=math.asin(vdeck*math.sin(alpha)/vwind) + v=vdeck*math.cos(alpha)-vwind*math.cos(theta) end - - -- Magnetic heading. - local magvar= magnetic and self.magvar or 0 - - -- Ship heading so cross wind is min for the given wind. - local intowind = (540 + (windto - magvar + math.deg(theta) )) % 360 - - return intowind, v -end - ---- Get base recovery course (BRC) when the carrier would head into the wind. --- This includes the current wind direction and accounts for the angled runway. --- @param #AIRBOSS self --- @param #number vdeck Desired wind velocity over deck in knots. --- @return #number BRC into the wind in degrees. -function AIRBOSS:GetBRCintoWind(vdeck) - -- BRC is the magnetic heading. - return self:GetHeadingIntoWind(vdeck, true ) -end - ---- Get final bearing (FB) of carrier. --- By default, the routine returns the magnetic FB depending on the current map (Caucasus, NTTR, Normandy, Persion Gulf etc). --- The true bearing can be obtained by setting the *TrueNorth* parameter to true. --- @param #AIRBOSS self --- @param #boolean magnetic If true, magnetic FB is returned. --- @return #number FB in degrees. -function AIRBOSS:GetFinalBearing( magnetic ) - - -- First get the heading. - local fb = self:GetHeading( magnetic ) - - -- Final baring = BRC including angled deck. - fb = fb + self.carrierparam.rwyangle - - -- Adjust negative values. - if fb < 0 then - fb = fb + 360 + local magvar=magnetic and self.magvar or 0 + local intowind=(540+(windto-magvar+math.deg(theta)))%360 + return intowind,v + end + function AIRBOSS:GetBRCintoWind(vdeck) + return self:GetHeadingIntoWind(vdeck,true) + end + function AIRBOSS:GetFinalBearing(magnetic) + local fb=self:GetHeading(magnetic) + fb=fb+self.carrierparam.rwyangle + if fb<0 then + fb=fb+360 end - return fb -end - ---- Get radial with respect to carrier BRC or FB and (optionally) holding offset. --- --- * case=1: radial=FB-180 --- * case=2: radial=HDG-180 (+offset) --- * case=3: radial=FB-180 (+offset) --- --- @param #AIRBOSS self --- @param #number case Recovery case. --- @param #boolean magnetic If true, magnetic radial is returned. Default is true radial. --- @param #boolean offset If true, inlcude holding offset. --- @param #boolean inverse Return inverse, i.e. radial-180 degrees. --- @return #number Radial in degrees. -function AIRBOSS:GetRadial( case, magnetic, offset, inverse ) - - -- Case or current case. - case = case or self.case - - -- Radial. + end + function AIRBOSS:GetRadial(case,magnetic,offset,inverse) + case=case or self.case local radial - - -- Select case. - if case == 1 then - - -- Get radial. - radial = self:GetFinalBearing( magnetic ) - 180 - - elseif case == 2 then - - -- Radial wrt to heading of carrier. - radial = self:GetHeading( magnetic ) - 180 - - -- Holding offset angle (+-15 or 30 degrees usually) - if offset then - radial = radial + self.holdingoffset - end - - elseif case == 3 then - - -- Radial wrt angled runway. - radial = self:GetFinalBearing( magnetic ) - 180 - - -- Holding offset angle (+-15 or 30 degrees usually) - if offset then - radial = radial + self.holdingoffset - end - + if case==1 then + radial=self:GetFinalBearing(magnetic)-180 + elseif case==2 then + radial=self:GetHeading(magnetic)-180 + if offset then + radial=radial+self.holdingoffset end - - -- Adjust for negative values. - if radial < 0 then - radial = radial + 360 + elseif case==3 then + radial=self:GetFinalBearing(magnetic)-180 + if offset then + radial=radial+self.holdingoffset + end + end + if radial<0 then + radial=radial+360 end - - -- Inverse? if inverse then - - -- Inverse radial - radial = radial - 180 - - -- Adjust for negative values. - if radial < 0 then - radial = radial + 360 - end - + radial=radial-180 + if radial<0 then + radial=radial+360 + end end - return radial -end - ---- Get difference between to headings in degrees taking into accound the [0,360) periodocity. --- @param #AIRBOSS self --- @param #number hdg1 Heading one. --- @param #number hdg2 Heading two. --- @return #number Difference between the two headings in degrees. -function AIRBOSS:_GetDeltaHeading( hdg1, hdg2 ) - - local V = {} -- DCS#Vec3 - V.x = math.cos( math.rad( hdg1 ) ) - V.y = 0 - V.z = math.sin( math.rad( hdg1 ) ) - - local W = {} -- DCS#Vec3 - W.x = math.cos( math.rad( hdg2 ) ) - W.y = 0 - W.z = math.sin( math.rad( hdg2 ) ) - - local alpha = UTILS.VecAngle( V, W ) - + end + function AIRBOSS:_GetDeltaHeading(hdg1,hdg2) + local V={} + V.x=math.cos(math.rad(hdg1)) + V.y=0 + V.z=math.sin(math.rad(hdg1)) + local W={} + W.x=math.cos(math.rad(hdg2)) + W.y=0 + W.z=math.sin(math.rad(hdg2)) + local alpha=UTILS.VecAngle(V,W) return alpha -end - ---- Get relative heading of player wrt carrier. --- This is the angle between the direction/orientation vector of the carrier and the direction/orientation vector of the provided unit. --- Note that this is calculated in the X-Z plane, i.e. the altitude Y is not taken into account. --- @param #AIRBOSS self --- @param Wrapper.Unit#UNIT unit Player unit. --- @param #boolean runway (Optional) If true, return relative heading of unit wrt to angled runway of the carrier. --- @return #number Relative heading in degrees. An angle of 0 means, unit fly parallel to carrier. An angle of + or - 90 degrees means, unit flies perpendicular to carrier. -function AIRBOSS:_GetRelativeHeading( unit, runway ) - - -- Direction vector of the carrier. - local vC = self.carrier:GetOrientationX() - - -- Include runway angle. + end + function AIRBOSS:_GetRelativeHeading(unit,runway) + local vC=self.carrier:GetOrientationX() if runway then - vC = UTILS.Rotate2D( vC, -self.carrierparam.rwyangle ) + vC=UTILS.Rotate2D(vC,-self.carrierparam.rwyangle) end - - -- Direction vector of the unit. - local vP = unit:GetOrientationX() - - -- We only want the X-Z plane. Aircraft could fly parallel but ballistic and we dont want the "pitch" angle. - vC.y = 0; - vP.y = 0 - - -- Get angle between the two orientation vectors in degrees. - local rhdg = UTILS.VecAngle( vC, vP ) - - -- Return heading in degrees. + local vP=unit:GetOrientationX() + vC.y=0; + vP.y=0 + local rhdg=UTILS.VecAngle(vC,vP) return rhdg -end - ---- Get relative velocity of player unit wrt to carrier --- @param #AIRBOSS self --- @param Wrapper.Unit#UNIT unit Player unit. --- @return #number Relative velocity in m/s. -function AIRBOSS:_GetRelativeVelocity( unit ) - - local vC = self.carrier:GetVelocityVec3() - local vP = unit:GetVelocityVec3() - - -- Only X-Z plane is necessary here. - vC.y = 0; - vP.y = 0 - - local v = UTILS.VecSubstract( vP, vC ) - - return UTILS.VecNorm( v ), v -end - ---- Calculate distances between carrier and aircraft unit. --- @param #AIRBOSS self --- @param Wrapper.Unit#UNIT unit Aircraft unit. --- @return #number Distance [m] in the direction of the orientation of the carrier. --- @return #number Distance [m] perpendicular to the orientation of the carrier. --- @return #number Distance [m] to the carrier. --- @return #number Angle [Deg] from carrier to plane. Phi=0 if the plane is directly behind the carrier, phi=90 if the plane is starboard, phi=180 if the plane is in front of the carrier. -function AIRBOSS:_GetDistances( unit ) - - -- Vector to carrier - local a = self.carrier:GetVec3() - - -- Vector to player - local b = unit:GetVec3() - - -- Vector from carrier to player. - local c = { x = b.x - a.x, y = 0, z = b.z - a.z } - - -- Orientation of carrier. - local x = self.carrier:GetOrientationX() - - -- Projection of player pos on x component. - local dx = UTILS.VecDot( x, c ) - - -- Orientation of carrier. - local z = self.carrier:GetOrientationZ() - - -- Projection of player pos on z component. - local dz = UTILS.VecDot( z, c ) - - -- Polar coordinates. - local rho = math.sqrt( dx * dx + dz * dz ) - - -- Not exactly sure any more what I wanted to calculate here. - local phi = math.deg( math.atan2( dz, dx ) ) - - -- Correct for negative values. - if phi < 0 then - phi = phi + 360 end - - return dx, dz, rho, phi -end - ---- Check limits for reaching next step. --- @param #AIRBOSS self --- @param #number X X position of player unit. --- @param #number Z Z position of player unit. --- @param #AIRBOSS.Checkpoint check Checkpoint. --- @return #boolean If true, checkpoint condition for next step was reached. -function AIRBOSS:_CheckLimits( X, Z, check ) - - -- Limits - local nextXmin = check.LimitXmin == nil or (check.LimitXmin and (check.LimitXmin < 0 and X <= check.LimitXmin or check.LimitXmin >= 0 and X >= check.LimitXmin)) - local nextXmax = check.LimitXmax == nil or (check.LimitXmax and (check.LimitXmax < 0 and X >= check.LimitXmax or check.LimitXmax >= 0 and X <= check.LimitXmax)) - local nextZmin = check.LimitZmin == nil or (check.LimitZmin and (check.LimitZmin < 0 and Z <= check.LimitZmin or check.LimitZmin >= 0 and Z >= check.LimitZmin)) - local nextZmax = check.LimitZmax == nil or (check.LimitZmax and (check.LimitZmax < 0 and Z >= check.LimitZmax or check.LimitZmax >= 0 and Z <= check.LimitZmax)) - - -- Proceed to next step if all conditions are fullfilled. - local next = nextXmin and nextXmax and nextZmin and nextZmax - - -- Debug info. - local text = string.format( "step=%s: next=%s: X=%d Xmin=%s Xmax=%s | Z=%d Zmin=%s Zmax=%s", check.name, tostring( next ), X, tostring( check.LimitXmin ), tostring( check.LimitXmax ), Z, tostring( check.LimitZmin ), tostring( check.LimitZmax ) ) - self:T3( self.lid .. text ) - + function AIRBOSS:_GetRelativeVelocity(unit) + local vC=self.carrier:GetVelocityVec3() + local vP=unit:GetVelocityVec3() + vC.y=0; + vP.y=0 + local v=UTILS.VecSubstract(vP,vC) + return UTILS.VecNorm(v),v + end + function AIRBOSS:_GetDistances(unit) + local a=self.carrier:GetVec3() + local b=unit:GetVec3() + local c={x=b.x-a.x,y=0,z=b.z-a.z} + local x=self.carrier:GetOrientationX() + local dx=UTILS.VecDot(x,c) + local z=self.carrier:GetOrientationZ() + local dz=UTILS.VecDot(z,c) + local rho=math.sqrt(dx*dx+dz*dz) + local phi=math.deg(math.atan2(dz,dx)) + if phi<0 then + phi=phi+360 + end + return dx,dz,rho,phi + end + function AIRBOSS:_CheckLimits(X,Z,check) + local nextXmin=check.LimitXmin==nil or(check.LimitXmin and(check.LimitXmin<0 and X<=check.LimitXmin or check.LimitXmin>=0 and X>=check.LimitXmin)) + local nextXmax=check.LimitXmax==nil or(check.LimitXmax and(check.LimitXmax<0 and X>=check.LimitXmax or check.LimitXmax>=0 and X<=check.LimitXmax)) + local nextZmin=check.LimitZmin==nil or(check.LimitZmin and(check.LimitZmin<0 and Z<=check.LimitZmin or check.LimitZmin>=0 and Z>=check.LimitZmin)) + local nextZmax=check.LimitZmax==nil or(check.LimitZmax and(check.LimitZmax<0 and Z>=check.LimitZmax or check.LimitZmax>=0 and Z<=check.LimitZmax)) + local next=nextXmin and nextXmax and nextZmin and nextZmax + local text=string.format("step=%s: next=%s: X=%d Xmin=%s Xmax=%s | Z=%d Zmin=%s Zmax=%s",check.name,tostring(next),X,tostring(check.LimitXmin),tostring(check.LimitXmax),Z,tostring(check.LimitZmin),tostring(check.LimitZmax)) + self:T3(self.lid..text) return next -end - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- LSO functions -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ---- LSO advice radio call. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. --- @param #number glideslopeError Error in degrees. --- @param #number lineupError Error in degrees. -function AIRBOSS:_LSOadvice( playerData, glideslopeError, lineupError ) - - -- Advice time. - local advice = 0 - - -- Glideslope high/low calls. - if glideslopeError > self.gle.HIGH then -- 1.5 then - -- "You're high!" - self:RadioTransmission( self.LSORadio, self.LSOCall.HIGH, true, nil, nil, true ) - advice = advice + self.LSOCall.HIGH.duration - elseif glideslopeError > self.gle.High then -- 0.8 then - -- "You're high." - self:RadioTransmission( self.LSORadio, self.LSOCall.HIGH, false, nil, nil, true ) - advice = advice + self.LSOCall.HIGH.duration - elseif glideslopeError < self.gle.LOW then -- -0.9 then - -- "Power!" - self:RadioTransmission( self.LSORadio, self.LSOCall.POWER, true, nil, nil, true ) - advice = advice + self.LSOCall.POWER.duration - elseif glideslopeError < self.gle.Low then -- -0.6 then - -- "Power." - self:RadioTransmission( self.LSORadio, self.LSOCall.POWER, false, nil, nil, true ) - advice = advice + self.LSOCall.POWER.duration + end + function AIRBOSS:_LSOadvice(playerData,glideslopeError,lineupError) + local advice=0 + if glideslopeError>self.gle.HIGH then + self:RadioTransmission(self.LSORadio,self.LSOCall.HIGH,true,nil,nil,true) + advice=advice+self.LSOCall.HIGH.duration + elseif glideslopeError>self.gle.High then + self:RadioTransmission(self.LSORadio,self.LSOCall.HIGH,false,nil,nil,true) + advice=advice+self.LSOCall.HIGH.duration + elseif glideslopeError self.lue.RIGHT then -- 3 then - -- "Right for lineup!" - self:RadioTransmission( self.LSORadio, self.LSOCall.RIGHTFORLINEUP, true, nil, nil, true ) - advice = advice + self.LSOCall.RIGHTFORLINEUP.duration - elseif lineupError > self.lue.Right then -- 1 then - -- "Right for lineup." - self:RadioTransmission( self.LSORadio, self.LSOCall.RIGHTFORLINEUP, false, nil, nil, true ) - advice = advice + self.LSOCall.RIGHTFORLINEUP.duration + if lineupErrorself.lue.RIGHT then + self:RadioTransmission(self.LSORadio,self.LSOCall.RIGHTFORLINEUP,true,nil,nil,true) + advice=advice+self.LSOCall.RIGHTFORLINEUP.duration + elseif lineupError>self.lue.Right then + self:RadioTransmission(self.LSORadio,self.LSOCall.RIGHTFORLINEUP,false,nil,nil,true) + advice=advice+self.LSOCall.RIGHTFORLINEUP.duration else - -- "Good lineup." end - - -- Get current AoA. - local AOA = playerData.unit:GetAoA() - - -- Get aircraft AoA parameters. - local acaoa = self:_GetAircraftAoA( playerData ) - - -- Speed via AoA - not for the Harrier. - if playerData.actype ~= AIRBOSS.AircraftCarrier.AV8B then - if AOA > acaoa.SLOW then - -- "Your're slow!" - self:RadioTransmission( self.LSORadio, self.LSOCall.SLOW, true, nil, nil, true ) - advice = advice + self.LSOCall.SLOW.duration - -- S=underline("SLO") - elseif AOA > acaoa.Slow then - -- "Your're slow." - self:RadioTransmission( self.LSORadio, self.LSOCall.SLOW, false, nil, nil, true ) - advice = advice + self.LSOCall.SLOW.duration - -- S="SLO" - elseif AOA > acaoa.OnSpeedMax then - -- No call. - -- S=little("SLO") - elseif AOA < acaoa.FAST then - -- "You're fast!" - self:RadioTransmission( self.LSORadio, self.LSOCall.FAST, true, nil, nil, true ) - advice = advice + self.LSOCall.FAST.duration - -- S=underline("F") - elseif AOA < acaoa.Fast then - -- "You're fast." - self:RadioTransmission( self.LSORadio, self.LSOCall.FAST, false, nil, nil, true ) - advice = advice + self.LSOCall.FAST.duration - -- S="F" - elseif AOA < acaoa.OnSpeedMin then - -- No Call. - -- S=little("F") - end + local AOA=playerData.unit:GetAoA() + local acaoa=self:_GetAircraftAoA(playerData) + if playerData.actype~=AIRBOSS.AircraftCarrier.AV8B then + if AOA>acaoa.SLOW then + self:RadioTransmission(self.LSORadio,self.LSOCall.SLOW,true,nil,nil,true) + advice=advice+self.LSOCall.SLOW.duration + elseif AOA>acaoa.Slow then + self:RadioTransmission(self.LSORadio,self.LSOCall.SLOW,false,nil,nil,true) + advice=advice+self.LSOCall.SLOW.duration + elseif AOA>acaoa.OnSpeedMax then + elseif AOA 24 seconds: No Grade "--" --- --- If you manage to be between 16.4 and and 16.6 seconds, you will even get and okay underline "\_OK\_". --- No groove time for Harrier on LHA, LHD set to Tgroove Unicorn as starting point to allow possible _OK_ 5.0. --- --- If time in the AV-8B --- --- * < 55 seconds: Fast V/STOL --- * < 75 seconds: OK V/STOL --- * > 76 Seconds: SLOW V/STOL (Early hover stop selection) --- --- If you manage to be between 60.0 and 65.0 seconds in the AV-8B, you will even get and okay underline "\_OK\_" --- --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. --- @return #string LSO grade for time in groove, i.e. \_OK\_, OK, (OK), --. -function AIRBOSS:_EvalGrooveTime( playerData ) - - -- Time in groove. - local t = playerData.Tgroove - - local grade = "" - if t < 9 then - grade = "_NESA_" - elseif t < 15 then - grade = "NESA" - elseif t < 19 then - grade = "OK Groove" - elseif t <= 24 then - grade = "(LIG)" - -- Time in groove for AV-8B - elseif playerData.actype == AIRBOSS.AircraftCarrier.AV8B and t < 55 then -- VSTOL Late Hover stop selection too fast to Abeam LDG Spot AV-8B. - grade = "FAST V/STOL Groove" - elseif playerData.actype == AIRBOSS.AircraftCarrier.AV8B and t < 75 then -- VSTOL Operations with AV-8B. - grade = "OK V/STOL Groove" - elseif playerData.actype == AIRBOSS.AircraftCarrier.AV8B and t >= 76 then -- VSTOL Early Hover stop selection slow to Abeam LDG Spot AV-8B. - grade = "SLOW V/STOL Groove" + end + playerData.Tlso=timer.getTime() + end + function AIRBOSS:_EvalGrooveTime(playerData) + local t=playerData.Tgroove + local grade="" + if t<9 then + grade="_NESA_" + elseif t<15 then + grade="NESA" + elseif t<19 then + grade="OK Groove" + elseif t<=24 then + grade="(LIG)" + elseif playerData.actype==AIRBOSS.AircraftCarrier.AV8B and t<55 then + grade="FAST V/STOL Groove" + elseif playerData.actype==AIRBOSS.AircraftCarrier.AV8B and t<75 then + grade="OK V/STOL Groove" + elseif playerData.actype==AIRBOSS.AircraftCarrier.AV8B and t>=76 then + grade="SLOW V/STOL Groove" else - grade = "LIG" + grade="LIG" end - - -- The unicorn! - if t >= 16.4 and t <= 16.6 then - grade = "_OK_" + if t>=16.4 and t<=16.6 then + grade="_OK_" end - - -- V/STOL Unicorn! - if playerData.actype == AIRBOSS.AircraftCarrier.AV8B and (t >= 60.0 and t <= 65.0) then - grade = "_OK_ V/STOL" + if playerData.actype==AIRBOSS.AircraftCarrier.AV8B and(t>=60.0 and t<=65.0)then + grade="_OK_ V/STOL" end - return grade -end - ---- Grade approach. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. --- @return #string LSO grade, i.g. _OK_, OK, (OK), --, etc. --- @return #number Points. --- @return #string LSO analysis of flight path. -function AIRBOSS:_LSOgrade( playerData ) - - --- Count deviations. - local function count( base, pattern ) - return select( 2, string.gsub( base, pattern, "" ) ) end - - -- Analyse flight data and convert to LSO text. - local GXX, nXX = self:_Flightdata2Text( playerData, AIRBOSS.GroovePos.XX ) - local GIM, nIM = self:_Flightdata2Text( playerData, AIRBOSS.GroovePos.IM ) - local GIC, nIC = self:_Flightdata2Text( playerData, AIRBOSS.GroovePos.IC ) - local GAR, nAR = self:_Flightdata2Text( playerData, AIRBOSS.GroovePos.AR ) - - -- VTOL approach, which is graded differently (currently only Harrier). + function AIRBOSS:_LSOgrade(playerData) + local function count(base,pattern) + return select(2,string.gsub(base,pattern,"")) + end + local GXX,nXX=self:_Flightdata2Text(playerData,AIRBOSS.GroovePos.XX) + local GIM,nIM=self:_Flightdata2Text(playerData,AIRBOSS.GroovePos.IM) + local GIC,nIC=self:_Flightdata2Text(playerData,AIRBOSS.GroovePos.IC) + local GAR,nAR=self:_Flightdata2Text(playerData,AIRBOSS.GroovePos.AR) local vtol=playerData.actype==AIRBOSS.AircraftCarrier.AV8B - - -- Put everything together. - local G = GXX .. " " .. GIM .. " " .. " " .. GIC .. " " .. GAR - - -- Count number of minor/small nS, normal nN and major/large deviations nL. + local G=GXX.." "..GIM.." ".." "..GIC.." "..GAR local N=nXX+nIM+nIC+nAR - local nL=count(G, '_')/2 - local nS=count(G, '%(') + local nL=count(G,'_')/2 + local nS=count(G,'%(') local nN=N-nS-nL - - - -- Groove time 15-18.99 sec for a unicorn. Or 60-65 for V/STOL unicorn. local Tgroove=playerData.Tgroove - local TgrooveUnicorn=Tgroove and (Tgroove>=15.0 and Tgroove<=18.99) or false - local TgrooveVstolUnicorn=Tgroove and (Tgroove>=60.0 and Tgroove<=65.0)and playerData.actype==AIRBOSS.AircraftCarrier.AV8B or false - + local TgrooveUnicorn=Tgroove and(Tgroove>=15.0 and Tgroove<=18.99)or false + local TgrooveVstolUnicorn=Tgroove and(Tgroove>=60.0 and Tgroove<=65.0)and playerData.actype==AIRBOSS.AircraftCarrier.AV8B or false local grade local points - if N == 0 and (TgrooveUnicorn or TgrooveVstolUnicorn or playerData.case==3) then - -- No deviations, should be REALLY RARE! - grade = "_OK_" - points = 5.0 - G = "Unicorn" + if N==0 and(TgrooveUnicorn or TgrooveVstolUnicorn or playerData.case==3)then + grade="_OK_" + points=5.0 + G="Unicorn" else - - if vtol then - - -- Add AV-8B Harrier devation allowances due to lower groundspeed and 3x conventional groove time, this allows to maintain LSO tolerances while respecting the deviations are not unsafe.--Pene testing - -- Large devaitions still result in a No Grade, A Unicorn still requires a clean pass with no deviation. - - -- Normal laning part at the beginning - local Gb = GXX .. " " .. GIM - - -- Number of deviations that occurred at the the beginning of the landing (XX or IM). These are graded like in non-VTOL landings, i.e. on deviations is - local N=nXX+nIM - local nL=count(Gb, '_')/2 - local nS=count(Gb, '%(') - local nN=N-nS-nL - - - -- VTOL part of the landing - local Gv = GIC .. " " .. GAR - - -- Number of deviations that occurred at the the end (VTOL part) of the landing (IC or AR). - local Nv=nIC+nAR - local nLv=count(Gv, '_')/2 - local nSv=count(Gv, '%(') - local nNv=Nv-nSv-nLv - - if nL>0 or nLv>1 then - -- Larger deviations at XX or IM or at least one larger deviation IC or AR==> "No grade" 2.0 points. - -- In other words, we allow one larger deviation at IC+AR - grade="--" - points=2.0 - elseif nN>0 or nNv>1 or nLv==1 then - -- Average deviations at XX+IM or more than one normal deviation IC or AR ==> "Fair Pass" Pass with average deviations and corrections. - grade="(OK)" - points=3.0 - else - -- Only minor corrections - grade="OK" - points=4.0 - end - - else - - -- This is a normal (non-VTOL) landing. - - if nL > 0 then - -- Larger deviations ==> "No grade" 2.0 points. - grade="--" - points=2.0 - elseif nN> 0 then - -- No larger but average/normal deviations ==> "Fair Pass" Pass with average deviations and corrections. - grade="(OK)" - points=3.0 - else - -- Only minor corrections ==> "Okay pass" 4.0 points. - grade="OK" - points=4.0 - end - - end + if vtol then + local Gb=GXX.." "..GIM + local N=nXX+nIM + local nL=count(Gb,'_')/2 + local nS=count(Gb,'%(') + local nN=N-nS-nL + local Gv=GIC.." "..GAR + local Nv=nIC+nAR + local nLv=count(Gv,'_')/2 + local nSv=count(Gv,'%(') + local nNv=Nv-nSv-nLv + if nL>0 or nLv>1 then + grade="--" + points=2.0 + elseif nN>0 or nNv>1 or nLv==1 then + grade="(OK)" + points=3.0 + else + grade="OK" + points=4.0 end - - -- Replace" )"( and "__" - G = G:gsub( "%)%(", "" ) - G = G:gsub( "__", "" ) - - -- Debug info - local text = "LSO grade:\n" - text = text .. G .. "\n" - text = text .. "Grade = " .. grade .. " points = " .. points .. "\n" - text = text .. "# of total deviations = " .. N .. "\n" - text = text .. "# of large deviations _ = " .. nL .. "\n" - text = text .. "# of normal deviations = " .. nN .. "\n" - text = text .. "# of small deviations ( = " .. nS .. "\n" - self:T2( self.lid .. text ) - - -- Special cases. + else + if nL>0 then + grade="--" + points=2.0 + elseif nN>0 then + grade="(OK)" + points=3.0 + else + grade="OK" + points=4.0 + end + end + end + G=G:gsub("%)%(","") + G=G:gsub("__","") + local text="LSO grade:\n" + text=text..G.."\n" + text=text.."Grade = "..grade.." points = "..points.."\n" + text=text.."# of total deviations = "..N.."\n" + text=text.."# of large deviations _ = "..nL.."\n" + text=text.."# of normal deviations = "..nN.."\n" + text=text.."# of small deviations ( = "..nS.."\n" + self:T2(self.lid..text) if playerData.wop then - --------------------- - -- Pattern Waveoff -- - --------------------- - if playerData.lig then - -- Long In the Groove (LIG). - -- According to Stingers this is a CUT pass and gives 1.0 points. - grade = "WO" - points = 1.0 - G = "LIG" - else - -- Other pattern WO - grade = "WOP" - points = 2.0 - G = "n/a" - end + if playerData.lig then + grade="WO" + points=1.0 + G="LIG" + else + grade="WOP" + points=2.0 + G="n/a" + end elseif playerData.wofd then - ----------------------- - -- Foul Deck Waveoff -- - ----------------------- - if playerData.landed then - -- AIRBOSS wants to talk to you! - grade = "CUT" - points = 0.0 - else - grade = "WOFD" - points = -1.0 - end - G = "n/a" + if playerData.landed then + grade="CUT" + points=0.0 + else + grade="WOFD" + points=-1.0 + end + G="n/a" elseif playerData.owo then - ----------------- - -- Own Waveoff -- - ----------------- - grade = "OWO" - points = 2.0 - if N == 0 then - G = "n/a" - end + grade="OWO" + points=2.0 + if N==0 then + G="n/a" + end elseif playerData.waveoff then - ------------- - -- Waveoff -- - ------------- - if playerData.landed then - -- AIRBOSS wants to talk to you! - grade = "CUT" - points = 0.0 - else - grade = "WO" - points = 1.0 - end + if playerData.landed then + grade="CUT" + points=0.0 + else + grade="WO" + points=1.0 + end elseif playerData.boltered then - -- Bolter - grade = "-- (BOLTER)" - points = 2.5 - - elseif not playerData.hover and playerData.actype == AIRBOSS.AircraftCarrier.AV8B then - ------------------------------- - -- AV-8B not cleared to land -- -- Landing clearence is carrier from LC to Landing - ------------------------------- - if playerData.landed then - -- AIRBOSS wants your balls! - grade = "CUT" - points = 0.0 - end - + grade="-- (BOLTER)" + points=2.5 + elseif not playerData.hover and playerData.actype==AIRBOSS.AircraftCarrier.AV8B then + if playerData.landed then + grade="CUT" + points=0.0 end - return grade, points, G -end - ---- Grade flight data. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. --- @param #string groovestep Step in the groove. --- @param #AIRBOSS.GrooveData fdata Flight data in the groove. --- @return #string LSO grade or empty string if flight data table is nil. --- @return #number Number of deviations from perfect flight path. -function AIRBOSS:_Flightdata2Text( playerData, groovestep ) - - local function little( text ) - return string.format( "(%s)", text ) end - local function underline( text ) - return string.format( "_%s_", text ) + return grade,points,G end - - -- Groove Data. - local fdata = playerData.groove[groovestep] -- #AIRBOSS.GrooveData - - -- No flight data ==> return empty string. - if fdata == nil then - self:T3( self.lid .. "Flight data is nil." ) - return "", 0 + function AIRBOSS:_Flightdata2Text(playerData,groovestep) + local function little(text) + return string.format("(%s)",text) end - - -- Flight data. - local step = fdata.Step - local AOA = fdata.AoA - local GSE = fdata.GSE - local LUE = fdata.LUE - local ROL = fdata.Roll - - -- Aircraft specific AoA values. - local acaoa = self:_GetAircraftAoA( playerData ) - - -- Angled Approach. - local P = nil - if step == AIRBOSS.PatternStep.GROOVE_XX and ROL <= 4.0 and playerData.case < 3 then - if LUE > self.lue.RIGHT then - P = underline( "AA" ) - elseif LUE > self.lue.RightMed then - P = "AA " - elseif LUE > self.lue.Right then - P = little( "AA" ) - end + local function underline(text) + return string.format("_%s_",text) end - - -- Overshoot Start. - local O = nil - if step == AIRBOSS.PatternStep.GROOVE_XX then - if LUE < self.lue.LEFT then - O = underline( "OS" ) - elseif LUE < self.lue.Left then - O = "OS" - elseif LUE < self.lue._min then - O = little( "OS" ) - end + local fdata=playerData.groove[groovestep] + if fdata==nil then + self:T3(self.lid.."Flight data is nil.") + return"",0 end - - -- Speed via AoA. Depends on aircraft type. - local S = nil - if AOA > acaoa.SLOW then - S = underline( "SLO" ) - elseif AOA > acaoa.Slow then - S = "SLO" - elseif AOA > acaoa.OnSpeedMax then - S = little( "SLO" ) - elseif AOA < acaoa.FAST then - S = underline( "F" ) - elseif AOA < acaoa.Fast then - S = "F" - elseif AOA < acaoa.OnSpeedMin then - S = little( "F" ) + local step=fdata.Step + local AOA=fdata.AoA + local GSE=fdata.GSE + local LUE=fdata.LUE + local ROL=fdata.Roll + local acaoa=self:_GetAircraftAoA(playerData) + local P=nil + if step==AIRBOSS.PatternStep.GROOVE_XX and ROL<=4.0 and playerData.case<3 then + if LUE>self.lue.RIGHT then + P=underline("AA") + elseif LUE>self.lue.RightMed then + P="AA " + elseif LUE>self.lue.Right then + P=little("AA") end - - -- Glideslope/altitude. Good [-0.3, 0.4] asymmetric! - local A = nil - if GSE > self.gle.HIGH then - A = underline( "H" ) - elseif GSE > self.gle.High then - A = "H" - elseif GSE > self.gle._max then - A = little( "H" ) - elseif GSE < self.gle.LOW then - A = underline( "LO" ) - elseif GSE < self.gle.Low then - A = "LO" - elseif GSE < self.gle._min then - A = little( "LO" ) end - - -- Line up. XX Step replaced by Overshoot start (OS). Good [-0.5, 0.5] - local D = nil - if LUE > self.lue.RIGHT then - D = underline( "LUL" ) - elseif LUE > self.lue.Right then - D = "LUL" - elseif LUE > self.lue._max then - D = little( "LUL" ) - elseif playerData.case < 3 then - if LUE < self.lue.LEFT and step ~= AIRBOSS.PatternStep.GROOVE_XX then - D = underline( "LUR" ) - elseif LUE < self.lue.Left and step ~= AIRBOSS.PatternStep.GROOVE_XX then - D = "LUR" - elseif LUE < self.lue._min and step ~= AIRBOSS.PatternStep.GROOVE_XX then - D = little( "LUR" ) - end - elseif playerData.case == 3 then - if LUE < self.lue.LEFT then - D = underline( "LUR" ) - elseif LUE < self.lue.Left then - D = "LUR" - elseif LUE < self.lue._min then - D = little( "LUR" ) - end + local O=nil + if step==AIRBOSS.PatternStep.GROOVE_XX then + if LUEacaoa.SLOW then + S=underline("SLO") + elseif AOA>acaoa.Slow then + S="SLO" + elseif AOA>acaoa.OnSpeedMax then + S=little("SLO") + elseif AOAself.gle.HIGH then + A=underline("H") + elseif GSE>self.gle.High then + A="H" + elseif GSE>self.gle._max then + A=little("H") + elseif GSEself.lue.RIGHT then + D=underline("LUL") + elseif LUE>self.lue.Right then + D="LUL" + elseif LUE>self.lue._max then + D=little("LUL") + elseif playerData.case<3 then + if LUE pos.Xmax then - self:T( string.format( "Xmax: X=%d > %d=Xmax", X, pos.Xmax ) ) - abort = true - elseif pos.Zmin and Z < pos.Zmin then - self:T( string.format( "Zmin: Z=%d < %d=Zmin", Z, pos.Zmin ) ) - abort = true - elseif pos.Zmax and Z > pos.Zmax then - self:T( string.format( "Zmax: Z=%d > %d=Zmax", Z, pos.Zmax ) ) - abort = true end - + function AIRBOSS:_CheckAbort(X,Z,pos) + local abort=false + if pos.Xmin and Xpos.Xmax then + self:T(string.format("Xmax: X=%d > %d=Xmax",X,pos.Xmax)) + abort=true + elseif pos.Zmin and Zpos.Zmax then + self:T(string.format("Zmax: Z=%d > %d=Zmax",Z,pos.Zmax)) + abort=true + end return abort -end - ---- Generate a text if a player is too far from where he should be. --- @param #AIRBOSS self --- @param #number X X distance player to carrier. --- @param #number Z Z distance player to carrier. --- @param #AIRBOSS.Checkpoint posData Checkpoint data. -function AIRBOSS:_TooFarOutText( X, Z, posData ) - - -- Intro. - -- local text = "you are too " - local text = "你离航母太 " - - -- X text. - local xtext = nil - if posData.Xmin and X < posData.Xmin then - if posData.Xmin <= 0 then - -- xtext = "far behind " - xtext = "落后 " - else - -- xtext = "close to " - xtext = "接近 " - end - elseif posData.Xmax and X > posData.Xmax then - if posData.Xmax >= 0 then - -- xtext = "far ahead of " - xtext = "超前 " - else - -- xtext = "close to " - xtext = "接近 " - end end - - -- Z text. - local ztext = nil - if posData.Zmin and Z < posData.Zmin then - if posData.Zmin <= 0 then - -- ztext = "far port of " - ztext = "靠左 " - else - -- ztext = "close to " - ztext = "接近 " - end - elseif posData.Zmax and Z > posData.Zmax then - if posData.Zmax >= 0 then - -- ztext = "far starboard of " - ztext = "靠右 " - else - -- ztext = "too close to " - ztext = "接近 " - end + function AIRBOSS:_TooFarOutText(X,Z,posData) + -- local text="you are too " + local text="你太 " + local xtext=nil + if posData.Xmin and XposData.Xmax then + if posData.Xmax>=0 then + -- xtext="far ahead of " + xtext="超前于 " + else + -- xtext="close to " + xtext="靠近 " + end + end + local ztext=nil + if posData.Zmin and ZposData.Zmax then + if posData.Zmax>=0 then + -- ztext="far starboard of " + ztext="右边远处(starboard) " + else + -- ztext="too close to " + ztext="太接近 " + end end - - -- Combine X-Z text. if xtext and ztext then - -- text = text .. xtext .. " and " .. ztext - text = text .. xtext .. " 而且 " .. ztext + -- text=text..xtext.." and "..ztext + text=text..xtext.." 而且 "..ztext elseif xtext then - text = text .. xtext + text=text..xtext elseif ztext then - text = text .. ztext + text=text..ztext end - - -- Complete the sentence - -- text = text .. "the carrier." - text = text .. "了." - - -- If no case could be identified. - if xtext == nil and ztext == nil then - -- text = "you are too far from where you should be!" - text = "你离你该在的位置太远了!" + -- text=text.."the carrier." + text=text.."相对于航母." + if xtext==nil and ztext==nil then + -- text="you are too far from where you should be!" + text="你离你改在的位置太远了!" end - return text -end - ---- Pattern aborted. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. --- @param #number X X distance player to carrier. --- @param #number Z Z distance player to carrier. --- @param #AIRBOSS.Checkpoint posData Checkpoint data. --- @param #boolean patternwo (Optional) Pattern wave off. -function AIRBOSS:_AbortPattern( playerData, X, Z, posData, patternwo ) - - -- Text where we are wrong. - local text = self:_TooFarOutText( X, Z, posData ) - - -- Debug. - local dtext = string.format( "Abort: X=%d Xmin=%s, Xmax=%s | Z=%d Zmin=%s Zmax=%s", X, tostring( posData.Xmin ), tostring( posData.Xmax ), Z, tostring( posData.Zmin ), tostring( posData.Zmax ) ) - self:T( self.lid .. dtext ) - - -- Message to player. - self:MessageToPlayer( playerData, text, "LSO" ) - + end + function AIRBOSS:_AbortPattern(playerData,X,Z,posData,patternwo) + local text=self:_TooFarOutText(X,Z,posData) + local dtext=string.format("Abort: X=%d Xmin=%s, Xmax=%s | Z=%d Zmin=%s Zmax=%s",X,tostring(posData.Xmin),tostring(posData.Xmax),Z,tostring(posData.Zmin),tostring(posData.Zmax)) + self:T(self.lid..dtext) + self:MessageToPlayer(playerData,text,"LSO") if patternwo then - - -- Pattern wave off! - playerData.wop = true - - -- Add to debrief. - -- self:_AddToDebrief( playerData, string.format( "Pattern wave off: %s", text ) ) - self:_AddToDebrief( playerData, string.format( "复飞: %s", text ) ) - - -- Depart and re-enter radio message. - -- TODO: Radio should depend on player step. - self:RadioTransmission( self.LSORadio, self.LSOCall.DEPARTANDREENTER, false, 3, nil, nil, true ) - - -- Next step debrief. - playerData.step = AIRBOSS.PatternStep.DEBRIEF - playerData.warning = nil + playerData.wop=true + -- self:_AddToDebrief(playerData,string.format("Pattern wave off: %s",text)) + self:_AddToDebrief(playerData,string.format("复飞程序: %s",text)) + self:RadioTransmission(self.LSORadio,self.LSOCall.DEPARTANDREENTER,false,3,nil,nil,true) + playerData.step=AIRBOSS.PatternStep.DEBRIEF + playerData.warning=nil end - -end - ---- Display hint to player. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. --- @param #number delay Delay before playing sound messages. Default 0 sec. --- @param #boolean soundoff If true, don't play and sound hint. -function AIRBOSS:_PlayerHint( playerData, delay, soundoff ) - - -- No hint for the pros. + end + function AIRBOSS:_PlayerHint(playerData,delay,soundoff) if not playerData.showhints then - return + return end - - -- Get optimal altitude, distance and speed. - local alt, aoa, dist, speed = self:_GetAircraftParameters( playerData ) - - -- Get altitude hint. - local hintAlt, debriefAlt, callAlt = self:_AltitudeCheck( playerData, alt ) - - -- Get speed hint. - local hintSpeed, debriefSpeed, callSpeed = self:_SpeedCheck( playerData, speed ) - - -- Get AoA hint. - local hintAoA, debriefAoA, callAoA = self:_AoACheck( playerData, aoa ) - - -- Get distance to the boat hint. - local hintDist, debriefDist, callDist = self:_DistanceCheck( playerData, dist ) - - -- Message to player. - local hint = "" - if hintAlt and hintAlt ~= "" then - hint = hint .. "\n" .. hintAlt + local alt,aoa,dist,speed=self:_GetAircraftParameters(playerData) + local hintAlt,debriefAlt,callAlt=self:_AltitudeCheck(playerData,alt) + local hintSpeed,debriefSpeed,callSpeed=self:_SpeedCheck(playerData,speed) + local hintAoA,debriefAoA,callAoA=self:_AoACheck(playerData,aoa) + local hintDist,debriefDist,callDist=self:_DistanceCheck(playerData,dist) + local hint="" + if hintAlt and hintAlt~=""then + hint=hint.."\n"..hintAlt end - if hintSpeed and hintSpeed ~= "" then - hint = hint .. "\n" .. hintSpeed + if hintSpeed and hintSpeed~=""then + hint=hint.."\n"..hintSpeed end - if hintAoA and hintAoA ~= "" then - hint = hint .. "\n" .. hintAoA + if hintAoA and hintAoA~=""then + hint=hint.."\n"..hintAoA end - if hintDist and hintDist ~= "" then - hint = hint .. "\n" .. hintDist + if hintDist and hintDist~=""then + hint=hint.."\n"..hintDist end - - -- Debriefing text. - local debrief = "" - if debriefAlt and debriefAlt ~= "" then - debrief = debrief .. "\n- " .. debriefAlt + local debrief="" + if debriefAlt and debriefAlt~=""then + debrief=debrief.."\n- "..debriefAlt end - if debriefSpeed and debriefSpeed ~= "" then - debrief = debrief .. "\n- " .. debriefSpeed + if debriefSpeed and debriefSpeed~=""then + debrief=debrief.."\n- "..debriefSpeed end - if debriefAoA and debriefAoA ~= "" then - debrief = debrief .. "\n- " .. debriefAoA + if debriefAoA and debriefAoA~=""then + debrief=debrief.."\n- "..debriefAoA end - if debriefDist and debriefDist ~= "" then - debrief = debrief .. "\n- " .. debriefDist + if debriefDist and debriefDist~=""then + debrief=debrief.."\n- "..debriefDist end - - -- Add step to debriefing. - if debrief ~= "" then - self:_AddToDebrief( playerData, debrief ) + if debrief~=""then + self:_AddToDebrief(playerData,debrief) end - - -- Voice hint. - delay = delay or 0 + delay=delay or 0 if not soundoff then - if callAlt then - self:Sound2Player( playerData, self.LSORadio, callAlt, false, delay ) - delay = delay + callAlt.duration + 0.5 - end - if callSpeed then - self:Sound2Player( playerData, self.LSORadio, callSpeed, false, delay ) - delay = delay + callSpeed.duration + 0.5 - end - if callAoA then - self:Sound2Player( playerData, self.LSORadio, callAoA, false, delay ) - delay = delay + callAoA.duration + 0.5 - end - if callDist then - self:Sound2Player( playerData, self.LSORadio, callDist, false, delay ) - delay = delay + callDist.duration + 0.5 - end + if callAlt then + self:Sound2Player(playerData,self.LSORadio,callAlt,false,delay) + delay=delay+callAlt.duration+0.5 end - - -- ARC IN info. - if playerData.step == AIRBOSS.PatternStep.ARCIN then - - -- Hint turn and set TACAN. - if playerData.difficulty == AIRBOSS.Difficulty.EASY then - -- Get inverse magnetic radial without offset ==> FB for Case II or BRC for Case III. - local radial = self:GetRadial( playerData.case, true, false, true ) - -- local turn = "right" - local turn = "右" - if self.holdingoffset < 0 then - -- turn = "left" - turn = "左" - end - -- hint = hint .. string.format( "\nTurn %s and select TACAN %03d°.", turn, radial ) - hint = hint .. string.format( "\n向 %s 转并且对正塔康方向 %03d°.", turn, radial ) - end - + if callSpeed then + self:Sound2Player(playerData,self.LSORadio,callSpeed,false,delay) + delay=delay+callSpeed.duration+0.5 end - - -- DIRTUP additonal info. - if playerData.step == AIRBOSS.PatternStep.DIRTYUP then - if playerData.difficulty == AIRBOSS.Difficulty.EASY then - if playerData.actype == AIRBOSS.AircraftCarrier.AV8B then - -- hint = hint .. "\nFAF! Checks completed. Nozzles 50°." - hint = hint .. "\nFAF! 检查完成. 喷口角度 50°." - else - -- TODO: Tomcat? - -- hint = hint .. "\nDirty up! Hook, gear and flaps down." - hint = hint .. "\n着舰构型! 放尾钩, 起落架 和 襟翼." - end - end + if callAoA then + self:Sound2Player(playerData,self.LSORadio,callAoA,false,delay) + delay=delay+callAoA.duration+0.5 end - - -- BULLSEYE additonal info. - if playerData.step == AIRBOSS.PatternStep.BULLSEYE then - -- Hint follow the needles. - if playerData.difficulty == AIRBOSS.Difficulty.EASY then - if playerData.actype == AIRBOSS.AircraftCarrier.HORNET - or playerData.actype == AIRBOSS.AircraftCarrier.RHINOE - or playerData.actype == AIRBOSS.AircraftCarrier.RHINOF - or playerData.actype == AIRBOSS.AircraftCarrier.GROWLER then - -- hint = hint .. string.format( "\nIntercept glideslope and follow the needles." ) - hint = hint .. string.format( "\n截获下滑道,执行仪表降落." ) - else - -- hint = hint .. string.format( "\nIntercept glideslope." ) - hint = hint .. string.format( "\n截获下滑道." ) - end - end + if callDist then + self:Sound2Player(playerData,self.LSORadio,callDist,false,delay) + delay=delay+callDist.duration+0.5 end - - -- Message to player. - if hint ~= "" then - local text = string.format( "%s%s", playerData.step, hint ) - self:MessageToPlayer( playerData, hint, "AIRBOSS", "" ) end -end - ---- Display hint for flight students about the (next) step. Message is displayed after one second. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. --- @param #string step Step for which hint is given. -function AIRBOSS:_StepHint( playerData, step ) - - -- Set step. - step = step or playerData.step - - -- Message is only for "Flight Students". - if playerData.difficulty == AIRBOSS.Difficulty.EASY and playerData.showhints then - - -- Get optimal parameters at step. - local alt, aoa, dist, speed = self:_GetAircraftParameters( playerData, step ) - - -- Hint: - local hint = "" - - -- Altitude. - if alt then - -- hint = hint .. string.format( "\nAltitude %d ft", UTILS.MetersToFeet( alt ) ) - hint = hint .. string.format( "\n高度 %d ft", UTILS.MetersToFeet( alt ) ) - end - - -- AoA. - if aoa then - hint = hint .. string.format( "\nAoA %.1f", self:_AoADeg2Units( playerData, aoa ) ) - end - - -- Speed. - if speed then - -- hint = hint .. string.format( "\nSpeed %d knots", UTILS.MpsToKnots( speed ) ) - hint = hint .. string.format( "\n速度 %d knots", UTILS.MpsToKnots( speed ) ) - end - - -- Distance to the boat. - if dist then - -- hint = hint .. string.format( "\nDistance to the boat %.1f NM", UTILS.MetersToNM( dist ) ) - hint = hint .. string.format( "\n距离舰船 %.1f NM", UTILS.MetersToNM( dist ) ) - end - - -- Late break. - if step == AIRBOSS.PatternStep.LATEBREAK then - if playerData.actype == AIRBOSS.AircraftCarrier.F14A or playerData.actype == AIRBOSS.AircraftCarrier.F14B then - -- hint = hint .. "\nWing Sweep 20°, Gear DOWN < 280 KIAS." - hint = hint .. "\n机翼角度 20°, 起落架 < 280 KIAS 后放下." - end - end - - -- Abeam. - if step == AIRBOSS.PatternStep.ABEAM then - if playerData.actype == AIRBOSS.AircraftCarrier.AV8B then - -- hint = hint .. "\nNozzles 50°-60°. Antiskid OFF. Lights OFF." - hint = hint .. "\n喷口角度 50°-60°. 刹车防滑 关. 灯光 关." - elseif playerData.actype == AIRBOSS.AircraftCarrier.F14A or playerData.actype == AIRBOSS.AircraftCarrier.F14B then - -- hint = hint .. "\nSlats/Flaps EXTENDED < 225 KIAS. DLC SELECTED. Auto Throttle IF DESIRED." - hint = hint .. "\n襟翼 < 225 KIAS 节后展开. DLC: 选择. 自动油门: 按需." - else - -- hint = hint .. "\nDirty up! Gear DOWN, flaps DOWN. Check hook down." - hint = hint .. "\n着舰构型! 放起落架,放襟翼,检查尾钩." - end - end - - -- Check if there was actually anything to tell. - if hint ~= "" then - - -- Compile text if any. - -- local text = string.format( "Optimal setup at next step %s:%s", step, hint ) - local text = string.format( "下个阶段的最佳构型 %s:%s", step, hint ) - - -- Send hint to player. - self:MessageToPlayer( playerData, text, "AIRBOSS", "", nil, false, 1 ) - - end - + if playerData.step==AIRBOSS.PatternStep.ARCIN then + if playerData.difficulty==AIRBOSS.Difficulty.EASY then + local radial=self:GetRadial(playerData.case,true,false,true) + -- local turn="right" + local turn="右" + if self.holdingoffset<0 then + -- turn="left" + turn="左" end -end - ---- Evaluate player's altitude at checkpoint. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. --- @param #number altopt Optimal altitude in meters. --- @return #string Feedback text. --- @return #string Debriefing text. --- @return #AIRBOSS.RadioCall Radio call. -function AIRBOSS:_AltitudeCheck( playerData, altopt ) - - if altopt == nil then - return nil, nil + -- hint=hint..string.format("\nTurn %s and select TACAN %03d°.",turn,radial) + hint=hint..string.format("\n%s转 设置TACAN航线 %03d°.",turn,radial) end - - -- Player altitude. - local altitude = playerData.unit:GetAltitude() - - -- Get relative score. - local lowscore, badscore = self:_GetGoodBadScore( playerData ) - - -- Altitude error +-X% - local _error = (altitude - altopt) / altopt * 100 - - -- Radio call for flight students. - local radiocall = nil -- #AIRBOSS.RadioCall - - local hint = "" - if _error > badscore then - -- hint=string.format("You're high.") - radiocall = self:_NewRadioCall( self.LSOCall.HIGH, "Paddles", "" ) - elseif _error > lowscore then - -- hint= string.format("You're slightly high.") - radiocall = self:_NewRadioCall( self.LSOCall.HIGH, "Paddles", "" ) - elseif _error < -badscore then - -- hint=string.format("You're low. ") - radiocall = self:_NewRadioCall( self.LSOCall.LOW, "Paddles", "" ) - elseif _error < -lowscore then - -- hint=string.format("You're slightly low.") - radiocall = self:_NewRadioCall( self.LSOCall.LOW, "Paddles", "" ) + end + if playerData.step==AIRBOSS.PatternStep.DIRTYUP then + if playerData.difficulty==AIRBOSS.Difficulty.EASY then + if playerData.actype==AIRBOSS.AircraftCarrier.AV8B then + -- hint=hint.."\nFAF! Checks completed. Nozzles 50°." + hint=hint.."\n最后进近定位点(FAF)! 检查已完成. 喷口角度 50°." else - -- hint = string.format( "Good altitude. " ) - hint = string.format( "高度不错. " ) + -- hint=hint.."\nDirty up! Hook, gear and flaps down." + hint=hint.."\nDirty up! 放下尾钩、起落架以及襟翼." end - - -- Extend or decrease depending on skill. - if playerData.difficulty == AIRBOSS.Difficulty.EASY then - -- Also inform students about the optimal altitude. - -- hint = hint .. string.format( "Optimal altitude is %d ft.", UTILS.MetersToFeet( altopt ) ) - hint = hint .. string.format( "最佳高度是 %d ft.", UTILS.MetersToFeet( altopt ) ) - elseif playerData.difficulty == AIRBOSS.Difficulty.NORMAL then - -- We keep it short normally. - hint = "" - elseif playerData.difficulty == AIRBOSS.Difficulty.HARD then - -- No hint at all for the pros. - hint = "" end - - -- Debrief text. - -- local debrief = string.format( "Altitude %d ft = %d%% deviation from %d ft.", UTILS.MetersToFeet( altitude ), _error, UTILS.MetersToFeet( altopt ) ) - local debrief = string.format( "高度 %d ft = %d%% 偏差 %d ft.", UTILS.MetersToFeet( altitude ), _error, UTILS.MetersToFeet( altopt ) ) - - return hint, debrief, radiocall -end - ---- Score for correct AoA. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. --- @param #number optaoa Optimal AoA. --- @return #string Feedback message text or easy and normal difficulty level or nil for hard. --- @return #string Debriefing text. --- @return #AIRBOSS.RadioCall Radio call. -function AIRBOSS:_AoACheck( playerData, optaoa ) - - if optaoa == nil then - return nil, nil end - - -- Get relative score. - local lowscore, badscore = self:_GetGoodBadScore( playerData ) - - -- Player AoA - local aoa = playerData.unit:GetAoA() - - -- Altitude error +-X% - local _error = (aoa - optaoa) / optaoa * 100 - - -- Get aircraft AoA parameters. - local aircraftaoa = self:_GetAircraftAoA( playerData ) - - -- Radio call for flight students. - local radiocall = nil -- #AIRBOSS.RadioCall - - -- Rate aoa. - local hint = "" - if aoa >= aircraftaoa.SLOW then - -- hint="Your're slow!" - radiocall = self:_NewRadioCall( self.LSOCall.SLOW, "Paddles", "" ) - elseif aoa >= aircraftaoa.Slow then - -- hint="Your're slow." - radiocall = self:_NewRadioCall( self.LSOCall.SLOW, "Paddles", "" ) - elseif aoa >= aircraftaoa.OnSpeedMax then - -- hint = "Your're a little slow. " - hint = "你有点慢了. " - elseif aoa >= aircraftaoa.OnSpeedMin then - -- hint = "You're on speed. " - hint = "你的速度合适. " - elseif aoa >= aircraftaoa.Fast then - -- hint = "You're a little fast. " - hint = "你有点快了. " - elseif aoa >= aircraftaoa.FAST then - -- hint="Your're fast." - radiocall = self:_NewRadioCall( self.LSOCall.FAST, "Paddles", "" ) + if playerData.step==AIRBOSS.PatternStep.BULLSEYE then + if playerData.difficulty==AIRBOSS.Difficulty.EASY then + if playerData.actype==AIRBOSS.AircraftCarrier.HORNET + or playerData.actype==AIRBOSS.AircraftCarrier.RHINOE + or playerData.actype==AIRBOSS.AircraftCarrier.RHINOF + or playerData.actype==AIRBOSS.AircraftCarrier.GROWLER then + -- hint=hint..string.format("\nIntercept glideslope and follow the needles.") + hint=hint..string.format("\n截获下滑道, 按照指针飞行.") else - -- hint="You're fast!" - radiocall = self:_NewRadioCall( self.LSOCall.FAST, "Paddles", "" ) + -- hint=hint..string.format("\nIntercept glideslope.") + hint=hint..string.format("\nn截获下滑道.") end - - -- Extend or decrease depending on skill. - if playerData.difficulty == AIRBOSS.Difficulty.EASY then - -- Also inform students about optimal value. - -- hint = hint .. string.format( "Optimal AoA is %.1f.", self:_AoADeg2Units( playerData, optaoa ) ) - hint = hint .. string.format( "最佳 AoA 是 %.1f.", self:_AoADeg2Units( playerData, optaoa ) ) - elseif playerData.difficulty == AIRBOSS.Difficulty.NORMAL then - -- We keep is short normally. - hint = "" - elseif playerData.difficulty == AIRBOSS.Difficulty.HARD then - -- No hint at all for the pros. - hint = "" end - - -- Debriefing text. - -- local debrief = string.format( "AoA %.1f = %d%% deviation from %.1f.", self:_AoADeg2Units( playerData, aoa ), _error, self:_AoADeg2Units( playerData, optaoa ) ) - local debrief = string.format( "AoA %.1f = %d%% 偏差 %.1f.", self:_AoADeg2Units( playerData, aoa ), _error, self:_AoADeg2Units( playerData, optaoa ) ) - - return hint, debrief, radiocall -end - ---- Evaluate player's speed. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. --- @param #number speedopt Optimal speed in m/s. --- @return #string Feedback text. --- @return #string Debriefing text. --- @return #AIRBOSS.RadioCall Radio call. -function AIRBOSS:_SpeedCheck( playerData, speedopt ) - - if speedopt == nil then - return nil, nil end - - -- Player altitude. - local speed = playerData.unit:GetVelocityMPS() - - -- Get relative score. - local lowscore, badscore = self:_GetGoodBadScore( playerData ) - - -- Altitude error +-X% - local _error = (speed - speedopt) / speedopt * 100 - - -- Radio call for flight students. - local radiocall = nil -- #AIRBOSS.RadioCall - - local hint = "" - if _error > badscore then - -- hint=string.format("You're fast.") - radiocall = self:_NewRadioCall( self.LSOCall.FAST, "AIRBOSS", "" ) - elseif _error > lowscore then - -- hint= string.format("You're slightly fast.") - radiocall = self:_NewRadioCall( self.LSOCall.FAST, "AIRBOSS", "" ) - elseif _error < -badscore then - -- hint=string.format("You're slow.") - radiocall = self:_NewRadioCall( self.LSOCall.SLOW, "AIRBOSS", "" ) - elseif _error < -lowscore then - -- hint=string.format("You're slightly slow.") - radiocall = self:_NewRadioCall( self.LSOCall.SLOW, "AIRBOSS", "" ) + if hint~=""then + local text=string.format("%s%s",playerData.step,hint) + self:MessageToPlayer(playerData,hint,"航空长","") + end + end + function AIRBOSS:_StepHint(playerData,step) + step=step or playerData.step + if playerData.difficulty==AIRBOSS.Difficulty.EASY and playerData.showhints then + local alt,aoa,dist,speed=self:_GetAircraftParameters(playerData,step) + local hint="" + if alt then + -- hint=hint..string.format("\nAltitude %d ft",UTILS.MetersToFeet(alt)) + hint=hint..string.format("\n高度 %d ft",UTILS.MetersToFeet(alt)) + end + if aoa then + hint=hint..string.format("\nAoA %.1f",self:_AoADeg2Units(playerData,aoa)) + end + if speed then + -- hint=hint..string.format("\nSpeed %d knots",UTILS.MpsToKnots(speed)) + hint=hint..string.format("\n速度 %d 节",UTILS.MpsToKnots(speed)) + end + if dist then + -- hint=hint..string.format("\nDistance to the boat %.1f NM",UTILS.MetersToNM(dist)) + hint=hint..string.format("\n距离航母 %.1f NM",UTILS.MetersToNM(dist)) + end + if step==AIRBOSS.PatternStep.LATEBREAK then + if playerData.actype==AIRBOSS.AircraftCarrier.F14A or playerData.actype==AIRBOSS.AircraftCarrier.F14B then + -- hint=hint.."\nWing Sweep 20°, Gear DOWN < 280 KIAS." + hint=hint.."\n机翼角度 20°, 放起落架速度 < 280 KIAS." + end + end + if step==AIRBOSS.PatternStep.ABEAM then + if playerData.actype==AIRBOSS.AircraftCarrier.AV8B then + -- hint=hint.."\nNozzles 50°-60°. Antiskid OFF. Lights OFF." + hint=hint.."\n喷口 50°-60°. 机轮防滑 关. 灯光 关." + elseif playerData.actype==AIRBOSS.AircraftCarrier.F14A or playerData.actype==AIRBOSS.AircraftCarrier.F14B then + -- hint=hint.."\nSlats/Flaps EXTENDED < 225 KIAS. DLC SELECTED. Auto Throttle IF DESIRED." + hint=hint.."\n缝翼 / 襟翼已伸出, 指示空速小于 225 节 .直接升力控制(DLC)已启用. 若需要, 可使用自动油门." else - -- hint = string.format( "Good speed. " ) - hint = string.format( "速度很好. " ) + -- hint=hint.."\nDirty up! Gear DOWN, flaps DOWN. Check hook down." + hint=hint.."\n开始构型! 放轮, 放襟翼. 检查尾勾放出." end - - -- Extend or decrease depending on skill. - if playerData.difficulty == AIRBOSS.Difficulty.EASY then - -- hint = hint .. string.format( "Optimal speed is %d knots.", UTILS.MpsToKnots( speedopt ) ) - hint = hint .. string.format( "最佳速度是 %d knots.", UTILS.MpsToKnots( speedopt ) ) - elseif playerData.difficulty == AIRBOSS.Difficulty.NORMAL then - -- We keep is short normally. - hint = "" - elseif playerData.difficulty == AIRBOSS.Difficulty.HARD then - -- No hint at all for pros. - hint = "" end - - -- Debrief text. - -- local debrief = string.format( "Speed %d knots = %d%% deviation from %d knots.", UTILS.MpsToKnots( speed ), _error, UTILS.MpsToKnots( speedopt ) ) - local debrief = string.format( "速度 %d knots = %d%% 偏差 %d knots.", UTILS.MpsToKnots( speed ), _error, UTILS.MpsToKnots( speedopt ) ) - - return hint, debrief, radiocall -end - ---- Evaluate player's distance to the boat at checkpoint. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. --- @param #number optdist Optimal distance in meters. --- @return #string Feedback message text. --- @return #string Debriefing text. --- @return #AIRBOSS.RadioCall Distance radio call. Not implemented yet. -function AIRBOSS:_DistanceCheck( playerData, optdist ) - - if optdist == nil then - return nil, nil + if hint~=""then + -- local text=string.format("Optimal setup at next step %s:%s",step,hint) + local text=string.format("最佳下一步的构型 %s:%s",step,hint) + self:MessageToPlayer(playerData,text,"航空长","",nil,false,1) end - - -- Distance to carrier. - local distance = playerData.unit:GetCoordinate():Get2DDistance( self:GetCoordinate() ) - - -- Get relative score. - local lowscore, badscore = self:_GetGoodBadScore( playerData ) - - -- Altitude error +-X% - local _error = (distance - optdist) / optdist * 100 - + end + end + function AIRBOSS:_AltitudeCheck(playerData,altopt) + if altopt==nil then + return nil,nil + end + local altitude=playerData.unit:GetAltitude() + local lowscore,badscore=self:_GetGoodBadScore(playerData) + local _error=(altitude-altopt)/altopt*100 + local radiocall=nil + local hint="" + if _error>badscore then + radiocall=self:_NewRadioCall(self.LSOCall.HIGH,"Paddles","") + elseif _error>lowscore then + radiocall=self:_NewRadioCall(self.LSOCall.HIGH,"Paddles","") + elseif _error<-badscore then + radiocall=self:_NewRadioCall(self.LSOCall.LOW,"Paddles","") + elseif _error<-lowscore then + radiocall=self:_NewRadioCall(self.LSOCall.LOW,"Paddles","") + else + hint=string.format("Good altitude. ") + end + if playerData.difficulty==AIRBOSS.Difficulty.EASY then + hint=hint..string.format("Optimal altitude is %d ft.",UTILS.MetersToFeet(altopt)) + elseif playerData.difficulty==AIRBOSS.Difficulty.NORMAL then + hint="" + elseif playerData.difficulty==AIRBOSS.Difficulty.HARD then + hint="" + end + local debrief=string.format("Altitude %d ft = %d%% deviation from %d ft.",UTILS.MetersToFeet(altitude),_error,UTILS.MetersToFeet(altopt)) + return hint,debrief,radiocall + end + function AIRBOSS:_AoACheck(playerData,optaoa) + if optaoa==nil then + return nil,nil + end + local lowscore,badscore=self:_GetGoodBadScore(playerData) + local aoa=playerData.unit:GetAoA() + local _error=(aoa-optaoa)/optaoa*100 + local aircraftaoa=self:_GetAircraftAoA(playerData) + local radiocall=nil + local hint="" + if aoa>=aircraftaoa.SLOW then + radiocall=self:_NewRadioCall(self.LSOCall.SLOW,"Paddles","") + elseif aoa>=aircraftaoa.Slow then + radiocall=self:_NewRadioCall(self.LSOCall.SLOW,"Paddles","") + elseif aoa>=aircraftaoa.OnSpeedMax then + hint="Your're a little slow. " + elseif aoa>=aircraftaoa.OnSpeedMin then + hint="You're on speed. " + elseif aoa>=aircraftaoa.Fast then + hint="You're a little fast. " + elseif aoa>=aircraftaoa.FAST then + radiocall=self:_NewRadioCall(self.LSOCall.FAST,"Paddles","") + else + radiocall=self:_NewRadioCall(self.LSOCall.FAST,"Paddles","") + end + if playerData.difficulty==AIRBOSS.Difficulty.EASY then + hint=hint..string.format("Optimal AoA is %.1f.",self:_AoADeg2Units(playerData,optaoa)) + elseif playerData.difficulty==AIRBOSS.Difficulty.NORMAL then + hint="" + elseif playerData.difficulty==AIRBOSS.Difficulty.HARD then + hint="" + end + local debrief=string.format("AoA %.1f = %d%% deviation from %.1f.",self:_AoADeg2Units(playerData,aoa),_error,self:_AoADeg2Units(playerData,optaoa)) + return hint,debrief,radiocall + end + function AIRBOSS:_SpeedCheck(playerData,speedopt) + if speedopt==nil then + return nil,nil + end + local speed=playerData.unit:GetVelocityMPS() + local lowscore,badscore=self:_GetGoodBadScore(playerData) + local _error=(speed-speedopt)/speedopt*100 + local radiocall=nil + local hint="" + if _error>badscore then + radiocall=self:_NewRadioCall(self.LSOCall.FAST,"AIRBOSS","") + elseif _error>lowscore then + radiocall=self:_NewRadioCall(self.LSOCall.FAST,"AIRBOSS","") + elseif _error<-badscore then + radiocall=self:_NewRadioCall(self.LSOCall.SLOW,"AIRBOSS","") + elseif _error<-lowscore then + radiocall=self:_NewRadioCall(self.LSOCall.SLOW,"AIRBOSS","") + else + hint=string.format("Good speed. ") + end + if playerData.difficulty==AIRBOSS.Difficulty.EASY then + hint=hint..string.format("Optimal speed is %d knots.",UTILS.MpsToKnots(speedopt)) + elseif playerData.difficulty==AIRBOSS.Difficulty.NORMAL then + hint="" + elseif playerData.difficulty==AIRBOSS.Difficulty.HARD then + hint="" + end + local debrief=string.format("Speed %d knots = %d%% deviation from %d knots.",UTILS.MpsToKnots(speed),_error,UTILS.MpsToKnots(speedopt)) + return hint,debrief,radiocall + end + function AIRBOSS:_DistanceCheck(playerData,optdist) + if optdist==nil then + return nil,nil + end + local distance=playerData.unit:GetCoordinate():Get2DDistance(self:GetCoordinate()) + local lowscore,badscore=self:_GetGoodBadScore(playerData) + local _error=(distance-optdist)/optdist*100 local hint - if _error > badscore then - -- hint = string.format( "You're too far from the boat!" ) - hint = string.format( "你离船只过于远!" ) - elseif _error > lowscore then - -- hint = string.format( "You're slightly too far from the boat." ) - hint = string.format( "你离船只有点远." ) - elseif _error < -badscore then - -- hint = string.format( "You're too close to the boat!" ) - hint = string.format( "你离船只太近了!" ) - elseif _error < -lowscore then - -- hint = string.format( "You're slightly too far from the boat." ) - hint = string.format( "你离船只有点近." ) + if _error>badscore then + hint=string.format("You're too far from the boat!") + elseif _error>lowscore then + hint=string.format("You're slightly too far from the boat.") + elseif _error<-badscore then + hint=string.format("You're too close to the boat!") + elseif _error<-lowscore then + hint=string.format("You're slightly too far from the boat.") else - -- hint = string.format( "Good distance to the boat." ) - hint = string.format( "离船只距离刚好." ) + hint=string.format("Good distance to the boat.") end - - -- Extend or decrease depending on skill. - if playerData.difficulty == AIRBOSS.Difficulty.EASY then - -- Also inform students about optimal value. - -- hint = hint .. string.format( " Optimal distance is %.1f NM.", UTILS.MetersToNM( optdist ) ) - hint = hint .. string.format( " 离船只最佳距离是 %.1f NM.", UTILS.MetersToNM( optdist ) ) - elseif playerData.difficulty == AIRBOSS.Difficulty.NORMAL then - -- We keep it short normally. - hint = "" - elseif playerData.difficulty == AIRBOSS.Difficulty.HARD then - -- No hint at all for the pros. - hint = "" + if playerData.difficulty==AIRBOSS.Difficulty.EASY then + hint=hint..string.format(" Optimal distance is %.1f NM.",UTILS.MetersToNM(optdist)) + elseif playerData.difficulty==AIRBOSS.Difficulty.NORMAL then + hint="" + elseif playerData.difficulty==AIRBOSS.Difficulty.HARD then + hint="" end - - -- Debriefing text. - -- local debrief = string.format( "Distance %.1f NM = %d%% deviation from %.1f NM.", UTILS.MetersToNM( distance ), _error, UTILS.MetersToNM( optdist ) ) - local debrief = string.format( "距离 %.1f NM = %d%% 偏差 from %.1f NM.", UTILS.MetersToNM( distance ), _error, UTILS.MetersToNM( optdist ) ) - - return hint, debrief, nil -end - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --- DEBRIEFING ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - ---- Append text to debriefing. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. --- @param #string hint Debrief text of this step. --- @param #string step (Optional) Current step in the pattern. Default from playerData. -function AIRBOSS:_AddToDebrief( playerData, hint, step ) - step = step or playerData.step - table.insert( playerData.debrief, { step = step, hint = hint } ) -end - ---- Debrief player and set next step. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. -function AIRBOSS:_Debrief( playerData ) - self:F( self.lid .. string.format( "Debriefing of player %s.", playerData.name ) ) - - -- Delete scheduler ID. - playerData.debriefschedulerID = nil - - -- Switch attitude monitor off if on. - playerData.attitudemonitor = false - - -- LSO grade, points, and flight data analyis. - local grade, points, analysis = self:_LSOgrade( playerData ) - - -- Insert points to table of all points until player landed. - if points and points >= 0 then - table.insert( playerData.points, points ) + local debrief=string.format("Distance %.1f NM = %d%% deviation from %.1f NM.",UTILS.MetersToNM(distance),_error,UTILS.MetersToNM(optdist)) + return hint,debrief,nil end - - -- Player has landed and is not airborne any more. - local Points = 0 - if playerData.landed and not playerData.unit:InAir() then - - -- Average over all points received so far. - for _, _points in pairs( playerData.points ) do - Points = Points + _points - end - - -- This is the final points. - Points = Points / #playerData.points - - -- Reset points array. - playerData.points = {} + function AIRBOSS:_AddToDebrief(playerData,hint,step) + step=step or playerData.step + table.insert(playerData.debrief,{step=step,hint=hint}) + end + function AIRBOSS:_Debrief(playerData) + self:F(self.lid..string.format("Debriefing of player %s.",playerData.name)) + playerData.debriefschedulerID=nil + playerData.attitudemonitor=false + local grade,points,analysis=self:_LSOgrade(playerData) + if points and points>=0 then + table.insert(playerData.points,points) + end + local Points=0 + if playerData.landed and not playerData.unit:InAir()then + for _,_points in pairs(playerData.points)do + Points=Points+_points + end + Points=Points/#playerData.points + playerData.points={} else - -- Player boltered or was waved off ==> We display the normal points. - Points = points + Points=points end - - -- My LSO grade. - local mygrade = {} -- #AIRBOSS.LSOgrade - mygrade.grade = grade - mygrade.points = points - mygrade.details = analysis - mygrade.wire = playerData.wire - mygrade.Tgroove = playerData.Tgroove - if playerData.landed and not playerData.unit:InAir() then - mygrade.finalscore = Points + local mygrade={} + mygrade.grade=grade + mygrade.points=points + mygrade.details=analysis + mygrade.wire=playerData.wire + mygrade.Tgroove=playerData.Tgroove + if playerData.landed and not playerData.unit:InAir()then + mygrade.finalscore=Points end - mygrade.case = playerData.case - local windondeck = self:GetWindOnDeck() - mygrade.wind = UTILS.Round( UTILS.MpsToKnots( windondeck ), 1 ) - mygrade.modex = playerData.onboard - mygrade.airframe = playerData.actype - mygrade.carriertype = self.carriertype - mygrade.carriername = self.alias - mygrade.carrierrwy = self.carrierparam.rwyangle - mygrade.theatre = self.theatre - mygrade.mitime = UTILS.SecondsToClock( timer.getAbsTime(), true ) - mygrade.midate = UTILS.GetDCSMissionDate() - mygrade.osdate = "n/a" + mygrade.case=playerData.case + local windondeck=self:GetWindOnDeck() + mygrade.wind=UTILS.Round(UTILS.MpsToKnots(windondeck),1) + mygrade.modex=playerData.onboard + mygrade.airframe=playerData.actype + mygrade.carriertype=self.carriertype + mygrade.carriername=self.alias + mygrade.carrierrwy=self.carrierparam.rwyangle + mygrade.theatre=self.theatre + mygrade.mitime=UTILS.SecondsToClock(timer.getAbsTime(),true) + mygrade.midate=UTILS.GetDCSMissionDate() + mygrade.osdate="n/a" if os then - mygrade.osdate = os.date() -- os.date("%d.%m.%Y") + mygrade.osdate=os.date() end - - -- Add last grade to playerdata for FunkMan. playerData.grade=mygrade - - -- Save trap sheet. if playerData.trapon and self.trapsheet then - self:_SaveTrapSheet( playerData, mygrade ) + self:_SaveTrapSheet(playerData,mygrade) end - - -- Add LSO grade to player grades table. - table.insert( self.playerscores[playerData.name], mygrade ) - - -- Trigger grading event. - self:LSOGrade( playerData, mygrade ) - - -- LSO grade: (OK) 3.0 PT - LURIM - local text = string.format( "%s %.1f PT - %s", grade, Points, analysis ) - if Points == -1 then - -- text = string.format( "%s n/a PT - Foul deck", grade, Points, analysis ) - text = string.format( "%s n/a PT - 甲板堵塞", grade, Points, analysis ) + table.insert(self.playerscores[playerData.name],mygrade) + self:LSOGrade(playerData,mygrade) + local text=string.format("%s %.1f PT - %s",grade,Points,analysis) + if Points==-1 then + text=string.format("%s n/a PT - Foul deck",grade,Points,analysis) end - - -- Wire and Groove time only if not pattern WO. - if not (playerData.wop or playerData.wofd) then - - -- Wire trapped. Not if pattern WI. - if playerData.wire and playerData.wire <= 4 then - text = text .. string.format( " %d-wire", playerData.wire ) - end - - -- Time in the groove. Only Case I/II and not pattern WO. - if playerData.Tgroove and playerData.Tgroove <= 360 and playerData.case < 3 then - -- text = text .. string.format( "\nTime in the groove %.1f seconds: %s", playerData.Tgroove, self:_EvalGrooveTime( playerData ) ) - text = text .. string.format( "\nT处在 groove %.1f 阶段的时间是: %s 秒", playerData.Tgroove, self:_EvalGrooveTime( playerData ) ) - end - + if not(playerData.wop or playerData.wofd)then + if playerData.wire and playerData.wire<=4 then + text=text..string.format(" %d-wire",playerData.wire) end - - -- Copy debriefing text. - playerData.lastdebrief = UTILS.DeepCopy( playerData.debrief ) - - -- Info text. - if playerData.difficulty == AIRBOSS.Difficulty.EASY then - -- text = text .. string.format( "\nYour detailed debriefing can be found via the F10 radio menu." ) - text = text .. string.format( "\n此次降落的详细简报可以在 无线电菜单 F10 查看" ) + if playerData.Tgroove and playerData.Tgroove<=360 and playerData.case<3 then + -- text=text..string.format("\nTime in the groove %.1f seconds: %s",playerData.Tgroove,self:_EvalGrooveTime(playerData)) + text=text..string.format("\n第五边(groove)时长 %.1f 秒: %s",playerData.Tgroove,self:_EvalGrooveTime(playerData)) end - - -- Message. - self:MessageToPlayer( playerData, text, "LSO", "", 30, true ) - - -- Set step to undefined and check if other cases apply. - playerData.step = AIRBOSS.PatternStep.UNDEFINED - - -- Check what happened? + end + playerData.lastdebrief=UTILS.DeepCopy(playerData.debrief) + if playerData.difficulty==AIRBOSS.Difficulty.EASY then + -- text=text..string.format("\nYour detailed debriefing can be found via the F10 radio menu.") + text=text..string.format("\n详细成绩情况可以在 通讯菜单F10 查看.") + end + self:MessageToPlayer(playerData,text,"LSO","",30,true) + playerData.step=AIRBOSS.PatternStep.UNDEFINED if playerData.wop then - - ---------------------- - -- Pattern Wave Off -- - ---------------------- - - -- Next step? - -- TODO: CASE I: After bolter/wo turn left and climb to 600 ft and re-enter the pattern. But do not go to initial but reenter earlier? - -- TODO: CASE I: After pattern wo? go back to initial, I guess? - -- TODO: CASE III: After bolter/wo turn left and climb to 1200 ft and re-enter pattern? - -- TODO: CASE III: After pattern wo? No idea... - - -- Can become nil when I crashed and changed to observer. Which events are captured? Nil check for unit? - if playerData.unit:IsAlive() then - - -- Heading and distance tip. - local heading, distance - - if playerData.case == 1 or playerData.case == 2 then - - -- Next step: Initial again. - playerData.step = AIRBOSS.PatternStep.INITIAL - - -- Create a point 3.0 NM astern for re-entry. - local initial = self:GetCoordinate():Translate( UTILS.NMToMeters( 3.5 ), self:GetRadial( 2, false, false, false ) ) - - -- Get heading and distance to initial zone ~3 NM astern. - heading = playerData.unit:GetCoordinate():HeadingTo( initial ) - distance = playerData.unit:GetCoordinate():Get2DDistance( initial ) - - elseif playerData.case == 3 then - - -- Next step? Bullseye for now. - -- TODO: Could be DIRTY UP or PLATFORM or even back to MARSHAL STACK? - playerData.step = AIRBOSS.PatternStep.BULLSEYE - - -- Get heading and distance to bullseye zone ~3 NM astern. - local zone = self:_GetZoneBullseye( playerData.case ) - - heading = playerData.unit:GetCoordinate():HeadingTo( zone:GetCoordinate() ) - distance = playerData.unit:GetCoordinate():Get2DDistance( zone:GetCoordinate() ) - - end - - -- Re-enter message. - -- local text = string.format( "fly heading %03d° for %d NM to re-enter the pattern.", heading, UTILS.MetersToNM( distance ) ) - local text = string.format( "飞向航向 %03d° 距离 %d NM 重新进入当前程序.", heading, UTILS.MetersToNM( distance ) ) - self:MessageToPlayer( playerData, text, "LSO", nil, nil, false, 5 ) - - else - - -- Unit does not seem to be alive! - -- TODO: What now? - self:E( self.lid .. string.format( "ERROR: Player unit not alive!" ) ) - - end - + if playerData.unit:IsAlive()then + local heading,distance + if playerData.case==1 or playerData.case==2 then + playerData.step=AIRBOSS.PatternStep.INITIAL + local initial=self:GetCoordinate():Translate(UTILS.NMToMeters(3.5),self:GetRadial(2,false,false,false)) + heading=playerData.unit:GetCoordinate():HeadingTo(initial) + distance=playerData.unit:GetCoordinate():Get2DDistance(initial) + elseif playerData.case==3 then + playerData.step=AIRBOSS.PatternStep.BULLSEYE + local zone=self:_GetZoneBullseye(playerData.case) + heading=playerData.unit:GetCoordinate():HeadingTo(zone:GetCoordinate()) + distance=playerData.unit:GetCoordinate():Get2DDistance(zone:GetCoordinate()) + end + -- local text=string.format("fly heading %03d° for %d NM to re-enter the pattern.",heading,UTILS.MetersToNM(distance)) + local text=string.format("飞航向 %03d° 距离 %d NM 来重新开始降落程序.",heading,UTILS.MetersToNM(distance)) + self:MessageToPlayer(playerData,text,"LSO",nil,nil,false,5) + else + self:E(self.lid..string.format("ERROR: Player unit not alive!")) + end elseif playerData.wofd then - - --------------- - -- Foul Deck -- - --------------- - - if playerData.unit:InAir() then - - -- Bolter pattern. Then Abeam or bullseye. - playerData.step = AIRBOSS.PatternStep.BOLTER - - else - - -- Welcome aboard! - self:Sound2Player( playerData, self.LSORadio, self.LSOCall.WELCOMEABOARD ) - - -- Airboss talkto! - -- local text = string.format( "deck was fouled but you landed anyway. Airboss wants to talk to you!" ) - local text = string.format( "汇报甲板阻塞但是你还是降落了. Airboss 想找你喝茶!" ) - self:MessageToPlayer( playerData, text, "LSO", nil, nil, false, 3 ) - - end - + if playerData.unit:InAir()then + playerData.step=AIRBOSS.PatternStep.BOLTER + else + self:Sound2Player(playerData,self.LSORadio,self.LSOCall.WELCOMEABOARD) + -- local text=string.format("deck was fouled but you landed anyway. Airboss wants to talk to you!") + local text=string.format("飞行甲板处于被占用的状况, 但你还是降落了. 航空长想找你谈谈!") + self:MessageToPlayer(playerData,text,"LSO",nil,nil,false,3) + end elseif playerData.owo then - - ------------------ - -- Own Wave Off -- - ------------------ - - if playerData.unit:InAir() then - - -- Bolter pattern. Then Abeam or bullseye. - playerData.step = AIRBOSS.PatternStep.BOLTER - - else - - -- Welcome aboard! - -- NOTE: This should not happen as owo is only triggered if player flew past the carrier. - self:E( self.lid .. "ERROR: player landed when OWO was issues. This should not happen. Please report!" ) - self:Sound2Player( playerData, self.LSORadio, self.LSOCall.WELCOMEABOARD ) - - end - + if playerData.unit:InAir()then + playerData.step=AIRBOSS.PatternStep.BOLTER + else + self:E(self.lid.."ERROR: player landed when OWO was issues. This should not happen. Please report!") + self:Sound2Player(playerData,self.LSORadio,self.LSOCall.WELCOMEABOARD) + end elseif playerData.waveoff then - - -------------- - -- Wave Off -- - -------------- - - if playerData.unit:InAir() then - - -- Bolter pattern. Then Abeam or bullseye. - playerData.step = AIRBOSS.PatternStep.BOLTER - - else - - -- Welcome aboard! - self:Sound2Player( playerData, self.LSORadio, self.LSOCall.WELCOMEABOARD ) - - -- Airboss talkto! - -- local text = string.format( "you were waved off but landed anyway. Airboss wants to talk to you!" ) - local text = string.format( "命令你复飞但是你还是降落了. Airboss 想找你喝茶" ) - self:MessageToPlayer( playerData, text, "LSO", nil, nil, false, 3 ) - - end - + if playerData.unit:InAir()then + playerData.step=AIRBOSS.PatternStep.BOLTER + else + self:Sound2Player(playerData,self.LSORadio,self.LSOCall.WELCOMEABOARD) + -- local text=string.format("you were waved off but landed anyway. Airboss wants to talk to you!") + local text=string.format("被指令复飞, 但是你仍然降落了. 航空长想找你谈谈!") + self:MessageToPlayer(playerData,text,"LSO",nil,nil,false,3) + end elseif playerData.boltered then - - -------------- - -- Boltered -- - -------------- - - if playerData.unit:InAir() then - - -- Bolter pattern. Then Abeam or bullseye. - playerData.step = AIRBOSS.PatternStep.BOLTER - - end - + if playerData.unit:InAir()then + playerData.step=AIRBOSS.PatternStep.BOLTER + end elseif playerData.landed then - - ------------ - -- Landed -- - ------------ - - if not playerData.unit:InAir() then - - -- Welcome aboard! - self:Sound2Player( playerData, self.LSORadio, self.LSOCall.WELCOMEABOARD ) - - end - + if not playerData.unit:InAir()then + self:Sound2Player(playerData,self.LSORadio,self.LSOCall.WELCOMEABOARD) + end else - - -- Message to player. - self:MessageToPlayer( playerData, "Undefined state after landing! Please report.", "ERROR", nil, 20 ) - - -- Next step. - playerData.step = AIRBOSS.PatternStep.UNDEFINED - + -- self:MessageToPlayer(playerData,"Undefined state after landing! Please report.","ERROR",nil,20) + self:MessageToPlayer(playerData,"未被定义的着陆后状态! 请联系服务器管理员汇报错误.","ERROR",nil,20) + playerData.step=AIRBOSS.PatternStep.UNDEFINED end - - -- Player landed and is not in air anymore. - if playerData.landed and not playerData.unit:InAir() then - -- Set recovered flag. - self:_RecoveredElement( playerData.unit ) - - -- Check if all elements - self:_CheckSectionRecovered( playerData ) + if playerData.landed and not playerData.unit:InAir()then + self:_RecoveredElement(playerData.unit) + self:_CheckSectionRecovered(playerData) end - - -- Increase number of passes. - playerData.passes = playerData.passes + 1 - - -- Next step hint for students if any. - self:_StepHint( playerData ) - - -- Reinitialize player data for new approach. - self:_InitPlayer( playerData, playerData.step ) - - -- Debug message. - MESSAGE:New( string.format( "Player step %s.", playerData.step ), 5, "DEBUG" ):ToAllIf( self.Debug ) - - -- Auto save player results. + playerData.passes=playerData.passes+1 + self:_StepHint(playerData) + self:_InitPlayer(playerData,playerData.step) + MESSAGE:New(string.format("Player step %s.",playerData.step),5,"DEBUG"):ToAllIf(self.Debug) if self.autosave and mygrade.finalscore then - self:Save( self.autosavepath, self.autosavefile ) + self:Save(self.autosavepath,self.autosavefile) end -end - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --- CARRIER ROUTING Functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - ---- Check for possible collisions between two coordinates. --- @param #AIRBOSS self --- @param Core.Point#COORDINATE coordto Coordinate to which the collision is check. --- @param Core.Point#COORDINATE coordfrom Coordinate from which the collision is check. --- @return #boolean If true, surface type ahead is not deep water. --- @return #number Max free distance in meters. -function AIRBOSS:_CheckCollisionCoord( coordto, coordfrom ) - - -- Increment in meters. - local dx = 100 - - -- From coordinate. Default 500 in front of the carrier. - local d = 0 + end + function AIRBOSS:_CheckCollisionCoord(coordto,coordfrom) + local dx=100 + local d=0 if coordfrom then - d = 0 + d=0 else - d = 250 - coordfrom = self:GetCoordinate():Translate( d, self:GetHeading() ) + d=250 + coordfrom=self:GetCoordinate():Translate(d,self:GetHeading()) end - - -- Distance between the two coordinates. - local dmax = coordfrom:Get2DDistance( coordto ) - - -- Direction. - local direction = coordfrom:HeadingTo( coordto ) - - -- Scan path between the two coordinates. - local clear = true - while d <= dmax do - - -- Check point. - local cp = coordfrom:Translate( d, direction ) - - -- Check if surface type is water. - if not cp:IsSurfaceTypeWater() then - - -- Debug mark points. - if self.Debug then - local st = cp:GetSurfaceType() - cp:MarkToAll( string.format( "Collision check surface type %d", st ) ) - end - - -- Collision WARNING! - clear = false - break - end - - -- Increase distance. - d = d + dx - end - - local text = "" - if clear then - text = string.format( "Path into direction %03d° is clear for the next %.1f NM.", direction, UTILS.MetersToNM( d ) ) - else - text = string.format( "Detected obstacle at distance %.1f NM into direction %03d°.", UTILS.MetersToNM( d ), direction ) - end - self:T2( self.lid .. text ) - - return not clear, d -end - ---- Check Collision. --- @param #AIRBOSS self --- @param Core.Point#COORDINATE fromcoord Coordinate from which the path to the next WP is calculated. Default current carrier position. --- @return #boolean If true, surface type ahead is not deep water. -function AIRBOSS:_CheckFreePathToNextWP( fromcoord ) - - -- Position. - fromcoord = fromcoord or self:GetCoordinate():Translate( 250, self:GetHeading() ) - - -- Next wp = current+1 (or last) - local Nnextwp = math.min( self.currentwp + 1, #self.waypoints ) - - -- Next waypoint. - local nextwp = self.waypoints[Nnextwp] -- Core.Point#COORDINATE - - -- Check for collision. - local collision = self:_CheckCollisionCoord( nextwp, fromcoord ) - - return collision -end - ---- Find free path to the next waypoint. --- @param #AIRBOSS self -function AIRBOSS:_Pathfinder() - - -- Heading and current coordiante. - local hdg = self:GetHeading() - local cv = self:GetCoordinate() - - -- Possible directions. - local directions = { -20, 20, -30, 30, -40, 40, -50, 50, -60, 60, -70, 70, -80, 80, -90, 90, -100, 100 } - - -- Starboard turns up to 90 degrees. - for _, _direction in pairs( directions ) do - - -- New direction. - local direction = hdg + _direction - - -- Check for collisions in the next 20 NM of the current direction. - local _, dfree = self:_CheckCollisionCoord( cv:Translate( UTILS.NMToMeters( 20 ), direction ), cv ) - - -- Loop over distances and find the first one which gives a clear path to the next waypoint. - local distance = 500 - while distance <= dfree do - - -- Coordinate from which we calculate the path. - local fromcoord = cv:Translate( distance, direction ) - - -- Check for collision between point and next waypoint. - local collision = self:_CheckFreePathToNextWP( fromcoord ) - - -- Debug info. - self:T2( self.lid .. string.format( "Pathfinder d=%.1f m, direction=%03d°, collision=%s", distance, direction, tostring( collision ) ) ) - - -- If path is clear, we start a little detour. - if not collision then - self:CarrierDetour( fromcoord ) - return - end - - distance = distance + 500 - end - end -end - ---- Carrier resumes the route at its next waypoint. --- @param #AIRBOSS self --- @param Core.Point#COORDINATE gotocoord (Optional) First goto this coordinate before resuming route. --- @return #AIRBOSS self -function AIRBOSS:CarrierResumeRoute( gotocoord ) - - -- Make carrier resume its route. - AIRBOSS._ResumeRoute( self.carrier:GetGroup(), self, gotocoord ) - - return self -end - ---- Let the carrier make a detour to a given point. When it reaches the point, it will resume its normal route. --- @param #AIRBOSS self --- @param Core.Point#COORDINATE coord Coordinate of the detour. --- @param #number speed Speed in knots. Default is current carrier velocity. --- @param #boolean uturn (Optional) If true, carrier will go back to where it came from before it resumes its route to the next waypoint. --- @param #number uspeed Speed in knots after U-turn. Default is same as before. --- @param Core.Point#COORDINATE tcoord Additional coordinate to make turn smoother. --- @return #AIRBOSS self -function AIRBOSS:CarrierDetour( coord, speed, uturn, uspeed, tcoord ) - - -- Current coordinate of the carrier. - local pos0 = self:GetCoordinate() - - -- Current speed in knots. - local vel0 = self.carrier:GetVelocityKNOTS() - - -- Default. If speed is not given we take the current speed but at least 5 knots. - speed = speed or math.max( vel0, 5 ) - - -- Speed in km/h. At least 2 knots. - local speedkmh = math.max( UTILS.KnotsToKmph( speed ), UTILS.KnotsToKmph( 2 ) ) - - -- Turn speed in km/h. At least 10 knots. - local cspeedkmh = math.max( self.carrier:GetVelocityKMH(), UTILS.KnotsToKmph( 10 ) ) - - -- U-turn speed in km/h. - local uspeedkmh = UTILS.KnotsToKmph( uspeed or speed ) - - -- Waypoint table. - local wp = {} - - -- Waypoint at current position. - table.insert( wp, pos0:WaypointGround( cspeedkmh ) ) - - -- Waypooint to help the turn. - if tcoord then - table.insert( wp, tcoord:WaypointGround( cspeedkmh ) ) - end - - -- Detour waypoint. - table.insert( wp, coord:WaypointGround( speedkmh ) ) - - -- U-turn waypoint. If enabled, go back to where you came from. - if uturn then - table.insert( wp, pos0:WaypointGround( uspeedkmh ) ) - end - - -- Get carrier group. - local group = self.carrier:GetGroup() - - -- Passing waypoint taskfunction - local TaskResumeRoute = group:TaskFunction( "AIRBOSS._ResumeRoute", self ) - - -- Set task to restart route at the last point. - group:SetTaskWaypoint( wp[#wp], TaskResumeRoute ) - - -- Debug mark. + local dmax=coordfrom:Get2DDistance(coordto) + local direction=coordfrom:HeadingTo(coordto) + local clear=true + while d<=dmax do + local cp=coordfrom:Translate(d,direction) + if not cp:IsSurfaceTypeWater()then if self.Debug then - if tcoord then - tcoord:MarkToAll( string.format( "Detour Turn Help WP. Speed %.1f knots", UTILS.KmphToKnots( cspeedkmh ) ) ) - end - coord:MarkToAll( string.format( "Detour Waypoint. Speed %.1f knots", UTILS.KmphToKnots( speedkmh ) ) ) - if uturn then - pos0:MarkToAll( string.format( "Detour U-turn WP. Speed %.1f knots", UTILS.KmphToKnots( uspeedkmh ) ) ) - end + local st=cp:GetSurfaceType() + cp:MarkToAll(string.format("Collision check surface type %d",st)) end - - -- Detour switch true. - self.detour = true - - -- Route carrier into the wind. - self.carrier:Route( wp ) -end - ---- Let the carrier turn into the wind. --- @param #AIRBOSS self --- @param #number time Time in seconds. --- @param #number vdeck Speed on deck m/s. Carrier will --- @param #boolean uturn Make U-turn and go back to initial after downwind leg. --- @return #AIRBOSS self -function AIRBOSS:CarrierTurnIntoWind( time, vdeck, uturn ) - - -- Wind speed. - local _, vwind = self:GetWind() - - -- Desired wind on deck in knots. + clear=false + break + end + d=d+dx + end + local text="" + if clear then + text=string.format("Path into direction %03d° is clear for the next %.1f NM.",direction,UTILS.MetersToNM(d)) + else + text=string.format("Detected obstacle at distance %.1f NM into direction %03d°.",UTILS.MetersToNM(d),direction) + end + self:T2(self.lid..text) + return not clear,d + end + function AIRBOSS:_CheckFreePathToNextWP(fromcoord) + fromcoord=fromcoord or self:GetCoordinate():Translate(250,self:GetHeading()) + local Nnextwp=math.min(self.currentwp+1,#self.waypoints) + local nextwp=self.waypoints[Nnextwp] + local collision=self:_CheckCollisionCoord(nextwp,fromcoord) + return collision + end + function AIRBOSS:_Pathfinder() + local hdg=self:GetHeading() + local cv=self:GetCoordinate() + local directions={-20,20,-30,30,-40,40,-50,50,-60,60,-70,70,-80,80,-90,90,-100,100} + for _,_direction in pairs(directions)do + local direction=hdg+_direction + local _,dfree=self:_CheckCollisionCoord(cv:Translate(UTILS.NMToMeters(20),direction),cv) + local distance=500 + while distance<=dfree do + local fromcoord=cv:Translate(distance,direction) + local collision=self:_CheckFreePathToNextWP(fromcoord) + self:T2(self.lid..string.format("Pathfinder d=%.1f m, direction=%03d°, collision=%s",distance,direction,tostring(collision))) + if not collision then + self:CarrierDetour(fromcoord) + return + end + distance=distance+500 + end + end + end + function AIRBOSS:CarrierResumeRoute(gotocoord) + AIRBOSS._ResumeRoute(self.carrier:GetGroup(),self,gotocoord) + return self + end + function AIRBOSS:CarrierDetour(coord,speed,uturn,uspeed,tcoord) + local pos0=self:GetCoordinate() + local vel0=self.carrier:GetVelocityKNOTS() + speed=speed or math.max(vel0,5) + local speedkmh=math.max(UTILS.KnotsToKmph(speed),UTILS.KnotsToKmph(2)) + local cspeedkmh=math.max(self.carrier:GetVelocityKMH(),UTILS.KnotsToKmph(10)) + local uspeedkmh=UTILS.KnotsToKmph(uspeed or speed) + local wp={} + table.insert(wp,pos0:WaypointGround(cspeedkmh)) + if tcoord then + table.insert(wp,tcoord:WaypointGround(cspeedkmh)) + end + table.insert(wp,coord:WaypointGround(speedkmh)) + if uturn then + table.insert(wp,pos0:WaypointGround(uspeedkmh)) + end + local group=self.carrier:GetGroup() + local TaskResumeRoute=group:TaskFunction("AIRBOSS._ResumeRoute",self) + group:SetTaskWaypoint(wp[#wp],TaskResumeRoute) + if self.Debug then + if tcoord then + tcoord:MarkToAll(string.format("Detour Turn Help WP. Speed %.1f knots",UTILS.KmphToKnots(cspeedkmh))) + end + coord:MarkToAll(string.format("Detour Waypoint. Speed %.1f knots",UTILS.KmphToKnots(speedkmh))) + if uturn then + pos0:MarkToAll(string.format("Detour U-turn WP. Speed %.1f knots",UTILS.KmphToKnots(uspeedkmh))) + end + end + self.detour=true + self.carrier:Route(wp) + end + function AIRBOSS:CarrierTurnIntoWind(time,vdeck,uturn) + local _,vwind=self:GetWind() local vdeck=UTILS.MpsToKnots(vdeck) - - -- Get heading into the wind accounting for angled runway. - local hiw, speedknots = self:GetHeadingIntoWind(vdeck) - - -- Speed of carrier in m/s but at least 4 knots. - local vtot = UTILS.KnotsToMps(speedknots) - - -- Distance to travel - local dist = vtot * time - - -- Distance in NM. - local distNM = UTILS.MetersToNM( dist ) - - -- Current heading. - local hdg = self:GetHeading() - - -- Heading difference. - local deltaH = self:_GetDeltaHeading( hdg, hiw ) - - -- Debug output - self:I( self.lid .. string.format( "Carrier steaming into the wind (%.1f kts). Heading=%03d-->%03d (Delta=%.1f), Speed=%.1f knots, Distance=%.1f NM, Time=%d sec", - UTILS.MpsToKnots( vwind ), hdg, hiw, deltaH, speedknots, distNM, speedknots, time ) ) - - -- Current coordinate. - local Cv = self:GetCoordinate() - - local Ctiw = nil -- Core.Point#COORDINATE - local Csoo = nil -- Core.Point#COORDINATE - - -- Define path depending on turn angle. - if deltaH < 45 then - -- Small turn. - - -- Point in the right direction to help turning. - Csoo = Cv:Translate( 750, hdg ):Translate( 750, hiw ) - - -- Heading into wind from Csoo. - local hsw = self:GetHeadingIntoWind(vdeck, false, Csoo ) - - -- Into the wind coord. - Ctiw = Csoo:Translate( dist, hsw ) - - elseif deltaH < 90 then - -- Medium turn. - - -- Point in the right direction to help turning. - Csoo = Cv:Translate( 900, hdg ):Translate( 900, hiw ) - - -- Heading into wind from Csoo. - local hsw = self:GetHeadingIntoWind(vdeck, false, Csoo ) - - -- Into the wind coord. - Ctiw = Csoo:Translate( dist, hsw ) - - elseif deltaH < 135 then - -- Large turn backwards. - - -- Point in the right direction to help turning. - Csoo = Cv:Translate( 1100, hdg - 90 ):Translate( 1000, hiw ) - - -- Heading into wind from Csoo. - local hsw = self:GetHeadingIntoWind(vdeck, false, Csoo ) - - -- Into the wind coord. - Ctiw = Csoo:Translate( dist, hsw ) - + local hiw,speedknots=self:GetHeadingIntoWind(vdeck) + local vtot=UTILS.KnotsToMps(speedknots) + local dist=vtot*time + local distNM=UTILS.MetersToNM(dist) + local hdg=self:GetHeading() + local deltaH=self:_GetDeltaHeading(hdg,hiw) + self:I(self.lid..string.format("Carrier steaming into the wind (%.1f kts). Heading=%03d-->%03d (Delta=%.1f), Speed=%.1f knots, Distance=%.1f NM, Time=%d sec", + UTILS.MpsToKnots(vwind),hdg,hiw,deltaH,speedknots,distNM,speedknots,time)) + local Cv=self:GetCoordinate() + local Ctiw=nil + local Csoo=nil + if deltaH<45 then + Csoo=Cv:Translate(750,hdg):Translate(750,hiw) + local hsw=self:GetHeadingIntoWind(vdeck,false,Csoo) + Ctiw=Csoo:Translate(dist,hsw) + elseif deltaH<90 then + Csoo=Cv:Translate(900,hdg):Translate(900,hiw) + local hsw=self:GetHeadingIntoWind(vdeck,false,Csoo) + Ctiw=Csoo:Translate(dist,hsw) + elseif deltaH<135 then + Csoo=Cv:Translate(1100,hdg-90):Translate(1000,hiw) + local hsw=self:GetHeadingIntoWind(vdeck,false,Csoo) + Ctiw=Csoo:Translate(dist,hsw) else - -- Huge turn backwards. - - -- Point in the right direction to help turning. - Csoo = Cv:Translate( 1200, hdg - 90 ):Translate( 1000, hiw ) - - -- Heading into wind from Csoo. - local hsw = self:GetHeadingIntoWind(vdeck, false, Csoo ) - - -- Into the wind coord. - Ctiw = Csoo:Translate( dist, hsw ) - + Csoo=Cv:Translate(1200,hdg-90):Translate(1000,hiw) + local hsw=self:GetHeadingIntoWind(vdeck,false,Csoo) + Ctiw=Csoo:Translate(dist,hsw) end - - -- Return to coordinate if collision is detected. - self.Creturnto = self:GetCoordinate() - - -- Next waypoint. - local nextwp = self:_GetNextWaypoint() - - -- For downwind, we take the velocity at the next WP. - local vdownwind = UTILS.MpsToKnots( nextwp:GetVelocity() ) - - -- Make sure we move at all in case the speed at the waypoint is zero. - if vdownwind < 1 then - vdownwind = 10 + self.Creturnto=self:GetCoordinate() + local nextwp=self:_GetNextWaypoint() + local vdownwind=UTILS.MpsToKnots(nextwp:GetVelocity()) + if vdownwind<1 then + vdownwind=10 end - - -- Let the carrier make a detour from its route but return to its current position. - self:CarrierDetour( Ctiw, speedknots, uturn, vdownwind, Csoo ) - - -- Set switch that we are currently turning into the wind. - self.turnintowind = true - + self:CarrierDetour(Ctiw,speedknots,uturn,vdownwind,Csoo) + self.turnintowind=true return self -end - ---- Get next waypoint of the carrier. --- @param #AIRBOSS self --- @return Core.Point#COORDINATE Coordinate of the next waypoint. --- @return #number Number of waypoint. -function AIRBOSS:_GetNextWaypoint() - - -- Next waypoint. - local Nextwp = nil - if self.currentwp == #self.waypoints then - Nextwp = 1 + end + function AIRBOSS:_GetNextWaypoint() + local Nextwp=nil + if self.currentwp==#self.waypoints then + Nextwp=1 else - Nextwp = self.currentwp + 1 + Nextwp=self.currentwp+1 + end + local text=string.format("Current WP=%d/%d, next WP=%d",self.currentwp,#self.waypoints,Nextwp) + self:T2(self.lid..text) + local nextwp=self.waypoints[Nextwp] + return nextwp,Nextwp + end + function AIRBOSS:_InitWaypoints() + local Waypoints=self.carrier:GetGroup():GetTemplateRoutePoints() + self.waypoints={} + for i,point in ipairs(Waypoints)do + local coord=COORDINATE:New(point.x,point.alt,point.y) + coord:SetVelocity(point.speed) + table.insert(self.waypoints,coord) + if self.Debug then + coord:MarkToAll(string.format("Carrier Waypoint %d, Speed=%.1f knots",i,UTILS.MpsToKnots(point.speed))) end - - -- Debug output - local text = string.format( "Current WP=%d/%d, next WP=%d", self.currentwp, #self.waypoints, Nextwp ) - self:T2( self.lid .. text ) - - -- Next waypoint. - local nextwp = self.waypoints[Nextwp] -- Core.Point#COORDINATE - - return nextwp, Nextwp -end - ---- Initialize Mission Editor waypoints. --- @param #AIRBOSS self --- @return #AIRBOSS self -function AIRBOSS:_InitWaypoints() - - -- Waypoints of group as defined in the ME. - local Waypoints = self.carrier:GetGroup():GetTemplateRoutePoints() - - -- Init array. - self.waypoints = {} - - -- Set waypoint table. - for i, point in ipairs( Waypoints ) do - - -- Coordinate of the waypoint - local coord = COORDINATE:New( point.x, point.alt, point.y ) - - -- Set velocity of the coordinate. - coord:SetVelocity( point.speed ) - - -- Add to table. - table.insert( self.waypoints, coord ) - - -- Debug info. - if self.Debug then - coord:MarkToAll( string.format( "Carrier Waypoint %d, Speed=%.1f knots", i, UTILS.MpsToKnots( point.speed ) ) ) - end - end - return self -end - ---- Patrol carrier. --- @param #AIRBOSS self --- @param #number n Next waypoint number. --- @return #AIRBOSS self -function AIRBOSS:_PatrolRoute( n ) - - -- Get next waypoint coordinate and number. - local nextWP, N = self:_GetNextWaypoint() - - -- Default resume is to next waypoint. - n = n or N - - -- Get carrier group. - local CarrierGroup = self.carrier:GetGroup() - - -- Waypoints table. - local Waypoints = {} - - -- Create a waypoint from the current coordinate. - local wp = self:GetCoordinate():WaypointGround( CarrierGroup:GetVelocityKMH() ) - - -- Add current position as first waypoint. - table.insert( Waypoints, wp ) - - -- Loop over waypoints. - for i = n, #self.waypoints do - local coord = self.waypoints[i] -- Core.Point#COORDINATE - - -- Create a waypoint from the coordinate. - local wp = coord:WaypointGround( UTILS.MpsToKmph( coord.Velocity ) ) - - -- Passing waypoint taskfunction - local TaskPassingWP = CarrierGroup:TaskFunction( "AIRBOSS._PassingWaypoint", self, i, #self.waypoints ) - - -- Call task function when carrier arrives at waypoint. - CarrierGroup:SetTaskWaypoint( wp, TaskPassingWP ) - - -- Add waypoint to table. - table.insert( Waypoints, wp ) end - - -- Route carrier group. - CarrierGroup:Route( Waypoints ) - + function AIRBOSS:_PatrolRoute(n) + local nextWP,N=self:_GetNextWaypoint() + n=n or N + local CarrierGroup=self.carrier:GetGroup() + local Waypoints={} + local wp=self:GetCoordinate():WaypointGround(CarrierGroup:GetVelocityKMH()) + table.insert(Waypoints,wp) + for i=n,#self.waypoints do + local coord=self.waypoints[i] + local wp=coord:WaypointGround(UTILS.MpsToKmph(coord.Velocity)) + local TaskPassingWP=CarrierGroup:TaskFunction("AIRBOSS._PassingWaypoint",self,i,#self.waypoints) + CarrierGroup:SetTaskWaypoint(wp,TaskPassingWP) + table.insert(Waypoints,wp) + end + CarrierGroup:Route(Waypoints) return self -end - ---- Estimated the carrier position at some point in the future given the current waypoints and speeds. --- @param #AIRBOSS self --- @return DCS#time ETA abs. time in seconds. -function AIRBOSS:_GetETAatNextWP() - - -- Current waypoint - local cwp = self.currentwp - - -- Current abs. time. - local tnow = timer.getAbsTime() - - -- Current position. - local p = self:GetCoordinate() - - -- Current velocity [m/s]. - local v = self.carrier:GetVelocityMPS() - - -- Next waypoint. - local nextWP = self:_GetNextWaypoint() - - -- Distance to next waypoint. - local s = p:Get2DDistance( nextWP ) - - -- Distance to next waypoint. - -- local s=0 - -- if #self.waypoints>cwp then - -- s=p:Get2DDistance(self.waypoints[cwp+1]) - -- end - - -- v=s/t <==> t=s/v - local t = s / v - - -- ETA - local eta = t + tnow - + end + function AIRBOSS:_GetETAatNextWP() + local cwp=self.currentwp + local tnow=timer.getAbsTime() + local p=self:GetCoordinate() + local v=self.carrier:GetVelocityMPS() + local nextWP=self:_GetNextWaypoint() + local s=p:Get2DDistance(nextWP) + local t=s/v + local eta=t+tnow return eta -end - ---- Check if carrier is turning. If turning started or stopped, we inform the players via radio message. --- @param #AIRBOSS self -function AIRBOSS:_CheckCarrierTurning() - - -- Current orientation of carrier. - local vNew = self.carrier:GetOrientationX() - - -- Last orientation from 30 seconds ago. - local vLast = self.Corientlast - - -- We only need the X-Z plane. - vNew.y = 0; - vLast.y = 0 - - -- Angle between current heading and last time we checked ~30 seconds ago. - local deltaLast = math.deg( math.acos( UTILS.VecDot( vNew, vLast ) / UTILS.VecNorm( vNew ) / UTILS.VecNorm( vLast ) ) ) - - -- Last orientation becomes new orientation - self.Corientlast = vNew - - -- Carrier is turning when its heading changed by at least one degree since last check. - local turning = math.abs( deltaLast ) >= 1 - - -- Check if turning stopped. (Carrier was turning but is not any more.) + end + function AIRBOSS:_CheckCarrierTurning() + local vNew=self.carrier:GetOrientationX() + local vLast=self.Corientlast + vNew.y=0; + vLast.y=0 + local deltaLast=math.deg(math.acos(UTILS.VecDot(vNew,vLast)/UTILS.VecNorm(vNew)/UTILS.VecNorm(vLast))) + self.Corientlast=vNew + local turning=math.abs(deltaLast)>=1 if self.turning and not turning then - - -- Get final bearing. - local FB = self:GetFinalBearing( true ) - - -- Marshal radio call: "99, new final bearing XYZ degrees." - self:_MarshalCallNewFinalBearing( FB ) - + local FB=self:GetFinalBearing(true) + self:_MarshalCallNewFinalBearing(FB) end - - -- Check if turning started. (Carrier was not turning and is now.) if turning and not self.turning then - - -- Get heading. - local hdg - if self.turnintowind then - -- We are now steaming into the wind. - local vdeck=self.recoverywindow and self.recoverywindow.SPEED or 20 - hdg = self:GetHeadingIntoWind(vdeck, false) - else - -- We turn towards the next waypoint. - hdg = self:GetCoordinate():HeadingTo( self:_GetNextWaypoint() ) - end - - -- Magnetic! - hdg = hdg - self.magvar - if hdg < 0 then - hdg = 360 + hdg - end - - -- Radio call: "99, Carrier starting turn to heading XYZ degrees". - self:_MarshalCallCarrierTurnTo( hdg ) + local hdg + if self.turnintowind then + local vdeck=self.recoverywindow and self.recoverywindow.SPEED or 20 + hdg=self:GetHeadingIntoWind(vdeck,false) + else + hdg=self:GetCoordinate():HeadingTo(self:_GetNextWaypoint()) end - - -- Update turning. - self.turning = turning -end - ---- Check if heading or position of carrier have changed significantly. --- @param #AIRBOSS self -function AIRBOSS:_CheckPatternUpdate() - - ---------------------------------------- - -- TODO: Make parameters input values -- - ---------------------------------------- - - -- Min 10 min between pattern updates. - local dTPupdate = 10 * 60 - - -- Update if carrier moves by more than 2.5 NM. - local Dupdate = UTILS.NMToMeters( 2.5 ) - - -- Update if carrier turned by more than 5°. - local Hupdate = 5 - - ----------------------- - -- Time Update Check -- - ----------------------- - - -- Time since last pattern update - local dt = timer.getTime() - self.Tpupdate - - -- Check whether at least 10 min between updates and not turning currently. - if dt < dTPupdate or self.turning then - return + hdg=hdg-self.magvar + if hdg<0 then + hdg=360+hdg end - - -------------------------- - -- Heading Update Check -- - -------------------------- - - -- Current orientation of carrier. - local vNew = self.carrier:GetOrientationX() - - -- Reference orientation of carrier after the last update. - local vOld = self.Corientation - - -- We only need the X-Z plane. - vNew.y = 0; - vOld.y = 0 - - -- Get angle between old and new orientation vectors in rad and convert to degrees. - local deltaHeading = math.deg( math.acos( UTILS.VecDot( vNew, vOld ) / UTILS.VecNorm( vNew ) / UTILS.VecNorm( vOld ) ) ) - - -- Check if orientation changed. - local Hchange = false - if math.abs( deltaHeading ) >= Hupdate then - self:T( self.lid .. string.format( "Carrier heading changed by %d°.", deltaHeading ) ) - Hchange = true + self:_MarshalCallCarrierTurnTo(hdg) end - - --------------------------- - -- Distance Update Check -- - --------------------------- - - -- Get current position and orientation of carrier. - local pos = self:GetCoordinate() - - -- Get distance to saved position. - local dist = pos:Get2DDistance( self.Cposition ) - - -- Check if carrier moved more than ~10 km. - local Dchange = false - if dist >= Dupdate then - self:T( self.lid .. string.format( "Carrier position changed by %.1f NM.", UTILS.MetersToNM( dist ) ) ) - Dchange = true + self.turning=turning + end + function AIRBOSS:_CheckPatternUpdate() + local dTPupdate=10*60 + local Dupdate=UTILS.NMToMeters(2.5) + local Hupdate=5 + local dt=timer.getTime()-self.Tpupdate + if dt=Hupdate then + self:T(self.lid..string.format("Carrier heading changed by %d°.",deltaHeading)) + Hchange=true + end + local pos=self:GetCoordinate() + local dist=pos:Get2DDistance(self.Cposition) + local Dchange=false + if dist>=Dupdate then + self:T(self.lid..string.format("Carrier position changed by %.1f NM.",UTILS.MetersToNM(dist))) + Dchange=true end - - ---------------------------- - -- Update Marshal Flights -- - ---------------------------- - - -- If heading or distance changed ==> update marshal AI patterns. if Hchange or Dchange then - - -- Loop over all marshal flights - for _, _flight in pairs( self.Qmarshal ) do - local flight = _flight -- #AIRBOSS.FlightGroup - - -- Update marshal pattern of AI keeping the same stack. - if flight.ai then - self:_MarshalAI( flight, flight.flag ) - end - - end - - -- Reset parameters for next update check. - self.Corientation = vNew - self.Cposition = pos - self.Tpupdate = timer.getTime() + for _,_flight in pairs(self.Qmarshal)do + local flight=_flight + if flight.ai then + self:_MarshalAI(flight,flight.flag) end - -end - ---- Function called when a group is passing a waypoint. --- @param Wrapper.Group#GROUP group Group that passed the waypoint --- @param #AIRBOSS airboss Airboss object. --- @param #number i Waypoint number that has been reached. --- @param #number final Final waypoint number. -function AIRBOSS._PassingWaypoint( group, airboss, i, final ) - - -- Debug message. - local text = string.format( "Group %s passing waypoint %d of %d.", group:GetName(), i, final ) - - -- Debug smoke and marker. + end + self.Corientation=vNew + self.Cposition=pos + self.Tpupdate=timer.getTime() + end + end + function AIRBOSS._PassingWaypoint(group,airboss,i,final) + local text=string.format("Group %s passing waypoint %d of %d.",group:GetName(),i,final) if airboss.Debug and false then - local pos = group:GetCoordinate() - pos:SmokeRed() - local MarkerID = pos:MarkToAll( string.format( "Group %s reached waypoint %d", group:GetName(), i ) ) + local pos=group:GetCoordinate() + pos:SmokeRed() + local MarkerID=pos:MarkToAll(string.format("Group %s reached waypoint %d",group:GetName(),i)) end - - -- Debug message. - MESSAGE:New( text, 10 ):ToAllIf( airboss.Debug ) - airboss:T( airboss.lid .. text ) - - -- Set current waypoint. - airboss.currentwp = i - - -- Passing Waypoint event. - airboss:PassingWaypoint( i ) - - -- Reactivate beacons. - -- airboss:_ActivateBeacons() - - -- If final waypoint reached, do route all over again. - if i == final and final > 1 and airboss.adinfinitum then - airboss:_PatrolRoute() + MESSAGE:New(text,10):ToAllIf(airboss.Debug) + airboss:T(airboss.lid..text) + airboss.currentwp=i + airboss:PassingWaypoint(i) + if i==final and final>1 and airboss.adinfinitum then + airboss:_PatrolRoute() end -end - ---- Carrier Strike Group resumes the route of the waypoints defined in the mission editor. --- @param Wrapper.Group#GROUP group Carrier Strike Group that passed the waypoint. --- @param #AIRBOSS airboss Airboss object. --- @param Core.Point#COORDINATE gotocoord Go to coordinate before route is resumed. -function AIRBOSS._ResumeRoute( group, airboss, gotocoord ) - - -- Get next waypoint - local nextwp, Nextwp = airboss:_GetNextWaypoint() - - -- Speed set at waypoint. - local speedkmh = nextwp.Velocity * 3.6 - - -- If speed at waypoint is zero, we set it to 10 knots. - if speedkmh < 1 then - speedkmh = UTILS.KnotsToKmph( 10 ) end - - -- Waypoints array. - local waypoints = {} - - -- Current position. - local c0 = group:GetCoordinate() - - -- Current positon as first waypoint. - local wp0 = c0:WaypointGround( speedkmh ) - table.insert( waypoints, wp0 ) - - -- First goto this coordinate. + function AIRBOSS._ResumeRoute(group,airboss,gotocoord) + local nextwp,Nextwp=airboss:_GetNextWaypoint() + local speedkmh=nextwp.Velocity*3.6 + if speedkmh<1 then + speedkmh=UTILS.KnotsToKmph(10) + end + local waypoints={} + local c0=group:GetCoordinate() + local wp0=c0:WaypointGround(speedkmh) + table.insert(waypoints,wp0) if gotocoord then - - -- gotocoord:MarkToAll(string.format("Goto waypoint speed=%.1f km/h", speedkmh)) - - local headingto = c0:HeadingTo( gotocoord ) - - local hdg1 = airboss:GetHeading() - local hdg2 = c0:HeadingTo( gotocoord ) - local delta = airboss:_GetDeltaHeading( hdg1, hdg2 ) - - -- env.info(string.format("FF hdg1=%d, hdg2=%d, delta=%d", hdg1, hdg2, delta)) - - -- Add additional turn points - if delta > 90 then - - -- Turn radius 3 NM. - local turnradius = UTILS.NMToMeters( 3 ) - - local gotocoordh = c0:Translate( turnradius, hdg1 + 45 ) - -- gotocoordh:MarkToAll(string.format("Goto help waypoint 1 speed=%.1f km/h", speedkmh)) - - local wp = gotocoordh:WaypointGround( speedkmh ) - table.insert( waypoints, wp ) - - gotocoordh = c0:Translate( turnradius, hdg1 + 90 ) - -- gotocoordh:MarkToAll(string.format("Goto help waypoint 2 speed=%.1f km/h", speedkmh)) - - wp = gotocoordh:WaypointGround( speedkmh ) - table.insert( waypoints, wp ) - - end - - local wp1 = gotocoord:WaypointGround( speedkmh ) - table.insert( waypoints, wp1 ) - + local headingto=c0:HeadingTo(gotocoord) + local hdg1=airboss:GetHeading() + local hdg2=c0:HeadingTo(gotocoord) + local delta=airboss:_GetDeltaHeading(hdg1,hdg2) + if delta>90 then + local turnradius=UTILS.NMToMeters(3) + local gotocoordh=c0:Translate(turnradius,hdg1+45) + local wp=gotocoordh:WaypointGround(speedkmh) + table.insert(waypoints,wp) + gotocoordh=c0:Translate(turnradius,hdg1+90) + wp=gotocoordh:WaypointGround(speedkmh) + table.insert(waypoints,wp) end - - -- Debug message. - local text = string.format( "Carrier is resuming route. Next waypoint %d, Speed=%.1f knots.", Nextwp, UTILS.KmphToKnots( speedkmh ) ) - - -- Debug message. - MESSAGE:New( text, 10 ):ToAllIf( airboss.Debug ) - airboss:I( airboss.lid .. text ) - - -- Loop over all remaining waypoints. - for i = Nextwp, #airboss.waypoints do - - -- Coordinate of the next WP. - local coord = airboss.waypoints[i] -- Core.Point#COORDINATE - - -- Speed in km/h of that WP. Velocity is in m/s. - local speed = coord.Velocity * 3.6 - - -- If speed is zero we set it to 10 knots. - if speed < 1 then - speed = UTILS.KnotsToKmph( 10 ) - end - - -- coord:MarkToAll(string.format("Resume route WP %d, speed=%.1f km/h", i, speed)) - - -- Create waypoint. - local wp = coord:WaypointGround( speed ) - - -- Passing waypoint task function. - local TaskPassingWP = group:TaskFunction( "AIRBOSS._PassingWaypoint", airboss, i, #airboss.waypoints ) - - -- Call task function when carrier arrives at waypoint. - group:SetTaskWaypoint( wp, TaskPassingWP ) - - -- Add waypoints to table. - table.insert( waypoints, wp ) + local wp1=gotocoord:WaypointGround(speedkmh) + table.insert(waypoints,wp1) end - - -- Set turn into wind switch false. - airboss.turnintowind = false - airboss.detour = false - - -- Route group. - group:Route( waypoints ) -end - ---- Function called when a group has reached the holding zone. --- @param Wrapper.Group#GROUP group Group that reached the holding zone. --- @param #AIRBOSS airboss Airboss object. --- @param #AIRBOSS.FlightGroup flight Flight group that has reached the holding zone. -function AIRBOSS._ReachedHoldingZone( group, airboss, flight ) - - -- Debug message. - local text = string.format( "Flight %s reached holding zone.", group:GetName() ) - MESSAGE:New( text, 10 ):ToAllIf( airboss.Debug ) - airboss:T( airboss.lid .. text ) - - -- Debug mark. + local text=string.format("Carrier is resuming route. Next waypoint %d, Speed=%.1f knots.",Nextwp,UTILS.KmphToKnots(speedkmh)) + MESSAGE:New(text,10):ToAllIf(airboss.Debug) + airboss:I(airboss.lid..text) + for i=Nextwp,#airboss.waypoints do + local coord=airboss.waypoints[i] + local speed=coord.Velocity*3.6 + if speed<1 then + speed=UTILS.KnotsToKmph(10) + end + local wp=coord:WaypointGround(speed) + local TaskPassingWP=group:TaskFunction("AIRBOSS._PassingWaypoint",airboss,i,#airboss.waypoints) + group:SetTaskWaypoint(wp,TaskPassingWP) + table.insert(waypoints,wp) + end + airboss.turnintowind=false + airboss.detour=false + group:Route(waypoints) + end + function AIRBOSS._ReachedHoldingZone(group,airboss,flight) + local text=string.format("Flight %s reached holding zone.",group:GetName()) + MESSAGE:New(text,10):ToAllIf(airboss.Debug) + airboss:T(airboss.lid..text) if airboss.Debug then - group:GetCoordinate():MarkToAll( text ) + group:GetCoordinate():MarkToAll(text) end - - -- Set holding flag true and set timestamp for marshal time check. if flight then - flight.holding = true - flight.time = timer.getAbsTime() + flight.holding=true + flight.time=timer.getAbsTime() end -end - ---- Function called when a group should be send to the Marshal stack. If stack is full, it is send to wait. --- @param Wrapper.Group#GROUP group Group that reached the holding zone. --- @param #AIRBOSS airboss Airboss object. --- @param #AIRBOSS.FlightGroup flight Flight group that has reached the holding zone. -function AIRBOSS._TaskFunctionMarshalAI( group, airboss, flight ) - - -- Debug message. - local text = string.format( "Flight %s is send to marshal.", group:GetName() ) - MESSAGE:New( text, 10 ):ToAllIf( airboss.Debug ) - airboss:T( airboss.lid .. text ) - - -- Get the next free stack for current recovery case. - local stack = airboss:_GetFreeStack( flight.ai ) - + end + function AIRBOSS._TaskFunctionMarshalAI(group,airboss,flight) + local text=string.format("Flight %s is send to marshal.",group:GetName()) + MESSAGE:New(text,10):ToAllIf(airboss.Debug) + airboss:T(airboss.lid..text) + local stack=airboss:_GetFreeStack(flight.ai) if stack then - - -- Send AI to marshal stack. - airboss:_MarshalAI( flight, stack ) - + airboss:_MarshalAI(flight,stack) else - - -- Send AI to orbit outside 10 NM zone and wait until the next Marshal stack is available. - if not airboss:_InQueue( airboss.Qwaiting, flight.group ) then - airboss:_WaitAI( flight ) - end - + if not airboss:_InQueue(airboss.Qwaiting,flight.group)then + airboss:_WaitAI(flight) end - - -- If it came from refueling. - if flight.refueling == true then - airboss:I( airboss.lid .. string.format( "Flight group %s finished refueling task.", flight.groupname ) ) end - - -- Not refueling any more in case it was. - flight.refueling = false - -end - ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- MISC functions ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ---- Get aircraft nickname. --- @param #AIRBOSS self --- @param #string actype Aircraft type name. --- @return #string Aircraft nickname. E.g. "Hornet" for the F/A-18C or "Tomcat" For the F-14A. -function AIRBOSS:_GetACNickname( actype ) - - local nickname = "unknown" - if actype == AIRBOSS.AircraftCarrier.A4EC then - nickname = "Skyhawk" - elseif actype == AIRBOSS.AircraftCarrier.T45C then - nickname = "Goshawk" - elseif actype == AIRBOSS.AircraftCarrier.AV8B then - nickname = "Harrier" - elseif actype == AIRBOSS.AircraftCarrier.E2D then - nickname = "Hawkeye" - elseif actype == AIRBOSS.AircraftCarrier.F14A_AI or actype == AIRBOSS.AircraftCarrier.F14A or actype == AIRBOSS.AircraftCarrier.F14B then - nickname = "Tomcat" - elseif actype == AIRBOSS.AircraftCarrier.FA18C or actype == AIRBOSS.AircraftCarrier.HORNET then - nickname = "Hornet" - elseif actype == AIRBOSS.AircraftCarrier.RHINOE or actype == AIRBOSS.AircraftCarrier.RHINOF then - nickname = "Rhino" - elseif actype == AIRBOSS.AircraftCarrier.GROWLER then - nickname = "Growler" - elseif actype == AIRBOSS.AircraftCarrier.S3B or actype == AIRBOSS.AircraftCarrier.S3BTANKER then - nickname = "Viking" + if flight.refueling==true then + airboss:I(airboss.lid..string.format("Flight group %s finished refueling task.",flight.groupname)) + end + flight.refueling=false + end + function AIRBOSS:_GetACNickname(actype) + local nickname="unknown" + if actype==AIRBOSS.AircraftCarrier.A4EC then + nickname="Skyhawk" + elseif actype==AIRBOSS.AircraftCarrier.T45C then + nickname="Goshawk" + elseif actype==AIRBOSS.AircraftCarrier.AV8B then + nickname="Harrier" + elseif actype==AIRBOSS.AircraftCarrier.E2D then + nickname="Hawkeye" + elseif actype==AIRBOSS.AircraftCarrier.C2A then + nickname="Greyhound" + elseif actype==AIRBOSS.AircraftCarrier.F14A_AI or actype==AIRBOSS.AircraftCarrier.F14A or actype==AIRBOSS.AircraftCarrier.F14B then + nickname="Tomcat" + elseif actype==AIRBOSS.AircraftCarrier.FA18C or actype==AIRBOSS.AircraftCarrier.HORNET then + nickname="Hornet" + elseif actype==AIRBOSS.AircraftCarrier.RHINOE or actype==AIRBOSS.AircraftCarrier.RHINOF then + nickname="Rhino" + elseif actype==AIRBOSS.AircraftCarrier.GROWLER then + nickname="Growler" + elseif actype==AIRBOSS.AircraftCarrier.S3B or actype==AIRBOSS.AircraftCarrier.S3BTANKER then + nickname="Viking" end - return nickname -end - ---- Get onboard number of player or client. --- @param #AIRBOSS self --- @param Wrapper.Group#GROUP group Aircraft group. --- @return #string Onboard number as string. -function AIRBOSS:_GetOnboardNumberPlayer( group ) - return self:_GetOnboardNumbers( group, true ) -end - ---- Get onboard numbers of all units in a group. --- @param #AIRBOSS self --- @param Wrapper.Group#GROUP group Aircraft group. --- @param #boolean playeronly If true, return the onboard number for player or client skill units. --- @return #table Table of onboard numbers. -function AIRBOSS:_GetOnboardNumbers( group, playeronly ) - -- self:F({groupname=group:GetName}) - - -- Get group name. - local groupname = group:GetName() - - -- Debug text. - local text = string.format( "Onboard numbers of group %s:", groupname ) - + end + function AIRBOSS:_GetOnboardNumberPlayer(group) + return self:_GetOnboardNumbers(group,true) + end + function AIRBOSS:_GetOnboardNumbers(group,playeronly) + local groupname=group:GetName() + local text=string.format("Onboard numbers of group %s:",groupname) local template=group:GetTemplate() - - local numbers = {} + local numbers={} if template then - - -- Units of template group. - local units = template.units - - -- Get numbers. - for _, unit in pairs( units ) do - - -- Onboard number and unit name. - local n = tostring( unit.onboard_num ) - local name = unit.name - local skill = unit.skill or "Unknown" - - -- Debug text. - text = text .. string.format( "\n- unit %s: onboard #=%s skill=%s", name, n, tostring( skill ) ) - - if playeronly and skill == "Client" or skill == "Player" then - -- There can be only one player in the group, so we skip everything else. - return n - end - - -- Table entry. - numbers[name] = n - end - - -- Debug info. - self:T2( self.lid .. text ) - + local units=template.units + for _,unit in pairs(units)do + local n=tostring(unit.onboard_num) + local name=unit.name + local skill=unit.skill or"Unknown" + text=text..string.format("\n- unit %s: onboard #=%s skill=%s",name,n,tostring(skill)) + if playeronly and skill=="Client"or skill=="Player"then + return n + end + numbers[name]=n + end + self:T2(self.lid..text) else - - if playeronly then - return 101 - else - - local units=group:GetUnits() - - for i,_unit in pairs(units) do - local name=_unit:GetName() - - numbers[name]=100+i - - end - - end - + if playeronly then + return 101 + else + local units=group:GetUnits() + for i,_unit in pairs(units)do + local name=_unit:GetName() + numbers[name]=100+i + end + end end - return numbers -end - ---- Get Tower frequency of carrier. --- @param #AIRBOSS self -function AIRBOSS:_GetTowerFrequency() - - -- Tower frequency in MHz - self.TowerFreq = 0 - - -- Get Template of Strike Group - local striketemplate = self.carrier:GetGroup():GetTemplate() - - -- Find the carrier unit. - for _, unit in pairs( striketemplate.units ) do - if self.carrier:GetName() == unit.name then - self.TowerFreq = unit.frequency / 1000000 - return - end end -end - ---- Get error margin depending on player skill. --- --- * Flight students: 10% and 20% --- * Naval Aviators: 5% and 10% --- * TOPGUN Graduates: 2.5% and 5% --- --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. --- @return #number Error margin for still being okay. --- @return #number Error margin for really sucking. -function AIRBOSS:_GetGoodBadScore( playerData ) - + function AIRBOSS:_GetTowerFrequency() + self.TowerFreq=0 + local striketemplate=self.carrier:GetGroup():GetTemplate() + for _,unit in pairs(striketemplate.units)do + if self.carrier:GetName()==unit.name then + self.TowerFreq=unit.frequency/1000000 + return + end + end + end + function AIRBOSS:_GetGoodBadScore(playerData) local lowscore local badscore - if playerData.difficulty == AIRBOSS.Difficulty.EASY then - lowscore = 10 - badscore = 20 - elseif playerData.difficulty == AIRBOSS.Difficulty.NORMAL then - lowscore = 5 - badscore = 10 - elseif playerData.difficulty == AIRBOSS.Difficulty.HARD then - lowscore = 2.5 - badscore = 5 - end - - return lowscore, badscore -end - ---- Check if aircraft is capable of landing on this aircraft carrier. --- @param #AIRBOSS self --- @param Wrapper.Unit#UNIT unit Aircraft unit. (Will also work with groups as given parameter.) --- @return #boolean If true, aircraft can land on a carrier. -function AIRBOSS:_IsCarrierAircraft( unit ) - - -- Get aircraft type name - local aircrafttype = unit:GetTypeName() - - -- Special case for Harrier which can only land on Tarawa, LHA and LHD. - if aircrafttype == AIRBOSS.AircraftCarrier.AV8B then - if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then - return true - else - return false - end - end - - -- Also only Harriers can land on the Tarawa, LHA and LHD. - if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then - if aircrafttype ~= AIRBOSS.AircraftCarrier.AV8B then - return false - end - end - - -- Loop over all other known carrier capable aircraft. - for _, actype in pairs( AIRBOSS.AircraftCarrier ) do - - -- Check if this is a carrier capable aircraft type. - if actype == aircrafttype then - return true - end - end - - -- No carrier carrier aircraft. - return false -end - ---- Checks if a human player sits in the unit. --- @param #AIRBOSS self --- @param Wrapper.Unit#UNIT unit Aircraft unit. --- @return #boolean If true, human player inside the unit. -function AIRBOSS:_IsHumanUnit( unit ) - - -- Get player unit or nil if no player unit. - local playerunit = self:_GetPlayerUnitAndName( unit:GetName() ) - - if playerunit then - return true - else - return false - end -end - ---- Checks if a group has a human player. --- @param #AIRBOSS self --- @param Wrapper.Group#GROUP group Aircraft group. --- @return #boolean If true, human player inside group. -function AIRBOSS:_IsHuman( group ) - - -- Get all units of the group. - local units = group:GetUnits() - - -- Loop over all units. - for _, _unit in pairs( units ) do - -- Check if unit is human. - local human = self:_IsHumanUnit( _unit ) - if human then - return true - end - end - - return false -end - ---- Get fuel state in pounds. --- @param #AIRBOSS self --- @param Wrapper.Unit#UNIT unit The unit for which the mass is determined. --- @return #number Fuel state in pounds. -function AIRBOSS:_GetFuelState( unit ) - - -- Get relative fuel [0,1]. - local fuel = unit:GetFuel() - - -- Get max weight of fuel in kg. - local maxfuel = self:_GetUnitMasses( unit ) - - -- Fuel state, i.e. what let's - local fuelstate = fuel * maxfuel - - -- Debug info. - self:T2( self.lid .. string.format( "Unit %s fuel state = %.1f kg = %.1f lbs", unit:GetName(), fuelstate, UTILS.kg2lbs( fuelstate ) ) ) - - return UTILS.kg2lbs( fuelstate ) -end - ---- Convert altitude from meters to angels (thousands of feet). --- @param #AIRBOSS self --- @param alt altitude in meters. --- @return #number Altitude in Anglels = thousands of feet using math.floor(). -function AIRBOSS:_GetAngels( alt ) - - if alt then - local angels = UTILS.Round( UTILS.MetersToFeet( alt ) / 1000, 0 ) - return angels - else - return 0 - end - -end - ---- Get unit masses especially fuel from DCS descriptor values. --- @param #AIRBOSS self --- @param Wrapper.Unit#UNIT unit The unit for which the mass is determined. --- @return #number Mass of fuel in kg. --- @return #number Empty weight of unit in kg. --- @return #number Max weight of unit in kg. --- @return #number Max cargo weight in kg. -function AIRBOSS:_GetUnitMasses( unit ) - - -- Get DCS descriptors table. - local Desc = unit:GetDesc() - - -- Mass of fuel in kg. - local massfuel = Desc.fuelMassMax or 0 - - -- Mass of empty unit in km. - local massempty = Desc.massEmpty or 0 - - -- Max weight of unit in kg. - local massmax = Desc.massMax or 0 - - -- Rest is cargo. - local masscargo = massmax - massfuel - massempty - - -- Debug info. - self:T2( self.lid .. string.format( "Unit %s mass fuel=%.1f kg, empty=%.1f kg, max=%.1f kg, cargo=%.1f kg", unit:GetName(), massfuel, massempty, massmax, masscargo ) ) - - return massfuel, massempty, massmax, masscargo -end - ---- Get player data from unit object --- @param #AIRBOSS self --- @param Wrapper.Unit#UNIT unit Unit in question. --- @return #AIRBOSS.PlayerData Player data or nil if not player with this name or unit exists. -function AIRBOSS:_GetPlayerDataUnit( unit ) - if unit:IsAlive() then - local unitname = unit:GetName() - local playerunit, playername = self:_GetPlayerUnitAndName( unitname ) - if playerunit and playername then - return self.players[playername] - end - end - return nil -end - ---- Get player data from group object. --- @param #AIRBOSS self --- @param Wrapper.Group#GROUP group Group in question. --- @return #AIRBOSS.PlayerData Player data or nil if not player with this name or unit exists. -function AIRBOSS:_GetPlayerDataGroup( group ) - local units = group:GetUnits() - for _, unit in pairs( units ) do - local playerdata = self:_GetPlayerDataUnit( unit ) - if playerdata then - return playerdata - end - end - return nil -end - ---- Returns the unit of a player and the player name from the self.players table if it exists. --- @param #AIRBOSS self --- @param #string _unitName Name of the player unit. --- @return Wrapper.Unit#UNIT Unit of player or nil. --- @return #string Name of player or nil. -function AIRBOSS:_GetPlayerUnit( _unitName ) - - for _, _player in pairs( self.players ) do - - local player = _player -- #AIRBOSS.PlayerData - - if player.unit and player.unit:GetName() == _unitName then - self:T( self.lid .. string.format( "Found player=%s unit=%s in players table.", tostring( player.name ), tostring( _unitName ) ) ) - return player.unit, player.name - end - - end - - return nil, nil -end - ---- Returns the unit of a player and the player name. If the unit does not belong to a player, nil is returned. --- @param #AIRBOSS self --- @param #string _unitName Name of the player unit. --- @return Wrapper.Unit#UNIT Unit of player or nil. --- @return #string Name of the player or nil. -function AIRBOSS:_GetPlayerUnitAndName( _unitName ) - self:F2( _unitName ) - - if _unitName ~= nil then - - -- First, let's look up all current players. - local u, pn = self:_GetPlayerUnit( _unitName ) - - -- Return - if u and pn then - return u, pn - end - - -- Get DCS unit from its name. - local DCSunit = Unit.getByName( _unitName ) - - if DCSunit then - - -- Get player name if any. - local playername = DCSunit:getPlayerName() - - -- Unit object. - local unit = UNIT:Find( DCSunit ) - - -- Debug. - self:T2( { DCSunit = DCSunit, unit = unit, playername = playername } ) - - -- Check if enverything is there. - if DCSunit and unit and playername then - self:T( self.lid .. string.format( "Found DCS unit %s with player %s.", tostring( _unitName ), tostring( playername ) ) ) - return unit, playername - end - - end - - end - - -- Return nil if we could not find a player. - return nil, nil -end - ---- Get carrier coalition. --- @param #AIRBOSS self --- @return #number Coalition side of carrier. -function AIRBOSS:GetCoalition() - return self.carrier:GetCoalition() -end - ---- Get carrier coordinate. --- @param #AIRBOSS self --- @return Core.Point#COORDINATE Carrier coordinate. -function AIRBOSS:GetCoordinate() - return self.carrier:GetCoord() -end - ---- Get carrier coordinate. --- @param #AIRBOSS self --- @return Core.Point#COORDINATE Carrier coordinate. -function AIRBOSS:GetCoord() - return self.carrier:GetCoord() -end - ---- Get static weather of this mission from env.mission.weather. --- @param #AIRBOSS self --- @param #table Clouds table which has entries "thickness", "density", "base", "iprecptns". --- @param #number Visibility distance in meters. --- @param #table Fog table, which has entries "thickness", "visibility" or nil if fog is disabled in the mission. --- @param #number Dust density or nil if dust is disabled in the mission. -function AIRBOSS:_GetStaticWeather() - - -- Weather data from mission file. - local weather = env.mission.weather - - -- Clouds - --[[ - ["clouds"] = - { - ["thickness"] = 430, - ["density"] = 7, - ["base"] = 0, - ["iprecptns"] = 1, - }, -- end of ["clouds"] - ]] - local clouds = weather.clouds - - -- Visibilty distance in meters. - local visibility = weather.visibility.distance - - -- Dust - --[[ - ["enable_dust"] = false, - ["dust_density"] = 0, - ]] - local dust = nil - if weather.enable_dust == true then - dust = weather.dust_density - end - - -- Fog - --[[ - ["enable_fog"] = false, - ["fog"] = - { - ["thickness"] = 0, - ["visibility"] = 25, - }, -- end of ["fog"] - ]] - local fog = nil - if weather.enable_fog == true then - fog = weather.fog - end - - return clouds, visibility, fog, dust -end - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --- RADIO MESSAGE Functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - ---- Function called by DCS timer. Unused. --- @param #table param Parameters. --- @param #number time Time. -function AIRBOSS._CheckRadioQueueT( param, time ) - AIRBOSS._CheckRadioQueue( param.airboss, param.radioqueue, param.name ) - return time + 0.05 -end - ---- Radio queue item. --- @type AIRBOSS.Radioitem --- @field #number Tplay Abs time when transmission should be played. --- @field #number Tstarted Abs time when transmission began to play. --- @field #boolean isplaying Currently playing. --- @field #AIRBOSS.Radio radio Radio object. --- @field #AIRBOSS.RadioCall call Radio call. --- @field #boolean loud If true, play loud version of file. --- @field #number interval Interval in seconds after the last sound was played. - ---- Check radio queue for transmissions to be broadcasted. --- @param #AIRBOSS self --- @param #table radioqueue The radio queue. --- @param #string name Name of the queue. -function AIRBOSS:_CheckRadioQueue( radioqueue, name ) - - -- env.info(string.format("FF %s #radioqueue %d", name, #radioqueue)) - - -- Check if queue is empty. - if #radioqueue == 0 then - - if name == "LSO" then - self:T( self.lid .. string.format( "Stopping LSO radio queue." ) ) - self.radiotimer:Stop( self.RQLid ) - self.RQLid = nil - elseif name == "MARSHAL" then - self:T( self.lid .. string.format( "Stopping Marshal radio queue." ) ) - self.radiotimer:Stop( self.RQMid ) - self.RQMid = nil - end - - return - end - - -- Get current abs time. - local _time = timer.getAbsTime() - - local playing = false - local next = nil -- #AIRBOSS.Radioitem - local _remove = nil - for i, _transmission in ipairs( radioqueue ) do - local transmission = _transmission -- #AIRBOSS.Radioitem - - -- Check if transmission time has passed. - if _time >= transmission.Tplay then - - -- Check if transmission is currently playing. - if transmission.isplaying then - - -- Check if transmission is finished. - if _time >= transmission.Tstarted + transmission.call.duration then - - -- Transmission over. - transmission.isplaying = false - _remove = i - - if transmission.radio.alias == "LSO" then - self.TQLSO = _time - elseif transmission.radio.alias == "MARSHAL" then - self.TQMarshal = _time - end - - else -- still playing - - -- Transmission is still playing. - playing = true - - end - - else -- not playing yet - - local Tlast = nil - if transmission.interval then - if transmission.radio.alias == "LSO" then - Tlast = self.TQLSO - elseif transmission.radio.alias == "MARSHAL" then - Tlast = self.TQMarshal - end - end - - if transmission.interval == nil then - - -- Not playing ==> this will be next. - if next == nil then - next = transmission - end - - else - - if _time - Tlast >= transmission.interval then - next = transmission - else - - end - end - - -- We got a transmission or one with an interval that is not due yet. No need for anything else. - if next or Tlast then - break - end - - end - - else - - -- Transmission not due yet. - - end - end - - -- Found a new transmission. - if next ~= nil and not playing then - self:Broadcast( next.radio, next.call, next.loud ) - next.isplaying = true - next.Tstarted = _time - end - - -- Remove completed calls from queue. - if _remove then - table.remove( radioqueue, _remove ) - end - - return -end - ---- Add Radio transmission to radio queue. --- @param #AIRBOSS self --- @param #AIRBOSS.Radio radio Radio sending the transmission. --- @param #AIRBOSS.RadioCall call Radio sound files and subtitles. --- @param #boolean loud If true, play loud sound file version. --- @param #number delay Delay in seconds, before the message is broadcasted. --- @param #number interval Interval in seconds after the last sound has been played. --- @param #boolean click If true, play radio click at the end. --- @param #boolean pilotcall If true, it's a pilot call. -function AIRBOSS:RadioTransmission( radio, call, loud, delay, interval, click, pilotcall ) - self:F2( { radio = radio, call = call, loud = loud, delay = delay, interval = interval, click = click } ) - - -- Nil check. - if radio == nil or call == nil then - return - end - - if not self.SRS then - - -- Create a new radio transmission item. - local transmission = {} -- #AIRBOSS.Radioitem - - transmission.radio = radio - transmission.call = call - transmission.Tplay = timer.getAbsTime() + (delay or 0) - transmission.interval = interval - transmission.isplaying = false - transmission.Tstarted = nil - transmission.loud = loud and call.loud - - -- Player onboard number if sender has one. - if self:_IsOnboard( call.modexsender ) then - self:_Number2Radio( radio, call.modexsender, delay, 0.3, pilotcall ) - end - - -- Play onboard number if receiver has one. - if self:_IsOnboard( call.modexreceiver ) then - self:_Number2Radio( radio, call.modexreceiver, delay, 0.3, pilotcall ) - end - - -- Add transmission to the right queue. - local caller = "" - if radio.alias == "LSO" then - - table.insert( self.RQLSO, transmission ) - - caller = "LSOCall" - - -- Schedule radio queue checks. - if not self.RQLid then - self:T( self.lid .. string.format( "Starting LSO radio queue." ) ) - self.RQLid = self.radiotimer:Schedule( nil, AIRBOSS._CheckRadioQueue, { self, self.RQLSO, "LSO" }, 0.02, 0.05 ) - end - - elseif radio.alias == "MARSHAL" then - - table.insert( self.RQMarshal, transmission ) - - caller = "MarshalCall" - - if not self.RQMid then - self:T( self.lid .. string.format( "Starting Marhal radio queue." ) ) - self.RQMid = self.radiotimer:Schedule( nil, AIRBOSS._CheckRadioQueue, { self, self.RQMarshal, "MARSHAL" }, 0.02, 0.05 ) - end - - end - - -- Append radio click sound at the end of the transmission. - if click then - self:RadioTransmission( radio, self[caller].CLICK, false, delay ) - end - - else - - -- SRS transmission - if call.subtitle ~= nil and string.len(call.subtitle) > 1 then - - local frequency = self.MarshalRadio.frequency - local modulation = self.MarshalRadio.modulation - local voice = nil - local gender = nil - local culture = nil - - if radio.alias == "AIRBOSS" then - frequency = self.AirbossRadio.frequency - modulation = self.AirbossRadio.modulation - voice = self.AirbossRadio.voice - gender = self.AirbossRadio.gender - culture = self.AirbossRadio.culture - end - - if radio.alias == "MARSHAL" then - voice = self.MarshalRadio.voice - gender = self.MarshalRadio.gender - culture = self.MarshalRadio.culture - end - - if radio.alias == "LSO" then - frequency = self.LSORadio.frequency - modulation = self.LSORadio.modulation - voice = self.LSORadio.voice - gender = self.LSORadio.gender - culture = self.LSORadio.culture - end - - if pilotcall then - voice = self.PilotRadio.voice - gender = self.PilotRadio.gender - culture = self.PilotRadio.culture - radio.alias = "PILOT" - end - - if not radio.alias then - -- TODO - what freq to use here? - frequency = self.AirbossRadio.frequency - modulation = self.AirbossRadio.modulation - radio.alias = "AIRBOSS" - end - - local volume = nil - - if loud then - volume = 1.0 - end - - --local text = tostring(call.modexreceiver).."; "..radio.alias.."; "..call.subtitle - local text = call.subtitle - self:T(self.lid..text) - local srstext = self:_GetNiceSRSText(text) - self.SRSQ:NewTransmission(srstext, call.duration, self.SRS, nil, 0.1, nil, call.subtitle, call.subduration, frequency, modulation, gender, culture, voice, volume, radio.alias) - end - end -end - ---- Set SRS voice for the pilot calls. --- @param #AIRBOSS self --- @param #string Voice (Optional) SRS specific voice --- @param #string Gender (Optional) SRS specific gender --- @param #string Culture (Optional) SRS specific culture --- @return #AIRBOSS self -function AIRBOSS:SetSRSPilotVoice( Voice, Gender, Culture ) - - self.PilotRadio = {} -- #AIRBOSS.Radio - self.PilotRadio.alias = "PILOT" - self.PilotRadio.voice = Voice or MSRS.Voices.Microsoft.David - self.PilotRadio.gender = Gender or "male" - self.PilotRadio.culture = Culture or "en-US" - - if (not Voice) and self.SRS and self.SRS:GetProvider() == MSRS.Provider.GOOGLE then - self.PilotRadio.voice = MSRS.Voices.Google.Standard.en_US_Standard_J - end - - return self -end - ---- Check if a call needs a subtitle because the complete voice overs are not available. --- @param #AIRBOSS self --- @param #AIRBOSS.RadioCall call Radio sound files and subtitles. --- @return #boolean If true, call needs a subtitle. -function AIRBOSS:_NeedsSubtitle( call ) - -- Currently we play the noise file. - if call.file == self.MarshalCall.NOISE.file or call.file == self.LSOCall.NOISE.file then - return true - else - return false - end -end - ---- Broadcast radio message. --- @param #AIRBOSS self --- @param #AIRBOSS.Radio radio Radio sending transmission. --- @param #AIRBOSS.RadioCall call Radio sound files and subtitles. --- @param #boolean loud Play loud version of file. -function AIRBOSS:Broadcast( radio, call, loud ) - self:F( call ) - - -- Check which sound output method to use. - if not self.usersoundradio then - - ---------------------------- - -- Transmission via Radio -- - ---------------------------- - - -- Get unit sending the transmission. - local sender = self:_GetRadioSender( radio ) - - -- Construct file name and subtitle. - local filename = self:_RadioFilename( call, loud, radio.alias ) - - -- Create subtitle for transmission. - local subtitle = self:_RadioSubtitle( radio, call, loud ) - - -- Debug. - self:T( { filename = filename, subtitle = subtitle } ) - - if sender then - - -- Broadcasting from aircraft. Only players tuned in to the right frequency will see the message. - self:T( self.lid .. string.format( "Broadcasting from aircraft %s", sender:GetName() ) ) - - -- Command to set the Frequency for the transmission. - local commandFrequency = { - id = "SetFrequency", - params = { - frequency = radio.frequency * 1000000, -- Frequency in Hz. - modulation = radio.modulation, - }, - } - - -- Command to tranmit the call. - local commandTransmit = { - id = "TransmitMessage", - params = { - file = filename, - duration = call.subduration or 5, - subtitle = subtitle, - loop = false, - }, - } - - -- Set commend for frequency - sender:SetCommand( commandFrequency ) - - -- Set command for radio transmission. - sender:SetCommand( commandTransmit ) - - else - - -- Broadcasting from carrier. No subtitle possible. Need to send messages to players. - self:T( self.lid .. string.format( "Broadcasting from carrier via trigger.action.radioTransmission()." ) ) - - -- Transmit from carrier position. - local vec3 = self.carrier:GetPositionVec3() - - -- Transmit via trigger. - trigger.action.radioTransmission( filename, vec3, radio.modulation, false, radio.frequency * 1000000, 100 ) - - -- Display subtitle of message to players. - for _, _player in pairs( self.players ) do - local playerData = _player -- #AIRBOSS.PlayerData - - -- Message to all players in CCA that have subtites on. - if playerData.unit:IsInZone( self.zoneCCA ) and playerData.actype ~= AIRBOSS.AircraftCarrier.A4EC then - - -- Only to players with subtitle on or if noise is played. - if playerData.subtitles or self:_NeedsSubtitle( call ) then - - -- Messages to marshal to everyone. Messages on LSO radio only to those in the pattern. - if radio.alias == "MARSHAL" or (radio.alias == "LSO" and self:_InQueue( self.Qpattern, playerData.group )) then - - -- Message to player. - self:MessageToPlayer( playerData, subtitle, nil, "", call.subduration or 5 ) - - end - - end - - end - end - end - end - - ---------------- - -- Easy Comms -- - ---------------- - - -- Workaround for the community A-4E-C as long as their radios are not functioning properly. - for _, _player in pairs( self.players ) do - local playerData = _player -- #AIRBOSS.PlayerData - - -- Easy comms if globally activated but definitly for all player in the community A-4E. - if self.usersoundradio or playerData.actype == AIRBOSS.AircraftCarrier.A4EC then - - -- Messages to marshal to everyone. Messages on LSO radio only to those in the pattern. - if radio.alias == "MARSHAL" or (radio.alias == "LSO" and self:_InQueue( self.Qpattern, playerData.group )) then - - -- User sound to players (inside CCA). - self:Sound2Player( playerData, radio, call, loud ) - end - - end - end - -end - ---- Player user sound to player if he is inside the CCA. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. --- @param #AIRBOSS.Radio radio The radio used for transmission. --- @param #AIRBOSS.RadioCall call Radio sound files and subtitles. --- @param #boolean loud If true, play loud sound file version. --- @param #number delay Delay in seconds, before the message is broadcasted. -function AIRBOSS:Sound2Player( playerData, radio, call, loud, delay ) - - -- Only to players inside the CCA. - if playerData.unit:IsInZone( self.zoneCCA ) and call then - - -- Construct file name. - local filename = self:_RadioFilename( call, loud, radio.alias ) - - -- Get Subtitle - local subtitle = self:_RadioSubtitle( radio, call, loud ) - - -- Play sound file via usersound trigger. - USERSOUND:New( filename ):ToGroup( playerData.group, delay ) - - -- Only to players with subtitle on or if noise is played. - if playerData.subtitles or self:_NeedsSubtitle( call ) then - self:MessageToPlayer( playerData, subtitle, nil, "", call.subduration, false, delay ) - end - - end -end - ---- Create radio subtitle from radio call. --- @param #AIRBOSS self --- @param #AIRBOSS.Radio radio The radio used for transmission. --- @param #AIRBOSS.RadioCall call Radio sound files and subtitles. --- @param #boolean loud If true, append "!" else ".". --- @return #string Subtitle to be displayed. -function AIRBOSS:_RadioSubtitle( radio, call, loud ) - - -- No subtitle if call is nil, or subtitle is nil or subtitle is empty. - if call == nil or call.subtitle == nil or call.subtitle == "" then - return "" - end - - -- Sender - local sender = call.sender or radio.alias - if call.modexsender then - sender = call.modexsender - end - - -- Modex of receiver. - local receiver = call.modexreceiver or "" - - -- Init subtitle. - local subtitle = string.format( "%s: %s", sender, call.subtitle ) - if receiver and receiver ~= "" then - subtitle = string.format( "%s: %s, %s", sender, receiver, call.subtitle ) - end - - -- Last character of the string. - local lastchar = string.sub( subtitle, -1 ) - - -- Append ! or . - if loud then - if lastchar == "." or lastchar == "!" then - subtitle = string.sub( subtitle, 1, -1 ) - end - subtitle = subtitle .. "!" - else - if lastchar == "!" then - -- This also okay. - elseif lastchar == "." then - -- Nothing to do. - else - subtitle = subtitle .. "." - end - end - - return subtitle -end - ---- Get full file name for radio call. --- @param #AIRBOSS self --- @param #AIRBOSS.RadioCall call Radio sound files and subtitles. --- @param #boolean loud Use loud version of file if available. --- @param #string channel Radio channel alias "LSO" or "LSOCall", "MARSHAL" or "MarshalCall". --- @return #string The file name of the radio sound. -function AIRBOSS:_RadioFilename( call, loud, channel ) - - -- Construct file name and subtitle. - local prefix = call.file or "" - local suffix = call.suffix or "ogg" - - -- Path to sound files. Default is in the ME - local path = self.soundfolder or "l10n/DEFAULT/" - - -- Check for special LSO and Marshal sound folders. - if string.find( call.file, "LSO-" ) and channel and (channel == "LSO" or channel == "LSOCall") then - path = self.soundfolderLSO or path - end - if string.find( call.file, "MARSHAL-" ) and channel and (channel == "MARSHAL" or channel == "MarshalCall") then - path = self.soundfolderMSH or path - end - - -- Loud version. - if loud then - prefix = prefix .. "_Loud" - end - - -- File name inclusing path in miz file. - local filename = string.format( "%s%s.%s", path, prefix, suffix ) - - return filename -end - ---- Format text into SRS friendly string --- @param #AIRBOSS self --- @param #string text --- @return #string text -function AIRBOSS:_GetNiceSRSText(text) - text = string.gsub(text,"================================\n","") - text = string.gsub(text,"||","parallel") - text = string.gsub(text,"==","perpendicular") - text = string.gsub(text,"BRC","Base recovery") - --text = string.gsub(text,"#","Number") - text = string.gsub(text,"%((%a+)%)","Morse %1") - text = string.gsub(text,"°C","° Celsius") - text = string.gsub(text,"°"," degrees") - text = string.gsub(text," FB "," Final bearing ") - text = string.gsub(text," ops"," operations ") - text = string.gsub(text," kts"," knots") - text = string.gsub(text,"TACAN","Tackan") - text = string.gsub(text,"ICLS","I.C.L.S.") - text = string.gsub(text,"LSO","L.S.O.") - text = string.gsub(text,"inHg","inches of Mercury") - text = string.gsub(text,"QFE","Q.F.E.") - text = string.gsub(text,"hPa","hecto pascal") - text = string.gsub(text," NM"," nautical miles") - text = string.gsub(text," ft"," feet") - text = string.gsub(text,"A/C","aircraft") - text = string.gsub(text,"(#[%a%d%p%s]+)\n","") - text = string.gsub(text,"%.000"," dot zero") - text = string.gsub(text,"00"," double zero") - text = string.gsub(text," 0 "," zero " ) - text = string.gsub(text,"\n","; ") - return text -end - ---- Send text message to player client. --- Message format will be "SENDER: RECCEIVER, MESSAGE". --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. --- @param #string message The message to send. --- @param #string sender The person who sends the message or nil. --- @param #string receiver The person who receives the message. Default player's onboard number. Set to "" for no receiver. --- @param #number duration Display message duration. Default 10 seconds. --- @param #boolean clear If true, clear screen from previous messages. --- @param #number delay Delay in seconds, before the message is displayed. -function AIRBOSS:MessageToPlayer( playerData, message, sender, receiver, duration, clear, delay ) - self:T({sender,receiver,message}) - if playerData and message and message ~= "" then - - -- Default duration. - duration = duration or self.Tmessage - - -- Format message. - local text - if receiver and receiver == "" then - -- No (blank) receiver. - text = string.format( "%s", message ) - else - -- Default "receiver" is onboard number of player. - receiver = receiver or playerData.onboard - text = string.format( "%s, %s", receiver, message ) - end - self:T( self.lid .. text ) - - if delay and delay > 0 then - -- Delayed call. - -- SCHEDULER:New(nil, self.MessageToPlayer, {self, playerData, message, sender, receiver, duration, clear}, delay) - self:ScheduleOnce( delay, self.MessageToPlayer, self, playerData, message, sender, receiver, duration, clear ) - else - - if not self.SRS then - -- Wait until previous sound finished. - local wait = 0 - - -- Onboard number to get the attention. - if receiver == playerData.onboard then - - -- Which voice over number to use. - if sender and (sender == "LSO" or sender == "MARSHAL" or sender == "AIRBOSS") then - - -- User sound of board number. - wait = wait + self:_Number2Sound( playerData, sender, receiver ) - - end - end - - -- Negative. - if string.find( text:lower(), "negative" ) then - local filename = self:_RadioFilename( self.MarshalCall.NEGATIVE, false, "MARSHAL" ) - USERSOUND:New( filename ):ToGroup( playerData.group, wait ) - wait = wait + self.MarshalCall.NEGATIVE.duration - end - - -- Affirm. - if string.find( text:lower(), "affirm" ) then - local filename = self:_RadioFilename( self.MarshalCall.AFFIRMATIVE, false, "MARSHAL" ) - USERSOUND:New( filename ):ToGroup( playerData.group, wait ) - wait = wait + self.MarshalCall.AFFIRMATIVE.duration - end - - -- Roger. - if string.find( text:lower(), "roger" ) then - local filename = self:_RadioFilename( self.MarshalCall.ROGER, false, "MARSHAL" ) - USERSOUND:New( filename ):ToGroup( playerData.group, wait ) - wait = wait + self.MarshalCall.ROGER.duration - end - - -- Play click sound to end message. - if wait > 0 then - local filename = self:_RadioFilename( self.MarshalCall.CLICK ) - USERSOUND:New( filename ):ToGroup( playerData.group, wait ) - end - else - -- SRS transmission - local frequency = self.MarshalRadio.frequency - local modulation = self.MarshalRadio.modulation - local voice = self.MarshalRadio.voice - local gender = self.MarshalRadio.gender - local culture = self.MarshalRadio.culture - - if not sender then sender = "AIRBOSS" end - - if string.find(sender,"AIRBOSS" ) then - frequency = self.AirbossRadio.frequency - modulation = self.AirbossRadio.modulation - voice = self.AirbossRadio.voice - gender = self.AirbossRadio.gender - culture = self.AirbossRadio.culture - end - - --if sender == "MARSHAL" then - --voice = self.MarshalRadio.voice - --gender = self.MarshalRadio.gender - --culture = self.MarshalRadio.culture - --end - - if sender == "LSO" then - frequency = self.LSORadio.frequency - modulation = self.LSORadio.modulation - voice = self.LSORadio.voice - gender = self.LSORadio.gender - culture = self.LSORadio.culture - --elseif not sender then - -- TODO - what freq to use here? - --frequency = self.AirbossRadio.frequency - --modulation = self.AirbossRadio.modulation - --sender = "AIRBOSS" - end - - self:T(self.lid..text) - self:T({sender,frequency,modulation,voice}) - local srstext = self:_GetNiceSRSText(text) - self.SRSQ:NewTransmission(srstext,duration,self.SRS,nil,0.1,nil,nil,nil,frequency,modulation,gender,culture,voice,nil,sender) - end - -- Text message to player client. - if playerData.client then - MESSAGE:New( text, duration, sender, clear ):ToClient( playerData.client ) - end - - end - - end -end - ---- Send text message to all players in the pattern queue. --- Message format will be "SENDER: RECCEIVER, MESSAGE". --- @param #AIRBOSS self --- @param #string message The message to send. --- @param #string sender The person who sends the message or nil. --- @param #string receiver The person who receives the message. Default player's onboard number. Set to "" for no receiver. --- @param #number duration Display message duration. Default 10 seconds. --- @param #boolean clear If true, clear screen from previous messages. --- @param #number delay Delay in seconds, before the message is displayed. -function AIRBOSS:MessageToPattern( message, sender, receiver, duration, clear, delay ) - - -- Create new (fake) radio call to show the subtitile. - local call = self:_NewRadioCall( self.LSOCall.NOISE, sender or "LSO", message, duration, receiver, sender ) - - -- Dummy radio transmission to display subtitle only to those who tuned in. - self:RadioTransmission( self.LSORadio, call, false, delay, nil, true ) - -end - ---- Send text message to all players in the marshal queue. --- Message format will be "SENDER: RECCEIVER, MESSAGE". --- @param #AIRBOSS self --- @param #string message The message to send. --- @param #string sender The person who sends the message or nil. --- @param #string receiver The person who receives the message. Default player's onboard number. Set to "" for no receiver. --- @param #number duration Display message duration. Default 10 seconds. --- @param #boolean clear If true, clear screen from previous messages. --- @param #number delay Delay in seconds, before the message is displayed. -function AIRBOSS:MessageToMarshal( message, sender, receiver, duration, clear, delay ) - - -- Create new (fake) radio call to show the subtitile. - local call = self:_NewRadioCall( self.MarshalCall.NOISE, sender or "MARSHAL", message, duration, receiver, sender ) - - -- Dummy radio transmission to display subtitle only to those who tuned in. - self:RadioTransmission( self.MarshalRadio, call, false, delay, nil, true ) - -end - ---- Generate a new radio call (deepcopy) from an existing default call. --- @param #AIRBOSS self --- @param #AIRBOSS.RadioCall call Radio call to be enhanced. --- @param #string sender Sender of the message. Default is the radio alias. --- @param #string subtitle Subtitle of the message. Default from original radio call. Use "" for no subtitle. --- @param #number subduration Time in seconds the subtitle is displayed. Default 10 seconds. --- @param #string modexreceiver Onboard number of the receiver or nil. --- @param #string modexsender Onboard number of the sender or nil. -function AIRBOSS:_NewRadioCall( call, sender, subtitle, subduration, modexreceiver, modexsender ) - - -- Create a new call - local newcall = UTILS.DeepCopy( call ) -- #AIRBOSS.RadioCall - - -- Sender for displaying the subtitle. - newcall.sender = sender - - -- Subtitle of the message. - newcall.subtitle = subtitle or call.subtitle - - -- Duration of subtitle display. - newcall.subduration = subduration or self.Tmessage - - -- Tail number of the receiver. - if self:_IsOnboard( modexreceiver ) then - newcall.modexreceiver = modexreceiver - end - - -- Tail number of the sender. - if self:_IsOnboard( modexsender ) then - newcall.modexsender = modexsender - end - - return newcall -end - ---- Get unit from which we want to transmit a radio message. This has to be an aircraft for subtitles to work. --- @param #AIRBOSS self --- @param #AIRBOSS.Radio radio Airboss radio data. --- @return Wrapper.Unit#UNIT Sending aircraft unit or nil if was not setup, is not an aircraft or is not alive. -function AIRBOSS:_GetRadioSender( radio ) - - -- Check if we have a sending aircraft. - local sender = nil -- Wrapper.Unit#UNIT - - -- Try the general default. - if self.senderac then - sender = UNIT:FindByName( self.senderac ) - end - - -- Try the specific marshal unit. - if radio.alias == "MARSHAL" then - if self.radiorelayMSH then - sender = UNIT:FindByName( self.radiorelayMSH ) - end - end - - -- Try the specific LSO unit. - if radio.alias == "LSO" then - if self.radiorelayLSO then - sender = UNIT:FindByName( self.radiorelayLSO ) - end - end - - -- Check that sender is alive and an aircraft. - if sender and sender:IsAlive() and sender:IsAir() then - return sender - end - - return nil -end - ---- Check if text is an onboard number of a flight. --- @param #AIRBOSS self --- @param #string text Text to check. --- @return #boolean If true, text is an onboard number of a flight. -function AIRBOSS:_IsOnboard( text ) - - -- Nil check. - if text == nil then - return false - end - - -- Message to all. - if text == "99" then - return true - end - - -- Loop over all flights. - for _, _flight in pairs( self.flights ) do - local flight = _flight -- #AIRBOSS.FlightGroup - - -- Loop over all onboard number of that flight. - for _, onboard in pairs( flight.onboardnumbers ) do - if text == onboard then - return true - end - end - - end - - return false -end - ---- Convert a number (as string) into an outsound and play it to a player group. E.g. for board number or headings. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data. --- @param #string sender Who is sending the call, either "LSO" or "MARSHAL". --- @param #string number Number string, e.g. "032" or "183". --- @param #number delay Delay before transmission in seconds. --- @return #number Duration of the call in seconds. -function AIRBOSS:_Number2Sound( playerData, sender, number, delay ) - - -- Default. - delay = delay or 0 - - --- Split string into characters. - local function _split( str ) - local chars = {} - for i = 1, #str do - local c = str:sub( i, i ) - table.insert( chars, c ) - end - return chars - end - - -- Sender - local Sender - if sender == "LSO" then - Sender = "LSOCall" - elseif sender == "MARSHAL" or sender == "AIRBOSS" then - Sender = "MarshalCall" - else - self:E( self.lid .. string.format( "ERROR: Unknown radio sender %s!", tostring( sender ) ) ) - return - end - - -- Split string into characters. - local numbers = _split( number ) - - local wait = 0 - for i = 1, #numbers do - - -- Current number - local n = numbers[i] - - -- Convert to N0, N1, ... - local N = string.format( "N%s", n ) - - -- Radio call. - local call = self[Sender][N] -- #AIRBOSS.RadioCall - - -- Create file name. - local filename = self:_RadioFilename( call, false, Sender ) - - -- Play sound. - USERSOUND:New( filename ):ToGroup( playerData.group, delay + wait ) - - -- Wait until this call is over before playing the next. - wait = wait + call.duration - end - - return wait -end - ---- Convert a number (as string) into a radio message. --- E.g. for board number or headings. --- @param #AIRBOSS self --- @param #AIRBOSS.Radio radio Radio used for transmission. --- @param #string number Number string, e.g. "032" or "183". --- @param #number delay Delay before transmission in seconds. --- @param #number interval Interval between the next call. --- @param #boolean pilotcall If true, use pilot sound files. --- @return #number Duration of the call in seconds. -function AIRBOSS:_Number2Radio( radio, number, delay, interval, pilotcall ) - - --- Split string into characters. - local function _split( str ) - local chars = {} - for i = 1, #str do - local c = str:sub( i, i ) - table.insert( chars, c ) - end - return chars - end - - -- Sender. - local Sender = "" - if radio.alias == "LSO" then - Sender = "LSOCall" - elseif radio.alias == "MARSHAL" then - Sender = "MarshalCall" - else - self:E( self.lid .. string.format( "ERROR: Unknown radio alias %s!", tostring( radio.alias ) ) ) - end - - if pilotcall then - Sender = "PilotCall" - end - - if Sender=="" then - self:E( self.lid .. string.format( "ERROR: Sender unknown!") ) - return - end - - -- Split string into characters. - local numbers = _split( number ) - - local wait = 0 - for i = 1, #numbers do - - -- Current number - local n = numbers[i] - - -- Convert to N0, N1, ... - local N = string.format( "N%s", n ) - - -- Radio call. - local call = self[Sender][N] -- #AIRBOSS.RadioCall - - if interval and i == 1 then - -- Transmit. - self:RadioTransmission( radio, call, false, delay, interval ) - else - self:RadioTransmission( radio, call, false, delay ) - end - - -- Add up duration of the number. - wait = wait + call.duration - end - - -- Return the total duration of the call. - return wait -end - ---- Aircraft request marshal (Inbound call both for players and AI). --- @param #AIRBOSS self --- @return Wrapper.Unit#UNIT Unit of player or nil. --- @param #string modex Tail number. -function AIRBOSS:_MarshallInboundCall(unit, modex) - - -- Calculate - local vectorCarrier = self:GetCoordinate():GetDirectionVec3(unit:GetCoordinate()) - local bearing = UTILS.Round(unit:GetCoordinate():GetAngleDegrees( vectorCarrier ), 0) - local distance = UTILS.Round(UTILS.MetersToNM(unit:GetCoordinate():Get2DDistance(self:GetCoordinate())),0) - local angels = UTILS.Round(UTILS.MetersToFeet(unit:GetHeight()/1000),0) - local state = UTILS.Round(self:_GetFuelState(unit)/1000,1) - - -- Pilot: "Marshall, [modex], marking mom's [bearing] for [distance], angels [XX], state [X.X]" - -- local text=string.format("Marshal, %s, marking mom's %d for %d, angels %d, state %.1f", modex, bearing, distance, angels, state) - local text=string.format("Marshal, %s, 相对航母 %d 距离 %d, 高度 %d, 油量 %.1f", modex, bearing, distance, angels, state) - -- Debug message. - self:T(self.lid..text) - - -- Fuel state. - local FS=UTILS.Split(string.format("%.1f", state), ".") - - -- Create new call to display complete subtitle. - local inboundcall=self:_NewRadioCall(self.MarshalCall.CLICK, unit.UnitName:upper() , text, self.Tmessage, nil, unit.UnitName:upper()) - - -- CLICK! - self:RadioTransmission(self.MarshalRadio, inboundcall) - -- Marshal .. - self:RadioTransmission(self.MarshalRadio, self.PilotCall.MARSHAL, nil, nil, nil, nil, true) - -- Modex.. - self:_Number2Radio(self.MarshalRadio, modex, nil, nil, true) - -- Marking Mom's, - self:RadioTransmission(self.MarshalRadio, self.PilotCall.MARKINGMOMS, nil, nil, nil, nil, true) - -- Bearing .. - self:_Number2Radio(self.MarshalRadio, tostring(bearing), nil, nil, true) - -- For .. - self:RadioTransmission(self.MarshalRadio, self.PilotCall.FOR, nil, nil, nil, nil, true) - -- Distance .. - self:_Number2Radio(self.MarshalRadio, tostring(distance), nil, nil, true) - -- Angels .. - self:RadioTransmission(self.MarshalRadio, self.PilotCall.ANGELS, nil, nil, nil, nil, true) - -- Angels Number .. - self:_Number2Radio(self.MarshalRadio, tostring(angels), nil, nil, true) - -- State .. - self:RadioTransmission(self.MarshalRadio, self.PilotCall.STATE, nil, nil, nil, nil, true) - -- X.. - self:_Number2Radio(self.MarshalRadio, FS[1], nil, nil, true) - -- Point.. - self:RadioTransmission(self.MarshalRadio, self.PilotCall.POINT, nil, nil, nil, nil, true) - -- Y. - self:_Number2Radio(self.MarshalRadio, FS[2], nil, nil, true) - -- CLICK! - self:RadioTransmission(self.MarshalRadio, self.MarshalRadio.CLICK, nil, nil, nil, nil, true) - -end - ---- Aircraft commencing call (both for players and AI). --- @param #AIRBOSS self --- @return Wrapper.Unit#UNIT Unit of player or nil. --- @param #string modex Tail number. -function AIRBOSS:_CommencingCall(unit, modex) - - -- Pilot: "[modex], commencing" - -- local text=string.format("%s, commencing", modex) - local text=string.format("%s, 开始进近", modex) - -- Debug message. - self:T(self.lid..text) - - -- Create new call to display complete subtitle. - local commencingCall=self:_NewRadioCall(self.MarshalCall.CLICK, unit.UnitName:upper() , text, self.Tmessage, nil, unit.UnitName:upper()) - - -- Click - self:RadioTransmission(self.MarshalRadio, commencingCall) - -- Modex.. - self:_Number2Radio(self.MarshalRadio, modex, nil, nil, true) - -- Commencing - self:RadioTransmission(self.MarshalRadio, self.PilotCall.COMMENCING, nil, nil, nil, nil, true) - -- CLICK! - self:RadioTransmission(self.MarshalRadio, self.MarshalRadio.CLICK, nil, nil, nil, nil, true) - -end - ---- AI aircraft calls the ball. --- @param #AIRBOSS self --- @param #string modex Tail number. --- @param #string nickname Aircraft nickname. --- @param #number fuelstate Aircraft fuel state in thouthands of pounds. -function AIRBOSS:_LSOCallAircraftBall( modex, nickname, fuelstate ) - - -- Pilot: "405, Hornet Ball, 3.2" - local text = string.format( "%s Ball, %.1f.", nickname, fuelstate ) - - -- Debug message. - self:T( self.lid .. text ) - - -- Nickname UPPERCASE. - local NICKNAME = nickname:upper() - - -- Fuel state. - local FS = UTILS.Split( string.format( "%.1f", fuelstate ), "." ) - - -- Create new call to display complete subtitle. - local call = self:_NewRadioCall( self.PilotCall[NICKNAME], modex, text, self.Tmessage, nil, modex ) - - -- Hornet .. - self:RadioTransmission( self.LSORadio, call, nil, nil, nil, nil, true ) - -- Ball, - self:RadioTransmission( self.LSORadio, self.PilotCall.BALL, nil, nil, nil, nil, true ) - -- X.. - self:_Number2Radio( self.LSORadio, FS[1], nil, nil, true ) - -- Point.. - self:RadioTransmission( self.LSORadio, self.PilotCall.POINT, nil, nil, nil, nil, true ) - -- Y. - self:_Number2Radio( self.LSORadio, FS[2], nil, nil, true ) - - -- CLICK! - self:RadioTransmission( self.LSORadio, self.LSOCall.CLICK ) - -end - ---- AI is bingo and goes to the recovery tanker. --- @param #AIRBOSS self --- @param #string modex Tail number. -function AIRBOSS:_MarshalCallGasAtTanker( modex ) - - -- Subtitle. - -- local text = string.format( "Bingo fuel! Going for gas at the recovery tanker." ) - local text = string.format( "Bingo 油量! 准备前往加油机加油." ) - - -- Debug message. - self:T( self.lid .. text ) - - - -- Create new call to display complete subtitle. - local call = self:_NewRadioCall( self.PilotCall.BINGOFUEL, modex, text, self.Tmessage, nil, modex ) - - -- MODEX, bingo fuel! - self:RadioTransmission( self.MarshalRadio, call, nil, nil, nil, nil, true ) - - -- Going for fuel at the recovery tanker. Click! - self:RadioTransmission( self.MarshalRadio, self.PilotCall.GASATTANKER, nil, nil, nil, true, true ) - -end - ---- AI is bingo and goes to the divert field. --- @param #AIRBOSS self --- @param #string modex Tail number. --- @param #string divertname Name of the divert field. -function AIRBOSS:_MarshalCallGasAtDivert( modex, divertname ) - - -- Subtitle. - -- local text = string.format( "Bingo fuel! Going for gas at divert field %s.", divertname ) - local text = string.format( "Bingo 油量! 准备前往备降机场 %s.", divertname ) - - -- Debug message. - self:T( self.lid .. text ) - - -- Create new call to display complete subtitle. - local call = self:_NewRadioCall( self.PilotCall.BINGOFUEL, modex, text, self.Tmessage, nil, modex ) - - -- MODEX, bingo fuel! - self:RadioTransmission( self.MarshalRadio, call, nil, nil, nil, nil, true ) - - -- Going for fuel at the divert field. Click! - self:RadioTransmission( self.MarshalRadio, self.PilotCall.GASATDIVERT, nil, nil, nil, true, true ) - -end - ---- Inform everyone that recovery ops are stopped and deck is closed. --- @param #AIRBOSS self --- @param #number case Recovery case. -function AIRBOSS:_MarshalCallRecoveryStopped( case ) - - -- Subtitle. - -- local text = string.format( "Case %d recovery ops are stopped. Deck is closed.", case ) - local text = string.format( "Case %d 回收作业停止. 甲板已关闭.", case ) - - -- Debug message. - self:T( self.lid .. text ) - - -- Create new call to display complete subtitle. - local call = self:_NewRadioCall( self.MarshalCall.CASE, "AIRBOSS", text, self.Tmessage, "99" ) - - -- 99, Case.. - self:RadioTransmission( self.MarshalRadio, call ) - -- X. - self:_Number2Radio( self.MarshalRadio, tostring( case ) ) - -- recovery ops are stopped. - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.RECOVERYOPSSTOPPED, nil, nil, 0.2 ) - -- Deck is closed. Click! - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.DECKCLOSED, nil, nil, nil, true ) - -end - ---- Inform everyone that recovery is paused and will resume at a certain time. --- @param #AIRBOSS self -function AIRBOSS:_MarshalCallRecoveryPausedUntilFurtherNotice() - - -- Create new call. Subtitle already set. - local call = self:_NewRadioCall( self.MarshalCall.RECOVERYPAUSEDNOTICE, "AIRBOSS", nil, self.Tmessage, "99" ) - - -- 99, aircraft recovery is paused until further notice. - self:RadioTransmission( self.MarshalRadio, call, nil, nil, nil, true ) - -end - ---- Inform everyone that recovery is paused and will resume at a certain time. --- @param #AIRBOSS self --- @param #string clock Time. -function AIRBOSS:_MarshalCallRecoveryPausedResumedAt( clock ) - - -- Get relevant part of clock. - local _clock = UTILS.Split( clock, "+" ) - local CT = UTILS.Split( _clock[1], ":" ) - - -- Subtitle. - -- local text = string.format( "aircraft recovery is paused and will be resumed at %s.", clock ) - local text = string.format( "航空器回收作业暂停,预计恢复时间: %s.", clock ) - - -- Debug message. - self:T( self.lid .. text ) - - -- Create new call with full subtitle. - local call = self:_NewRadioCall( self.MarshalCall.RECOVERYPAUSEDRESUMED, "AIRBOSS", text, self.Tmessage, "99" ) - - -- 99, aircraft recovery is paused and will resume at... - self:RadioTransmission( self.MarshalRadio, call ) - - -- XY.. (hours) - self:_Number2Radio( self.MarshalRadio, CT[1] ) - -- XY (minutes).. - self:_Number2Radio( self.MarshalRadio, CT[2] ) - -- hours. Click! - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.HOURS, nil, nil, nil, true ) - -end - ---- Inform flight that he is cleared for recovery. --- @param #AIRBOSS self --- @param #string modex Tail number. --- @param #number case Recovery case. -function AIRBOSS:_MarshalCallClearedForRecovery( modex, case ) - - -- Subtitle. - -- local text = string.format( "you're cleared for Case %d recovery.", case ) - local text = string.format( "你已被批准执行 Case %d 回收.", case ) - - -- Debug message. - self:T( self.lid .. text ) - - -- Create new call with full subtitle. - local call = self:_NewRadioCall( self.MarshalCall.CLEAREDFORRECOVERY, "MARSHAL", text, self.Tmessage, modex ) - - -- Two second delay. - local delay = 2 - - -- XYZ, you're cleared for case.. - self:RadioTransmission( self.MarshalRadio, call, nil, delay ) - -- X.. - self:_Number2Radio( self.MarshalRadio, tostring( case ), delay ) - -- recovery. Click! - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.RECOVERY, nil, delay, nil, true ) - -end - ---- Inform everyone that recovery is resumed after pause. --- @param #AIRBOSS self -function AIRBOSS:_MarshalCallResumeRecovery() - - -- Create new call with full subtitle. - local call = self:_NewRadioCall( self.MarshalCall.RESUMERECOVERY, "AIRBOSS", nil, self.Tmessage, "99" ) - - -- 99, aircraft recovery resumed. Click! - self:RadioTransmission( self.MarshalRadio, call, nil, nil, nil, true ) - -end - ---- Inform everyone about new final bearing. --- @param #AIRBOSS self --- @param #number FB Final Bearing in degrees. -function AIRBOSS:_MarshalCallNewFinalBearing( FB ) - - -- Subtitle. - -- local text = string.format( "new final bearing %03d°.", FB ) - local text = string.format( "新的最终航向 %03d°.", FB ) - - -- Debug message. - self:T( self.lid .. text ) - - -- Create new call with full subtitle. - local call = self:_NewRadioCall( self.MarshalCall.NEWFB, "AIRBOSS", text, self.Tmessage, "99" ) - - -- 99, new final bearing.. - self:RadioTransmission( self.MarshalRadio, call ) - -- XYZ.. - self:_Number2Radio( self.MarshalRadio, string.format( "%03d", FB ), nil, 0.2 ) - -- Degrees. Click! - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.DEGREES, nil, nil, nil, true ) - -end - ---- Compile a radio call when Marshal tells a flight the holding altitude. --- @param #AIRBOSS self --- @param #number hdg Heading in degrees. -function AIRBOSS:_MarshalCallCarrierTurnTo( hdg ) - - -- Subtitle. - -- local text = string.format( "carrier is now starting turn to heading %03d°.", hdg ) - local text = string.format( "航母开始转向航向 %03d°.", hdg ) - - -- Debug message. - self:T( self.lid .. text ) - - -- Create new call with full subtitle. - local call = self:_NewRadioCall( self.MarshalCall.CARRIERTURNTOHEADING, "AIRBOSS", text, self.Tmessage, "99" ) - - -- 99, turning to heading... - self:RadioTransmission( self.MarshalRadio, call ) - -- XYZ.. - self:_Number2Radio( self.MarshalRadio, string.format( "%03d", hdg ), nil, 0.2 ) - -- Degrees. Click! - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.DEGREES, nil, nil, nil, true ) - -end - ---- Compile a radio call when Marshal tells a flight the holding altitude. --- @param #AIRBOSS self --- @param #string modex Tail number. --- @param #number nwaiting Number of flights already waiting. -function AIRBOSS:_MarshalCallStackFull( modex, nwaiting ) - - -- Subtitle. - -- local text = string.format( "Marshal stack is currently full. Hold outside 10 NM zone and wait for further instructions. " ) - local text = string.format( "Marshal 队列目前已满. 请在 10海里 区域外等待进一步指示. " ) - if nwaiting == 1 then - -- text = text .. string.format( "There is one flight ahead of you." ) - text = text .. string.format( "你前面还有一个机队." ) - elseif nwaiting > 1 then - -- text = text .. string.format( "There are %d flights ahead of you.", nwaiting ) - text = text .. string.format( "你前面还有 %d 个机队.", nwaiting ) - else - -- text = text .. string.format( "You are next in line." ) - text = text .. string.format( "下一个就轮到你开始." ) - end - - -- Debug message. - self:T( self.lid .. text ) - - -- Create new call with full subtitle. - local call = self:_NewRadioCall( self.MarshalCall.STACKFULL, "AIRBOSS", text, self.Tmessage, modex ) - - -- XYZ, Marshal stack is currently full. - self:RadioTransmission( self.MarshalRadio, call, nil, nil, nil, true ) -end - ---- Compile a radio call when Marshal tells a flight the holding altitude. --- @param #AIRBOSS self -function AIRBOSS:_MarshalCallRecoveryStart( case ) - - -- Marshal radial. - local radial = self:GetRadial( case, true, true, false ) - - -- Debug output. - -- local text = string.format( "Starting aircraft recovery Case %d ops.", case ) - local text = string.format( "开始 Case %d 航空器回收.", case ) - if case == 1 then - text = text .. string.format( " BRC %03d°.", self:GetBRC() ) - elseif case == 2 then - -- text = text .. string.format( " Marshal radial %03d°. BRC %03d°.", radial, self:GetBRC() ) - text = text .. string.format( " Marshal 航向 %03d°. BRC %03d°.", radial, self:GetBRC() ) - elseif case == 3 then - -- text = text .. string.format( " Marshal radial %03d°. Final heading %03d°.", radial, self:GetFinalBearing( false ) ) - text = text .. string.format( " Marshal 航向 %03d°. 最终航向 %03d°.", radial, self:GetFinalBearing( false ) ) - end - self:T( self.lid .. text ) - - -- New call including the subtitle. - local call = self:_NewRadioCall( self.MarshalCall.STARTINGRECOVERY, "AIRBOSS", text, self.Tmessage, "99" ) - - -- 99, Starting aircraft recovery case.. - self:RadioTransmission( self.MarshalRadio, call ) - -- X.. - self:_Number2Radio( self.MarshalRadio, tostring( case ), nil, 0.1 ) - -- ops. - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.OPS ) - - -- Marshal Radial - if case > 1 then - -- Marshal radial.. - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.MARSHALRADIAL ) - -- XYZ.. - self:_Number2Radio( self.MarshalRadio, string.format( "%03d", radial ), nil, 0.2 ) - -- Degrees. - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.DEGREES, nil, nil, nil, true ) - end - -end - ---- Compile a radio call when Marshal tells a flight the holding altitude. --- @param #AIRBOSS self --- @param #string modex Tail number. --- @param #number case Recovery case. --- @param #number brc Base recovery course. --- @param #number altitude Holding altitude. --- @param #string charlie Charlie Time estimate. --- @param #number qfe Alitmeter inHg. -function AIRBOSS:_MarshalCallArrived( modex, case, brc, altitude, charlie, qfe ) - self:F( { modex = modex, case = case, brc = brc, altitude = altitude, charlie = charlie, qfe = qfe } ) - - -- Split strings etc. - local angels = self:_GetAngels( altitude ) - -- local QFE=UTILS.Split(tostring(UTILS.Round(qfe,2)), ".") - local QFE = UTILS.Split( string.format( "%.2f", qfe ), "." ) - local clock = UTILS.Split( charlie, "+" ) - local CT = UTILS.Split( clock[1], ":" ) - - -- Subtitle text. - -- local text = string.format( "Case %d, expected BRC %03d°, hold at angels %d. Expected Charlie Time %s. Altimeter %.2f. Report see me.", case, brc, angels, charlie, qfe ) - local text = string.format( "Case %d, 预计 BRC %03d°, 等待高度 %d. 预计进近时间[Charlie Time] %s. 修正气压 %.2f. 汇报十海里目视.", case, brc, angels, charlie, qfe ) - - -- Debug message. - self:T( self.lid .. text ) - - -- Create new call to display complete subtitle. - local casecall = self:_NewRadioCall( self.MarshalCall.CASE, "MARSHAL", text, self.Tmessage, modex ) - - -- Case.. - self:RadioTransmission( self.MarshalRadio, casecall ) - -- X. - self:_Number2Radio( self.MarshalRadio, tostring( case ) ) - - -- Expected.. - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.EXPECTED, nil, nil, 0.5 ) - -- BRC.. - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.BRC ) - -- XYZ... - self:_Number2Radio( self.MarshalRadio, string.format( "%03d", brc ) ) - -- Degrees. - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.DEGREES ) - - -- Hold at.. - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.HOLDATANGELS, nil, nil, 0.5 ) - -- X. - self:_Number2Radio( self.MarshalRadio, tostring( angels ) ) - - -- Expected.. - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.EXPECTED, nil, nil, 0.5 ) - -- Charlie time.. - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.CHARLIETIME ) - -- XY.. (hours) - self:_Number2Radio( self.MarshalRadio, CT[1] ) - -- XY (minutes). - self:_Number2Radio( self.MarshalRadio, CT[2] ) - -- hours. - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.HOURS ) - - -- Altimeter.. - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.ALTIMETER, nil, nil, 0.5 ) - -- XY.. - self:_Number2Radio( self.MarshalRadio, QFE[1] ) - -- Point.. - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.POINT ) - -- XY. - self:_Number2Radio( self.MarshalRadio, QFE[2] ) - - -- Report see me. Click! - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.REPORTSEEME, nil, nil, 0.5, true ) - -end - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --- RADIO MENU Functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - ---- Add menu commands for player. --- @param #AIRBOSS self --- @param #string _unitName Name of player unit. -function AIRBOSS:_AddF10Commands( _unitName ) - self:F( _unitName ) - - -- Get player unit and name. - local _unit, playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check for player unit. - if _unit and playername then - - -- Get group and ID. - local group = _unit:GetGroup() - local gid = group:GetID() - - if group and gid then - - if not self.menuadded[gid] then - - -- Enable switch so we don't do this twice. - self.menuadded[gid] = true - - -- Set menu root path. - local _rootPath = nil - if AIRBOSS.MenuF10Root then - ------------------------ - -- MISSON LEVEL MENUE -- - ------------------------ - - if self.menusingle then - -- F10/Airboss/... - _rootPath = AIRBOSS.MenuF10Root - else - -- F10/Airboss//... - _rootPath = missionCommands.addSubMenuForGroup( gid, self.alias, AIRBOSS.MenuF10Root ) - end - - else - ------------------------ - -- GROUP LEVEL MENUES -- - ------------------------ - - -- Main F10 menu: F10/Airboss/ - if AIRBOSS.MenuF10[gid] == nil then - AIRBOSS.MenuF10[gid] = missionCommands.addSubMenuForGroup( gid, "Airboss" ) - end - - if self.menusingle then - -- F10/Airboss/... - _rootPath = AIRBOSS.MenuF10[gid] - else - -- F10/Airboss//... - _rootPath = missionCommands.addSubMenuForGroup( gid, self.alias, AIRBOSS.MenuF10[gid] ) - end - - end - - -------------------------------- - -- F10/Airboss//F1 Help - -------------------------------- - -- local _helpPath = missionCommands.addSubMenuForGroup( gid, "Help", _rootPath ) - local _helpPath = missionCommands.addSubMenuForGroup( gid, "帮助", _rootPath ) - -- F10/Airboss//F1 Help/F1 Mark Zones - if self.menumarkzones then - -- local _markPath = missionCommands.addSubMenuForGroup( gid, "Mark Zones", _helpPath ) - local _markPath = missionCommands.addSubMenuForGroup( gid, "标记飞行航线区域", _helpPath ) - -- F10/Airboss//F1 Help/F1 Mark Zones/ - if self.menusmokezones then - -- missionCommands.addCommandForGroup( gid, "Smoke Pattern Zones", _markPath, self._MarkCaseZones, self, _unitName, false ) -- F1 - missionCommands.addCommandForGroup( gid, "烟雾标记当前航线[不推荐]", _markPath, self._MarkCaseZones, self, _unitName, false ) -- F1 - end - -- missionCommands.addCommandForGroup( gid, "Flare Pattern Zones", _markPath, self._MarkCaseZones, self, _unitName, true ) -- F2 - missionCommands.addCommandForGroup( gid, "信号弹标记当前航线[推荐]", _markPath, self._MarkCaseZones, self, _unitName, true ) -- F2 - if self.menusmokezones then - -- missionCommands.addCommandForGroup( gid, "Smoke Marshal Zone", _markPath, self._MarkMarshalZone, self, _unitName, false ) -- F3 - missionCommands.addCommandForGroup( gid, "烟雾标记 Marshal 区域[不推荐]", _markPath, self._MarkMarshalZone, self, _unitName, false ) -- F3 - end - -- missionCommands.addCommandForGroup( gid, "Flare Marshal Zone", _markPath, self._MarkMarshalZone, self, _unitName, true ) -- F4 - missionCommands.addCommandForGroup( gid, "信号弹标记 Marshal 区域[推荐]", _markPath, self._MarkMarshalZone, self, _unitName, true ) -- F4 - end - -- F10/Airboss//F1 Help/F2 Skill Level - -- local _skillPath = missionCommands.addSubMenuForGroup( gid, "Skill Level", _helpPath ) - local _skillPath = missionCommands.addSubMenuForGroup( gid, "熟练度", _helpPath ) - -- F10/Airboss//F1 Help/F2 Skill Level/ - -- missionCommands.addCommandForGroup( gid, "Flight Student", _skillPath, self._SetDifficulty, self, _unitName, AIRBOSS.Difficulty.EASY ) -- F1 - missionCommands.addCommandForGroup( gid, "飞行学员", _skillPath, self._SetDifficulty, self, _unitName, AIRBOSS.Difficulty.EASY ) -- F1 - -- missionCommands.addCommandForGroup( gid, "Naval Aviator", _skillPath, self._SetDifficulty, self, _unitName, AIRBOSS.Difficulty.NORMAL ) -- F2 - missionCommands.addCommandForGroup( gid, "海军飞行员", _skillPath, self._SetDifficulty, self, _unitName, AIRBOSS.Difficulty.NORMAL ) -- F2 - -- missionCommands.addCommandForGroup( gid, "TOPGUN Graduate", _skillPath, self._SetDifficulty, self, _unitName, AIRBOSS.Difficulty.HARD ) -- F3 - missionCommands.addCommandForGroup( gid, "TOPGUN 毕业生", _skillPath, self._SetDifficulty, self, _unitName, AIRBOSS.Difficulty.HARD ) -- F3 - -- missionCommands.addCommandForGroup( gid, "Hints On/Off", _skillPath, self._SetHintsOnOff, self, _unitName ) -- F4 - missionCommands.addCommandForGroup( gid, "提示 开/关", _skillPath, self._SetHintsOnOff, self, _unitName ) -- F4 - -- F10/Airboss//F1 Help/ - -- missionCommands.addCommandForGroup( gid, "My Status", _helpPath, self._DisplayPlayerStatus, self, _unitName ) -- F3 - missionCommands.addCommandForGroup( gid, "我的数据", _helpPath, self._DisplayPlayerStatus, self, _unitName ) -- F3 - -- missionCommands.addCommandForGroup( gid, "Attitude Monitor", _helpPath, self._DisplayAttitude, self, _unitName ) -- F4 - missionCommands.addCommandForGroup( gid, "开启实时高度监控", _helpPath, self._DisplayAttitude, self, _unitName ) -- F4 - -- missionCommands.addCommandForGroup( gid, "Radio Check LSO", _helpPath, self._LSORadioCheck, self, _unitName ) -- F5 - missionCommands.addCommandForGroup( gid, "LSO 无线电检查", _helpPath, self._LSORadioCheck, self, _unitName ) -- F5 - -- missionCommands.addCommandForGroup( gid, "Radio Check Marshal", _helpPath, self._MarshalRadioCheck, self, _unitName ) -- F6 - missionCommands.addCommandForGroup( gid, "Marshal 无线电检查", _helpPath, self._MarshalRadioCheck, self, _unitName ) -- F6 - -- missionCommands.addCommandForGroup( gid, "Subtitles On/Off", _helpPath, self._SubtitlesOnOff, self, _unitName ) -- F7 - missionCommands.addCommandForGroup( gid, "字幕 开/关", _helpPath, self._SubtitlesOnOff, self, _unitName ) -- F7 - -- missionCommands.addCommandForGroup( gid, "Trapsheet On/Off", _helpPath, self._TrapsheetOnOff, self, _unitName ) -- F8 - missionCommands.addCommandForGroup( gid, "着舰记录表 开/关", _helpPath, self._TrapsheetOnOff, self, _unitName ) -- F8 - - ------------------------------------- - -- F10/Airboss//F2 Kneeboard - ------------------------------------- - -- local _kneeboardPath = missionCommands.addSubMenuForGroup( gid, "Kneeboard", _rootPath ) - local _kneeboardPath = missionCommands.addSubMenuForGroup( gid, "膝板", _rootPath ) - -- F10/Airboss//F2 Kneeboard/F1 Results - -- local _resultsPath = missionCommands.addSubMenuForGroup( gid, "Results", _kneeboardPath ) - local _resultsPath = missionCommands.addSubMenuForGroup( gid, "总结", _kneeboardPath ) - -- F10/Airboss//F2 Kneeboard/F1 Results/ - -- missionCommands.addCommandForGroup( gid, "Greenie Board", _resultsPath, self._DisplayScoreBoard, self, _unitName ) -- F1 - missionCommands.addCommandForGroup( gid, "着陆质量评分板", _resultsPath, self._DisplayScoreBoard, self, _unitName ) -- F1 - -- missionCommands.addCommandForGroup( gid, "My LSO Grades", _resultsPath, self._DisplayPlayerGrades, self, _unitName ) -- F2 - missionCommands.addCommandForGroup( gid, "我的 LSO 成绩", _resultsPath, self._DisplayPlayerGrades, self, _unitName ) -- F2 - -- missionCommands.addCommandForGroup( gid, "Last Debrief", _resultsPath, self._DisplayDebriefing, self, _unitName ) -- F3 - missionCommands.addCommandForGroup( gid, "上次降落简报", _resultsPath, self._DisplayDebriefing, self, _unitName ) -- F3 - - -- F10/Airboss//F2 Kneeboard/F2 Skipper/ - if self.skipperMenu then - -- local _skipperPath = missionCommands.addSubMenuForGroup( gid, "Skipper", _kneeboardPath ) - local _skipperPath = missionCommands.addSubMenuForGroup( gid, "联系船长", _kneeboardPath ) - -- local _menusetspeed = missionCommands.addSubMenuForGroup( gid, "Set Speed", _skipperPath ) - local _menusetspeed = missionCommands.addSubMenuForGroup( gid, "设置速度", _skipperPath ) - missionCommands.addCommandForGroup( gid, "10 knots", _menusetspeed, self._SkipperRecoverySpeed, self, _unitName, 10 ) - missionCommands.addCommandForGroup( gid, "15 knots", _menusetspeed, self._SkipperRecoverySpeed, self, _unitName, 15 ) - missionCommands.addCommandForGroup( gid, "20 knots", _menusetspeed, self._SkipperRecoverySpeed, self, _unitName, 20 ) - missionCommands.addCommandForGroup( gid, "25 knots", _menusetspeed, self._SkipperRecoverySpeed, self, _unitName, 25 ) - missionCommands.addCommandForGroup( gid, "30 knots", _menusetspeed, self._SkipperRecoverySpeed, self, _unitName, 30 ) - -- local _menusetrtime = missionCommands.addSubMenuForGroup( gid, "Set Time", _skipperPath ) - local _menusetrtime = missionCommands.addSubMenuForGroup( gid, "设置时间", _skipperPath ) - missionCommands.addCommandForGroup( gid, "15 min", _menusetrtime, self._SkipperRecoveryTime, self, _unitName, 15 ) - missionCommands.addCommandForGroup( gid, "30 min", _menusetrtime, self._SkipperRecoveryTime, self, _unitName, 30 ) - missionCommands.addCommandForGroup( gid, "45 min", _menusetrtime, self._SkipperRecoveryTime, self, _unitName, 45 ) - missionCommands.addCommandForGroup( gid, "60 min", _menusetrtime, self._SkipperRecoveryTime, self, _unitName, 60 ) - missionCommands.addCommandForGroup( gid, "90 min", _menusetrtime, self._SkipperRecoveryTime, self, _unitName, 90 ) - -- local _menusetrtime = missionCommands.addSubMenuForGroup( gid, "Set Marshal Radial", _skipperPath ) - local _menusetrtime = missionCommands.addSubMenuForGroup( gid, "设置 Marshal 方向", _skipperPath ) - missionCommands.addCommandForGroup( gid, "+30°", _menusetrtime, self._SkipperRecoveryOffset, self, _unitName, 30 ) - missionCommands.addCommandForGroup( gid, "+15°", _menusetrtime, self._SkipperRecoveryOffset, self, _unitName, 15 ) - missionCommands.addCommandForGroup( gid, "0°", _menusetrtime, self._SkipperRecoveryOffset, self, _unitName, 0 ) - missionCommands.addCommandForGroup( gid, "-15°", _menusetrtime, self._SkipperRecoveryOffset, self, _unitName, -15 ) - missionCommands.addCommandForGroup( gid, "-30°", _menusetrtime, self._SkipperRecoveryOffset, self, _unitName, -30 ) - -- missionCommands.addCommandForGroup( gid, "U-turn On/Off", _skipperPath, self._SkipperRecoveryUturn, self, _unitName ) - missionCommands.addCommandForGroup( gid, "U-turn 开/关", _skipperPath, self._SkipperRecoveryUturn, self, _unitName ) - -- missionCommands.addCommandForGroup( gid, "Start CASE I", _skipperPath, self._SkipperStartRecovery, self, _unitName, 1 ) - -- missionCommands.addCommandForGroup( gid, "Start CASE II", _skipperPath, self._SkipperStartRecovery, self, _unitName, 2 ) - -- missionCommands.addCommandForGroup( gid, "Start CASE III", _skipperPath, self._SkipperStartRecovery, self, _unitName, 3 ) - -- missionCommands.addCommandForGroup( gid, "Stop Recovery", _skipperPath, self._SkipperStopRecovery, self, _unitName ) - missionCommands.addCommandForGroup( gid, "开始 CASE I", _skipperPath, self._SkipperStartRecovery, self, _unitName, 1 ) - missionCommands.addCommandForGroup( gid, "开始 CASE II", _skipperPath, self._SkipperStartRecovery, self, _unitName, 2 ) - missionCommands.addCommandForGroup( gid, "开始 CASE III", _skipperPath, self._SkipperStartRecovery, self, _unitName, 3 ) - missionCommands.addCommandForGroup( gid, "停止回收", _skipperPath, self._SkipperStopRecovery, self, _unitName ) - end - - -- F10/Airboss// - ------------------------- - -- missionCommands.addCommandForGroup( gid, "Request Marshal", _rootPath, self._RequestMarshal, self, _unitName ) -- F3 - -- missionCommands.addCommandForGroup( gid, "Request Commence", _rootPath, self._RequestCommence, self, _unitName ) -- F4 - -- missionCommands.addCommandForGroup( gid, "Request Refueling", _rootPath, self._RequestRefueling, self, _unitName ) -- F5 - -- missionCommands.addCommandForGroup( gid, "Spinning", _rootPath, self._RequestSpinning, self, _unitName ) -- F6 - -- missionCommands.addCommandForGroup( gid, "Emergency Landing", _rootPath, self._RequestEmergency, self, _unitName ) -- F7 - -- missionCommands.addCommandForGroup( gid, "[Reset My Status]", _rootPath, self._ResetPlayerStatus, self, _unitName ) -- F8 - missionCommands.addCommandForGroup( gid, "请求 Marshal", _rootPath, self._RequestMarshal, self, _unitName ) -- F3 - missionCommands.addCommandForGroup( gid, "请求进近", _rootPath, self._RequestCommence, self, _unitName ) -- F4 - missionCommands.addCommandForGroup( gid, "请求空中加油", _rootPath, self._RequestRefueling, self, _unitName ) -- F5 - missionCommands.addCommandForGroup( gid, "Spinning[重新执行五边]", _rootPath, self._RequestSpinning, self, _unitName ) -- F6 - missionCommands.addCommandForGroup( gid, "紧急降落[跳过所有流程]", _rootPath, self._RequestEmergency, self, _unitName ) -- F7 - missionCommands.addCommandForGroup( gid, "[重置我现在的降落状态]", _rootPath, self._ResetPlayerStatus, self, _unitName ) -- F8 - end - else - self:E( self.lid .. string.format( "ERROR: Could not find group or group ID in AddF10Menu() function. Unit name: %s.", _unitName ) ) - end - else - self:E( self.lid .. string.format( "ERROR: Player unit does not exist in AddF10Menu() function. Unit name: %s.", _unitName ) ) - end - -end - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --- SKIPPER MENU ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - ---- Reset player status. Player is removed from all queues and its status is set to undefined. --- @param #AIRBOSS self --- @param #string _unitName Name fo the player unit. --- @param #number case Recovery case. -function AIRBOSS:_SkipperStartRecovery( _unitName, case ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - - if playerData then - - -- Inform player. - -- local text = string.format( "affirm, Case %d recovery will start in 5 min for %d min. Wind on deck %d knots. U-turn=%s.", case, self.skipperTime, self.skipperSpeed, tostring( self.skipperUturn ) ) - local text = string.format( "收到, Case %d 回收将在 5 min 之内开始,持续 %d min . 甲板风 %d knots. U-turn=%s.", case, self.skipperTime, self.skipperSpeed, tostring( self.skipperUturn ) ) - if case > 1 then - -- text = text .. string.format( " Marshal radial %d°.", self.skipperOffset ) - text = text .. string.format( " Marshal 方向 %d°.", self.skipperOffset ) - end - if self:IsRecovering() then - -- text = "negative, carrier is already recovering." - text = "不行, 航母已经在执行回收作业了." - self:MessageToPlayer( playerData, text, "AIRBOSS" ) - return - end - self:MessageToPlayer( playerData, text, "AIRBOSS" ) - - -- Recovery staring in 5 min for 30 min. - local t0 = timer.getAbsTime() + 5 * 60 - local t9 = t0 + self.skipperTime * 60 - local C0 = UTILS.SecondsToClock( t0 ) - local C9 = UTILS.SecondsToClock( t9 ) - - -- Carrier will turn into the wind. Wind on deck 25 knots. U-turn on. - self:AddRecoveryWindow( C0, C9, case, self.skipperOffset, true, self.skipperSpeed, self.skipperUturn ) - - end - end -end - ---- Skipper Stop recovery function. --- @param #AIRBOSS self --- @param #string _unitName Name fo the player unit. -function AIRBOSS:_SkipperStopRecovery( _unitName ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - - if playerData then - - -- Inform player. - -- local text = "roger, stopping recovery right away." - local text = "收到, 马上停止回收作业." - if not self:IsRecovering() then - -- text = "negative, carrier is currently not recovering." - text = "无法执行, 航母现在已经没在回收了." - self:MessageToPlayer( playerData, text, "AIRBOSS" ) - return - end - self:MessageToPlayer( playerData, text, "AIRBOSS" ) - - self:RecoveryStop() - end - end -end - ---- Skipper set recovery offset angle. --- @param #AIRBOSS self --- @param #string _unitName Name fo the player unit. --- @param #number offset Recovery holding offset angle in degrees for Case II/III. -function AIRBOSS:_SkipperRecoveryOffset( _unitName, offset ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - - if playerData then - - -- Inform player. - -- local text = string.format( "roger, relative CASE II/III Marshal radial set to %d°.", offset ) - local text = string.format( "收到, 相对 CASE II/III Marshal 航向设置为 %d°.", offset ) - self:MessageToPlayer( playerData, text, "AIRBOSS" ) - - self.skipperOffset = offset - end - end -end - ---- Skipper set recovery time. --- @param #AIRBOSS self --- @param #string _unitName Name fo the player unit. --- @param #number time Recovery time in minutes. -function AIRBOSS:_SkipperRecoveryTime( _unitName, time ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - - if playerData then - - -- Inform player. - -- local text = string.format( "roger, manual recovery time set to %d min.", time ) - local text = string.format( "收到, 手动设置回收时间到 %d min.", time ) - self:MessageToPlayer( playerData, text, "AIRBOSS" ) - - self.skipperTime = time - - end - end -end - ---- Skipper set recovery speed. --- @param #AIRBOSS self --- @param #string _unitName Name fo the player unit. --- @param #number speed Recovery speed in knots. -function AIRBOSS:_SkipperRecoverySpeed( _unitName, speed ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - - if playerData then - - -- Inform player. - -- local text = string.format( "roger, wind on deck set to %d knots.", speed ) - local text = string.format( "收到, 甲板风设置到 %d knots.", speed ) - self:MessageToPlayer( playerData, text, "AIRBOSS" ) - - self.skipperSpeed = speed - end - end -end - ---- Skipper set recovery speed. --- @param #AIRBOSS self --- @param #string _unitName Name fo the player unit. -function AIRBOSS:_SkipperRecoveryUturn( _unitName ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - - if playerData then - - self.skipperUturn = not self.skipperUturn - - -- Inform player. - -- local text = string.format( "roger, U-turn is now %s.", tostring( self.skipperUturn ) ) - local text = string.format( "收到, U-turn 现在为 %s.", tostring( self.skipperUturn ) ) - self:MessageToPlayer( playerData, text, "AIRBOSS" ) - - end - end -end - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --- ROOT MENU ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - ---- Reset player status. Player is removed from all queues and its status is set to undefined. --- @param #AIRBOSS self --- @param #string _unitName Name fo the player unit. -function AIRBOSS:_ResetPlayerStatus( _unitName ) - self:F( _unitName ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - - if playerData then - - -- Inform player. - -- local text = "roger, status reset executed! You have been removed from all queues." - local text = "收到, 已经执行状态重置! 你现在已经不在任何队列中了." - self:MessageToPlayer( playerData, text, "AIRBOSS" ) - - -- Remove flight from queues. Collapse marshal stack if necessary. - -- Section members are removed from the Spinning queue. If flight is member, he is removed from the section. - self:_RemoveFlight( playerData ) - - -- Stop pending debrief scheduler. - if playerData.debriefschedulerID and self.Scheduler then - self.Scheduler:Stop( playerData.debriefschedulerID ) - end - - -- Initialize player data. - self:_InitPlayer( playerData ) - - end - end -end - ---- Request marshal. --- @param #AIRBOSS self --- @param #string _unitName Name fo the player unit. -function AIRBOSS:_RequestMarshal( _unitName ) - self:F( _unitName ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - - if playerData then - - -- Voice over of inbound call (regardless of airboss rejecting it or not) - if self.xtVoiceOvers then - self:_MarshallInboundCall(_unit, playerData.onboard) - end - - -- Check if player is in CCA - local inCCA = playerData.unit:IsInZone( self.zoneCCA ) - - if inCCA then - - if self:_InQueue( self.Qmarshal, playerData.group ) then - - -- Flight group is already in marhal queue. - -- local text = string.format( "negative, you are already in the Marshal queue. New marshal request denied!" ) - local text = string.format( "无法执行, 你已经在 Marshal 队列. 新的 marshal 请求被取消!" ) - self:MessageToPlayer( playerData, text, "MARSHAL" ) - - elseif self:_InQueue( self.Qpattern, playerData.group ) then - - -- Flight group is already in pattern queue. - -- local text = string.format( "negative, you are already in the Pattern queue. Marshal request denied!" ) - local text = string.format( "无法执行, 你已经在 Pattern 队列. 新的 marshal 请求被取消!" ) - self:MessageToPlayer( playerData, text, "MARSHAL" ) - - elseif self:_InQueue( self.Qwaiting, playerData.group ) then - - -- Flight group is already in pattern queue. - -- local text = string.format( "negative, you are in the Waiting queue with %d flights ahead of you. Marshal request denied!", #self.Qwaiting ) - local text = string.format( "无法执行, 你已经在等待队列 前方有 %d 组机队. Marshal 请求被取消!", #self.Qwaiting ) - self:MessageToPlayer( playerData, text, "MARSHAL" ) - - elseif not _unit:InAir() then - - -- Flight group is already in pattern queue. - -- local text = string.format( "negative, you are not airborne. Marshal request denied!" ) - local text = string.format( "无法执行, 你还没起飞. Marshal 请求被取消!" ) - self:MessageToPlayer( playerData, text, "MARSHAL" ) - - elseif playerData.name ~= playerData.seclead then - - -- Flight group is already in pattern queue. - -- local text = string.format( "negative, your section lead %s needs to request Marshal.", playerData.seclead ) - local text = string.format( "无法执行, 你需要小队长 %s 来请求 Marshal.", playerData.seclead ) - self:MessageToPlayer( playerData, text, "MARSHAL" ) - - else - - -- Get next free Marshal stack. - local freestack = self:_GetFreeStack( playerData.ai ) - - -- Check if stack is available. For Case I the number is limited. - if freestack then - - -- Add flight to marshal stack. - self:_MarshalPlayer( playerData, freestack ) - - else - - -- Add flight to waiting queue. - self:_WaitPlayer( playerData ) - - end - - end - - else - - -- Flight group is not in CCA yet. - -- local text = string.format( "negative, you are not inside CCA. Marshal request denied!" ) - local text = string.format( "无法执行, 你不在 CCA[航母管制区域]. Marshal 请求取消!" ) - self:MessageToPlayer( playerData, text, "MARSHAL" ) - - end - end - end -end - ---- Request emergency landing. --- @param #AIRBOSS self --- @param #string _unitName Name fo the player unit. -function AIRBOSS:_RequestEmergency( _unitName ) - self:F( _unitName ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - - if playerData then - - local text = "" - if not self.emergency then - - -- Mission designer did not allow emergency landing. - -- text = "negative, no emergency landings on my carrier. We are currently busy. See how you get along!" - text = "无法执行, 我的航母不允许紧急降落. 航母现在繁忙. 你需要自己解决问题!" - - elseif not _unit:InAir() then - - -- Carrier zone. - local zone = self:_GetZoneCarrierBox() - - -- Check if player is on the carrier. - if playerData.unit:IsInZone( zone ) then - - -- Bolter pattern. - -- text = "roger, you are now technically in the bolter pattern. Your next step after takeoff is abeam!" - text = "收到, 已将你安排到 脱钩[bolter]程序. 你的下一步动作是起飞后直接进入第三边!" - - -- Get flight lead. - local lead = self:_GetFlightLead( playerData ) - - -- Set set for lead. - self:_SetPlayerStep( lead, AIRBOSS.PatternStep.BOLTER ) - - -- Also set bolter pattern for all members. - for _, sec in pairs( lead.section ) do - local sectionmember = sec -- #AIRBOSS.PlayerData - self:_SetPlayerStep( sectionmember, AIRBOSS.PatternStep.BOLTER ) - end - - -- Remove flight from waiting queue just in case. - self:_RemoveFlightFromQueue( self.Qwaiting, lead ) - - if self:_InQueue( self.Qmarshal, lead.group ) then - -- Remove flight from Marshal queue and add to pattern. - self:_RemoveFlightFromMarshalQueue( lead ) - else - -- Add flight to pattern if he was not. - if not self:_InQueue( self.Qpattern, lead.group ) then - self:_AddFlightToPatternQueue( lead ) - end - end - - else - -- Flight group is not in air. - -- text = string.format( "negative, you are not airborne. Request denied!" ) - text = string.format( "无法执行, 你还没有起飞. 请求被否决!" ) - end - - else - - -- Cleared. - -- text = "affirmative, you can bypass the pattern and are cleared for final approach!" - text = "收到, 你可以跳过所有程序直接进入第五边!" - - -- Now, if player is in the marshal or waiting queue he will be removed. But the new leader should stay in or not. - local lead = self:_GetFlightLead( playerData ) - - -- Set set for lead. - self:_SetPlayerStep( lead, AIRBOSS.PatternStep.EMERGENCY ) - - -- Also set emergency landing for all members. - for _, sec in pairs( lead.section ) do - local sectionmember = sec -- #AIRBOSS.PlayerData - self:_SetPlayerStep( sectionmember, AIRBOSS.PatternStep.EMERGENCY ) - - -- Remove flight from spinning queue just in case (everone can spin on his own). - self:_RemoveFlightFromQueue( self.Qspinning, sectionmember ) - end - - -- Remove flight from waiting queue just in case. - self:_RemoveFlightFromQueue( self.Qwaiting, lead ) - - if self:_InQueue( self.Qmarshal, lead.group ) then - -- Remove flight from Marshal queue and add to pattern. - self:_RemoveFlightFromMarshalQueue( lead ) - else - -- Add flight to pattern if he was not. - if not self:_InQueue( self.Qpattern, lead.group ) then - self:_AddFlightToPatternQueue( lead ) - end - end - - end - - -- Send message. - self:MessageToPlayer( playerData, text, "AIRBOSS" ) - - end - - end -end - ---- Request spinning. --- @param #AIRBOSS self --- @param #string _unitName Name fo the player unit. -function AIRBOSS:_RequestSpinning( _unitName ) - self:F( _unitName ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - - if playerData then - - local text = "" - if not self:_InQueue( self.Qpattern, playerData.group ) then - - -- Player not in pattern queue. - -- text = "negative, you have to be in the pattern to spin it!" - text = "无法执行, 你得先进入五边才能请求 spinning!" - - elseif playerData.step == AIRBOSS.PatternStep.SPINNING then - - -- Player is already spinning. - -- text = "negative, you are already spinning." - text = "无法执行, 你已经在 spinning 了." - - -- Check if player is in the right step. - elseif not (playerData.step == AIRBOSS.PatternStep.BREAKENTRY or - playerData.step == AIRBOSS.PatternStep.EARLYBREAK or - playerData.step == AIRBOSS.PatternStep.LATEBREAK) then - - -- Player is not in the right step. - -- text = "negative, you have to be in the right step to spin it!" - text = "无法执行, 你得在进入第三边前申请 spinning!" - - else - - -- Set player step. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.SPINNING ) - - -- Add player to spinning queue. - table.insert( self.Qspinning, playerData ) - - -- 405, Spin it! Click. - local call = self:_NewRadioCall( self.LSOCall.SPINIT, "AIRBOSS", "Spin it!", self.Tmessage, playerData.onboard ) - self:RadioTransmission( self.LSORadio, call, nil, nil, nil, true ) - - -- Some advice. - if playerData.difficulty == AIRBOSS.Difficulty.EASY then - -- local text = "Climb to 1200 feet and proceed to the initial again." - local text = "爬升到 1200 feet 重新执行第一边." - self:MessageToPlayer( playerData, text, "AIRBOSS", "" ) - end - - return - end - - -- Send message. - self:MessageToPlayer( playerData, text, "AIRBOSS" ) - - end - end -end - ---- Request to commence landing approach. --- @param #AIRBOSS self --- @param #string _unitName Name fo the player unit. -function AIRBOSS:_RequestCommence( _unitName ) - self:F( _unitName ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - - if playerData then - - -- Voice over of Commencing call (regardless of Airboss will rejected or not) - if self.xtVoiceOvers then - self:_CommencingCall(_unit, playerData.onboard) - end - - -- Check if unit is in CCA. - local text = "" - local cleared = false - if _unit:IsInZone( self.zoneCCA ) then - - -- Get stack value. - local stack = playerData.flag - - -- Number of airborne aircraft currently in pattern. - local _, npattern = self:_GetQueueInfo( self.Qpattern ) - - -- TODO: Check distance to initial or platform. Only allow commence if < max distance. Otherwise say bearing. - - if self:_InQueue( self.Qpattern, playerData.group ) then - - -- Flight group is already in pattern queue. - -- text = string.format( "negative, %s, you are already in the Pattern queue.", playerData.name ) - text = string.format( "无法执行, %s, 你已经在 Pattern 队列里了.", playerData.name ) - - elseif not _unit:InAir() then - - -- Flight group is already in pattern queue. - -- text = string.format( "negative, %s, you are not airborne.", playerData.name ) - text = string.format( "无法执行, %s, 你还没起飞.", playerData.name ) - - elseif playerData.seclead ~= playerData.name then - - -- Flight group is already in pattern queue. - -- text = string.format( "negative, %s, your section leader %s has to request commence!", playerData.name, playerData.seclead ) - text = string.format( "无法执行, %s, 你的小队长 %s 还没请求进近!", playerData.name, playerData.seclead ) - - elseif stack > 1 then - - -- We are in a higher stack. - -- text = string.format( "negative, %s, it's not your turn yet! You are in stack no. %s.", playerData.name, stack ) - text = string.format( "无法执行, %s, 还没轮到你呢! 你处在队列位置 no. %s.", playerData.name, stack ) - - elseif npattern >= self.Nmaxpattern then - - -- Patern is full! - -- text = string.format( "negative ghostrider, pattern is full!\nThere are %d aircraft currently in the pattern.", npattern ) - text = string.format( "无法执行 队列已满!\n现在有 %d 架飞机正在执行五边程序.", npattern ) - - elseif self:IsRecovering() == false and not self.airbossnice then - - -- Carrier is not recovering right now. - if self.recoverywindow then - local clock = UTILS.SecondsToClock( self.recoverywindow.START ) - -- text = string.format( "negative, carrier is currently not recovery. Next window will open at %s.", clock ) - text = string.format( "无法执行, 航母已经暂停回收. 下一个回收窗口预计: %s.", clock ) - else - -- text = string.format( "negative, carrier is not recovering. No future windows planned." ) - text = string.format( "无法执行, 航母已经停止回收. 没有计划中的回收窗口." ) - end - - elseif not self:_InQueue( self.Qmarshal, playerData.group ) and not self.airbossnice then - - -- text = "negative, you have to request Marshal before you can commence." - text = "无法执行, 你得先请求 Marshal 才能请求进近." - - else - - ----------------------- - -- Positive Response -- - ----------------------- - - -- text = text .. "roger." - text = text .. "收到." - - -- Carrier is not recovering but Airboss has a good day. - if not self:IsRecovering() then - -- text = text .. " Carrier is not recovering currently! However, you are cleared anyway as I have a nice day." - text = text .. " 航母已经暂停回收! 不过, 你还是被批准降落因为我今天心情好." - end - - -- If player is not in the Marshal queue set player case to current case. - if not self:_InQueue( self.Qmarshal, playerData.group ) then - - -- Set current case. - playerData.case = self.case - - -- Hint about TACAN bearing. - if self.TACANon and playerData.difficulty ~= AIRBOSS.Difficulty.HARD then - -- Get inverse magnetic radial potential offset. - local radial = self:GetRadial( playerData.case, true, true, true ) - if playerData.case == 1 then - -- For case 1 we want the BRC but above routine return FB. - radial = self:GetBRC() - end - -- text = text .. string.format( "\nSelect TACAN %03d°, Channel %d%s (%s).\n", radial, self.TACANchannel, self.TACANmode, self.TACANmorse ) - text = text .. string.format( "\n设置塔康航向 %03d°, 频道 %d%s (%s).\n", radial, self.TACANchannel, self.TACANmode, self.TACANmorse ) - end - - -- TODO: Inform section members. - - -- Set case of section members as well. Not sure if necessary any more since it is set as soon as the recovery case is changed. - for _, flight in pairs( playerData.section ) do - flight.case = playerData.case - end - - -- Add player to pattern queue. Usually this is done when the stack is collapsed but this player is not in the Marshal queue. - self:_AddFlightToPatternQueue( playerData ) - end - - -- Clear player for commence. - cleared = true - end - - else - -- This flight is not yet registered! - -- text = string.format( "negative, %s, you are not inside the CCA!", playerData.name ) - text = string.format( "无法执行, %s, 你不在航母管制区域[CCA]!", playerData.name ) - end - - -- Debug - self:T( self.lid .. text ) - - -- Send message. - self:MessageToPlayer( playerData, text, "MARSHAL" ) - - -- Check if player was cleard. Need to do this after the message above is displayed. - if cleared then - -- Call commence routine. No zone check. NOTE: Commencing will set step for all section members as well. - self:_Commencing( playerData, false ) - end - end - end -end - ---- Player requests refueling. --- @param #AIRBOSS self --- @param #string _unitName Name of the player unit. -function AIRBOSS:_RequestRefueling( _unitName ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - - if playerData then - - -- Check if there is a recovery tanker defined. - local text - if self.tanker then - - -- Check if player is in CCA. - if _unit:IsInZone( self.zoneCCA ) then - - -- Check if tanker is running or refueling or returning. - if self.tanker:IsRunning() or self.tanker:IsRefueling() then - - -- Get alt of tanker in angels. - -- local angels=UTILS.Round(UTILS.MetersToFeet(self.tanker.altitude)/1000, 0) - local angels = self:_GetAngels( self.tanker.altitude ) - - -- Tanker is up and running. - -- text = string.format( "affirmative, proceed to tanker at angels %d.", angels ) - text = string.format( "确认, 前往加油机高度 %d.", angels ) - - -- State TACAN channel of tanker if defined. - if self.tanker.TACANon then - -- text = text .. string.format( "\nTanker TACAN channel %d%s (%s).", self.tanker.TACANchannel, self.tanker.TACANmode, self.tanker.TACANmorse ) - -- text = text .. string.format( "\nRadio frequency %.3f MHz AM.", self.tanker.RadioFreq ) - text = text .. string.format( "\n加油机 塔康频道 %d%s (%s).", self.tanker.TACANchannel, self.tanker.TACANmode, self.tanker.TACANmorse ) - text = text .. string.format( "\n无线电频率 %.3f MHz AM.", self.tanker.RadioFreq ) - end - - -- Tanker is currently refueling. Inform player. - if self.tanker:IsRefueling() then - -- text = text .. "\nTanker is currently refueling. You might have to queue up." - text = text .. "\n加油机正在执行加油. 你可能需要排个队." - end - - -- Collapse marshal stack if player is in queue. - self:_RemoveFlightFromMarshalQueue( playerData, true ) - - -- Set step to refueling. - self:_SetPlayerStep( playerData, AIRBOSS.PatternStep.REFUELING ) - - -- Inform section and set step. - for _, sec in pairs( playerData.section ) do - -- local sectext = "follow your section leader to the tanker." - local sectext = "跟随你的长机前往加油机位置." - self:MessageToPlayer( sec, sectext, "MARSHAL" ) - self:_SetPlayerStep( sec, AIRBOSS.PatternStep.REFUELING ) - end - - elseif self.tanker:IsReturning() then - -- Tanker is RTB. - -- text = "negative, tanker is RTB. Request denied!\nWait for the tanker to be back on station if you can." - text = "无法执行, 加油机已经 RTB. 请求否决!\n如果可以请等待下一架加油机升空." - end - - else - -- text = "negative, you are not inside the CCA yet." - text = "无法执行, 你还不在航母管制区[CCA]." - end - else - -- text = "negative, no refueling tanker available." - text = "无法执行, 没有可用的加油机." - end - - -- Send message. - self:MessageToPlayer( playerData, text, "MARSHAL" ) - end - end -end - ---- Remove a member from the player's section. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player --- @param #AIRBOSS.PlayerData sectionmember The section member to be removed. --- @return #boolean If true, flight was a section member and could be removed. False otherwise. -function AIRBOSS:_RemoveSectionMember( playerData, sectionmember ) - -- Loop over all flights in player's section - for i, _flight in pairs( playerData.section ) do - local flight = _flight -- #AIRBOSS.PlayerData - if flight.name == sectionmember.name then - table.remove( playerData.section, i ) - return true - end - end - return false -end - ---- Set all flights within 100 meters to be part of my section. --- @param #AIRBOSS self --- @param #string _unitName Name of the player unit. -function AIRBOSS:_SetSection( _unitName ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - - if playerData then - - -- Coordinate of flight lead. - local mycoord = _unit:GetCoordinate() - - -- Max distance up to which section members are allowed. - local dmax = 100 - - -- Check if player is in Marshal or pattern queue already. - local text - if self.NmaxSection == 0 then - -- text = string.format( "negative, setting sections is disabled in this mission. You stay alone." ) - text = string.format( "无法执行, 当前任务不允许设置机队. 你只能一个人了." ) - elseif self:_InQueue( self.Qmarshal, playerData.group ) then - -- text = string.format( "negative, you are already in the Marshal queue. Setting section not possible any more!" ) - text = string.format( "无法执行, 你已经在 Marshal 队列. 无法设置小队了!" ) - elseif self:_InQueue( self.Qpattern, playerData.group ) then - -- text = string.format( "negative, you are already in the Pattern queue. Setting section not possible any more!" ) - text = string.format( "无法执行, 你已经在 Pattern 队列. 无法设置小队了!" ) - else - - -- Check if player is member of another section already. If so, remove him from his current section. - if playerData.seclead ~= playerData.name then - local lead = self.players[playerData.seclead] -- #AIRBOSS.PlayerData - if lead then - - -- Remove player from his old section lead. - local removed = self:_RemoveSectionMember( lead, playerData ) - if removed then - -- self:MessageToPlayer( lead, string.format( "Flight %s has been removed from your section.", playerData.name ), "AIRBOSS", "", 5 ) - -- self:MessageToPlayer( playerData, string.format( "You have been removed from %s's section.", lead.name ), "AIRBOSS", "", 5 ) - self:MessageToPlayer( lead, string.format( "成员 %s 已被从你的小队移除.", playerData.name ), "AIRBOSS", "", 5 ) - self:MessageToPlayer( playerData, string.format( "你已被 %s 的小队移除.", lead.name ), "AIRBOSS", "", 5 ) - end - - end - end - - -- Potential section members. - local section = {} - - -- Loop over all registered flights. - for _, _flight in pairs( self.flights ) do - local flight = _flight -- #AIRBOSS.FlightGroup - - -- Only human flight groups excluding myself. Also only flights that dont have a section itself (would get messy) or are part of another section (no double membership). - if flight.ai == false and flight.groupname ~= playerData.groupname and #flight.section == 0 and flight.seclead == flight.name then - - -- Distance (3D) to other flight group. - local distance = flight.group:GetCoordinate():Get3DDistance( mycoord ) - - -- Check distance. - if distance < dmax then - self:T( self.lid .. string.format( "Found potential section member %s for lead %s at distance %.1f m.", flight.name, playerData.name, distance ) ) - table.insert( section, { flight = flight, distance = distance } ) - end - - end - end - - -- Sort potential section members wrt to distance to lead. - table.sort( section, function( a, b ) - return a.distance < b.distance - end ) - - -- Make player section lead if he was not before. - playerData.seclead = playerData.name - - -- Loop over all flights in player's current section and inform those members that will be removed because they are not in range any more. - for _, _flight in pairs( playerData.section ) do - local flight = _flight -- #AIRBOSS.PlayerData - - -- Loop over all potential new members and check if they were already part of the player's section. - local gotit = false - for _, _new in pairs( section ) do - local newflight = _new.flight -- #AIRBOSS.PlayerData - if newflight.name == flight.name then - gotit = true -- This is an old one that stays. - end - end - - -- Flight is not a member any more ==> remove it. - if not gotit then - -- self:MessageToPlayer( flight, string.format( "you were removed from %s's section and are on your own now.", playerData.name ), "AIRBOSS", "", 5 ) - self:MessageToPlayer( flight, string.format( "你已被 %s 的小队移除,你现在独自一人了.", playerData.name ), "AIRBOSS", "", 5 ) - flight.seclead = flight.name - self:_RemoveSectionMember( playerData, flight ) - end - end - - -- Remove all flights that are currently in the player's section already from scanned potential new section members. - for i, _new in pairs( section ) do - local newflight = _new.flight -- #AIRBOSS.PlayerData - for _, _flight in pairs( playerData.section ) do - local currentflight = _flight -- #AIRBOSS.PlayerData - if newflight.name == currentflight.name then - table.remove( section, i ) - end - end - end - - -- Init section table. Should not be necessary as all members are removed anyhow above. - -- playerData.section={} - - -- Output text. - -- text = string.format( "Registered flight section:" ) - text = string.format( "已注册小队:" ) - -- text = text .. string.format( "\n- %s (lead)", playerData.seclead ) - text = text .. string.format( "\n- %s (长机)", playerData.seclead ) - -- Old members that stay (if any). - for _, _flight in pairs( playerData.section ) do - local flight = _flight -- #AIRBOSS.PlayerData - text = text .. string.format( "\n- %s", flight.name ) - end - -- New members (if any). - for i = 1, math.min( self.NmaxSection - #playerData.section, #section ) do - local flight = section[i].flight -- #AIRBOSS.PlayerData - - -- New flight members. - text = text .. string.format( "\n- %s", flight.name ) - - -- Set section lead of player flight. - flight.seclead = playerData.name - - -- Set case of f - flight.case = playerData.case - - -- Inform player that he is now part of a section. - -- self:MessageToPlayer( flight, string.format( "your section lead is now %s.", playerData.name ), "AIRBOSS" ) - self:MessageToPlayer( flight, string.format( "你的小队长现在是 %s.", playerData.name ), "AIRBOSS" ) - - -- Add flight to section table. - table.insert( playerData.section, flight ) - end - - -- Section is empty. - if #playerData.section == 0 then - -- text = text .. string.format( "\n- No other human flights found within radius of %.1f meters!", dmax ) - text = text .. string.format( "\n- 没有其它玩家驾驶的飞机在 %.1f 米内!", dmax ) - end - - end - - -- Message to section lead. - self:MessageToPlayer( playerData, text, "MARSHAL" ) - end - end -end - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --- RESULTS MENU ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - ---- Display top 10 player scores. --- @param #AIRBOSS self --- @param #string _unitName Name fo the player unit. -function AIRBOSS:_DisplayScoreBoard( _unitName ) - self:F( _unitName ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - - -- Results table. - local _playerResults = {} - - -- Calculate average points for all players. - for playerName, playerGrades in pairs( self.playerscores ) do - - if playerGrades then - - -- Loop over all grades - local Paverage = 0 - local n = 0 - for _, _grade in pairs( playerGrades ) do - local grade = _grade -- #AIRBOSS.LSOgrade - - -- Add up only final scores for the average. - if grade.finalscore then -- grade.points>=0 then - Paverage = Paverage + grade.finalscore - n = n + 1 - else - -- Case when the player just leaves after an unfinished pass, e.g bolter, without landing. - -- But this should now be solved by deleteing all unfinished results. - end - end - - -- We dont want to devide by zero. - if n > 0 then - _playerResults[playerName] = Paverage / n - end - - end - end - - -- Message text. - -- local text = string.format( "Greenie Board (top ten):" ) - local text = string.format( "着舰评分板 (前十):" ) - local i = 1 - for _playerName, _points in UTILS.spairs( _playerResults, function( t, a, b ) - return t[b] < t[a] - end ) do - - -- Text. - text = text .. string.format( "\n[%d] %s %.1f||", i, _playerName, _points ) - - -- All player grades. - local playerGrades = self.playerscores[_playerName] - - -- Add grades of passes. We use the actual grade of each pass here and not the average after player has landed. - for _, _grade in pairs( playerGrades ) do - local grade = _grade -- #AIRBOSS.LSOgrade - if grade.finalscore then - text = text .. string.format( "%.1f|", grade.points ) - elseif grade.points >= 0 then -- Only points >=0 as foul deck gives -1. - text = text .. string.format( "(%.1f)", grade.points ) - end - end - - -- Display only the top ten. - i = i + 1 - if i > 10 then - break - end - end - - -- If no results yet. - if i == 1 then - -- text = text .. "\nNo results yet." - text = text .. "\n还没有任何信息." - end - - -- Send message. - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - if playerData.client then - MESSAGE:New( text, 30, nil, true ):ToClient( playerData.client ) - end - - end -end - ---- Display top 10 player scores. --- @param #AIRBOSS self --- @param #string _unitName Name fo the player unit. -function AIRBOSS:_DisplayPlayerGrades( _unitName ) - self:F( _unitName ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - - if playerData then - - -- Grades of player: - -- local text = string.format( "Your last 10 grades, %s:", _playername ) - local text = string.format( "你的最近10次成绩, %s:", _playername ) - - -- All player grades. - local playerGrades = self.playerscores[_playername] or {} - - local p = 0 -- Average points. - local n = 0 -- Number of final passes. - local m = 0 -- Number of total passes. - -- for i,_grade in pairs(playerGrades) do - for i = #playerGrades, 1, -1 do - -- local grade=_grade --#AIRBOSS.LSOgrade - local grade = playerGrades[i] -- #AIRBOSS.LSOgrade - - -- Check if points >=0. For foul deck WO we give -1 and pass is not counted. - if grade.points >= 0 then - - -- Show final points or points of pass. - local points = grade.finalscore or grade.points - - -- Display max 10 results. - if m < 10 then - text = text .. string.format( "\n[%d] %s %.1f PT - %s", i, grade.grade, points, grade.details ) - - -- Wire trapped if any. - if grade.wire and grade.wire <= 4 then - text = text .. string.format( " %d-wire", grade.wire ) - end - - -- Time in the groove if any. - if grade.Tgroove and grade.Tgroove <= 360 then - -- text = text .. string.format( " Tgroove=%.1f s", grade.Tgroove ) - text = text .. string.format( " groove耗时=%.1f s", grade.Tgroove ) - end - end - - -- Add up final points. - if grade.finalscore then - p = p + grade.finalscore - n = n + 1 - end - - -- Total passes - m = m + 1 - end - end - - if n > 0 then - -- text = text .. string.format( "\nAverage points = %.1f", p / n ) - text = text .. string.format( "\n平均得分 = %.1f", p / n ) - else - -- text = text .. string.format( "\nNo data available." ) - text = text .. string.format( "\n无可用数据." ) - end - - -- Send message. - if playerData.client then - MESSAGE:New( text, 30, nil, true ):ToClient( playerData.client ) - end - end - end -end - ---- Display last debriefing. --- @param #AIRBOSS self --- @param #string _unitName Name fo the player unit. -function AIRBOSS:_DisplayDebriefing( _unitName ) - self:F( _unitName ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - - if playerData then - - -- Debriefing text. - -- local text = string.format( "Debriefing:" ) - local text = string.format( "总结:" ) - - -- Check if data is present. - if #playerData.lastdebrief > 0 then - text = text .. string.format( "\n================================\n" ) - for _, _data in pairs( playerData.lastdebrief ) do - local step = _data.step - local comment = _data.hint - text = text .. string.format( "* %s:", step ) - text = text .. string.format( "%s\n", comment ) - end - else - -- text = text .. " Nothing to show yet." - text = text .. " 没啥可显示的." - end - - -- Send debrief message to player - self:MessageToPlayer( playerData, text, nil, "", 30, true ) - - end - end -end - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --- KNEEBOARD MENU ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - ---- Display marshal or pattern queue. --- @param #AIRBOSS self --- @param #string _unitname Name of the player unit. --- @param #string qname Name of the queue. -function AIRBOSS:_DisplayQueue( _unitname, qname ) - - -- Get player unit and player name. - local unit, playername = self:_GetPlayerUnitAndName( _unitname ) - - -- Check if we have a player. - if unit and playername then - - -- Player data. - local playerData = self.players[playername] -- #AIRBOSS.PlayerData - - if playerData then - - -- Queue to display. - local queue = nil - if qname == "Marshal" then - queue = self.Qmarshal - elseif qname == "Pattern" then - queue = self.Qpattern - elseif qname == "Waiting" then - queue = self.Qwaiting - end - - -- Number of group and units in queue - local Nqueue, nqueue = self:_GetQueueInfo( queue, playerData.case ) - - -- local text = string.format( "%s Queue:", qname ) - local text = string.format( "%s 队列:", qname ) - if #queue == 0 then - -- text = text .. " empty" - text = text .. " 空" - else - local N = 0 - if qname == "Marshal" then - for i, _flight in pairs( queue ) do - local flight = _flight -- #AIRBOSS.FlightGroup - local charlie = self:_GetCharlieTime( flight ) - local Charlie = UTILS.SecondsToClock( charlie ) - local stack = flight.flag - local angels = self:_GetAngels( self:_GetMarshalAltitude( stack, flight.case ) ) - local _, nunit, nsec = self:_GetFlightUnits( flight, true ) - local nick = self:_GetACNickname( flight.actype ) - N = N + nunit - -- text = text .. string.format( "\n[Stack %d] %s (%s*%d+%d): Case %d, Angels %d, Charlie %s", stack, flight.onboard, nick, nunit, nsec, flight.case, angels, tostring( Charlie ) ) - text = text .. string.format( "\n[Stack %d] %s (%s*%d+%d): Case %d, 高度 %d, 预计开始时间 %s", stack, flight.onboard, nick, nunit, nsec, flight.case, angels, tostring( Charlie ) ) - end - elseif qname == "Pattern" or qname == "Waiting" then - for i, _flight in pairs( queue ) do - local flight = _flight -- #AIRBOSS.FlightGroup - local _, nunit, nsec = self:_GetFlightUnits( flight, true ) - local nick = self:_GetACNickname( flight.actype ) - local ptime = UTILS.SecondsToClock( timer.getAbsTime() - flight.time ) - N = N + nunit - text = text .. string.format( "\n[%d] %s (%s*%d+%d): Case %d, T=%s", i, flight.onboard, nick, nunit, nsec, flight.case, ptime ) - end - end - -- text = text .. string.format( "\nTotal AC: %d (airborne %d)", N, nqueue ) - text = text .. string.format( "\n总飞机数: %d (已升空 %d)", N, nqueue ) - end - - -- Send message. - self:MessageToPlayer( playerData, text, nil, "", nil, true ) - end - end -end - ---- Report information about carrier. --- @param #AIRBOSS self --- @param #string _unitname Name of the player unit. -function AIRBOSS:_DisplayCarrierInfo( _unitname ) - self:F2( _unitname ) - - -- Get player unit and player name. - local unit, playername = self:_GetPlayerUnitAndName( _unitname ) - - -- Check if we have a player. - if unit and playername then - - -- Player data. - local playerData = self.players[playername] -- #AIRBOSS.PlayerData - - if playerData then - - -- Current coordinates. - local coord = self:GetCoordinate() - - -- Carrier speed and heading. - local carrierheading = self.carrier:GetHeading() - local carrierspeed = UTILS.MpsToKnots( self.carrier:GetVelocityMPS() ) - - -- TACAN/ICLS. - local tacan = "unknown" - local icls = "unknown" - if self.TACANon and self.TACANchannel ~= nil then - tacan = string.format( "%d%s (%s)", self.TACANchannel, self.TACANmode, self.TACANmorse ) - end - if self.ICLSon and self.ICLSchannel ~= nil then - icls = string.format( "%d (%s)", self.ICLSchannel, self.ICLSmorse ) - end - - -- Wind on flight deck - local wind = UTILS.MpsToKnots( select( 1, self:GetWindOnDeck() ) ) - - -- Get groups, units in queues. - local Nmarshal, nmarshal = self:_GetQueueInfo( self.Qmarshal, playerData.case ) - local Npattern, npattern = self:_GetQueueInfo( self.Qpattern ) - local Nspinning, nspinning = self:_GetQueueInfo( self.Qspinning ) - local Nwaiting, nwaiting = self:_GetQueueInfo( self.Qwaiting ) - local Ntotal, ntotal = self:_GetQueueInfo( self.flights ) - - -- Current abs time. - local Tabs = timer.getAbsTime() - - -- Get recovery times of carrier. - -- local recoverytext = "Recovery time windows (max 5):" - local recoverytext = "回收窗口时间 (max 5):" - if #self.recoverytimes == 0 then - -- recoverytext = recoverytext .. " none." - recoverytext = recoverytext .. " 无." - else - -- Loop over recovery windows. - local rw = 0 - for _, _recovery in pairs( self.recoverytimes ) do - local recovery = _recovery -- #AIRBOSS.Recovery - -- Only include current and future recovery windows. - if Tabs < recovery.STOP then - -- Output text. - recoverytext = recoverytext .. string.format( "\n* %s - %s: Case %d (%d°)", UTILS.SecondsToClock( recovery.START ), UTILS.SecondsToClock( recovery.STOP ), recovery.CASE, recovery.OFFSET ) - if recovery.WIND then - -- recoverytext = recoverytext .. string.format( " @ %.1f kts wind", recovery.SPEED ) - recoverytext = recoverytext .. string.format( " @ %.1f kts 风", recovery.SPEED ) - end - rw = rw + 1 - if rw >= 5 then - -- Break the loop after 5 recovery times. - break - end - end - end - end - - -- Recovery tanker TACAN text. - local tankertext = nil - if self.tanker then - -- tankertext = string.format( "Recovery tanker frequency %.3f MHz\n", self.tanker.RadioFreq ) - tankertext = string.format( "加油机频率 %.3f MHz\n", self.tanker.RadioFreq ) - if self.tanker.TACANon then - -- tankertext = tankertext .. string.format( "Recovery tanker TACAN %d%s (%s)", self.tanker.TACANchannel, self.tanker.TACANmode, self.tanker.TACANmorse ) - tankertext = tankertext .. string.format( "加油机塔康 %d%s (%s)", self.tanker.TACANchannel, self.tanker.TACANmode, self.tanker.TACANmorse ) - else - -- tankertext = tankertext .. "Recovery tanker TACAN n/a" - tankertext = tankertext .. "加油机塔康 n/a[无]" - end - end - - -- Carrier FSM state. Idle is not clear enough. - local state = self:GetState() - if state == "Idle" then - state = "Deck closed" - end - if self.turning then - state = state .. " (currently turning)" - end - - -- Message text. - -- local text = string.format( "%s info:\n", self.alias ) - -- text = text .. string.format( "================================\n" ) - -- text = text .. string.format( "Carrier state: %s\n", state ) - -- if self.case == 1 then - -- text = text .. string.format( "Case %d recovery ops\n", self.case ) - -- else - -- local radial = self:GetRadial( self.case, true, true, false ) - -- text = text .. string.format( "Case %d recovery ops\nMarshal radial %03d°\n", self.case, radial ) - -- end - -- text = text .. string.format( "BRC %03d° - FB %03d°\n", self:GetBRC(), self:GetFinalBearing( true ) ) - -- text = text .. string.format( "Speed %.1f kts - Wind on deck %.1f kts\n", carrierspeed, wind ) - -- text = text .. string.format( "Tower frequency %.3f MHz\n", self.TowerFreq ) - -- text = text .. string.format( "Marshal radio %.3f MHz\n", self.MarshalFreq ) - -- text = text .. string.format( "LSO radio %.3f MHz\n", self.LSOFreq ) - -- text = text .. string.format( "TACAN Channel %s\n", tacan ) - -- text = text .. string.format( "ICLS Channel %s\n", icls ) - -- if tankertext then - -- text = text .. tankertext .. "\n" - -- end - -- text = text .. string.format( "# A/C total %d (%d)\n", Ntotal, ntotal ) - -- text = text .. string.format( "# A/C marshal %d (%d)\n", Nmarshal, nmarshal ) - -- text = text .. string.format( "# A/C pattern %d (%d) - spinning %d (%d)\n", Npattern, npattern, Nspinning, nspinning ) - -- text = text .. string.format( "# A/C waiting %d (%d)\n", Nwaiting, nwaiting ) - -- text = text .. string.format( recoverytext ) - - local text = string.format( "%s 信息:\n", self.alias ) - text = text .. string.format( "================================\n" ) - text = text .. string.format( "航母状态: %s\n", state ) - if self.case == 1 then - text = text .. string.format( "Case %d 回收作业\n", self.case ) - else - local radial = self:GetRadial( self.case, true, true, false ) - text = text .. string.format( "Case %d 回收作业\nMarshal 航向 %03d°\n", self.case, radial ) - end - text = text .. string.format( "BRC %03d° - FB %03d°\n", self:GetBRC(), self:GetFinalBearing( true ) ) - text = text .. string.format( "速度 %.1f kts - 甲板风 %.1f kts\n", carrierspeed, wind ) - text = text .. string.format( "塔台频率 %.3f MHz\n", self.TowerFreq ) - text = text .. string.format( "Marshal 频率 %.3f MHz\n", self.MarshalFreq ) - text = text .. string.format( "LSO 频率 %.3f MHz\n", self.LSOFreq ) - text = text .. string.format( "塔康 频道 %s\n", tacan ) - text = text .. string.format( "ICLS 频道 %s\n", icls ) - if tankertext then - text = text .. tankertext .. "\n" - end - text = text .. string.format( "# 飞行器总数 %d (%d)\n", Ntotal, ntotal ) - text = text .. string.format( "# 飞行器 marshal %d (%d)\n", Nmarshal, nmarshal ) - text = text .. string.format( "# 飞行器 pattern %d (%d) - spinning %d (%d)\n", Npattern, npattern, Nspinning, nspinning ) - text = text .. string.format( "# 飞行器 等待 %d (%d)\n", Nwaiting, nwaiting ) - text = text .. string.format( recoverytext ) - self:T2( self.lid .. text ) - - -- Send message. - self:MessageToPlayer( playerData, text, nil, "", 30, true ) - - else - self:E( self.lid .. string.format( "ERROR: Could not get player data for player %s.", playername ) ) - end - end - -end - ---- Report weather conditions at the carrier location. Temperature, QFE pressure and wind data. --- @param #AIRBOSS self --- @param #string _unitname Name of the player unit. -function AIRBOSS:_DisplayCarrierWeather( _unitname ) - self:F2( _unitname ) - - -- Get player unit and player name. - local unit, playername = self:_GetPlayerUnitAndName( _unitname ) - - -- Check if we have a player. - if unit and playername then - - -- Message text. - local text = "" - - -- Current coordinates. - local coord = self:GetCoordinate() - - -- Get atmospheric data at carrier location. - local T = coord:GetTemperature() - local P = coord:GetPressure() - - -- Get wind direction (magnetic) and strength. - local Wd, Ws = self:GetWind( nil, true ) - - -- Get Beaufort wind scale. - local Bn, Bd = UTILS.BeaufortScale( Ws ) - - -- Wind on flight deck. - local WodPA, WodPP = self:GetWindOnDeck() - local WodPA = UTILS.MpsToKnots( WodPA ) - local WodPP = UTILS.MpsToKnots( WodPP ) - - local WD = string.format( '%03d°', Wd ) - local Ts = string.format( "%d°C", T ) - - local tT = string.format( "%d°C", T ) - local tW = string.format( "%.1f knots", UTILS.MpsToKnots( Ws ) ) - local tP = string.format( "%.2f inHg", UTILS.hPa2inHg( P ) ) - - -- Report text. - -- text = text .. string.format( "Weather Report at Carrier %s:\n", self.alias ) - -- text = text .. string.format( "================================\n" ) - -- text = text .. string.format( "Temperature %s\n", tT ) - -- text = text .. string.format( "Wind from %s at %s (%s)\n", WD, tW, Bd ) - -- text = text .. string.format( "Wind on deck || %.1f kts, == %.1f kts\n", WodPA, WodPP ) - -- text = text .. string.format( "QFE %.1f hPa = %s", P, tP ) - - text = text .. string.format( "航母天气汇报 %s:\n", self.alias ) - text = text .. string.format( "================================\n" ) - text = text .. string.format( "温度 %s\n", tT ) - text = text .. string.format( "风向 %s at %s (%s)\n", WD, tW, Bd ) - text = text .. string.format( "甲板风|| %.1f kts, == %.1f kts\n", WodPA, WodPP ) - text = text .. string.format( "QFE %.1f hPa = %s", P, tP ) - - -- More info only reliable if Mission uses static weather. - if self.staticweather then - -- local clouds, visibility, fog, dust = self:_GetStaticWeather() - -- text = text .. string.format( "\nVisibility %.1f NM", UTILS.MetersToNM( visibility ) ) - -- text = text .. string.format( "\nCloud base %d ft", UTILS.MetersToFeet( clouds.base ) ) - -- text = text .. string.format( "\nCloud thickness %d ft", UTILS.MetersToFeet( clouds.thickness ) ) - -- text = text .. string.format( "\nCloud density %d", clouds.density ) - -- text = text .. string.format( "\nPrecipitation %d", clouds.iprecptns ) - -- if fog then - -- text = text .. string.format( "\nFog thickness %d ft", UTILS.MetersToFeet( fog.thickness ) ) - -- text = text .. string.format( "\nFog visibility %d ft", UTILS.MetersToFeet( fog.visibility ) ) - -- else - -- text = text .. string.format( "\nNo fog" ) - -- end - -- if dust then - -- text = text .. string.format( "\nDust density %d", dust ) - -- else - -- text = text .. string.format( "\nNo dust" ) - -- end - - local clouds, visibility, fog, dust = self:_GetStaticWeather() - text = text .. string.format( "\n可见度 %.1f NM", UTILS.MetersToNM( visibility ) ) - text = text .. string.format( "\n云低高 %d ft", UTILS.MetersToFeet( clouds.base ) ) - text = text .. string.format( "\n云层厚度 %d ft", UTILS.MetersToFeet( clouds.thickness ) ) - text = text .. string.format( "\n云层密度 %d", clouds.density ) - text = text .. string.format( "\n降水量 %d", clouds.iprecptns ) - if fog then - text = text .. string.format( "\n雾厚度 %d ft", UTILS.MetersToFeet( fog.thickness ) ) - text = text .. string.format( "\n雾 能见度 %d ft", UTILS.MetersToFeet( fog.visibility ) ) - else - text = text .. string.format( "\n无雾" ) - end - if dust then - text = text .. string.format( "\n灰尘密度 %d", dust ) - else - text = text .. string.format( "\n无灰尘" ) - end - end - - -- Debug output. - self:T2( self.lid .. text ) - - -- Send message to player group. - self:MessageToPlayer( self.players[playername], text, nil, "", 30, true ) - - else - self:E( self.lid .. string.format( "ERROR! Could not find player unit in CarrierWeather! Unit name = %s", _unitname ) ) - end -end - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --- HELP MENU ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - ---- Set difficulty level. --- @param #AIRBOSS self --- @param #string _unitname Name of the player unit. --- @param #AIRBOSS.Difficulty difficulty Difficulty level. -function AIRBOSS:_SetDifficulty( _unitname, difficulty ) - self:T2( { difficulty = difficulty, unitname = _unitname } ) - - -- Get player unit and player name. - local unit, playername = self:_GetPlayerUnitAndName( _unitname ) - - -- Check if we have a player. - if unit and playername then - - -- Player data. - local playerData = self.players[playername] -- #AIRBOSS.PlayerData - - if playerData then - playerData.difficulty = difficulty - -- local text = string.format( "roger, your skill level is now: %s.", difficulty ) - local text = string.format( "收到, 你的熟练度现在是: %s.", difficulty ) - self:MessageToPlayer( playerData, text, nil, playerData.name, 5 ) - else - self:E( self.lid .. string.format( "ERROR: Could not get player data for player %s.", playername ) ) - end - - -- Set hints as well. - if playerData.difficulty == AIRBOSS.Difficulty.HARD then - playerData.showhints = false - else - playerData.showhints = true - end - - end -end - ---- Turn player's aircraft attitude display on or off. --- @param #AIRBOSS self --- @param #string _unitname Name of the player unit. -function AIRBOSS:_SetHintsOnOff( _unitname ) - self:F2( _unitname ) - - -- Get player unit and player name. - local unit, playername = self:_GetPlayerUnitAndName( _unitname ) - - -- Check if we have a player. - if unit and playername then - - -- Player data. - local playerData = self.players[playername] -- #AIRBOSS.PlayerData - - if playerData then - - -- Invert hints. - playerData.showhints = not playerData.showhints - - -- Inform player. - local text = "" - if playerData.showhints == true then - -- text = string.format( "roger, hints are now ON." ) - text = string.format( "收到, 已开启提示." ) - else - -- text = string.format( "affirm, hints are now OFF." ) - text = string.format( "确认, 已关闭提示." ) - end - self:MessageToPlayer( playerData, text, nil, playerData.name, 5 ) - - end - end -end - ---- Turn player's aircraft attitude display on or off. --- @param #AIRBOSS self --- @param #string _unitname Name of the player unit. -function AIRBOSS:_DisplayAttitude( _unitname ) - self:F2( _unitname ) - - -- Get player unit and player name. - local unit, playername = self:_GetPlayerUnitAndName( _unitname ) - - -- Check if we have a player. - if unit and playername then - - -- Player data. - local playerData = self.players[playername] -- #AIRBOSS.PlayerData - - if playerData then - playerData.attitudemonitor = not playerData.attitudemonitor - end - end - -end - ---- Turn radio subtitles of player on or off. --- @param #AIRBOSS self --- @param #string _unitname Name of the player unit. -function AIRBOSS:_SubtitlesOnOff( _unitname ) - self:F2( _unitname ) - - -- Get player unit and player name. - local unit, playername = self:_GetPlayerUnitAndName( _unitname ) - - -- Check if we have a player. - if unit and playername then - - -- Player data. - local playerData = self.players[playername] -- #AIRBOSS.PlayerData - - if playerData then - playerData.subtitles = not playerData.subtitles - -- Inform player. - local text = "" - if playerData.subtitles == true then - -- text = string.format( "roger, subtitiles are now ON." ) - text = string.format( "收到, 字幕已打开." ) - elseif playerData.subtitles == false then - -- text = string.format( "affirm, subtitiles are now OFF." ) - text = string.format( "确认, 字幕已关闭." ) - end - self:MessageToPlayer( playerData, text, nil, playerData.name, 5 ) - end - end - -end - ---- Turn radio subtitles of player on or off. --- @param #AIRBOSS self --- @param #string _unitname Name of the player unit. -function AIRBOSS:_TrapsheetOnOff( _unitname ) - self:F2( _unitname ) - - -- Get player unit and player name. - local unit, playername = self:_GetPlayerUnitAndName( _unitname ) - - -- Check if we have a player. - if unit and playername then - - -- Player data. - local playerData = self.players[playername] -- #AIRBOSS.PlayerData - - if playerData then - - -- Check if option is enabled at all. - local text = "" - if self.trapsheet then - - -- Invert current setting. - playerData.trapon = not playerData.trapon - - -- Inform player. - if playerData.trapon == true then - -- text = string.format( "roger, your trapsheets are now SAVED." ) - text = string.format( "收到, 你的着舰记录表已保存." ) - else - -- text = string.format( "affirm, your trapsheets are NOT SAVED." ) - text = string.format( "确认, 你的着舰记录表没有保存." ) - end - - else - -- text = "negative, trap sheet data recorder is broken on this carrier." - text = "无法执行, 着舰记录表当前不能保存." - end - - -- Message to player. - self:MessageToPlayer( playerData, text, nil, playerData.name, 5 ) - end - end - -end - ---- Display player status. --- @param #AIRBOSS self --- @param #string _unitName Name of the player unit. -function AIRBOSS:_DisplayPlayerStatus( _unitName ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - - if playerData then - - -- Pattern step text. - local steptext = playerData.step - -- if playerData.step == AIRBOSS.PatternStep.HOLDING then - -- if playerData.holding == nil then - -- steptext = "Transit to Marshal" - -- elseif playerData.holding == false then - -- steptext = "Marshal (outside zone)" - -- elseif playerData.holding == true then - -- steptext = "Marshal Stack Holding" - -- end - -- end - - if playerData.step == AIRBOSS.PatternStep.HOLDING then - if playerData.holding == nil then - steptext = "过渡至 Marshal" - elseif playerData.holding == false then - steptext = "Marshal (在区域外)" - elseif playerData.holding == true then - steptext = "Marshal 等待航线" - end - end - - -- Stack. - local stack = playerData.flag - - -- Stack text. - local stacktext = nil - if stack > 0 then - local stackalt = self:_GetMarshalAltitude( stack ) - local angels = self:_GetAngels( stackalt ) - -- stacktext = string.format( "Marshal Stack %d, Angels %d\n", stack, angels ) - stacktext = string.format( "Marshal 队列 %d, 高度 %d\n", stack, angels ) - - -- Hint about TACAN bearing. - if playerData.step == AIRBOSS.PatternStep.HOLDING and playerData.case > 1 then - -- Get inverse magnetic radial potential offset. - local radial = self:GetRadial( playerData.case, true, true, true ) - -- stacktext = stacktext .. string.format( "Select TACAN %03d°, %d DME\n", radial, angels + 15 ) - stacktext = stacktext .. string.format( "选择塔康航向 %03d°, %d DME\n", radial, angels + 15 ) - end - end - - -- Fuel and fuel state. - local fuel = playerData.unit:GetFuel() * 100 - local fuelstate = self:_GetFuelState( playerData.unit ) - - -- Number of units in group. - local _, nunitsGround = self:_GetFlightUnits( playerData, true ) - local _, nunitsAirborne = self:_GetFlightUnits( playerData, false ) - - -- Player data. - -- local text = string.format( "Status of player %s (%s)\n", playerData.name, playerData.callsign ) - -- text = text .. string.format( "================================\n" ) - -- text = text .. string.format( "Step: %s\n", steptext ) - -- if stacktext then - -- text = text .. stacktext - -- end - -- text = text .. string.format( "Recovery Case: %d\n", playerData.case ) - -- text = text .. string.format( "Skill Level: %s\n", playerData.difficulty ) - -- text = text .. string.format( "Modex: %s (%s)\n", playerData.onboard, self:_GetACNickname( playerData.actype ) ) - -- text = text .. string.format( "Fuel State: %.1f lbs/1000 (%.1f %%)\n", fuelstate / 1000, fuel ) - -- text = text .. string.format( "# units: %d (%d airborne)\n", nunitsGround, nunitsAirborne ) - -- text = text .. string.format( "Section Lead: %s (%d/%d)", tostring( playerData.seclead ), #playerData.section + 1, self.NmaxSection + 1 ) - - local text = string.format( "玩家数据 %s (%s)\n", playerData.name, playerData.callsign ) - text = text .. string.format( "================================\n" ) - text = text .. string.format( "目前位于: %s\n", steptext ) - if stacktext then - text = text .. stacktext - end - text = text .. string.format( "回收 Case: %d\n", playerData.case ) - text = text .. string.format( "熟练度: %s\n", playerData.difficulty ) - text = text .. string.format( "Modex: %s (%s)\n", playerData.onboard, self:_GetACNickname( playerData.actype ) ) - text = text .. string.format( "油量: %.1f lbs/1000 (%.1f %%)\n", fuelstate / 1000, fuel ) - text = text .. string.format( "# 单位: %d (%d 已升空)\n", nunitsGround, nunitsAirborne ) - text = text .. string.format( "长机: %s (%d/%d)", tostring( playerData.seclead ), #playerData.section + 1, self.NmaxSection + 1 ) - for _, _sec in pairs( playerData.section ) do - local sec = _sec -- #AIRBOSS.PlayerData - text = text .. string.format( "\n- %s", sec.name ) - end - - if playerData.step == AIRBOSS.PatternStep.INITIAL then - - -- Create a point 3.0 NM astern for re-entry. - local zoneinitial = self:GetCoordinate():Translate( UTILS.NMToMeters( 3.5 ), self:GetRadial( 2, false, false, false ) ) - - -- Heading and distance to initial zone. - local flyhdg = playerData.unit:GetCoordinate():HeadingTo( zoneinitial ) - local flydist = UTILS.MetersToNM( playerData.unit:GetCoordinate():Get2DDistance( zoneinitial ) ) - local brc = self:GetBRC() - - -- Help player to find its way to the initial zone. - -- text = text .. string.format( "\nTo Initial: Fly heading %03d° for %.1f NM and turn to BRC %03d°", flyhdg, flydist, brc ) - text = text .. string.format( "\n前往第一边: 转航向 %03d° 距离 %.1f NM 然后转 BRC %03d°", flyhdg, flydist, brc ) - - elseif playerData.step == AIRBOSS.PatternStep.PLATFORM then - - -- Coordinate of the platform zone. - local zoneplatform = self:_GetZonePlatform( playerData.case ):GetCoordinate() - - -- Heading and distance to platform zone. - local flyhdg = playerData.unit:GetCoordinate():HeadingTo( zoneplatform ) - local flydist = UTILS.MetersToNM( playerData.unit:GetCoordinate():Get2DDistance( zoneplatform ) ) - - -- Get heading. - local hdg = self:GetRadial( playerData.case, true, true, true ) - - -- Help player to find its way to the initial zone. - -- text = text .. string.format( "\nTo Platform: Fly heading %03d° for %.1f NM and turn to %03d°", flyhdg, flydist, hdg ) - text = text .. string.format( "\n前往平台[Platform]: 转航向 %03d° 距离 %.1f NM 然后转 %03d°", flyhdg, flydist, hdg ) - - end - - -- Send message. - self:MessageToPlayer( playerData, text, nil, "", 30, true ) - else - self:E( self.lid .. string.format( "ERROR: playerData=nil. Unit name=%s, player name=%s", _unitName, _playername ) ) - end - else - self:E( self.lid .. string.format( "ERROR: could not find player for unit %s", _unitName ) ) - end - -end - ---- Mark current marshal zone of player by either smoke or flares. --- @param #AIRBOSS self --- @param #string _unitName Name of the player unit. --- @param #boolean flare If true, flare the zone. If false, smoke the zone. -function AIRBOSS:_MarkMarshalZone( _unitName, flare ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - - if playerData then - - -- Get player stack and recovery case. - local stack = playerData.flag - local case = playerData.case - - local text = "" - if stack > 0 then - - -- Get current holding zone. - local zoneHolding = self:_GetZoneHolding( case, stack ) - - -- Get Case I commence zone at three position. - local zoneThree = self:_GetZoneCommence( case, stack ) - - -- Pattern altitude. - local patternalt = self:_GetMarshalAltitude( stack, case ) - - -- Flare and smoke at the ground. - patternalt = 5 - - -- Roger! - -- text = "roger, marking" - text = "收到, 正在标记" - if flare then - - -- Marshal WHITE flares. - -- text = text .. string.format( "\n* Marshal zone stack %d with WHITE flares.", stack ) - text = text .. string.format( "\n*白色信号弹标记 Marshal 区域.", stack ) - zoneHolding:FlareZone( FLARECOLOR.White, 45, nil, patternalt ) - - -- Commence RED flares. - -- text = text .. "\n* Commence zone with RED flares." - text = text .. "\n* 红色信号弹标记进近区域." - zoneThree:FlareZone( FLARECOLOR.Red, 45, nil, patternalt ) - - else - - -- Marshal WHITE smoke. - -- text = text .. string.format( "\n* Marshal zone stack %d with WHITE smoke.", stack ) - text = text .. string.format( "\n* 白色烟雾弹标记 Marshal 区域.", stack ) - zoneHolding:SmokeZone( SMOKECOLOR.White, 45, patternalt ) - - -- Commence RED smoke - -- text = text .. "\n* Commence zone with RED smoke." - text = text .. "\n* 红色烟雾弹标记进近区域." - zoneThree:SmokeZone( SMOKECOLOR.Red, 45, patternalt ) - - end - - else - -- text = "negative, you are currently not in a Marshal stack. No zones will be marked!" - text = "无法执行, 你现在不在 Marshal 程序. 没有区域可标记!" - end - - -- Send message to player. - self:MessageToPlayer( playerData, text, "MARSHAL", playerData.name ) - end - end - -end - ---- Mark CASE I or II/II zones by either smoke or flares. --- @param #AIRBOSS self --- @param #string _unitName Name of the player unit. --- @param #boolean flare If true, flare the zone. If false, smoke the zone. -function AIRBOSS:_MarkCaseZones( _unitName, flare ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - - if playerData then - - -- Player's recovery case. - local case = playerData.case - - -- Initial - -- local text = string.format( "affirm, marking CASE %d zones", case ) - local text = string.format( "确认, 标记 CASE %d 区域", case ) - - -- Flare or smoke? - if flare then - - ----------- - -- Flare -- - ----------- - - -- Case I/II: Initial - if case == 1 or case == 2 then - -- text = text .. "\n* initial with GREEN flares" - text = text .. "\n* 绿色信号弹标记第一边" - self:_GetZoneInitial( case ):FlareZone( FLARECOLOR.Green, 45 ) - end - - -- Case II/III: approach corridor - if case == 2 or case == 3 then - -- text = text .. "\n* approach corridor with GREEN flares" - text = text .. "\n* 绿色信号弹标记进近航道" - self:_GetZoneCorridor( case ):FlareZone( FLARECOLOR.Green, 45 ) - end - - -- Case II/III: platform - if case == 2 or case == 3 then - -- text = text .. "\n* platform with RED flares" - text = text .. "\n* 红色信号弹标记平台区域[Platform]" - self:_GetZonePlatform( case ):FlareZone( FLARECOLOR.Red, 45 ) - end - - -- Case III: dirty up - if case == 3 then - -- text = text .. "\n* dirty up with YELLOW flares" - text = text .. "\n* 黄色信号弹标记改平区域[着舰构型]" - self:_GetZoneDirtyUp( case ):FlareZone( FLARECOLOR.Yellow, 45 ) - end - - -- Case II/III: arc in/out - if case == 2 or case == 3 then - if math.abs( self.holdingoffset ) > 0 then - self:_GetZoneArcIn( case ):FlareZone( FLARECOLOR.White, 45 ) - -- text = text .. "\n* arc turn in with WHITE flares" - text = text .. "\n* 白色信号弹标记 Arc turn 入口" - self:_GetZoneArcOut( case ):FlareZone( FLARECOLOR.White, 45 ) - -- text = text .. "\n* arc trun out with WHITE flares" - text = text .. "\n* 白色信号弹标记 Arc turn 出口" - end - end - - -- Case III: bullseye - if case == 3 then - -- text = text .. "\n* bullseye with GREEN flares" - text = text .. "\n* 绿色信号弹标记 bullseye" - self:_GetZoneBullseye( case ):FlareZone( FLARECOLOR.Green, 45 ) - end - - -- Tarawa, LHA and LHD landing spots. - if self.carriertype == AIRBOSS.CarrierType.INVINCIBLE or self.carriertype == AIRBOSS.CarrierType.HERMES or self.carriertype == AIRBOSS.CarrierType.TARAWA or self.carriertype == AIRBOSS.CarrierType.AMERICA or self.carriertype == AIRBOSS.CarrierType.JCARLOS or self.carriertype == AIRBOSS.CarrierType.CANBERRA then - text = text .. "\n* abeam landing stop with RED flares" - -- Abeam landing spot zone. - local ALSPT = self:_GetZoneAbeamLandingSpot() - ALSPT:FlareZone( FLARECOLOR.Red, 5, nil, UTILS.FeetToMeters( 110 ) ) - -- Primary landing spot zone. - text = text .. "\n* primary landing spot with GREEN flares" - local LSPT = self:_GetZoneLandingSpot() - LSPT:FlareZone( FLARECOLOR.Green, 5, nil, self.carrierparam.deckheight ) - end - - else - - ----------- - -- Smoke -- - ----------- - - -- Case I/II: Initial - if case == 1 or case == 2 then - -- text = text .. "\n* initial with GREEN smoke" - text = text .. "\n* 绿色烟雾弹标记第一边" - self:_GetZoneInitial( case ):SmokeZone( SMOKECOLOR.Green, 45 ) - end - - -- Case II/III: Approach Corridor - if case == 2 or case == 3 then - -- text = text .. "\n* approach corridor with GREEN smoke" - text = text .. "\n* 绿色烟雾弹标记进近航道" - self:_GetZoneCorridor( case ):SmokeZone( SMOKECOLOR.Green, 45 ) - end - - -- Case II/III: platform - if case == 2 or case == 3 then - -- text = text .. "\n* platform with RED smoke" - text = text .. "\n* 红色烟雾弹标记平台[Platform]" - self:_GetZonePlatform( case ):SmokeZone( SMOKECOLOR.Red, 45 ) - end - - -- Case II/III: arc in/out if offset>0. - if case == 2 or case == 3 then - if math.abs( self.holdingoffset ) > 0 then - self:_GetZoneArcIn( case ):SmokeZone( SMOKECOLOR.Blue, 45 ) - -- text = text .. "\n* arc turn in with BLUE smoke" - text = text .. "\n* 蓝色烟雾弹标记 Arc turn 入口" - self:_GetZoneArcOut( case ):SmokeZone( SMOKECOLOR.Blue, 45 ) - -- text = text .. "\n* arc trun out with BLUE smoke" - text = text .. "\n* 蓝色烟雾弹标记 Arc turn 出口" - end - end - - -- Case III: dirty up - if case == 3 then - -- text = text .. "\n* dirty up with ORANGE smoke" - text = text .. "\n* 黄色烟雾弹标记改平区域[着舰构型]" - self:_GetZoneDirtyUp( case ):SmokeZone( SMOKECOLOR.Orange, 45 ) - end - - -- Case III: bullseye - if case == 3 then - -- text = text .. "\n* bullseye with GREEN smoke" - text = text .. "\n* 绿色烟雾弹标记 bullseye" - self:_GetZoneBullseye( case ):SmokeZone( SMOKECOLOR.Green, 45 ) - end - - end - - -- Send message to player. - self:MessageToPlayer( playerData, text, "MARSHAL", playerData.name ) - end - end - -end - ---- LSO radio check. Will broadcase LSO message at given LSO frequency. --- @param #AIRBOSS self --- @param #string _unitName Name fo the player unit. -function AIRBOSS:_LSORadioCheck( _unitName ) - self:F( _unitName ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - if playerData then - -- Broadcase LSO radio check message on LSO radio. - self:RadioTransmission( self.LSORadio, self.LSOCall.RADIOCHECK, nil, nil, nil, true ) - end - end -end - ---- Marshal radio check. Will broadcase Marshal message at given Marshal frequency. --- @param #AIRBOSS self --- @param #string _unitName Name fo the player unit. -function AIRBOSS:_MarshalRadioCheck( _unitName ) - self:F( _unitName ) - - -- Get player unit and name. - local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) - - -- Check if we have a unit which is a player. - if _unit and _playername then - local playerData = self.players[_playername] -- #AIRBOSS.PlayerData - if playerData then - -- Broadcase Marshal radio check message on Marshal radio. - self:RadioTransmission( self.MarshalRadio, self.MarshalCall.RADIOCHECK, nil, nil, nil, true ) - end - end -end - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- Persistence Functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - ---- Save trapsheet data. --- @param #AIRBOSS self --- @param #AIRBOSS.PlayerData playerData Player data table. --- @param #AIRBOSS.LSOgrade grade LSO grad data. -function AIRBOSS:_SaveTrapSheet( playerData, grade ) - - -- Nothing to save. - if playerData.trapsheet == nil or #playerData.trapsheet == 0 or not io then - return - end - - --- Function that saves data to file - local function _savefile( filename, data ) - local f = io.open( filename, "wb" ) - if f then - f:write( data ) - f:close() - else - self:E( self.lid .. string.format( "ERROR: could not save trap sheet to file %s.\nFile may contain invalid characters.", tostring( filename ) ) ) - end - end - - -- Set path or default. - local path = self.trappath - if lfs then - path = path or lfs.writedir() - end - - -- Create unused file name. - local filename = nil - for i = 1, 9999 do - - -- Create file name - if self.trapprefix then - filename = string.format( "%s_%s-%04d.csv", self.trapprefix, playerData.actype, i ) - else - local name = UTILS.ReplaceIllegalCharacters( playerData.name, "_" ) - filename = string.format( "AIRBOSS-%s_Trapsheet-%s_%s-%04d.csv", self.alias, name, playerData.actype, i ) - end - - -- Set path. - if path ~= nil then - filename = path .. "\\" .. filename - end - - -- Check if file exists. - local _exists = UTILS.FileExists( filename ) - if not _exists then - break - end - end - - -- Info - local text = string.format( "Saving player %s trapsheet to file %s", playerData.name, filename ) - self:I( self.lid .. text ) - - -- Header line - local data = "#Time,Rho,X,Z,Alt,AoA,GSE,LUE,Vtot,Vy,Gamma,Pitch,Roll,Yaw,Step,Grade,Points,Details\n" - - local g0 = playerData.trapsheet[1] -- #AIRBOSS.GrooveData - local T0 = g0.Time - - -- for _,_groove in ipairs(playerData.trapsheet) do - for i = 1, #playerData.trapsheet do - -- local groove=_groove --#AIRBOSS.GrooveData - local groove = playerData.trapsheet[i] - local t = groove.Time - T0 - local a = UTILS.MetersToNM( groove.Rho or 0 ) - local b = -groove.X or 0 - local c = groove.Z or 0 - local d = UTILS.MetersToFeet( groove.Alt or 0 ) - local e = groove.AoA or 0 - local f = groove.GSE or 0 - local g = -groove.LUE or 0 - local h = UTILS.MpsToKnots( groove.Vel or 0 ) - local i = (groove.Vy or 0) * 196.85 - local j = groove.Gamma or 0 - local k = groove.Pitch or 0 - local l = groove.Roll or 0 - local m = groove.Yaw or 0 - local n = self:_GS( groove.Step, -1 ) or "n/a" - local o = groove.Grade or "n/a" - local p = groove.GradePoints or 0 - local q = groove.GradeDetail or "n/a" - -- t a b c d e f g h i j k l m n o p q - data = data .. string.format( "%.2f,%.3f,%.1f,%.1f,%.1f,%.2f,%.2f,%.2f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%s,%s,%.1f,%s\n", t, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q ) - end - - -- Save file. - _savefile( filename, data ) -end - ---- On before "Save" event. Checks if io and lfs are available. --- @param #AIRBOSS self --- @param #string From From state. --- @param #string Event Event. --- @param #string To To state. --- @param #string path (Optional) Path where the file is saved. Default is the DCS root installation folder or your "Saved Games\\DCS" folder if the lfs module is desanitized. --- @param #string filename (Optional) File name for saving the player grades. Default is "AIRBOSS-_LSOgrades.csv". -function AIRBOSS:onbeforeSave( From, Event, To, path, filename ) - - -- Check io module is available. - if not io then - self:E( self.lid .. "ERROR: io not desanitized. Can't save player grades." ) - return false - end - - -- Check default path. - if path == nil and not lfs then - self:E( self.lid .. "WARNING: lfs not desanitized. Results will be saved in DCS installation root directory rather than your \"Saved Games\\DCS\" folder." ) - end - + if playerData.difficulty==AIRBOSS.Difficulty.EASY then + lowscore=10 + badscore=20 + elseif playerData.difficulty==AIRBOSS.Difficulty.NORMAL then + lowscore=5 + badscore=10 + elseif playerData.difficulty==AIRBOSS.Difficulty.HARD then + lowscore=2.5 + badscore=5 + end + return lowscore,badscore + end + function AIRBOSS:_IsCarrierAircraft(unit) + local aircrafttype=unit:GetTypeName() + if aircrafttype==AIRBOSS.AircraftCarrier.AV8B then + if self.carriertype==AIRBOSS.CarrierType.INVINCIBLE or self.carriertype==AIRBOSS.CarrierType.HERMES or self.carriertype==AIRBOSS.CarrierType.TARAWA or self.carriertype==AIRBOSS.CarrierType.AMERICA or self.carriertype==AIRBOSS.CarrierType.JCARLOS or self.carriertype==AIRBOSS.CarrierType.CANBERRA then return true -end - ---- On after "Save" event. Player data is saved to file. --- @param #AIRBOSS self --- @param #string From From state. --- @param #string Event Event. --- @param #string To To state. --- @param #string path Path where the file is saved. If nil, file is saved in the DCS root installtion directory or your "Saved Games" folder if lfs was desanitized. --- @param #string filename (Optional) File name for saving the player grades. Default is "AIRBOSS-_LSOgrades.csv". -function AIRBOSS:onafterSave( From, Event, To, path, filename ) - - --- Function that saves data to file - local function _savefile( filename, data ) - local f = assert( io.open( filename, "wb" ) ) - f:write( data ) - f:close() - end - - -- Set path or default. - if lfs then - path = path or lfs.writedir() - end - - -- Set file name. - filename = filename or string.format( "AIRBOSS-%s_LSOgrades.csv", self.alias ) - - -- Set path. - if path ~= nil then - filename = path .. "\\" .. filename - end - - -- Header line - local scores = "Name,Pass,Points Final,Points Pass,Grade,Details,Wire,Tgroove,Case,Wind,Modex,Airframe,Carrier Type,Carrier Name,Theatre,Mission Time,Mission Date,OS Date\n" - - -- Loop over all players. - local n = 0 - for playername, grades in pairs( self.playerscores ) do - - -- Loop over player grades table. - for i, _grade in pairs( grades ) do - local grade = _grade -- #AIRBOSS.LSOgrade - - -- Check some stuff that could be nil. - local wire = "n/a" - if grade.wire and grade.wire <= 4 then - wire = tostring( grade.wire ) - end - - local Tgroove = "n/a" - if grade.Tgroove and grade.Tgroove <= 360 and grade.case < 3 then - Tgroove = tostring( UTILS.Round( grade.Tgroove, 1 ) ) - end - - local finalscore = "n/a" - if grade.finalscore then - finalscore = tostring( UTILS.Round( grade.finalscore, 1 ) ) - end - - -- Compile grade line. - scores = scores .. string.format( "%s,%d,%s,%.1f,%s,%s,%s,%s,%d,%s,%s,%s,%s,%s,%s,%s,%s,%s\n", playername, i, finalscore, grade.points, grade.grade, grade.details, wire, Tgroove, grade.case, grade.wind, grade.modex, grade.airframe, grade.carriertype, grade.carriername, grade.theatre, grade.mitime, grade.midate, grade.osdate ) - n = n + 1 - end - end - - -- Info - local text = string.format( "Saving %d player LSO grades to file %s", n, filename ) - self:I( self.lid .. text ) - - -- Save file. - _savefile( filename, scores ) -end - ---- On before "Load" event. Checks if the file that the player grades from exists. --- @param #AIRBOSS self --- @param #string From From state. --- @param #string Event Event. --- @param #string To To state. --- @param #string path (Optional) Path where the file is loaded from. Default is the DCS installation root directory or your "Saved Games\\DCS" folder if lfs was desanizized. --- @param #string filename (Optional) File name for saving the player grades. Default is "AIRBOSS-_LSOgrades.csv". -function AIRBOSS:onbeforeLoad( From, Event, To, path, filename ) - - --- Function that check if a file exists. - local function _fileexists( name ) - local f = io.open( name, "r" ) - if f ~= nil then - io.close( f ) - return true - else - return false - end - end - - -- Check io module is available. - if not io then - self:E( self.lid .. "WARNING: io not desanitized. Can't load player grades." ) - return false - end - - -- Check default path. - if path == nil and not lfs then - self:E( self.lid .. "WARNING: lfs not desanitized. Results will be saved in DCS installation root directory rather than your \"Saved Games\\DCS\" folder." ) - end - - -- Set path or default. - if lfs then - path = path or lfs.writedir() - end - - -- Set file name. - filename = filename or string.format( "AIRBOSS-%s_LSOgrades.csv", self.alias ) - - -- Set path. - if path ~= nil then - filename = path .. "\\" .. filename - end - - -- Check if file exists. - local exists = _fileexists( filename ) - - if exists then - return true else - self:E( self.lid .. string.format( "WARNING: Player LSO grades file %s does not exist.", filename ) ) - return false + return false end - -end - ---- On after "Load" event. Loads grades of all players from file. --- @param #AIRBOSS self --- @param #string From From state. --- @param #string Event Event. --- @param #string To To state. --- @param #string path Path where the file is loaded from. Default is the DCS root installation folder or your "Saved Games\\DCS" folder if lfs was desanizied. --- @param #string filename (Optional) File name for saving the player grades. Default is "AIRBOSS-_LSOgrades.csv". -function AIRBOSS:onafterLoad( From, Event, To, path, filename ) - - --- Function that load data from a file. - local function _loadfile( filename ) - local f = assert( io.open( filename, "rb" ) ) - local data = f:read( "*all" ) - f:close() - return data end - - -- Set path or default. + if self.carriertype==AIRBOSS.CarrierType.INVINCIBLE or self.carriertype==AIRBOSS.CarrierType.TARAWA or self.carriertype==AIRBOSS.CarrierType.AMERICA or self.carriertype==AIRBOSS.CarrierType.JCARLOS or self.carriertype==AIRBOSS.CarrierType.CANBERRA then + if aircrafttype~=AIRBOSS.AircraftCarrier.AV8B then + return false + end + end + for _,actype in pairs(AIRBOSS.AircraftCarrier)do + if actype==aircrafttype then + return true + end + end + return false + end + function AIRBOSS:_IsHumanUnit(unit) + local playerunit=self:_GetPlayerUnitAndName(unit:GetName()) + if playerunit then + return true + else + return false + end + end + function AIRBOSS:_IsHuman(group) + local units=group:GetUnits() + for _,_unit in pairs(units)do + local human=self:_IsHumanUnit(_unit) + if human then + return true + end + end + return false + end + function AIRBOSS:_GetFuelState(unit) + local fuel=unit:GetFuel() + local maxfuel=self:_GetUnitMasses(unit) + local fuelstate=fuel*maxfuel + self:T2(self.lid..string.format("Unit %s fuel state = %.1f kg = %.1f lbs",unit:GetName(),fuelstate,UTILS.kg2lbs(fuelstate))) + return UTILS.kg2lbs(fuelstate) + end + function AIRBOSS:_GetAngels(alt) + if alt then + local angels=UTILS.Round(UTILS.MetersToFeet(alt)/1000,0) + return angels + else + return 0 + end + end + function AIRBOSS:_GetUnitMasses(unit) + local Desc=unit:GetDesc() + local massfuel=Desc.fuelMassMax or 0 + local massempty=Desc.massEmpty or 0 + local massmax=Desc.massMax or 0 + local masscargo=massmax-massfuel-massempty + self:T2(self.lid..string.format("Unit %s mass fuel=%.1f kg, empty=%.1f kg, max=%.1f kg, cargo=%.1f kg",unit:GetName(),massfuel,massempty,massmax,masscargo)) + return massfuel,massempty,massmax,masscargo + end + function AIRBOSS:_GetPlayerDataUnit(unit) + if unit:IsAlive()then + local unitname=unit:GetName() + local playerunit,playername=self:_GetPlayerUnitAndName(unitname) + if playerunit and playername then + return self.players[playername] + end + end + return nil + end + function AIRBOSS:_GetPlayerDataGroup(group) + local units=group:GetUnits() + for _,unit in pairs(units)do + local playerdata=self:_GetPlayerDataUnit(unit) + if playerdata then + return playerdata + end + end + return nil + end + function AIRBOSS:_GetPlayerUnit(_unitName) + for _,_player in pairs(self.players)do + local player=_player + if player.unit and player.unit:GetName()==_unitName then + self:T(self.lid..string.format("Found player=%s unit=%s in players table.",tostring(player.name),tostring(_unitName))) + return player.unit,player.name + end + end + return nil,nil + end + function AIRBOSS:_GetPlayerUnitAndName(_unitName) + self:F2(_unitName) + if _unitName~=nil then + local u,pn=self:_GetPlayerUnit(_unitName) + if u and pn then + return u,pn + end + local DCSunit=Unit.getByName(_unitName) + if DCSunit and DCSunit.getPlayerName then + local playername=DCSunit:getPlayerName() + local unit=UNIT:Find(DCSunit) + self:T2({DCSunit=DCSunit,unit=unit,playername=playername}) + if DCSunit and unit and playername then + self:T(self.lid..string.format("Found DCS unit %s with player %s.",tostring(_unitName),tostring(playername))) + return unit,playername + end + end + end + return nil,nil + end + function AIRBOSS:GetCoalition() + return self.carrier:GetCoalition() + end + function AIRBOSS:GetCoordinate() + return self.carrier:GetCoord() + end + function AIRBOSS:GetCoord() + return self.carrier:GetCoord() + end + function AIRBOSS:_GetStaticWeather() + local weather=env.mission.weather + local clouds=weather.clouds + local visibility=weather.visibility.distance + local dust=nil + if weather.enable_dust==true then + dust=weather.dust_density + end + local fog=nil + if weather.enable_fog==true then + fog=weather.fog + end + return clouds,visibility,fog,dust + end + function AIRBOSS._CheckRadioQueueT(param,time) + AIRBOSS._CheckRadioQueue(param.airboss,param.radioqueue,param.name) + return time+0.05 + end + function AIRBOSS:_CheckRadioQueue(radioqueue,name) + if#radioqueue==0 then + if name=="LSO"then + self:T(self.lid..string.format("Stopping LSO radio queue.")) + self.radiotimer:Stop(self.RQLid) + self.RQLid=nil + elseif name=="MARSHAL"then + self:T(self.lid..string.format("Stopping Marshal radio queue.")) + self.radiotimer:Stop(self.RQMid) + self.RQMid=nil + end + return + end + local _time=timer.getAbsTime() + local playing=false + local next=nil + local _remove=nil + for i,_transmission in ipairs(radioqueue)do + local transmission=_transmission + if _time>=transmission.Tplay then + if transmission.isplaying then + if _time>=transmission.Tstarted+transmission.call.duration then + transmission.isplaying=false + _remove=i + if transmission.radio.alias=="LSO"then + self.TQLSO=_time + elseif transmission.radio.alias=="MARSHAL"then + self.TQMarshal=_time + end + else + playing=true + end + else + local Tlast=nil + if transmission.interval then + if transmission.radio.alias=="LSO"then + Tlast=self.TQLSO + elseif transmission.radio.alias=="MARSHAL"then + Tlast=self.TQMarshal + end + end + if transmission.interval==nil then + if next==nil then + next=transmission + end + else + if _time-Tlast>=transmission.interval then + next=transmission + else + end + end + if next or Tlast then + break + end + end + else + end + end + if next~=nil and not playing then + self:Broadcast(next.radio,next.call,next.loud) + next.isplaying=true + next.Tstarted=_time + end + if _remove then + table.remove(radioqueue,_remove) + end + return + end + function AIRBOSS:RadioTransmission(radio,call,loud,delay,interval,click,pilotcall) + self:F2({radio=radio,call=call,loud=loud,delay=delay,interval=interval,click=click}) + if radio==nil or call==nil then + return + end + if not self.SRS then + local transmission={} + transmission.radio=radio + transmission.call=call + transmission.Tplay=timer.getAbsTime()+(delay or 0) + transmission.interval=interval + transmission.isplaying=false + transmission.Tstarted=nil + transmission.loud=loud and call.loud + if self:_IsOnboard(call.modexsender)then + self:_Number2Radio(radio,call.modexsender,delay,0.3,pilotcall) + end + if self:_IsOnboard(call.modexreceiver)then + self:_Number2Radio(radio,call.modexreceiver,delay,0.3,pilotcall) + end + local caller="" + if radio.alias=="LSO"then + table.insert(self.RQLSO,transmission) + caller="LSOCall" + if not self.RQLid then + self:T(self.lid..string.format("Starting LSO radio queue.")) + self.RQLid=self.radiotimer:Schedule(nil,AIRBOSS._CheckRadioQueue,{self,self.RQLSO,"LSO"},0.02,0.05) + end + elseif radio.alias=="MARSHAL"then + table.insert(self.RQMarshal,transmission) + caller="MarshalCall" + if not self.RQMid then + self:T(self.lid..string.format("Starting Marhal radio queue.")) + self.RQMid=self.radiotimer:Schedule(nil,AIRBOSS._CheckRadioQueue,{self,self.RQMarshal,"MARSHAL"},0.02,0.05) + end + end + if click then + self:RadioTransmission(radio,self[caller].CLICK,false,delay) + end + else + if call.subtitle~=nil and string.len(call.subtitle)>1 then + local frequency=self.MarshalRadio.frequency + local modulation=self.MarshalRadio.modulation + local voice=nil + local gender=nil + local culture=nil + if radio.alias=="AIRBOSS"then + frequency=self.AirbossRadio.frequency + modulation=self.AirbossRadio.modulation + voice=self.AirbossRadio.voice + gender=self.AirbossRadio.gender + culture=self.AirbossRadio.culture + end + if radio.alias=="MARSHAL"then + voice=self.MarshalRadio.voice + gender=self.MarshalRadio.gender + culture=self.MarshalRadio.culture + end + if radio.alias=="LSO"then + frequency=self.LSORadio.frequency + modulation=self.LSORadio.modulation + voice=self.LSORadio.voice + gender=self.LSORadio.gender + culture=self.LSORadio.culture + end + if pilotcall then + voice=self.PilotRadio.voice + gender=self.PilotRadio.gender + culture=self.PilotRadio.culture + radio.alias="PILOT" + end + if not radio.alias then + frequency=self.AirbossRadio.frequency + modulation=self.AirbossRadio.modulation + radio.alias="AIRBOSS" + end + local volume=nil + if loud then + volume=1.0 + end + local text=call.subtitle + self:T(self.lid..text) + local srstext=self:_GetNiceSRSText(text) + self.SRSQ:NewTransmission(srstext,call.duration,self.SRS,nil,0.1,nil,call.subtitle,call.subduration,frequency,modulation,gender,culture,voice,volume,radio.alias) + end + end + end + function AIRBOSS:SetSRSPilotVoice(Voice,Gender,Culture) + self.PilotRadio={} + self.PilotRadio.alias="PILOT" + self.PilotRadio.voice=Voice or MSRS.Voices.Microsoft.David + self.PilotRadio.gender=Gender or"male" + self.PilotRadio.culture=Culture or"en-US" + if(not Voice)and self.SRS and self.SRS:GetProvider()==MSRS.Provider.GOOGLE then + self.PilotRadio.voice=MSRS.Voices.Google.Standard.en_US_Standard_J + end + return self + end + function AIRBOSS:_NeedsSubtitle(call) + if call.file==self.MarshalCall.NOISE.file or call.file==self.LSOCall.NOISE.file then + return true + else + return false + end + end + function AIRBOSS:Broadcast(radio,call,loud) + self:F(call) + if not self.usersoundradio then + local sender=self:_GetRadioSender(radio) + local filename=self:_RadioFilename(call,loud,radio.alias) + local subtitle=self:_RadioSubtitle(radio,call,loud) + self:T({filename=filename,subtitle=subtitle}) + if sender then + self:T(self.lid..string.format("Broadcasting from aircraft %s",sender:GetName())) + local commandFrequency={ + id="SetFrequency", + params={ + frequency=radio.frequency*1000000, + modulation=radio.modulation, + }, + } + local commandTransmit={ + id="TransmitMessage", + params={ + file=filename, + duration=call.subduration or 5, + subtitle=subtitle, + loop=false, + }, + } + sender:SetCommand(commandFrequency) + sender:SetCommand(commandTransmit) + else + self:T(self.lid..string.format("Broadcasting from carrier via trigger.action.radioTransmission().")) + local vec3=self.carrier:GetPositionVec3() + trigger.action.radioTransmission(filename,vec3,radio.modulation,false,radio.frequency*1000000,100) + for _,_player in pairs(self.players)do + local playerData=_player + if playerData.unit:IsInZone(self.zoneCCA)and playerData.actype~=AIRBOSS.AircraftCarrier.A4EC then + if playerData.subtitles or self:_NeedsSubtitle(call)then + if radio.alias=="MARSHAL"or(radio.alias=="LSO"and self:_InQueue(self.Qpattern,playerData.group))then + self:MessageToPlayer(playerData,subtitle,nil,"",call.subduration or 5) + end + end + end + end + end + end + for _,_player in pairs(self.players)do + local playerData=_player + if self.usersoundradio or playerData.actype==AIRBOSS.AircraftCarrier.A4EC then + if radio.alias=="MARSHAL"or(radio.alias=="LSO"and self:_InQueue(self.Qpattern,playerData.group))then + self:Sound2Player(playerData,radio,call,loud) + end + end + end + end + function AIRBOSS:Sound2Player(playerData,radio,call,loud,delay) + if playerData.unit:IsInZone(self.zoneCCA)and call then + local filename=self:_RadioFilename(call,loud,radio.alias) + local subtitle=self:_RadioSubtitle(radio,call,loud) + USERSOUND:New(filename):ToGroup(playerData.group,delay) + if playerData.subtitles or self:_NeedsSubtitle(call)then + self:MessageToPlayer(playerData,subtitle,nil,"",call.subduration,false,delay) + end + end + end + function AIRBOSS:_RadioSubtitle(radio,call,loud) + if call==nil or call.subtitle==nil or call.subtitle==""then + return"" + end + local sender=call.sender or radio.alias + if call.modexsender then + sender=call.modexsender + end + local receiver=call.modexreceiver or"" + local subtitle=string.format("%s: %s",sender,call.subtitle) + if receiver and receiver~=""then + subtitle=string.format("%s: %s, %s",sender,receiver,call.subtitle) + end + local lastchar=string.sub(subtitle,-1) + if loud then + if lastchar=="."or lastchar=="!"then + subtitle=string.sub(subtitle,1,-1) + end + subtitle=subtitle.."!" + else + if lastchar=="!"then + elseif lastchar=="."then + else + subtitle=subtitle.."." + end + end + return subtitle + end + function AIRBOSS:_RadioFilename(call,loud,channel) + local prefix=call.file or"" + local suffix=call.suffix or"ogg" + local path=self.soundfolder or"l10n/DEFAULT/" + if string.find(call.file,"LSO-")and channel and(channel=="LSO"or channel=="LSOCall")then + path=self.soundfolderLSO or path + end + if string.find(call.file,"MARSHAL-")and channel and(channel=="MARSHAL"or channel=="MarshalCall")then + path=self.soundfolderMSH or path + end + if loud then + prefix=prefix.."_Loud" + end + local filename=string.format("%s%s.%s",path,prefix,suffix) + return filename + end + function AIRBOSS:_GetNiceSRSText(text) + text=string.gsub(text,"================================\n","") + text=string.gsub(text,"||","parallel") + text=string.gsub(text,"==","perpendicular") + text=string.gsub(text,"BRC","Base recovery") + text=string.gsub(text,"%((%a+)%)","Morse %1") + text=string.gsub(text,"°C","° Celsius") + text=string.gsub(text,"°"," degrees") + text=string.gsub(text," FB "," Final bearing ") + text=string.gsub(text," ops"," operations ") + text=string.gsub(text," kts"," knots") + text=string.gsub(text,"TACAN","Tackan") + text=string.gsub(text,"ICLS","I.C.L.S.") + text=string.gsub(text,"LSO","L.S.O.") + text=string.gsub(text,"inHg","inches of Mercury") + text=string.gsub(text,"QFE","Q.F.E.") + text=string.gsub(text,"hPa","hecto pascal") + text=string.gsub(text," NM"," nautical miles") + text=string.gsub(text," ft"," feet") + text=string.gsub(text,"A/C","aircraft") + text=string.gsub(text,"(#[%a%d%p%s]+)\n","") + text=string.gsub(text,"%.000"," dot zero") + text=string.gsub(text,"00"," double zero") + text=string.gsub(text," 0 "," zero ") + text=string.gsub(text,"\n","; ") + return text + end + function AIRBOSS:MessageToPlayer(playerData,message,sender,receiver,duration,clear,delay) + self:T({sender,receiver,message}) + if playerData and message and message~=""then + duration=duration or self.Tmessage + local text + if receiver and receiver==""then + text=string.format("%s",message) + else + receiver=receiver or playerData.onboard + text=string.format("%s, %s",receiver,message) + end + self:T(self.lid..text) + if delay and delay>0 then + self:ScheduleOnce(delay,self.MessageToPlayer,self,playerData,message,sender,receiver,duration,clear) + else + if not self.SRS then + local wait=0 + if receiver==playerData.onboard then + if sender and(sender=="LSO"or sender=="MARSHAL"or sender=="AIRBOSS")then + wait=wait+self:_Number2Sound(playerData,sender,receiver) + end + end + if string.find(text:lower(),"negative")then + local filename=self:_RadioFilename(self.MarshalCall.NEGATIVE,false,"MARSHAL") + USERSOUND:New(filename):ToGroup(playerData.group,wait) + wait=wait+self.MarshalCall.NEGATIVE.duration + end + if string.find(text:lower(),"affirm")then + local filename=self:_RadioFilename(self.MarshalCall.AFFIRMATIVE,false,"MARSHAL") + USERSOUND:New(filename):ToGroup(playerData.group,wait) + wait=wait+self.MarshalCall.AFFIRMATIVE.duration + end + if string.find(text:lower(),"roger")then + local filename=self:_RadioFilename(self.MarshalCall.ROGER,false,"MARSHAL") + USERSOUND:New(filename):ToGroup(playerData.group,wait) + wait=wait+self.MarshalCall.ROGER.duration + end + if wait>0 then + local filename=self:_RadioFilename(self.MarshalCall.CLICK) + USERSOUND:New(filename):ToGroup(playerData.group,wait) + end + else + local frequency=self.MarshalRadio.frequency + local modulation=self.MarshalRadio.modulation + local voice=self.MarshalRadio.voice + local gender=self.MarshalRadio.gender + local culture=self.MarshalRadio.culture + if not sender then sender="AIRBOSS"end + if string.find(sender,"AIRBOSS")then + frequency=self.AirbossRadio.frequency + modulation=self.AirbossRadio.modulation + voice=self.AirbossRadio.voice + gender=self.AirbossRadio.gender + culture=self.AirbossRadio.culture + end + if sender=="LSO"then + frequency=self.LSORadio.frequency + modulation=self.LSORadio.modulation + voice=self.LSORadio.voice + gender=self.LSORadio.gender + culture=self.LSORadio.culture + end + self:T(self.lid..text) + self:T({sender,frequency,modulation,voice}) + local srstext=self:_GetNiceSRSText(text) + self.SRSQ:NewTransmission(srstext,duration,self.SRS,nil,0.1,nil,nil,nil,frequency,modulation,gender,culture,voice,nil,sender) + end + if playerData.client then + MESSAGE:New(text,duration,sender,clear):ToClient(playerData.client) + end + end + end + end + function AIRBOSS:MessageToPattern(message,sender,receiver,duration,clear,delay) + local call=self:_NewRadioCall(self.LSOCall.NOISE,sender or"LSO",message,duration,receiver,sender) + self:RadioTransmission(self.LSORadio,call,false,delay,nil,true) + end + function AIRBOSS:MessageToMarshal(message,sender,receiver,duration,clear,delay) + local call=self:_NewRadioCall(self.MarshalCall.NOISE,sender or"MARSHAL",message,duration,receiver,sender) + self:RadioTransmission(self.MarshalRadio,call,false,delay,nil,true) + end + function AIRBOSS:_NewRadioCall(call,sender,subtitle,subduration,modexreceiver,modexsender) + local newcall=UTILS.DeepCopy(call) + newcall.sender=sender + newcall.subtitle=subtitle or call.subtitle + newcall.subduration=subduration or self.Tmessage + if self:_IsOnboard(modexreceiver)then + newcall.modexreceiver=modexreceiver + end + if self:_IsOnboard(modexsender)then + newcall.modexsender=modexsender + end + return newcall + end + function AIRBOSS:_GetRadioSender(radio) + local sender=nil + if self.senderac then + sender=UNIT:FindByName(self.senderac) + end + if radio.alias=="MARSHAL"then + if self.radiorelayMSH then + sender=UNIT:FindByName(self.radiorelayMSH) + end + end + if radio.alias=="LSO"then + if self.radiorelayLSO then + sender=UNIT:FindByName(self.radiorelayLSO) + end + end + if sender and sender:IsAlive()and sender:IsAir()then + return sender + end + return nil + end + function AIRBOSS:_IsOnboard(text) + if text==nil then + return false + end + if text=="99"then + return true + end + for _,_flight in pairs(self.flights)do + local flight=_flight + for _,onboard in pairs(flight.onboardnumbers)do + if text==onboard then + return true + end + end + end + return false + end + function AIRBOSS:_Number2Sound(playerData,sender,number,delay) + delay=delay or 0 + local function _split(str) + local chars={} + for i=1,#str do + local c=str:sub(i,i) + table.insert(chars,c) + end + return chars + end + local Sender + if sender=="LSO"then + Sender="LSOCall" + elseif sender=="MARSHAL"or sender=="AIRBOSS"then + Sender="MarshalCall" + else + self:E(self.lid..string.format("ERROR: Unknown radio sender %s!",tostring(sender))) + return + end + local numbers=_split(tostring(number)) + local wait=0 + for i=1,#numbers do + local n=numbers[i] + local N=string.format("N%s",n) + local call=self[Sender][N] + local filename=self:_RadioFilename(call,false,Sender) + USERSOUND:New(filename):ToGroup(playerData.group,delay+wait) + wait=wait+call.duration + end + return wait + end + function AIRBOSS:_Number2Radio(radio,number,delay,interval,pilotcall) + local function _split(str) + local chars={} + for i=1,#str do + local c=str:sub(i,i) + table.insert(chars,c) + end + return chars + end + local Sender="" + if radio.alias=="LSO"then + Sender="LSOCall" + elseif radio.alias=="MARSHAL"then + Sender="MarshalCall" + else + self:E(self.lid..string.format("ERROR: Unknown radio alias %s!",tostring(radio.alias))) + end + if pilotcall then + Sender="PilotCall" + end + if Sender==""then + self:E(self.lid..string.format("ERROR: Sender unknown!")) + return + end + local numbers=_split(tostring(number)) + local wait=0 + for i=1,#numbers do + local n=numbers[i] + local N=string.format("N%s",n) + local call=self[Sender][N] + if interval and i==1 then + self:RadioTransmission(radio,call,false,delay,interval) + else + self:RadioTransmission(radio,call,false,delay) + end + wait=wait+call.duration + end + return wait + end + function AIRBOSS:_MarshallInboundCall(unit,modex) + local vectorCarrier=self:GetCoordinate():GetDirectionVec3(unit:GetCoordinate()) + local bearing=UTILS.Round(unit:GetCoordinate():GetAngleDegrees(vectorCarrier),0) + local distance=UTILS.Round(UTILS.MetersToNM(unit:GetCoordinate():Get2DDistance(self:GetCoordinate())),0) + local angels=UTILS.Round(UTILS.MetersToFeet(unit:GetHeight()/1000),0) + local state=UTILS.Round(self:_GetFuelState(unit)/1000,1) + local text=string.format("Marshal, %s, marking mom's %d for %d, angels %d, state %.1f",modex,bearing,distance,angels,state) + self:T(self.lid..text) + local FS=UTILS.Split(string.format("%.1f",state),".") + local inboundcall=self:_NewRadioCall(self.MarshalCall.CLICK,unit.UnitName:upper(),text,self.Tmessage,nil,unit.UnitName:upper()) + self:RadioTransmission(self.MarshalRadio,inboundcall) + self:RadioTransmission(self.MarshalRadio,self.PilotCall.MARSHAL,nil,nil,nil,nil,true) + self:_Number2Radio(self.MarshalRadio,modex,nil,nil,true) + self:RadioTransmission(self.MarshalRadio,self.PilotCall.MARKINGMOMS,nil,nil,nil,nil,true) + self:_Number2Radio(self.MarshalRadio,tostring(bearing),nil,nil,true) + self:RadioTransmission(self.MarshalRadio,self.PilotCall.FOR,nil,nil,nil,nil,true) + self:_Number2Radio(self.MarshalRadio,tostring(distance),nil,nil,true) + self:RadioTransmission(self.MarshalRadio,self.PilotCall.ANGELS,nil,nil,nil,nil,true) + self:_Number2Radio(self.MarshalRadio,tostring(angels),nil,nil,true) + self:RadioTransmission(self.MarshalRadio,self.PilotCall.STATE,nil,nil,nil,nil,true) + self:_Number2Radio(self.MarshalRadio,FS[1],nil,nil,true) + self:RadioTransmission(self.MarshalRadio,self.PilotCall.POINT,nil,nil,nil,nil,true) + self:_Number2Radio(self.MarshalRadio,FS[2],nil,nil,true) + self:RadioTransmission(self.MarshalRadio,self.MarshalRadio.CLICK,nil,nil,nil,nil,true) + end + function AIRBOSS:_CommencingCall(unit,modex) + local text=string.format("%s, commencing",modex) + self:T(self.lid..text) + local commencingCall=self:_NewRadioCall(self.MarshalCall.CLICK,unit.UnitName:upper(),text,self.Tmessage,nil,unit.UnitName:upper()) + self:RadioTransmission(self.MarshalRadio,commencingCall) + self:_Number2Radio(self.MarshalRadio,modex,nil,nil,true) + self:RadioTransmission(self.MarshalRadio,self.PilotCall.COMMENCING,nil,nil,nil,nil,true) + self:RadioTransmission(self.MarshalRadio,self.MarshalRadio.CLICK,nil,nil,nil,nil,true) + end + function AIRBOSS:_LSOCallAircraftBall(modex,nickname,fuelstate) + local text=string.format("%s Ball, %.1f.",nickname,fuelstate) + self:T(self.lid..text) + local NICKNAME=nickname:upper() + local FS=UTILS.Split(string.format("%.1f",fuelstate),".") + local call=self:_NewRadioCall(self.PilotCall[NICKNAME],modex,text,self.Tmessage,nil,modex) + self:RadioTransmission(self.LSORadio,call,nil,nil,nil,nil,true) + self:RadioTransmission(self.LSORadio,self.PilotCall.BALL,nil,nil,nil,nil,true) + self:_Number2Radio(self.LSORadio,FS[1],nil,nil,true) + self:RadioTransmission(self.LSORadio,self.PilotCall.POINT,nil,nil,nil,nil,true) + self:_Number2Radio(self.LSORadio,FS[2],nil,nil,true) + self:RadioTransmission(self.LSORadio,self.LSOCall.CLICK) + end + function AIRBOSS:_MarshalCallGasAtTanker(modex) + local text=string.format("Bingo fuel! Going for gas at the recovery tanker.") + self:T(self.lid..text) + local call=self:_NewRadioCall(self.PilotCall.BINGOFUEL,modex,text,self.Tmessage,nil,modex) + self:RadioTransmission(self.MarshalRadio,call,nil,nil,nil,nil,true) + self:RadioTransmission(self.MarshalRadio,self.PilotCall.GASATTANKER,nil,nil,nil,true,true) + end + function AIRBOSS:_MarshalCallGasAtDivert(modex,divertname) + local text=string.format("Bingo fuel! Going for gas at divert field %s.",divertname) + self:T(self.lid..text) + local call=self:_NewRadioCall(self.PilotCall.BINGOFUEL,modex,text,self.Tmessage,nil,modex) + self:RadioTransmission(self.MarshalRadio,call,nil,nil,nil,nil,true) + self:RadioTransmission(self.MarshalRadio,self.PilotCall.GASATDIVERT,nil,nil,nil,true,true) + end + function AIRBOSS:_MarshalCallRecoveryStopped(case) + local text=string.format("Case %d recovery ops are stopped. Deck is closed.",case) + self:T(self.lid..text) + local call=self:_NewRadioCall(self.MarshalCall.CASE,"AIRBOSS",text,self.Tmessage,"99") + self:RadioTransmission(self.MarshalRadio,call) + self:_Number2Radio(self.MarshalRadio,tostring(case)) + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.RECOVERYOPSSTOPPED,nil,nil,0.2) + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.DECKCLOSED,nil,nil,nil,true) + end + function AIRBOSS:_MarshalCallRecoveryPausedUntilFurtherNotice() + local call=self:_NewRadioCall(self.MarshalCall.RECOVERYPAUSEDNOTICE,"AIRBOSS",nil,self.Tmessage,"99") + self:RadioTransmission(self.MarshalRadio,call,nil,nil,nil,true) + end + function AIRBOSS:_MarshalCallRecoveryPausedResumedAt(clock) + local _clock=UTILS.Split(clock,"+") + local CT=UTILS.Split(_clock[1],":") + local text=string.format("aircraft recovery is paused and will be resumed at %s.",clock) + self:T(self.lid..text) + local call=self:_NewRadioCall(self.MarshalCall.RECOVERYPAUSEDRESUMED,"AIRBOSS",text,self.Tmessage,"99") + self:RadioTransmission(self.MarshalRadio,call) + self:_Number2Radio(self.MarshalRadio,CT[1]) + self:_Number2Radio(self.MarshalRadio,CT[2]) + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.HOURS,nil,nil,nil,true) + end + function AIRBOSS:_MarshalCallClearedForRecovery(modex,case) + local text=string.format("you're cleared for Case %d recovery.",case) + self:T(self.lid..text) + local call=self:_NewRadioCall(self.MarshalCall.CLEAREDFORRECOVERY,"MARSHAL",text,self.Tmessage,modex) + local delay=2 + self:RadioTransmission(self.MarshalRadio,call,nil,delay) + self:_Number2Radio(self.MarshalRadio,tostring(case),delay) + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.RECOVERY,nil,delay,nil,true) + end + function AIRBOSS:_MarshalCallResumeRecovery() + local call=self:_NewRadioCall(self.MarshalCall.RESUMERECOVERY,"AIRBOSS",nil,self.Tmessage,"99") + self:RadioTransmission(self.MarshalRadio,call,nil,nil,nil,true) + end + function AIRBOSS:_MarshalCallNewFinalBearing(FB) + local text=string.format("new final bearing %03d°.",FB) + self:T(self.lid..text) + local call=self:_NewRadioCall(self.MarshalCall.NEWFB,"AIRBOSS",text,self.Tmessage,"99") + self:RadioTransmission(self.MarshalRadio,call) + self:_Number2Radio(self.MarshalRadio,string.format("%03d",FB),nil,0.2) + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.DEGREES,nil,nil,nil,true) + end + function AIRBOSS:_MarshalCallCarrierTurnTo(hdg) + local text=string.format("carrier is now starting turn to heading %03d°.",hdg) + self:T(self.lid..text) + local call=self:_NewRadioCall(self.MarshalCall.CARRIERTURNTOHEADING,"AIRBOSS",text,self.Tmessage,"99") + self:RadioTransmission(self.MarshalRadio,call) + self:_Number2Radio(self.MarshalRadio,string.format("%03d",hdg),nil,0.2) + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.DEGREES,nil,nil,nil,true) + end + function AIRBOSS:_MarshalCallStackFull(modex,nwaiting) + local text=string.format("Marshal stack is currently full. Hold outside 10 NM zone and wait for further instructions. ") + if nwaiting==1 then + text=text..string.format("There is one flight ahead of you.") + elseif nwaiting>1 then + text=text..string.format("There are %d flights ahead of you.",nwaiting) + else + text=text..string.format("You are next in line.") + end + self:T(self.lid..text) + local call=self:_NewRadioCall(self.MarshalCall.STACKFULL,"AIRBOSS",text,self.Tmessage,modex) + self:RadioTransmission(self.MarshalRadio,call,nil,nil,nil,true) + end + function AIRBOSS:_MarshalCallRecoveryStart(case) + local radial=self:GetRadial(case,true,true,false) + local text=string.format("Starting aircraft recovery Case %d ops.",case) + if case==1 then + text=text..string.format(" BRC %03d°.",self:GetBRC()) + elseif case==2 then + text=text..string.format(" Marshal radial %03d°. BRC %03d°.",radial,self:GetBRC()) + elseif case==3 then + text=text..string.format(" Marshal radial %03d°. Final heading %03d°.",radial,self:GetFinalBearing(false)) + end + self:T(self.lid..text) + local call=self:_NewRadioCall(self.MarshalCall.STARTINGRECOVERY,"AIRBOSS",text,self.Tmessage,"99") + self:RadioTransmission(self.MarshalRadio,call) + self:_Number2Radio(self.MarshalRadio,tostring(case),nil,0.1) + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.OPS) + if case>1 then + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.MARSHALRADIAL) + self:_Number2Radio(self.MarshalRadio,string.format("%03d",radial),nil,0.2) + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.DEGREES,nil,nil,nil,true) + end + end + function AIRBOSS:_MarshalCallArrived(modex,case,brc,altitude,charlie,qfe) + self:F({modex=modex,case=case,brc=brc,altitude=altitude,charlie=charlie,qfe=qfe}) + local angels=self:_GetAngels(altitude) + local QFE=UTILS.Split(string.format("%.2f",qfe),".") + local clock=UTILS.Split(charlie,"+") + local CT=UTILS.Split(clock[1],":") + local text=string.format("Case %d, expected BRC %03d°, hold at angels %d. Expected Charlie Time %s. Altimeter %.2f. Report see me.",case,brc,angels,charlie,qfe) + self:T(self.lid..text) + local casecall=self:_NewRadioCall(self.MarshalCall.CASE,"MARSHAL",text,self.Tmessage,modex) + self:RadioTransmission(self.MarshalRadio,casecall) + self:_Number2Radio(self.MarshalRadio,tostring(case)) + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.EXPECTED,nil,nil,0.5) + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.BRC) + self:_Number2Radio(self.MarshalRadio,string.format("%03d",brc)) + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.DEGREES) + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.HOLDATANGELS,nil,nil,0.5) + self:_Number2Radio(self.MarshalRadio,tostring(angels)) + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.EXPECTED,nil,nil,0.5) + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.CHARLIETIME) + self:_Number2Radio(self.MarshalRadio,CT[1]) + self:_Number2Radio(self.MarshalRadio,CT[2]) + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.HOURS) + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.ALTIMETER,nil,nil,0.5) + self:_Number2Radio(self.MarshalRadio,QFE[1]) + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.POINT) + self:_Number2Radio(self.MarshalRadio,QFE[2]) + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.REPORTSEEME,nil,nil,0.5,true) + end + function AIRBOSS:_AddF10Commands(_unitName) + self:F(_unitName) + local _unit,playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and playername then + local group=_unit:GetGroup() + local gid=group:GetID() + if group and gid then + if not self.menuadded[gid]then + self.menuadded[gid]=true + local _rootPath=nil + if AIRBOSS.MenuF10Root then + if self.menusingle then + _rootPath=AIRBOSS.MenuF10Root + else + _rootPath=missionCommands.addSubMenuForGroup(gid,self.alias,AIRBOSS.MenuF10Root) + end + else + if AIRBOSS.MenuF10[gid]==nil then + -- AIRBOSS.MenuF10[gid]=missionCommands.addSubMenuForGroup(gid,"Airboss") + AIRBOSS.MenuF10[gid]=missionCommands.addSubMenuForGroup(gid,"航母降落") + end + if self.menusingle then + _rootPath=AIRBOSS.MenuF10[gid] + else + _rootPath=missionCommands.addSubMenuForGroup(gid,self.alias,AIRBOSS.MenuF10[gid]) + end + end + -- local _helpPath=missionCommands.addSubMenuForGroup(gid,"Help",_rootPath) + local _helpPath=missionCommands.addSubMenuForGroup(gid,"帮助",_rootPath) + if self.menumarkzones then + -- local _markPath=missionCommands.addSubMenuForGroup(gid,"Mark Zones",_helpPath) + local _markPath=missionCommands.addSubMenuForGroup(gid,"区域标记",_helpPath) + if self.menusmokezones then + -- missionCommands.addCommandForGroup(gid,"Smoke Pattern Zones",_markPath,self._MarkCaseZones,self,_unitName,false) + missionCommands.addCommandForGroup(gid,"烟雾标记降落程序区域",_markPath,self._MarkCaseZones,self,_unitName,false) + end + -- missionCommands.addCommandForGroup(gid,"Flare Pattern Zones",_markPath,self._MarkCaseZones,self,_unitName,true) + missionCommands.addCommandForGroup(gid,"信号弹标记降落程序区域 - 推荐",_markPath,self._MarkCaseZones,self,_unitName,true) + if self.menusmokezones then + -- missionCommands.addCommandForGroup(gid,"Smoke Marshal Zone",_markPath,self._MarkMarshalZone,self,_unitName,false) + missionCommands.addCommandForGroup(gid,"烟雾标记 Marshal 区域",_markPath,self._MarkMarshalZone,self,_unitName,false) + end + -- missionCommands.addCommandForGroup(gid,"Flare Marshal Zone",_markPath,self._MarkMarshalZone,self,_unitName,true) + missionCommands.addCommandForGroup(gid,"信号弹标记 Marshal 区域 - 推荐",_markPath,self._MarkMarshalZone,self,_unitName,true) + end + -- local _skillPath=missionCommands.addSubMenuForGroup(gid,"Skill Level",_helpPath) + -- missionCommands.addCommandForGroup(gid,"Flight Student",_skillPath,self._SetDifficulty,self,_unitName,AIRBOSS.Difficulty.EASY) + -- missionCommands.addCommandForGroup(gid,"Naval Aviator",_skillPath,self._SetDifficulty,self,_unitName,AIRBOSS.Difficulty.NORMAL) + -- missionCommands.addCommandForGroup(gid,"TOPGUN Graduate",_skillPath,self._SetDifficulty,self,_unitName,AIRBOSS.Difficulty.HARD) + -- missionCommands.addCommandForGroup(gid,"Hints On/Off",_skillPath,self._SetHintsOnOff,self,_unitName) + -- missionCommands.addCommandForGroup(gid,"My Status",_helpPath,self._DisplayPlayerStatus,self,_unitName) + -- missionCommands.addCommandForGroup(gid,"Attitude Monitor",_helpPath,self._DisplayAttitude,self,_unitName) + -- missionCommands.addCommandForGroup(gid,"Radio Check LSO",_helpPath,self._LSORadioCheck,self,_unitName) + -- missionCommands.addCommandForGroup(gid,"Radio Check Marshal",_helpPath,self._MarshalRadioCheck,self,_unitName) + -- missionCommands.addCommandForGroup(gid,"Subtitles On/Off",_helpPath,self._SubtitlesOnOff,self,_unitName) + -- missionCommands.addCommandForGroup(gid,"Trapsheet On/Off",_helpPath,self._TrapsheetOnOff,self,_unitName) + -- local _kneeboardPath=missionCommands.addSubMenuForGroup(gid,"Kneeboard",_rootPath) + -- local _resultsPath=missionCommands.addSubMenuForGroup(gid,"Results",_kneeboardPath) + -- missionCommands.addCommandForGroup(gid,"Greenie Board",_resultsPath,self._DisplayScoreBoard,self,_unitName) + -- missionCommands.addCommandForGroup(gid,"My LSO Grades",_resultsPath,self._DisplayPlayerGrades,self,_unitName) + -- missionCommands.addCommandForGroup(gid,"Last Debrief",_resultsPath,self._DisplayDebriefing,self,_unitName) + local _skillPath=missionCommands.addSubMenuForGroup(gid,"技能等级",_helpPath) + missionCommands.addCommandForGroup(gid,"学员(Flight Student)",_skillPath,self._SetDifficulty,self,_unitName,AIRBOSS.Difficulty.EASY) + missionCommands.addCommandForGroup(gid,"海航飞行员(Naval Aviator)",_skillPath,self._SetDifficulty,self,_unitName,AIRBOSS.Difficulty.NORMAL) + missionCommands.addCommandForGroup(gid,"顶枪毕业生(TOPGUN Graduate)",_skillPath,self._SetDifficulty,self,_unitName,AIRBOSS.Difficulty.HARD) + missionCommands.addCommandForGroup(gid,"提示 On/Off",_skillPath,self._SetHintsOnOff,self,_unitName) + missionCommands.addCommandForGroup(gid,"我的数据",_helpPath,self._DisplayPlayerStatus,self,_unitName) + missionCommands.addCommandForGroup(gid,"实时高度监控",_helpPath,self._DisplayAttitude,self,_unitName) + missionCommands.addCommandForGroup(gid,"LSO 无线电检查",_helpPath,self._LSORadioCheck,self,_unitName) + missionCommands.addCommandForGroup(gid,"Marshal 无线电检查",_helpPath,self._MarshalRadioCheck,self,_unitName) + missionCommands.addCommandForGroup(gid,"字幕 On/Off",_helpPath,self._SubtitlesOnOff,self,_unitName) + missionCommands.addCommandForGroup(gid,"着舰记录单 On/Off",_helpPath,self._TrapsheetOnOff,self,_unitName) + local _kneeboardPath=missionCommands.addSubMenuForGroup(gid,"膝板",_rootPath) + local _resultsPath=missionCommands.addSubMenuForGroup(gid,"成绩",_kneeboardPath) + missionCommands.addCommandForGroup(gid,"复飞指示板",_resultsPath,self._DisplayScoreBoard,self,_unitName) + missionCommands.addCommandForGroup(gid,"我的 LSO 评分",_resultsPath,self._DisplayPlayerGrades,self,_unitName) + missionCommands.addCommandForGroup(gid,"上一次成绩报告",_resultsPath,self._DisplayDebriefing,self,_unitName) + if self.skipperMenu then + local _skipperPath=missionCommands.addSubMenuForGroup(gid,"联系舰长 - 控制航母",_kneeboardPath) + local _menusetspeed=missionCommands.addSubMenuForGroup(gid,"设置航母速度",_skipperPath) + missionCommands.addCommandForGroup(gid,"10 knots",_menusetspeed,self._SkipperRecoverySpeed,self,_unitName,10) + missionCommands.addCommandForGroup(gid,"15 knots",_menusetspeed,self._SkipperRecoverySpeed,self,_unitName,15) + missionCommands.addCommandForGroup(gid,"20 knots",_menusetspeed,self._SkipperRecoverySpeed,self,_unitName,20) + missionCommands.addCommandForGroup(gid,"25 knots",_menusetspeed,self._SkipperRecoverySpeed,self,_unitName,25) + missionCommands.addCommandForGroup(gid,"30 knots",_menusetspeed,self._SkipperRecoverySpeed,self,_unitName,30) + local _menusetrtime=missionCommands.addSubMenuForGroup(gid,"设置回收持续时间",_skipperPath) + missionCommands.addCommandForGroup(gid,"15 min",_menusetrtime,self._SkipperRecoveryTime,self,_unitName,15) + missionCommands.addCommandForGroup(gid,"30 min",_menusetrtime,self._SkipperRecoveryTime,self,_unitName,30) + missionCommands.addCommandForGroup(gid,"45 min",_menusetrtime,self._SkipperRecoveryTime,self,_unitName,45) + missionCommands.addCommandForGroup(gid,"60 min",_menusetrtime,self._SkipperRecoveryTime,self,_unitName,60) + missionCommands.addCommandForGroup(gid,"90 min",_menusetrtime,self._SkipperRecoveryTime,self,_unitName,90) + local _menusetrtime=missionCommands.addSubMenuForGroup(gid,"设置引导径向线方向",_skipperPath) + missionCommands.addCommandForGroup(gid,"+30°",_menusetrtime,self._SkipperRecoveryOffset,self,_unitName,30) + missionCommands.addCommandForGroup(gid,"+15°",_menusetrtime,self._SkipperRecoveryOffset,self,_unitName,15) + missionCommands.addCommandForGroup(gid,"0°",_menusetrtime,self._SkipperRecoveryOffset,self,_unitName,0) + missionCommands.addCommandForGroup(gid,"-15°",_menusetrtime,self._SkipperRecoveryOffset,self,_unitName,-15) + missionCommands.addCommandForGroup(gid,"-30°",_menusetrtime,self._SkipperRecoveryOffset,self,_unitName,-30) + missionCommands.addCommandForGroup(gid,"U-turn On/Off",_skipperPath,self._SkipperRecoveryUturn,self,_unitName) + missionCommands.addCommandForGroup(gid,"开始 CASE I 回收",_skipperPath,self._SkipperStartRecovery,self,_unitName,1) + missionCommands.addCommandForGroup(gid,"开始 CASE II 回收",_skipperPath,self._SkipperStartRecovery,self,_unitName,2) + missionCommands.addCommandForGroup(gid,"开始 CASE III 回收",_skipperPath,self._SkipperStartRecovery,self,_unitName,3) + missionCommands.addCommandForGroup(gid,"终止回收",_skipperPath,self._SkipperStopRecovery,self,_unitName) + end + missionCommands.addCommandForGroup(gid,"航母信息",_kneeboardPath,self._DisplayCarrierInfo,self,_unitName) + missionCommands.addCommandForGroup(gid,"天气汇报",_kneeboardPath,self._DisplayCarrierWeather,self,_unitName) + missionCommands.addCommandForGroup(gid,"设置中队",_kneeboardPath,self._SetSection,self,_unitName) + missionCommands.addCommandForGroup(gid,"调度队列 (Marshal)",_kneeboardPath,self._DisplayQueue,self,_unitName,"Marshal") + missionCommands.addCommandForGroup(gid,"降落程序队列 (Pattern)",_kneeboardPath,self._DisplayQueue,self,_unitName,"Pattern") + missionCommands.addCommandForGroup(gid,"等待程序队列",_kneeboardPath,self._DisplayQueue,self,_unitName,"Waiting") + missionCommands.addCommandForGroup(gid,"请求降落 (Marshal)",_rootPath,self._RequestMarshal,self,_unitName) + missionCommands.addCommandForGroup(gid,"请求开始进近",_rootPath,self._RequestCommence,self,_unitName) + missionCommands.addCommandForGroup(gid,"请求空中加油机",_rootPath,self._RequestRefueling,self,_unitName) + missionCommands.addCommandForGroup(gid,"Spinning",_rootPath,self._RequestSpinning,self,_unitName) + missionCommands.addCommandForGroup(gid,"请求紧急降落(无视程序直接进入第五边)",_rootPath,self._RequestEmergency,self,_unitName) + missionCommands.addCommandForGroup(gid,"[重置我的降落阶段]",_rootPath,self._ResetPlayerStatus,self,_unitName) + end + else + self:E(self.lid..string.format("ERROR: Could not find group or group ID in AddF10Menu() function. Unit name: %s.",_unitName)) + end + else + self:E(self.lid..string.format("ERROR: Player unit does not exist in AddF10Menu() function. Unit name: %s.",_unitName)) + end + end + function AIRBOSS:_SkipperStartRecovery(_unitName,case) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + -- local text=string.format("affirm, Case %d recovery will start in 5 min for %d min. Wind on deck %d knots. U-turn=%s.",case,self.skipperTime,self.skipperSpeed,tostring(self.skipperUturn)) + local text=string.format("确认, Case %d 回收将在 5分钟 后开始, 窗口开放时长 %d分钟. 甲板风 %d knots. U-turn=%s.",case,self.skipperTime,self.skipperSpeed,tostring(self.skipperUturn)) + if case>1 then + -- text=text..string.format(" Marshal radial %d°.",self.skipperOffset) + text=text..string.format(" Marshal 径向线 %d°.",self.skipperOffset) + end + if self:IsRecovering()then + -- text="negative, carrier is already recovering." + -- self:MessageToPlayer(playerData,text,"AIRBOSS") + text="无法执行, 航母正在进行回收作业." + self:MessageToPlayer(playerData,text,"航空长") + return + end + -- self:MessageToPlayer(playerData,text,"AIRBOSS") + self:MessageToPlayer(playerData,text,"航空长") + local t0=timer.getAbsTime()+5*60 + local t9=t0+self.skipperTime*60 + local C0=UTILS.SecondsToClock(t0) + local C9=UTILS.SecondsToClock(t9) + self:AddRecoveryWindow(C0,C9,case,self.skipperOffset,true,self.skipperSpeed,self.skipperUturn) + end + end + end + function AIRBOSS:_SkipperStopRecovery(_unitName) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + -- local text="roger, stopping recovery right away." + local text="收到, 马上停止回收." + if not self:IsRecovering()then + -- text="negative, carrier is currently not recovering." + -- self:MessageToPlayer(playerData,text,"AIRBOSS") + text="无法执行, 航母目前没有执行回收." + self:MessageToPlayer(playerData,text,"航空长") + return + end + -- self:MessageToPlayer(playerData,text,"AIRBOSS") + self:MessageToPlayer(playerData,text,"航空长") + self:RecoveryStop() + end + end + end + function AIRBOSS:_SkipperRecoveryOffset(_unitName,offset) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + -- local text=string.format("roger, relative CASE II/III Marshal radial set to %d°.",offset) + -- self:MessageToPlayer(playerData,text,"AIRBOSS") + local text=string.format("收到, 相对 CASE II/III Marshal 径向线设置到 %d°.",offset) + self:MessageToPlayer(playerData,text,"航空长") + self.skipperOffset=offset + end + end + end + function AIRBOSS:_SkipperRecoveryTime(_unitName,time) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + -- local text=string.format("roger, manual recovery time set to %d min.",time) + -- self:MessageToPlayer(playerData,text,"AIRBOSS") + local text=string.format("收到, 手动设置回收时长到 %d分钟.",time) + self:MessageToPlayer(playerData,text,"航空长") + self.skipperTime=time + end + end + end + function AIRBOSS:_SkipperRecoverySpeed(_unitName,speed) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + -- local text=string.format("roger, wind on deck set to %d knots.",speed) + -- self:MessageToPlayer(playerData,text,"AIRBOSS") + local text=string.format("收到, 甲板风设置到 %d knots.",speed) + self:MessageToPlayer(playerData,text,"航空长") + self.skipperSpeed=speed + end + end + end + function AIRBOSS:_SkipperRecoveryUturn(_unitName) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + self.skipperUturn=not self.skipperUturn + -- local text=string.format("roger, U-turn is now %s.",tostring(self.skipperUturn)) + -- self:MessageToPlayer(playerData,text,"AIRBOSS") + local text=string.format("收到, U-turn 现在设置为 %s.",tostring(self.skipperUturn)) + self:MessageToPlayer(playerData,text,"航空长") + end + end + end + function AIRBOSS:_ResetPlayerStatus(_unitName) + self:F(_unitName) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + -- local text="roger, status reset executed! You have been removed from all queues." + -- self:MessageToPlayer(playerData,text,"AIRBOSS") + local text="收到, 已经重置你的状态! 你已被移出所有队列." + self:MessageToPlayer(playerData,text,"航空长") + self:_RemoveFlight(playerData) + if playerData.debriefschedulerID and self.Scheduler then + self.Scheduler:Stop(playerData.debriefschedulerID) + end + self:_InitPlayer(playerData) + end + end + end + function AIRBOSS:_RequestMarshal(_unitName) + self:F(_unitName) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + if self.xtVoiceOvers then + self:_MarshallInboundCall(_unit,playerData.onboard) + end + local inCCA=playerData.unit:IsInZone(self.zoneCCA) + if inCCA then + if self:_InQueue(self.Qmarshal,playerData.group)then + -- local text=string.format("negative, you are already in the Marshal queue. New marshal request denied!") + local text=string.format("无法执行,你已经在调度(Marshal)队列了. 新的着陆请求被拒绝!") + self:MessageToPlayer(playerData,text,"MARSHAL") + elseif self:_InQueue(self.Qpattern,playerData.group)then + -- local text=string.format("negative, you are already in the Pattern queue. Marshal request denied!") + local text=string.format("无法执行, 你已经在降落程序(Pattern)队列了. 新的着陆请求被拒绝!") + self:MessageToPlayer(playerData,text,"MARSHAL") + elseif self:_InQueue(self.Qwaiting,playerData.group)then + -- local text=string.format("negative, you are in the Waiting queue with %d flights ahead of you. Marshal request denied!",#self.Qwaiting) + local text=string.format("无法执行,你已经在等待(Waiting)队列了, 还要 %d 架飞机在你前面. 新的着陆请求被拒绝!",#self.Qwaiting) + self:MessageToPlayer(playerData,text,"MARSHAL") + elseif not _unit:InAir()then + -- local text=string.format("negative, you are not airborne. Marshal request denied!") + local text=string.format("无法执行, 你还没起飞呢. 新的着陆请求被拒绝!") + self:MessageToPlayer(playerData,text,"MARSHAL") + elseif playerData.name~=playerData.seclead then + -- local text=string.format("negative, your section lead %s needs to request Marshal.",playerData.seclead) + local text=string.format("无法执行, 你需要中队长机 %s 来呼叫着陆请求(Request Marshal).",playerData.seclead) + self:MessageToPlayer(playerData,text,"MARSHAL") + else + local freestack=self:_GetFreeStack(playerData.ai) + if freestack then + self:_MarshalPlayer(playerData,freestack) + else + self:_WaitPlayer(playerData) + end + end + else + -- local text=string.format("negative, you are not inside CCA. Marshal request denied!") + local text=string.format("无法执行, 你不在航母管制区域内, 着陆请求被拒绝!") + self:MessageToPlayer(playerData,text,"MARSHAL") + end + end + end + end + function AIRBOSS:_RequestEmergency(_unitName) + self:F(_unitName) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + local text="" + if not self.emergency then + -- text="negative, no emergency landings on my carrier. We are currently busy. See how you get along!" + text="不行, 今天谁也别想在我航母上紧急降落. 我们忙得一匹. 你自己想办法吧!" + elseif not _unit:InAir()then + local zone=self:_GetZoneCarrierBox() + if playerData.unit:IsInZone(zone)then + -- text="roger, you are now technically in the bolter pattern. Your next step after takeoff is abeam!" + text="收到, 技术上来说你现在在执行脱钩(bolter)程序. 你下一步是进入第三边(abeam)!" + local lead=self:_GetFlightLead(playerData) + self:_SetPlayerStep(lead,AIRBOSS.PatternStep.BOLTER) + for _,sec in pairs(lead.section)do + local sectionmember=sec + self:_SetPlayerStep(sectionmember,AIRBOSS.PatternStep.BOLTER) + end + self:_RemoveFlightFromQueue(self.Qwaiting,lead) + if self:_InQueue(self.Qmarshal,lead.group)then + self:_RemoveFlightFromMarshalQueue(lead) + else + if not self:_InQueue(self.Qpattern,lead.group)then + self:_AddFlightToPatternQueue(lead) + end + end + else + -- text=string.format("negative, you are not airborne. Request denied!") + text=string.format("不行, 你还没起飞呢. 请求已否定!") + end + else + -- text="affirmative, you can bypass the pattern and are cleared for final approach!" + text="收到, 你可以跳过所有步骤, 直接进入最终进近!" + local lead=self:_GetFlightLead(playerData) + self:_SetPlayerStep(lead,AIRBOSS.PatternStep.EMERGENCY) + for _,sec in pairs(lead.section)do + local sectionmember=sec + self:_SetPlayerStep(sectionmember,AIRBOSS.PatternStep.EMERGENCY) + self:_RemoveFlightFromQueue(self.Qspinning,sectionmember) + end + self:_RemoveFlightFromQueue(self.Qwaiting,lead) + if self:_InQueue(self.Qmarshal,lead.group)then + self:_RemoveFlightFromMarshalQueue(lead) + else + if not self:_InQueue(self.Qpattern,lead.group)then + self:_AddFlightToPatternQueue(lead) + end + end + end + -- self:MessageToPlayer(playerData,text,"AIRBOSS") + self:MessageToPlayer(playerData,text,"航空长") + end + end + end + function AIRBOSS:_RequestSpinning(_unitName) + self:F(_unitName) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + local text="" + if not self:_InQueue(self.Qpattern,playerData.group)then + -- text="negative, you have to be in the pattern to spin it!" + text="无法执行, 你得先加入降落程序(pattern)才能进入 spin!" + elseif playerData.step==AIRBOSS.PatternStep.SPINNING then + -- text="negative, you are already spinning." + text="无法执行, 你已经在 spinning 了." + elseif not(playerData.step==AIRBOSS.PatternStep.BREAKENTRY or + playerData.step==AIRBOSS.PatternStep.EARLYBREAK or + playerData.step==AIRBOSS.PatternStep.LATEBREAK)then + -- text="negative, you have to be in the right step to spin it!" + text="无法执行, 你必须在正确的步骤上才能进入 spin!" + else + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.SPINNING) + table.insert(self.Qspinning,playerData) + -- local call=self:_NewRadioCall(self.LSOCall.SPINIT,"AIRBOSS","Spin it!",self.Tmessage,playerData.onboard) + local call=self:_NewRadioCall(self.LSOCall.SPINIT,"航空长","Spin it!",self.Tmessage,playerData.onboard) + self:RadioTransmission(self.LSORadio,call,nil,nil,nil,true) + if playerData.difficulty==AIRBOSS.Difficulty.EASY then + -- local text="Climb to 1200 feet and proceed to the initial again." + -- self:MessageToPlayer(playerData,text,"AIRBOSS","") + local text="爬升至 1200ft 然后重新开始 initial." + self:MessageToPlayer(playerData,text,"航空长","") + end + return + end + -- self:MessageToPlayer(playerData,text,"AIRBOSS") + self:MessageToPlayer(playerData,text,"航空长") + end + end + end + function AIRBOSS:_RequestCommence(_unitName) + self:F(_unitName) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + if self.xtVoiceOvers then + self:_CommencingCall(_unit,playerData.onboard) + end + local text="" + local cleared=false + if _unit:IsInZone(self.zoneCCA)then + local stack=playerData.flag + local _,npattern=self:_GetQueueInfo(self.Qpattern) + if self:_InQueue(self.Qpattern,playerData.group)then + -- text=string.format("negative, %s, you are already in the Pattern queue.",playerData.name) + text=string.format("无法执行, %s, 你已经在降落(Pattern)队列了.",playerData.name) + elseif not _unit:InAir()then + -- text=string.format("negative, %s, you are not airborne.",playerData.name) + text=string.format("无法执行, %s, 你都没起飞.",playerData.name) + elseif playerData.seclead~=playerData.name then + -- text=string.format("negative, %s, your section leader %s has to request commence!",playerData.name,playerData.seclead) + text=string.format("无法执行, %s, 你的长机 %s 才能请求开始进近!",playerData.name,playerData.seclead) + elseif stack>1 then + -- text=string.format("negative, %s, it's not your turn yet! You are in stack no. %s.",playerData.name,stack) + text=string.format("无法执行, %s, 还没轮到你! 你在队列的 no. %s.",playerData.name,stack) + elseif npattern>=self.Nmaxpattern then + -- text=string.format("negative ghostrider, pattern is full!\nThere are %d aircraft currently in the pattern.",npattern) + text=string.format("不行啊, 小飞侠, 降落程序已经满员了!\nT现在有 %d 架飞机正在执行降落.",npattern) + elseif self:IsRecovering()==false and not self.airbossnice then + if self.recoverywindow then + local clock=UTILS.SecondsToClock(self.recoverywindow.START) + -- text=string.format("negative, carrier is currently not recovery. Next window will open at %s.",clock) + text=string.format("无法执行, 航母回收窗口已经关闭了. 下一个窗口在 %s.",clock) + else + -- text=string.format("negative, carrier is not recovering. No future windows planned.") + text=string.format("无法执行, 航母回收窗口已经关闭了. 未来没有计划中的窗口.") + end + elseif not self:_InQueue(self.Qmarshal,playerData.group)and not self.airbossnice then + -- text="negative, you have to request Marshal before you can commence." + text="无法执行, 你得先申请调度(Marshal)才能申请降落进近(commence)." + else + -- text=text.."roger." + text=text.."收到." + if not self:IsRecovering()then + -- text=text.." Carrier is not recovering currently! However, you are cleared anyway as I have a nice day." + text=text.." 航母已经停止回收了! 但是捏, 航空长今天开心, 就让你降落吧." + end + if not self:_InQueue(self.Qmarshal,playerData.group)then + playerData.case=self.case + if self.TACANon and playerData.difficulty~=AIRBOSS.Difficulty.HARD then + local radial=self:GetRadial(playerData.case,true,true,true) + if playerData.case==1 then + radial=self:GetBRC() + end + -- text=text..string.format("\nSelect TACAN %03d°, Channel %d%s (%s).\n",radial,self.TACANchannel,self.TACANmode,self.TACANmorse) + text=text..string.format("\n设置TACAN航向 %03d°, 频道 %d%s (%s).\n",radial,self.TACANchannel,self.TACANmode,self.TACANmorse) + end + for _,flight in pairs(playerData.section)do + flight.case=playerData.case + end + self:_AddFlightToPatternQueue(playerData) + end + cleared=true + end + else + -- text=string.format("negative, %s, you are not inside the CCA!",playerData.name) + text=string.format("不行, %s, 你都不在航母管制区域!",playerData.name) + end + self:T(self.lid..text) + self:MessageToPlayer(playerData,text,"MARSHAL") + if cleared then + self:_Commencing(playerData,false) + end + end + end + end + function AIRBOSS:_RequestRefueling(_unitName) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + local text + if self.tanker then + if _unit:IsInZone(self.zoneCCA)then + if self.tanker:IsRunning()or self.tanker:IsRefueling()then + local angels=self:_GetAngels(self.tanker.altitude) + -- text=string.format("affirmative, proceed to tanker at angels %d.",angels) + text=string.format("收到, 前进至加油机高度 %d.",angels) + if self.tanker.TACANon then + -- text=text..string.format("\nTanker TACAN channel %d%s (%s).",self.tanker.TACANchannel,self.tanker.TACANmode,self.tanker.TACANmorse) + -- text=text..string.format("\nRadio frequency %.3f MHz AM.",self.tanker.RadioFreq) + text=text..string.format("\n加油机 TACAN 频道 %d%s (%s).",self.tanker.TACANchannel,self.tanker.TACANmode,self.tanker.TACANmorse) + text=text..string.format("\n加油机无线电 %.3f MHz AM.",self.tanker.RadioFreq) + end + if self.tanker:IsRefueling()then + -- text=text.."\nTanker is currently refueling. You might have to queue up." + text=text.."\n加油机目前正在执行控制加油作业. 你可能需要排队." + end + self:_RemoveFlightFromMarshalQueue(playerData,true) + self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.REFUELING) + for _,sec in pairs(playerData.section)do + -- local sectext="follow your section leader to the tanker." + local sectext="跟随你的长机与加油机回合." + self:MessageToPlayer(sec,sectext,"MARSHAL") + self:_SetPlayerStep(sec,AIRBOSS.PatternStep.REFUELING) + end + elseif self.tanker:IsReturning()then + -- text="negative, tanker is RTB. Request denied!\nWait for the tanker to be back on station if you can." + text="无法执行, 加油机正在返航RTB. 请求被否决!\n如果可以, 请等待加油机重新执行任务." + end + else + -- text="negative, you are not inside the CCA yet." + text="无法执行, 你都还不在航母管制区域." + end + else + -- text="negative, no refueling tanker available." + text="无法执行, 没有可用的加油机." + end + self:MessageToPlayer(playerData,text,"MARSHAL") + end + end + end + function AIRBOSS:_RemoveSectionMember(playerData,sectionmember) + for i,_flight in pairs(playerData.section)do + local flight=_flight + if flight.name==sectionmember.name then + table.remove(playerData.section,i) + return true + end + end + return false + end + function AIRBOSS:_SetSection(_unitName) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + local mycoord=_unit:GetCoordinate() + local dmax=100 + local text + if self.NmaxSection==0 then + -- text=string.format("negative, setting sections is disabled in this mission. You stay alone.") + text=string.format("无法执行, 服务器不让设置小队, 你一个人飞吧.") + elseif self:_InQueue(self.Qmarshal,playerData.group)then + -- text=string.format("negative, you are already in the Marshal queue. Setting section not possible any more!") + text=string.format("无法执行, 你已经在调度(Marshal)队列了. 现在不能创建小队了!") + elseif self:_InQueue(self.Qpattern,playerData.group)then + -- text=string.format("negative, you are already in the Pattern queue. Setting section not possible any more!") + text=string.format("无法执行, 你已经在降落(Pattern)队列了. 现在不能创建小队了!") + else + if playerData.seclead~=playerData.name then + local lead=self.players[playerData.seclead] + if lead then + local removed=self:_RemoveSectionMember(lead,playerData) + -- if removed then + -- self:MessageToPlayer(lead,string.format("Flight %s has been removed from your section.",playerData.name),"AIRBOSS","",5) + -- self:MessageToPlayer(playerData,string.format("You have been removed from %s's section.",lead.name),"AIRBOSS","",5) + if removed then + self:MessageToPlayer(lead,string.format("飞机 %s 已经从你的小队中移除.",playerData.name),"航空长","",5) + self:MessageToPlayer(playerData,string.format("你已经被移出 %s's 的小队.",lead.name),"航空长","",5) + end + end + end + local section={} + for _,_flight in pairs(self.flights)do + local flight=_flight + if flight.ai==false and flight.groupname~=playerData.groupname and#flight.section==0 and flight.seclead==flight.name then + local distance=flight.group:GetCoordinate():Get3DDistance(mycoord) + if distance0 then + _playerResults[playerName]=Paverage/n + end + end + end + -- local text=string.format("Greenie Board (top ten):") + local text=string.format("Greenie Board (top ten):") + local i=1 + for _playerName,_points in UTILS.spairs(_playerResults,function(t,a,b) + return t[b]=0 then + text=text..string.format("(%.1f)",grade.points) + end + end + i=i+1 + if i>10 then + break + end + end + if i==1 then + -- text=text.."\nNo results yet." + text=text.."\n暂无结果." + end + local playerData=self.players[_playername] + if playerData.client then + MESSAGE:New(text,30,nil,true):ToClient(playerData.client) + end + end + end + function AIRBOSS:_DisplayPlayerGrades(_unitName) + self:F(_unitName) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + -- local text=string.format("Your last 10 grades, %s:",_playername) + local text=string.format("你的近10次成绩, %s:",_playername) + local playerGrades=self.playerscores[_playername]or{} + local p=0 + local n=0 + local m=0 + for i=#playerGrades,1,-1 do + local grade=playerGrades[i] + if grade.points>=0 then + local points=grade.finalscore or grade.points + if m<10 then + text=text..string.format("\n[%d] %s %.1f PT - %s",i,grade.grade,points,grade.details) + if grade.wire and grade.wire<=4 then + text=text..string.format(" %d-wire",grade.wire) + end + if grade.Tgroove and grade.Tgroove<=360 then + -- text=text..string.format(" Tgroove=%.1f s",grade.Tgroove) + text=text..string.format(" 五边(groove)时长=%.1f s",grade.Tgroove) + end + end + if grade.finalscore then + p=p+grade.finalscore + n=n+1 + end + m=m+1 + end + end + if n>0 then + -- text=text..string.format("\nAverage points = %.1f",p/n) + text=text..string.format("\n平均得分 = %.1f",p/n) + else + -- text=text..string.format("\nNo data available.") + text=text..string.format("\n暂无数据.") + end + if playerData.client then + MESSAGE:New(text,30,nil,true):ToClient(playerData.client) + end + end + end + end + function AIRBOSS:_DisplayDebriefing(_unitName) + self:F(_unitName) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + -- local text=string.format("Debriefing:") + local text=string.format("总结(Debriefing):") + if#playerData.lastdebrief>0 then + text=text..string.format("\n================================\n") + for _,_data in pairs(playerData.lastdebrief)do + local step=_data.step + local comment=_data.hint + text=text..string.format("* %s:",step) + text=text..string.format("%s\n",comment) + end + else + -- text=text.." Nothing to show yet." + text=text.." n暂无数据." + end + self:MessageToPlayer(playerData,text,nil,"",30,true) + end + end + end + function AIRBOSS:_DisplayQueue(_unitname,qname) + local unit,playername=self:_GetPlayerUnitAndName(_unitname) + if unit and playername then + local playerData=self.players[playername] + if playerData then + local queue=nil + if qname=="Marshal"then + queue=self.Qmarshal + elseif qname=="Pattern"then + queue=self.Qpattern + elseif qname=="Waiting"then + queue=self.Qwaiting + end + local Nqueue,nqueue=self:_GetQueueInfo(queue,playerData.case) + -- local text=string.format("%s Queue:",qname) + local text=string.format("%s 队列:",qname) + if#queue==0 then + -- text=text.." empty" + text=text.." 空" + else + local N=0 + if qname=="Marshal"then + for i,_flight in pairs(queue)do + local flight=_flight + local charlie=self:_GetCharlieTime(flight) + local Charlie=UTILS.SecondsToClock(charlie) + local stack=flight.flag + local angels=self:_GetAngels(self:_GetMarshalAltitude(stack,flight.case)) + local _,nunit,nsec=self:_GetFlightUnits(flight,true) + local nick=self:_GetACNickname(flight.actype) + N=N+nunit + -- text=text..string.format("\n[Stack %d] %s (%s*%d+%d): Case %d, Angels %d, Charlie %s",stack,flight.onboard,nick,nunit,nsec,flight.case,angels,tostring(Charlie)) + text=text..string.format("\n[Stack %d] %s (%s*%d+%d): Case %d, 高度 %d, Charlie时间 %s",stack,flight.onboard,nick,nunit,nsec,flight.case,angels,tostring(Charlie)) + end + elseif qname=="Pattern"or qname=="Waiting"then + for i,_flight in pairs(queue)do + local flight=_flight + local _,nunit,nsec=self:_GetFlightUnits(flight,true) + local nick=self:_GetACNickname(flight.actype) + local ptime=UTILS.SecondsToClock(timer.getAbsTime()-flight.time) + N=N+nunit + text=text..string.format("\n[%d] %s (%s*%d+%d): Case %d, T=%s",i,flight.onboard,nick,nunit,nsec,flight.case,ptime) + end + end + -- text=text..string.format("\nTotal AC: %d (airborne %d)",N,nqueue) + text=text..string.format("\n总飞行器 %d (%d 在空中)",N,nqueue) + end + self:MessageToPlayer(playerData,text,nil,"",nil,true) + end + end + end + function AIRBOSS:_DisplayCarrierInfo(_unitname) + self:F2(_unitname) + local unit,playername=self:_GetPlayerUnitAndName(_unitname) + if unit and playername then + local playerData=self.players[playername] + if playerData then + local coord=self:GetCoordinate() + local carrierheading=self.carrier:GetHeading() + local carrierspeed=UTILS.MpsToKnots(self.carrier:GetVelocityMPS()) + local tacan="unknown" + local icls="unknown" + if self.TACANon and self.TACANchannel~=nil then + tacan=string.format("%d%s (%s)",self.TACANchannel,self.TACANmode,self.TACANmorse) + end + if self.ICLSon and self.ICLSchannel~=nil then + icls=string.format("%d (%s)",self.ICLSchannel,self.ICLSmorse) + end + local wind=UTILS.MpsToKnots(select(1,self:GetWindOnDeck())) + local Nmarshal,nmarshal=self:_GetQueueInfo(self.Qmarshal,playerData.case) + local Npattern,npattern=self:_GetQueueInfo(self.Qpattern) + local Nspinning,nspinning=self:_GetQueueInfo(self.Qspinning) + local Nwaiting,nwaiting=self:_GetQueueInfo(self.Qwaiting) + local Ntotal,ntotal=self:_GetQueueInfo(self.flights) + local Tabs=timer.getAbsTime() + -- local recoverytext="Recovery time windows (max 5):" + local recoverytext="回收窗口 (max 5):" + if#self.recoverytimes==0 then + -- recoverytext=recoverytext.." none." + recoverytext=recoverytext.." 无." + else + local rw=0 + for _,_recovery in pairs(self.recoverytimes)do + local recovery=_recovery + if Tabs=5 then + break + end + end + end + end + local tankertext=nil + if self.tanker then + -- tankertext=string.format("Recovery tanker frequency %.3f MHz\n",self.tanker.RadioFreq) + tankertext=string.format("加油机无线电 %.3f MHz\n",self.tanker.RadioFreq) + if self.tanker.TACANon then + -- tankertext=tankertext..string.format("Recovery tanker TACAN %d%s (%s)",self.tanker.TACANchannel,self.tanker.TACANmode,self.tanker.TACANmorse) + tankertext=tankertext..string.format("加油机 TACAN %d%s (%s)",self.tanker.TACANchannel,self.tanker.TACANmode,self.tanker.TACANmorse) + else + -- tankertext=tankertext.."Recovery tanker TACAN n/a" + tankertext=tankertext.."加油机 TACAN n/a" + end + end + local state=self:GetState() + if state=="Idle"then + state="Deck closed" + end + if self.turning then + state=state.." (currently turning)" + end + -- local text=string.format("%s info:\n",self.alias) + -- text=text..string.format("================================\n") + -- text=text..string.format("Carrier state: %s\n",state) + local text=string.format("%s 信息:\n",self.alias) + text=text..string.format("================================\n") + text=text..string.format("航母状态: %s\n",state) + if self.case==1 then + -- text=text..string.format("Case %d recovery ops\n",self.case) + text=text..string.format("Case %d 回收作业中\n",self.case) + else + local radial=self:GetRadial(self.case,true,true,false) + -- text=text..string.format("Case %d recovery ops\nMarshal radial %03d°\n",self.case,radial) + text=text..string.format("Case %d 回收作业中\nMarshal 径向线 %03d°\n",self.case,radial) + end + -- text=text..string.format("BRC %03d° - FB %03d°\n",self:GetBRC(),self:GetFinalBearing(true)) + -- text=text..string.format("Speed %.1f kts - Wind on deck %.1f kts\n",carrierspeed,wind) + -- text=text..string.format("Tower frequency %.3f MHz\n",self.TowerFreq) + -- text=text..string.format("Marshal radio %.3f MHz\n",self.MarshalFreq) + -- text=text..string.format("LSO radio %.3f MHz\n",self.LSOFreq) + -- text=text..string.format("TACAN Channel %s\n",tacan) + -- text=text..string.format("ICLS Channel %s\n",icls) + text=text..string.format("BRC %03d° - FB %03d°\n",self:GetBRC(),self:GetFinalBearing(true)) + text=text..string.format("速度 %.1f kts - 甲板风 %.1f kts\n",carrierspeed,wind) + text=text..string.format("塔台无线电 %.3f MHz\n",self.TowerFreq) + text=text..string.format("Marshal 无线电 %.3f MHz\n",self.MarshalFreq) + text=text..string.format("LSO 无线电 %.3f MHz\n",self.LSOFreq) + text=text..string.format("TACAN 频道 %s\n",tacan) + text=text..string.format("ICLS 频道 %s\n",icls) + if tankertext then + text=text..tankertext.."\n" + end + text=text..string.format("# 飞行器总数 %d (%d)\n",Ntotal,ntotal) + text=text..string.format("# 在 marshal 的飞机数量 %d (%d)\n",Nmarshal,nmarshal) + text=text..string.format("# 在 pattern 的飞机数量 %d (%d) - spinning 的飞机数量 %d (%d)\n",Npattern,npattern,Nspinning,nspinning) + text=text..string.format("# 在 waiting 的飞机数量 %d (%d)\n",Nwaiting,nwaiting) + text=text..string.format(recoverytext) + self:T2(self.lid..text) + self:MessageToPlayer(playerData,text,nil,"",30,true) + else + self:E(self.lid..string.format("ERROR: Could not get player data for player %s.",playername)) + end + end + end + function AIRBOSS:_DisplayCarrierWeather(_unitname) + self:F2(_unitname) + local unit,playername=self:_GetPlayerUnitAndName(_unitname) + if unit and playername then + local text="" + local coord=self:GetCoordinate() + local T=coord:GetTemperature() + local P=coord:GetPressure() + local Wd,Ws=self:GetWind(nil,true) + local Bn,Bd=UTILS.BeaufortScale(Ws) + local WodPA,WodPP=self:GetWindOnDeck() + local WodPA=UTILS.MpsToKnots(WodPA) + local WodPP=UTILS.MpsToKnots(WodPP) + local WD=string.format('%03d°',Wd) + local Ts=string.format("%d°C",T) + local tT=string.format("%d°C",T) + local tW=string.format("%.1f knots",UTILS.MpsToKnots(Ws)) + local tP=string.format("%.2f inHg",UTILS.hPa2inHg(P)) + -- text=text..string.format("Weather Report at Carrier %s:\n",self.alias) + -- text=text..string.format("================================\n") + -- text=text..string.format("Temperature %s\n",tT) + -- text=text..string.format("Wind from %s at %s (%s)\n",WD,tW,Bd) + -- text=text..string.format("Wind on deck || %.1f kts, == %.1f kts\n",WodPA,WodPP) + -- text=text..string.format("QFE %.1f hPa = %s",P,tP) + text=text..string.format("航母天气报告 %s:\n",self.alias) + text=text..string.format("================================\n") + text=text..string.format("温度 %s\n",tT) + text=text..string.format("风向 %s 风速 %s (%s)\n",WD,tW,Bd) + text=text..string.format("甲板风 || %.1f kts, == %.1f kts\n",WodPA,WodPP) + text=text..string.format("QFE %.1f hPa = %s",P,tP) + if self.staticweather then + local clouds,visibility,fog,dust=self:_GetStaticWeather() + -- text=text..string.format("\nVisibility %.1f NM",UTILS.MetersToNM(visibility)) + -- text=text..string.format("\nCloud base %d ft",UTILS.MetersToFeet(clouds.base)) + -- text=text..string.format("\nCloud thickness %d ft",UTILS.MetersToFeet(clouds.thickness)) + -- text=text..string.format("\nCloud density %d",clouds.density) + -- text=text..string.format("\nPrecipitation %d",clouds.iprecptns) + text=text..string.format("\n可见度 %.1f NM",UTILS.MetersToNM(visibility)) + text=text..string.format("\n云底高 %d ft",UTILS.MetersToFeet(clouds.base)) + text=text..string.format("\n云层厚度 %d ft",UTILS.MetersToFeet(clouds.thickness)) + text=text..string.format("\n云层密度 %d",clouds.density) + text=text..string.format("\n结冰点 %d",clouds.iprecptns) + if fog then + -- text=text..string.format("\nFog thickness %d ft",UTILS.MetersToFeet(fog.thickness)) + -- text=text..string.format("\nFog visibility %d ft",UTILS.MetersToFeet(fog.visibility)) + text=text..string.format("\n雾厚度 %d ft",UTILS.MetersToFeet(fog.thickness)) + text=text..string.format("\n雾可见度 %d ft",UTILS.MetersToFeet(fog.visibility)) + else + -- text=text..string.format("\nNo fog") + text=text..string.format("\n无雾") + end + if dust then + -- text=text..string.format("\nDust density %d",dust) + text=text..string.format("\n沙尘密度 %d",dust) + else + -- text=text..string.format("\nNo dust") + text=text..string.format("\n无沙尘") + end + end + self:T2(self.lid..text) + self:MessageToPlayer(self.players[playername],text,nil,"",30,true) + else + self:E(self.lid..string.format("ERROR! Could not find player unit in CarrierWeather! Unit name = %s",_unitname)) + end + end + function AIRBOSS:_SetDifficulty(_unitname,difficulty) + self:T2({difficulty=difficulty,unitname=_unitname}) + local unit,playername=self:_GetPlayerUnitAndName(_unitname) + if unit and playername then + local playerData=self.players[playername] + if playerData then + playerData.difficulty=difficulty + -- local text=string.format("roger, your skill level is now: %s.",difficulty) + local text=string.format("收到, 你的熟练度现在是: %s.",difficulty) + self:MessageToPlayer(playerData,text,nil,playerData.name,5) + else + self:E(self.lid..string.format("ERROR: Could not get player data for player %s.",playername)) + end + if playerData.difficulty==AIRBOSS.Difficulty.HARD then + playerData.showhints=false + else + playerData.showhints=true + end + end + end + function AIRBOSS:_SetHintsOnOff(_unitname) + self:F2(_unitname) + local unit,playername=self:_GetPlayerUnitAndName(_unitname) + if unit and playername then + local playerData=self.players[playername] + if playerData then + playerData.showhints=not playerData.showhints + local text="" + if playerData.showhints==true then + -- text=string.format("roger, hints are now ON.") + text=string.format("好的, 提示已经开启.") + else + text=string.format("收到, 关闭提示.") + end + self:MessageToPlayer(playerData,text,nil,playerData.name,5) + end + end + end + function AIRBOSS:_DisplayAttitude(_unitname) + self:F2(_unitname) + local unit,playername=self:_GetPlayerUnitAndName(_unitname) + if unit and playername then + local playerData=self.players[playername] + if playerData then + playerData.attitudemonitor=not playerData.attitudemonitor + end + end + end + function AIRBOSS:_SubtitlesOnOff(_unitname) + self:F2(_unitname) + local unit,playername=self:_GetPlayerUnitAndName(_unitname) + if unit and playername then + local playerData=self.players[playername] + if playerData then + playerData.subtitles=not playerData.subtitles + local text="" + if playerData.subtitles==true then + -- text=string.format("roger, subtitiles are now ON.") + text=string.format("收到, 开启字幕.") + elseif playerData.subtitles==false then + text=string.format("收到, 关闭字幕.") + end + self:MessageToPlayer(playerData,text,nil,playerData.name,5) + end + end + end + function AIRBOSS:_TrapsheetOnOff(_unitname) + self:F2(_unitname) + local unit,playername=self:_GetPlayerUnitAndName(_unitname) + if unit and playername then + local playerData=self.players[playername] + if playerData then + local text="" + if self.trapsheet then + playerData.trapon=not playerData.trapon + if playerData.trapon==true then + -- text=string.format("roger, your trapsheets are now SAVED.") + text=string.format("收到, 你的降落报告已经保存.") + else + text=string.format("收到, 你的降落报告不会保存.") + end + else + -- text="negative, trap sheet data recorder is broken on this carrier." + text="不行, 现在不能保存降落报告." + end + self:MessageToPlayer(playerData,text,nil,playerData.name,5) + end + end + end + function AIRBOSS:_DisplayPlayerStatus(_unitName) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + local steptext=playerData.step + if playerData.step==AIRBOSS.PatternStep.HOLDING then + if playerData.holding==nil then + -- steptext="Transit to Marshal" + steptext="Transit to Marshal" + elseif playerData.holding==false then + steptext="Marshal (outside zone)" + elseif playerData.holding==true then + steptext="Marshal Stack Holding" + end + end + local stack=playerData.flag + local stacktext=nil + if stack>0 then + local stackalt=self:_GetMarshalAltitude(stack) + local angels=self:_GetAngels(stackalt) + -- stacktext=string.format("Marshal Stack %d, Angels %d\n",stack,angels) + stacktext=string.format("调度(Marshal Stack) %d, 高度 %d\n",stack,angels) + if playerData.step==AIRBOSS.PatternStep.HOLDING and playerData.case>1 then + local radial=self:GetRadial(playerData.case,true,true,true) + -- stacktext=stacktext..string.format("Select TACAN %03d°, %d DME\n",radial,angels+15) + stacktext=stacktext..string.format("设置 TACAN 航向%03d°, %d DME\n",radial,angels+15) + end + end + local fuel=playerData.unit:GetFuel()*100 + local fuelstate=self:_GetFuelState(playerData.unit) + local _,nunitsGround=self:_GetFlightUnits(playerData,true) + local _,nunitsAirborne=self:_GetFlightUnits(playerData,false) + -- local text=string.format("Status of player %s (%s)\n",playerData.name,playerData.callsign) + -- text=text..string.format("================================\n") + -- text=text..string.format("Step: %s\n",steptext) + local text=string.format("玩家数据 %s (%s)\n",playerData.name,playerData.callsign) + text=text..string.format("================================\n") + text=text..string.format("阶段: %s\n",steptext) + if stacktext then + text=text..stacktext + end + -- text=text..string.format("Recovery Case: %d\n",playerData.case) + -- text=text..string.format("Skill Level: %s\n",playerData.difficulty) + -- text=text..string.format("Modex: %s (%s)\n",playerData.onboard,self:_GetACNickname(playerData.actype)) + -- text=text..string.format("Fuel State: %.1f lbs/1000 (%.1f %%)\n",fuelstate/1000,fuel) + -- text=text..string.format("# units: %d (%d airborne)\n",nunitsGround,nunitsAirborne) + -- text=text..string.format("Section Lead: %s (%d/%d)",tostring(playerData.seclead),#playerData.section+1,self.NmaxSection+1) + text=text..string.format("Case: %d 回收\n",playerData.case) + text=text..string.format("S熟练度: %s\n",playerData.difficulty) + text=text..string.format("Modex: %s (%s)\n",playerData.onboard,self:_GetACNickname(playerData.actype)) + text=text..string.format("油量: %.1f lbs/1000 (%.1f %%)\n",fuelstate/1000,fuel) + text=text..string.format("# 小队队员: %d (%d 在空中)\n",nunitsGround,nunitsAirborne) + text=text..string.format("长机: %s (%d/%d)",tostring(playerData.seclead),#playerData.section+1,self.NmaxSection+1) + for _,_sec in pairs(playerData.section)do + local sec=_sec + text=text..string.format("\n- %s",sec.name) + end + if playerData.step==AIRBOSS.PatternStep.INITIAL then + local zoneinitial=self:GetCoordinate():Translate(UTILS.NMToMeters(3.5),self:GetRadial(2,false,false,false)) + local flyhdg=playerData.unit:GetCoordinate():HeadingTo(zoneinitial) + local flydist=UTILS.MetersToNM(playerData.unit:GetCoordinate():Get2DDistance(zoneinitial)) + local brc=self:GetBRC() + -- text=text..string.format("\nTo Initial: Fly heading %03d° for %.1f NM and turn to BRC %03d°",flyhdg,flydist,brc) + text=text..string.format("\n飞起始(Initial): 沿航向 %03d° 飞行 %.1f NM 然后转向至 BRC %03d°",flyhdg,flydist,brc) + elseif playerData.step==AIRBOSS.PatternStep.PLATFORM then + local zoneplatform=self:_GetZonePlatform(playerData.case):GetCoordinate() + local flyhdg=playerData.unit:GetCoordinate():HeadingTo(zoneplatform) + local flydist=UTILS.MetersToNM(playerData.unit:GetCoordinate():Get2DDistance(zoneplatform)) + local hdg=self:GetRadial(playerData.case,true,true,true) + -- text=text..string.format("\nTo Platform: Fly heading %03d° for %.1f NM and turn to %03d°",flyhdg,flydist,hdg) + text=text..string.format("\n飞平台(Platform): 沿航向 %03d° 飞行 %.1f NM 然后转向至 %03d°",flyhdg,flydist,hdg) + end + self:MessageToPlayer(playerData,text,nil,"",30,true) + else + self:E(self.lid..string.format("ERROR: playerData=nil. Unit name=%s, player name=%s",_unitName,_playername)) + end + else + self:E(self.lid..string.format("ERROR: could not find player for unit %s",_unitName)) + end + end + function AIRBOSS:_MarkMarshalZone(_unitName,flare) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + local stack=playerData.flag + local case=playerData.case + local text="" + if stack>0 then + local zoneHolding=self:_GetZoneHolding(case,stack) + local zoneThree=self:_GetZoneCommence(case,stack) + local patternalt=self:_GetMarshalAltitude(stack,case) + patternalt=5 + -- text="roger, marking" + text="收到, 正在标记区域" + if flare then + -- text=text..string.format("\n* Marshal zone stack %d with WHITE flares.",stack) + text=text..string.format("\n* 调度(Marshal)区域 队列 %d - 白色信号弹.",stack) + zoneHolding:FlareZone(FLARECOLOR.White,45,nil,patternalt) + -- text=text.."\n* Commence zone with RED flares." + text=text.."\n* 进近(Commence)区域 - 红色信号弹." + zoneThree:FlareZone(FLARECOLOR.Red,45,nil,patternalt) + else + -- text=text..string.format("\n* Marshal zone stack %d with WHITE smoke.",stack) + text=text..string.format("\n* 调度(Marshal)区域 队列 %d - 白色烟雾弹..",stack) + zoneHolding:SmokeZone(SMOKECOLOR.White,45,patternalt) + -- text=text.."\n* Commence zone with RED smoke." + text=text.."\n* 进近(Commence)区域 - 红色烟雾弹." + zoneThree:SmokeZone(SMOKECOLOR.Red,45,patternalt) + end + else + -- text="negative, you are currently not in a Marshal stack. No zones will be marked!" + text="无法执行, 你没有在调度(Marshal)队列中. 没有区域可标记!" + end + self:MessageToPlayer(playerData,text,"MARSHAL",playerData.name) + end + end + end + function AIRBOSS:_MarkCaseZones(_unitName,flare) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + local case=playerData.case + -- local text=string.format("affirm, marking CASE %d zones",case) + local text=string.format("收到, 标记 CASE %d 区域",case) + if flare then + if case==1 or case==2 then + -- text=text.."\n* initial with GREEN flares" + text=text.."\n* 起始阶段(initial) - 绿色信号弹" + self:_GetZoneInitial(case):FlareZone(FLARECOLOR.Green,45) + end + if case==2 or case==3 then + -- text=text.."\n* approach corridor with GREEN flares" + text=text.."\n* 进近下滑道 - 绿色信号弹" + self:_GetZoneCorridor(case):FlareZone(FLARECOLOR.Green,45) + end + if case==2 or case==3 then + -- text=text.."\n* platform with RED flares" + text=text.."\n* 平台(platform)区域 - 红色信号弹" + self:_GetZonePlatform(case):FlareZone(FLARECOLOR.Red,45) + end + if case==3 then + -- text=text.."\n* dirty up with YELLOW flares" + text=text.."\n* 构型开始区域 - 黄色信号弹" + self:_GetZoneDirtyUp(case):FlareZone(FLARECOLOR.Yellow,45) + end + if case==2 or case==3 then + if math.abs(self.holdingoffset)>0 then + self:_GetZoneArcIn(case):FlareZone(FLARECOLOR.White,45) + -- text=text.."\n* arc turn in with WHITE flares" + text=text.."\n* 一转三(前半段) - 白色信号弹" + self:_GetZoneArcOut(case):FlareZone(FLARECOLOR.White,45) + -- text=text.."\n* arc turn out with WHITE flares" + text=text.."\n* 一转三(后半段) - 白色信号弹" + end + end + if case==3 then + -- text=text.."\n* bullseye with GREEN flares" + text=text.."\n* bullseye - 绿色信号弹" + self:_GetZoneBullseye(case):FlareZone(FLARECOLOR.Green,45) + end + if self.carriertype==AIRBOSS.CarrierType.INVINCIBLE or self.carriertype==AIRBOSS.CarrierType.HERMES or self.carriertype==AIRBOSS.CarrierType.TARAWA or self.carriertype==AIRBOSS.CarrierType.AMERICA or self.carriertype==AIRBOSS.CarrierType.JCARLOS or self.carriertype==AIRBOSS.CarrierType.CANBERRA then + text=text.."\n* abeam landing stop with RED flares" + local ALSPT=self:_GetZoneAbeamLandingSpot() + ALSPT:FlareZone(FLARECOLOR.Red,5,nil,UTILS.FeetToMeters(110)) + text=text.."\n* primary landing spot with GREEN flares" + local LSPT=self:_GetZoneLandingSpot() + LSPT:FlareZone(FLARECOLOR.Green,5,nil,self.carrierparam.deckheight) + end + else + if case==1 or case==2 then + -- text=text.."\n* initial with GREEN smoke" + text=text.."\n* 起始阶段(initial) - 绿色信号弹" + self:_GetZoneInitial(case):SmokeZone(SMOKECOLOR.Green,45) + end + if case==2 or case==3 then + -- text=text.."\n* approach corridor with GREEN smoke" + text=text.."\n* 进近下滑道 - 绿色信号弹" + self:_GetZoneCorridor(case):SmokeZone(SMOKECOLOR.Green,45) + end + if case==2 or case==3 then + -- text=text.."\n* platform with RED smoke" + text=text.."\n* 平台(platform)区域 - 红色信号弹" + self:_GetZonePlatform(case):SmokeZone(SMOKECOLOR.Red,45) + end + if case==2 or case==3 then + if math.abs(self.holdingoffset)>0 then + self:_GetZoneArcIn(case):SmokeZone(SMOKECOLOR.Blue,45) + -- text=text.."\n* arc turn in with BLUE smoke" + text=text.."\n* 一转三(前半段) - 蓝色信号弹" + self:_GetZoneArcOut(case):SmokeZone(SMOKECOLOR.Blue,45) + -- text=text.."\n* arc turn out with BLUE smoke" + text=text.."\n* 一转三(后半段) - 蓝色信号弹" + end + end + if case==3 then + text=text.."\n* 构型开始区域 - 橙色信号弹" + self:_GetZoneDirtyUp(case):SmokeZone(SMOKECOLOR.Orange,45) + end + if case==3 then + text=text.."\n* bullseye with GREEN smoke" + self:_GetZoneBullseye(case):SmokeZone(SMOKECOLOR.Green,45) + end + end + self:MessageToPlayer(playerData,text,"MARSHAL",playerData.name) + end + end + end + function AIRBOSS:_LSORadioCheck(_unitName) + self:F(_unitName) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + self:RadioTransmission(self.LSORadio,self.LSOCall.RADIOCHECK,nil,nil,nil,true) + end + end + end + function AIRBOSS:_MarshalRadioCheck(_unitName) + self:F(_unitName) + local _unit,_playername=self:_GetPlayerUnitAndName(_unitName) + if _unit and _playername then + local playerData=self.players[_playername] + if playerData then + self:RadioTransmission(self.MarshalRadio,self.MarshalCall.RADIOCHECK,nil,nil,nil,true) + end + end + end + function AIRBOSS:_SaveTrapSheet(playerData,grade) + if playerData.trapsheet==nil or#playerData.trapsheet==0 or not io then + return + end + local function _savefile(filename,data) + local f=io.open(filename,"wb") + if f then + f:write(data) + f:close() + else + self:E(self.lid..string.format("ERROR: could not save trap sheet to file %s.\nFile may contain invalid characters.",tostring(filename))) + end + end + local path=self.trappath if lfs then - path = path or lfs.writedir() + path=path or lfs.writedir() end - - -- Set file name. - filename = filename or string.format( "AIRBOSS-%s_LSOgrades.csv", self.alias ) - - -- Set path. - if path ~= nil then - filename = path .. "\\" .. filename + local filename=nil + for i=1,9999 do + if self.trapprefix then + filename=string.format("%s_%s-%04d.csv",self.trapprefix,playerData.actype,i) + else + local name=UTILS.ReplaceIllegalCharacters(playerData.name,"_") + filename=string.format("AIRBOSS-%s_Trapsheet-%s_%s-%04d.csv",self.alias,name,playerData.actype,i) end - - -- Info message. - local text = string.format( "Loading player LSO grades from file %s", filename ) - MESSAGE:New( text, 10 ):ToAllIf( self.Debug ) - self:I( self.lid .. text ) - - -- Load asset data from file. - local data = _loadfile( filename ) - - -- Split by line break. - local playergrades = UTILS.Split( data, "\n" ) - - -- Remove first header line. - table.remove( playergrades, 1 ) - - -- Init player scores table. - self.playerscores = {} - - -- Loop over all lines. - local n = 0 - for _, gradeline in pairs( playergrades ) do - - -- Parameters are separated by commata. - local gradedata = UTILS.Split( gradeline, "," ) - - -- Debug info. - self:T2( gradedata ) - - -- Grade table - local grade = {} -- #AIRBOSS.LSOgrade - - --- Line format: - -- playername, i, grade.finalscore, grade.points, grade.grade, grade.details, wire, Tgroove, case, - -- time, wind, airframe, modex, carriertype, carriername, theatre, date - local playername = gradedata[1] - if gradedata[3] ~= nil and gradedata[3] ~= "n/a" then - grade.finalscore = tonumber( gradedata[3] ) - end - grade.points = tonumber( gradedata[4] ) - grade.grade = tostring( gradedata[5] ) - grade.details = tostring( gradedata[6] ) - if gradedata[7] ~= nil and gradedata[7] ~= "n/a" then - grade.wire = tonumber( gradedata[7] ) - end - if gradedata[8] ~= nil and gradedata[8] ~= "n/a" then - grade.Tgroove = tonumber( gradedata[8] ) - end - grade.case = tonumber( gradedata[9] ) - -- new - grade.wind = gradedata[10] or "n/a" - grade.modex = gradedata[11] or "n/a" - grade.airframe = gradedata[12] or "n/a" - grade.carriertype = gradedata[13] or "n/a" - grade.carriername = gradedata[14] or "n/a" - grade.theatre = gradedata[15] or "n/a" - grade.mitime = gradedata[16] or "n/a" - grade.midate = gradedata[17] or "n/a" - grade.osdate = gradedata[18] or "n/a" - - -- Init player table if necessary. - self.playerscores[playername] = self.playerscores[playername] or {} - - -- Add grade to table. - table.insert( self.playerscores[playername], grade ) - - n = n + 1 - - -- Debug info. - self:T2( { playername, self.playerscores[playername] } ) + if path~=nil then + filename=path.."\\"..filename end - - -- Info message. - local text = string.format( "Loaded %d player LSO grades from file %s", n, filename ) - self:I( self.lid .. text ) - -end - ---- On after "LSOGrade" event. --- @param #AIRBOSS self --- @param #string From From state. --- @param #string Event Event. --- @param #string To To state. --- @param #AIRBOSS.PlayerData playerData Player Data. --- @param #AIRBOSS.LSOgrade grade LSO grade. -function AIRBOSS:onafterLSOGrade(From, Event, To, playerData, grade) - + local _exists=UTILS.FileExists(filename) + if not _exists then + break + end + end + local text=string.format("Saving player %s trapsheet to file %s",playerData.name,filename) + self:I(self.lid..text) + local data="#Time,Rho,X,Z,Alt,AoA,GSE,LUE,Vtot,Vy,Gamma,Pitch,Roll,Yaw,Step,Grade,Points,Details\n" + local g0=playerData.trapsheet[1] + local T0=g0.Time + for i=1,#playerData.trapsheet do + local groove=playerData.trapsheet[i] + local t=groove.Time-T0 + local a=UTILS.MetersToNM(groove.Rho or 0) + local b=-groove.X or 0 + local c=groove.Z or 0 + local d=UTILS.MetersToFeet(groove.Alt or 0) + local e=groove.AoA or 0 + local f=groove.GSE or 0 + local g=-groove.LUE or 0 + local h=UTILS.MpsToKnots(groove.Vel or 0) + local i=(groove.Vy or 0)*196.85 + local j=groove.Gamma or 0 + local k=groove.Pitch or 0 + local l=groove.Roll or 0 + local m=groove.Yaw or 0 + local n=self:_GS(groove.Step,-1)or"n/a" + local o=groove.Grade or"n/a" + local p=groove.GradePoints or 0 + local q=groove.GradeDetail or"n/a" + data=data..string.format("%.2f,%.3f,%.1f,%.1f,%.1f,%.2f,%.2f,%.2f,%.1f,%.1f,%.1f,%.1f,%.1f,%.1f,%s,%s,%.1f,%s\n",t,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) + end + _savefile(filename,data) + end + function AIRBOSS:onbeforeSave(From,Event,To,path,filename) + if not io then + self:E(self.lid.."ERROR: io not desanitized. Can't save player grades.") + return false + end + if path==nil and not lfs then + self:E(self.lid.."WARNING: lfs not desanitized. Results will be saved in DCS installation root directory rather than your \"Saved Games\\DCS\" folder.") + end + return true + end + function AIRBOSS:onafterSave(From,Event,To,path,filename) + local function _savefile(filename,data) + local f=assert(io.open(filename,"wb")) + f:write(data) + f:close() + end + if lfs then + path=path or lfs.writedir() + end + filename=filename or string.format("AIRBOSS-%s_LSOgrades.csv",self.alias) + if path~=nil then + filename=path.."\\"..filename + end + local scores="Name,Pass,Points Final,Points Pass,Grade,Details,Wire,Tgroove,Case,Wind,Modex,Airframe,Carrier Type,Carrier Name,Theatre,Mission Time,Mission Date,OS Date\n" + local n=0 + for playername,grades in pairs(self.playerscores)do + for i,_grade in pairs(grades)do + local grade=_grade + local wire="n/a" + if grade.wire and grade.wire<=4 then + wire=tostring(grade.wire) + end + local Tgroove="n/a" + if grade.Tgroove and grade.Tgroove<=360 and grade.case<3 then + Tgroove=tostring(UTILS.Round(grade.Tgroove,1)) + end + local finalscore="n/a" + if grade.finalscore then + finalscore=tostring(UTILS.Round(grade.finalscore,1)) + end + scores=scores..string.format("%s,%d,%s,%.1f,%s,%s,%s,%s,%d,%s,%s,%s,%s,%s,%s,%s,%s,%s\n",playername,i,finalscore,grade.points,grade.grade,grade.details,wire,Tgroove,grade.case,grade.wind,grade.modex,grade.airframe,grade.carriertype,grade.carriername,grade.theatre,grade.mitime,grade.midate,grade.osdate) + n=n+1 + end + end + local text=string.format("Saving %d player LSO grades to file %s",n,filename) + self:I(self.lid..text) + _savefile(filename,scores) + end + function AIRBOSS:onbeforeLoad(From,Event,To,path,filename) + local function _fileexists(name) + local f=io.open(name,"r") + if f~=nil then + io.close(f) + return true + else + return false + end + end + if not io then + self:E(self.lid.."WARNING: io not desanitized. Can't load player grades.") + return false + end + if path==nil and not lfs then + self:E(self.lid.."WARNING: lfs not desanitized. Results will be saved in DCS installation root directory rather than your \"Saved Games\\DCS\" folder.") + end + if lfs then + path=path or lfs.writedir() + end + filename=filename or string.format("AIRBOSS-%s_LSOgrades.csv",self.alias) + if path~=nil then + filename=path.."\\"..filename + end + local exists=_fileexists(filename) + if exists then + return true + else + self:E(self.lid..string.format("WARNING: Player LSO grades file %s does not exist.",filename)) + return false + end + end + function AIRBOSS:onafterLoad(From,Event,To,path,filename) + local function _loadfile(filename) + local f=assert(io.open(filename,"rb")) + local data=f:read("*all") + f:close() + return data + end + if lfs then + path=path or lfs.writedir() + end + filename=filename or string.format("AIRBOSS-%s_LSOgrades.csv",self.alias) + if path~=nil then + filename=path.."\\"..filename + end + local text=string.format("Loading player LSO grades from file %s",filename) + MESSAGE:New(text,10):ToAllIf(self.Debug) + self:I(self.lid..text) + local data=_loadfile(filename) + local playergrades=UTILS.Split(data,"\n") + table.remove(playergrades,1) + self.playerscores={} + local n=0 + for _,gradeline in pairs(playergrades)do + local gradedata=UTILS.Split(gradeline,",") + self:T2(gradedata) + local grade={} + local playername=gradedata[1] + if gradedata[3]~=nil and gradedata[3]~="n/a"then + grade.finalscore=tonumber(gradedata[3]) + end + grade.points=tonumber(gradedata[4]) + grade.grade=tostring(gradedata[5]) + grade.details=tostring(gradedata[6]) + if gradedata[7]~=nil and gradedata[7]~="n/a"then + grade.wire=tonumber(gradedata[7]) + end + if gradedata[8]~=nil and gradedata[8]~="n/a"then + grade.Tgroove=tonumber(gradedata[8]) + end + grade.case=tonumber(gradedata[9]) + grade.wind=gradedata[10]or"n/a" + grade.modex=gradedata[11]or"n/a" + grade.airframe=gradedata[12]or"n/a" + grade.carriertype=gradedata[13]or"n/a" + grade.carriername=gradedata[14]or"n/a" + grade.theatre=gradedata[15]or"n/a" + grade.mitime=gradedata[16]or"n/a" + grade.midate=gradedata[17]or"n/a" + grade.osdate=gradedata[18]or"n/a" + self.playerscores[playername]=self.playerscores[playername]or{} + table.insert(self.playerscores[playername],grade) + n=n+1 + self:T2({playername,self.playerscores[playername]}) + end + local text=string.format("Loaded %d player LSO grades from file %s",n,filename) + self:I(self.lid..text) + end + function AIRBOSS:onafterLSOGrade(From,Event,To,playerData,grade) if self.funkmanSocket then - - -- Extract used info for FunkMan. We need to be careful with the amount of data send via UDP socket. - local trapsheet={} ; trapsheet.X={} ; trapsheet.Z={} ; trapsheet.AoA={} ; trapsheet.Alt={} - - -- Loop over trapsheet and extract used values. - for i = 1, #playerData.trapsheet do - local ts=playerData.trapsheet[i] --#AIRBOSS.GrooveData - table.insert(trapsheet.X, UTILS.Round(ts.X, 1)) - table.insert(trapsheet.Z, UTILS.Round(ts.Z, 1)) - table.insert(trapsheet.AoA, UTILS.Round(ts.AoA, 2)) - table.insert(trapsheet.Alt, UTILS.Round(ts.Alt, 1)) - end - - local result={} - result.command=SOCKET.DataType.LSOGRADE - result.name=playerData.name - result.trapsheet=trapsheet - result.airframe=grade.airframe - result.mitime=grade.mitime - result.midate=grade.midate - result.wind=grade.wind - result.carriertype=grade.carriertype - result.carriername=grade.carriername - result.carrierrwy=grade.carrierrwy - result.landingdist=self.carrierparam.landingdist - result.theatre=grade.theatre - result.case=playerData.case - result.Tgroove=grade.Tgroove - result.wire=grade.wire - result.grade=grade.grade - result.points=grade.points - result.details=grade.details - - -- Debug info. - self:T(self.lid.."Result onafterLSOGrade") - self:T(result) - - -- Send result. - self.funkmanSocket:SendTable(result) + local trapsheet={};trapsheet.X={};trapsheet.Z={};trapsheet.AoA={};trapsheet.Alt={} + for i=1,#playerData.trapsheet do + local ts=playerData.trapsheet[i] + table.insert(trapsheet.X,UTILS.Round(ts.X,1)) + table.insert(trapsheet.Z,UTILS.Round(ts.Z,1)) + table.insert(trapsheet.AoA,UTILS.Round(ts.AoA,2)) + table.insert(trapsheet.Alt,UTILS.Round(ts.Alt,1)) + end + local result={} + result.command=SOCKET.DataType.LSOGRADE + result.name=playerData.name + result.trapsheet=trapsheet + result.airframe=grade.airframe + result.mitime=grade.mitime + result.midate=grade.midate + result.wind=grade.wind + result.carriertype=grade.carriertype + result.carriername=grade.carriername + result.carrierrwy=grade.carrierrwy + result.landingdist=self.carrierparam.landingdist + result.theatre=grade.theatre + result.case=playerData.case + result.Tgroove=grade.Tgroove + result.wire=grade.wire + result.grade=grade.grade + result.points=grade.points + result.details=grade.details + self:T(self.lid.."Result onafterLSOGrade") + self:T(result) + self.funkmanSocket:SendTable(result) + end end - -end - ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/Scripts/Mission_Init.lua b/Scripts/Mission_Init.lua index 5684eb5..33549c2 100644 --- a/Scripts/Mission_Init.lua +++ b/Scripts/Mission_Init.lua @@ -3,7 +3,8 @@ local script_list = -- Load order must be correct -- "mist.lua", --mist_4_5_122 "Moose_.lua", - "spawnListener.lua", + -- "spawnListener.lua", + -- "Airboss[EN].lua", "Airboss[CN].lua", } diff --git a/Scripts/spawnListener.lua b/Scripts/spawnListener.lua index 4e06151..2ed462e 100644 --- a/Scripts/spawnListener.lua +++ b/Scripts/spawnListener.lua @@ -16,4 +16,11 @@ do world.addEventHandler(ev) + + -- USS Arleigh Burke lla-1 + local base = Airbase.getByName('USS Arleigh Burke lla-1') + if base then + local typeName = base:getTypeName() or 'None' + trigger.action.outText(typeName,10) + end end \ No newline at end of file