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", F14A="F-14A-135-GR", F14B="F-14B", F14A_AI="F-14A", FA18C="F/A-18C", T45C="T-45", S3B="S-3B", S3BTANKER="S-3B Tanker", E2D="E-2C", C2A="C2A_Greyhound", RHINOE="FA-18E", RHINOF="FA-18F", GROWLER="EA-18G", } 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 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() self.playerscores={} self:_InitWaypoints() self.currentwp=1 self:_PatrolRoute() self:SetMarshalRadio() self:SetAirbossRadio() self:SetLSORadio() self:SetLSOCallInterval() self.radiotimer=SCHEDULER:New() self:SetMagneticDeclination() self:SetICLS() self:SetTACAN() self:SetBeaconRefresh() self:SetMaxLandingPattern() self:SetMaxMarshalStacks() self:SetMaxSectionSize() self:SetMaxFlightsPerStack() self:SetHandleAION() self:SetExtraVoiceOvers(false) self:SetExtraVoiceOversAI(false) self:SetAirbossNiceGuy() self:SetEmergencyLandings() self:SetDespawnOnEngineShutdown(false) self:SetRespawnAI(false) self:SetStaticWeather() self:SetRecoveryCase() self:SetRecoveryTurnTime() self:SetHoldingOffsetAngle() self:SetMarshalRadius() self:SetInitialMaxAlt() self:SetDefaultPlayerSkill(AIRBOSS.Difficulty.EASY) self:SetGlideslopeErrorThresholds() self:SetLineupErrorThresholds() self:SetCarrierControlledArea() self:SetCarrierControlledZone() self:SetPatrolAdInfinitum(true) self:SetCollisionDistance() self:SetQueueUpdateTime() self:SetStatusUpdateTime() self:SetDefaultMessageDuration() self:SetMenuMarkZones() self:SetMenuSmokeZones() 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 end self:_InitVoiceOvers() if false then self.Debug=true BASE:TraceOnOff(true) BASE:TraceClass(self.ClassName) BASE:TraceLevel(3) end 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) end if false then 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 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 function AIRBOSS:SetWelcomePlayers(Switch) self.welcome=Switch return self 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 function AIRBOSS:SetCarrierControlledZone(Radius) Radius=UTILS.NMToMeters(Radius or 5) self.zoneCCZ=ZONE_UNIT:New("Carrier Controlled Zone",self.carrier,Radius) return self end function AIRBOSS:SetCollisionDistance(Distance) self.collisiondist=UTILS.NMToMeters(Distance or 5) return self end function AIRBOSS:SetRecoveryCase(Case) self.defaultcase=Case or 1 self.case=self.defaultcase return self end function AIRBOSS:SetHoldingOffsetAngle(Offset) self.defaultoffset=Offset or 0 self.holdingoffset=self.defaultoffset return self 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 else self.skipperUturn=false end return self end 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 if stoptime and type(stoptime)=="number"then stoptime=UTILS.SecondsToClock(Tnow+stoptime) end 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 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 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 end table.insert(self.recoverytimes,recovery) return recovery end function AIRBOSS:SetSquadronAI(SetGroup) self.squadsetAI=SetGroup return self end function AIRBOSS:SetExcludeAI(SetGroup) self.excludesetAI=SetGroup return self end function AIRBOSS:AddExcludeAI(Group) self.excludesetAI=self.excludesetAI or SET_GROUP:New() self.excludesetAI:AddGroup(Group) return 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 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 function AIRBOSS:GetRecoveryWindowByID(id) if id then 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 function AIRBOSS:DeleteRecoveryWindow(Window,Delay) if Delay and Delay>0 then self:ScheduleOnce(Delay,self.DeleteRecoveryWindow,self,Window) else 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 function AIRBOSS:SetEmergencyLandings(Switch) if Switch==true or Switch==nil then self.emergency=true else self.emergency=false end return self end function AIRBOSS:SetDespawnOnEngineShutdown(Switch) if Switch==true or Switch==nil then self.despawnshutdown=true else self.despawnshutdown=false end return self end function AIRBOSS:SetRespawnAI(Switch) if Switch==true or Switch==nil then self.respawnAI=true else self.respawnAI=false end return self end function AIRBOSS:SetRefuelAI(LowFuelThreshold) self.lowfuelAI=LowFuelThreshold or 10 return self end function AIRBOSS:SetInitialMaxAlt(MaxAltitude) self.initialmaxalt=UTILS.FeetToMeters(MaxAltitude or 1300) return self end function AIRBOSS:SetSoundfilesFolder(FolderPath) if FolderPath then local lastchar=string.sub(FolderPath,-1) if lastchar~="/"then FolderPath=FolderPath.."/" end end self.soundfolder=FolderPath self:I(self.lid..string.format("Setting sound files folder to: %s",self.soundfolder)) return self end function AIRBOSS:SetStatusUpdateTime(TimeInterval) self.dTstatus=TimeInterval or 0.5 return self end function AIRBOSS:SetDefaultMessageDuration(Duration) self.Tmessage=Duration or 10 return self 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 end return self 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 end return self end function AIRBOSS:SetMarshalRadius(Radius) self.marshalradius=UTILS.NMToMeters(Radius or 2.8) return self end function AIRBOSS:SetMenuSingleCarrier(Switch) if Switch==true or Switch==nil then self.menusingle=true else self.menusingle=false end return self end function AIRBOSS:SetMenuMarkZones(Switch) if Switch==nil or Switch==true then self.menumarkzones=true else self.menumarkzones=false end return self end function AIRBOSS:SetMenuSmokeZones(Switch) if Switch==nil or Switch==true then self.menusmokezones=true else self.menusmokezones=false end return self end function AIRBOSS:SetTrapSheet(Path,Prefix) if io then self.trapsheet=true self.trappath=Path self.trapprefix=Prefix else self:E(self.lid.."ERROR: io is not desanitized. Cannot save trap sheet.") end return self end function AIRBOSS:SetStaticWeather(Switch) if Switch==nil or Switch==true then self.staticweather=true else self.staticweather=false end return self end function AIRBOSS:SetTACANoff() self.TACANon=false return self 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 function AIRBOSS:SetICLSoff() self.ICLSon=false return self end function AIRBOSS:SetICLS(Channel,MorseCode) self.ICLSchannel=Channel or 1 self.ICLSmorse=MorseCode or"STN" self.ICLSon=true return self end function AIRBOSS:SetBeaconRefresh(TimeInterval) self.dTbeacon=TimeInterval or(20*60) return self 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:SetGender(Gender or"male") self.SRS:SetPath(PathToSRS) self.SRS:SetPort(Port or 5002) self.SRS:SetLabel(self.AirbossRadio.alias or"AIRBOSS") self.SRS:SetCoordinate(self.carrier:GetCoordinate()) self.SRS:SetVolume(Volume or 1) if GoogleCreds then self.SRS:SetProviderOptionsGoogle(GoogleCreds,GoogleCreds) self.SRS:SetProvider(MSRS.Provider.GOOGLE) end if Voice then self.SRS:SetVoice(Voice) end self.SRS:SetVolume(Volume or 1.0) self.SRSQ=MSRSQUEUE:New("AIRBOSS") self.SRSQ:SetTransmitOnlyWithPlayers(true) if not self.PilotRadio then self:SetSRSPilotVoice() end 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 end 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 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={} 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 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 self.MarshalModu=radio.modulation.AM end 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 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 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 function AIRBOSS:SetMaxMarshalStacks(nmax) self.Nmaxmarshal=nmax or 3 self.Nmaxmarshal=math.max(self.Nmaxmarshal,1) return self 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 function AIRBOSS:SetMaxFlightsPerStack(nmax) nmax=nmax or 2 nmax=math.max(nmax,1) nmax=math.min(nmax,4) self.NmaxStack=nmax return self end function AIRBOSS:SetHandleAION() self.handleai=true return self end function AIRBOSS:SetExtraVoiceOvers(status) self.xtVoiceOvers=status return self end function AIRBOSS:SetExtraVoiceOversAI(status) self.xtVoiceOversAI=status return self end 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))) end return self end function AIRBOSS:SetAutoSave(path,filename) self.autosave=true self.autosavepath=path self.autosavefile=filename return self end function AIRBOSS:SetDebugModeON() self.Debug=true return self end function AIRBOSS:SetPatrolAdInfinitum(switch) if switch==false then self.adinfinitum=false else self.adinfinitum=true end return self end function AIRBOSS:SetMagneticDeclination(declination) self.magvar=declination or UTILS.GetMagneticDeclination() return self end function AIRBOSS:SetDebugModeOFF() self.Debug=false return self end function AIRBOSS:SetFunkManOn(Port,Host) self.funkmanSocket=SOCKET:New(Port,Host) return self 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 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) end 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) end 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() 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 self:_CheckRecoveryTimes() 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 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 local collision=false local holdtime=0 if self.holdtimestamp then holdtime=timer.getTime()-self.holdtimestamp end 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) self:CarrierResumeRoute(coord) self.holdtimestamp=nil end 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 if i==0 then text=text.." none" end self:T(self.lid..text) if collision then if self.turnintowind then self:CarrierResumeRoute(self.Creturnto) if self:IsRecovering()and self.recoverywindow and self.recoverywindow.WIND then self.recoverywindow.WIND=false end end end self:_CheckRecoveryTimes() 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 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.") self:_MarshalCallRecoveryPausedNotice() end end function AIRBOSS:onafterRecoveryUnpause(From,Event,To) self:T(self.lid..string.format("Unpausing aircraft recovery.")) self:_MarshalCallResumeRecovery() 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 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() 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() 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() 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 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() 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 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() 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 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() 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 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() 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 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:_InitCanberra() self:_InitJcarlos() end function AIRBOSS:SetVoiceOversMarshalByGabriella(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 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.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.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}, } 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}, } 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}, } self:SetVoiceOversLSOByRaynor() self:SetVoiceOversMarshalByRaynor() 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 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 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 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 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 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 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 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 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 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 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) 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 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 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 if flight.step~=AIRBOSS.PatternStep.COMMENCING then return flight end end end end end return nil end function AIRBOSS:_CheckQueue() if self.Debug then 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 local Template=group:GetTemplate() Template.route.points=wp group=group:Respawn(Template,true) end group:WayPointInitialize(wp) group:Route(wp,1) end 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 if flight.group:GetCoordinate()==nil then self:E(self.lid.."ERROR: cannot get coordinate of flight group.") return end 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 local p1 local p2 altitude,p1,p2=self:_GetMarshalAltitude(nstack,case) local wp={} if not flight.holding then 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 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 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) end if respawn then local Template=group:GetTemplate() Template.route.points=wp flight.group=group:Respawn(Template,true) end 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 end local text="" if self.tanker and refuelac then 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 local divertfield=self:GetCoordinate():GetClosestAirbase(Airbase.Category.AIRDROME,self:GetCoalition()) if divertfield==nil then divertfield=self:GetCoordinate():GetClosestAirbase(Airbase.Category.AIRDROME,0) end 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 end 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 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 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 local altitude=UTILS.FeetToMeters((nstack+angels0)*1000) p1:SetAltitude(altitude,true) p2:SetAltitude(altitude,true) return altitude,p1,p2 end function AIRBOSS:_GetCharlieTime(flightgroup) local stack=flightgroup.flag if stack<=0 then return nil end local Tnow=timer.getAbsTime() local Tcharlie=0 local Trecovery=0 if self.recoverywindow then Trecovery=math.max(self.recoverywindow.START-Tnow,0) else Trecovery=7*60 end 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 if mstack==1 then local tholding=timer.getAbsTime()-flight.time Tholding=math.max(3*60-tholding,0) end 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 local onboard=flight.onboardnumbers[flight.seclead] flight.onboard=onboard else flight.onboard=self:_GetOnboardNumberPlayer(group) end 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 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 playerData.difficulty=playerData.difficulty or self.defaultskill if playerData.subtitles==nil then playerData.subtitles=true end if playerData.showhints==nil then if playerData.difficulty==AIRBOSS.Difficulty.HARD then playerData.showhints=false else playerData.showhints=true end end 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 end return playerData end return nil end 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 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 self:T("WARNING: Flight element could not be removed from flight group. Index=nil!") return nil end end 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 end return false end 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 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 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 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 self:_PlayerHint(playerData) self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.ARCOUT) end end function AIRBOSS:_ArcOutTurn(playerData) self:_CheckCorridor(playerData) local inzone=playerData.unit:IsInZone(self:_GetZoneArcOut(playerData.case)) if inzone then self:_PlayerHint(playerData) local nextstep if playerData.case==3 then nextstep=AIRBOSS.PatternStep.DIRTYUP else nextstep=AIRBOSS.PatternStep.INITIAL end 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 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 self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.BULLSEYE) end end 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 self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.GROOVE_XX) end end 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 self:_SetPlayerStep(playerData,nextstep) end end 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 if self:_CheckLimits(X,Z,self.BreakEntry)then self:_PlayerHint(playerData) self:_SetPlayerStep(playerData,AIRBOSS.PatternStep.EARLYBREAK) end end 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 if self:_CheckAbort(X,Z,breakpoint)then self:_AbortPattern(playerData,X,Z,breakpoint,true) return end 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 Z90 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=X=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 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 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 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 if playerData and fouldeck then -- 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 function AIRBOSS:_GetSternCoord() local hdg=self.carrier:GetHeading() local FB=self:GetFinalBearing() local case=self.case 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 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 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 self.sterncoord:Translate(self.carrierparam.sterndist,hdg,true,true):Translate(9.5,FB+90,true,true) end self.sterncoord:SetAltitude(self.carrierparam.deckheight) return self.sterncoord 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 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 wire=%d (dc=%.1f)",Ldist,Ldist-dc,wire,dc)) return wire end 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 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 self:ScheduleOnce(0.1,self._Trapped,self,playerData) return end if self.Debug then coord:SmokeBlue() coord:MarkToAll(text) stern:MarkToAll("Stern") end 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 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 playerData.step=AIRBOSS.PatternStep.DEBRIEF playerData.warning=nil end 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 self.zoneInitial:UpdateFromVec2(vec2) return self.zoneInitial end 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 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 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 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) 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 self.zoneHolding=ZONE_RADIUS:New("CASE I Holding Zone",self.carrier:GetVec2(),UTILS.NMToMeters(5)) end else 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 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 function AIRBOSS:GetHeading(magnetic) self:F3({magnetic=magnetic}) local hdg=self.carrier:GetHeading() if magnetic then hdg=hdg-self.magvar end if hdg<0 then hdg=hdg+360 end return hdg end 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 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 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 if magnetic then intowind=intowind-self.magvar end if intowind<0 then intowind=intowind+360 end 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 local windfrom,vwind=self:GetWind(18,nil,coord) local Vmin=4 local Vmax=UTILS.KmphToKnots(self.carrier:GetSpeedMax()) if vwind<0.1 then local h=self:GetHeading(magnetic) return h,math.min(vdeck,Vmax) end vwind=UTILS.MpsToKnots(vwind) local windto=(windfrom+180)%360 local alpha=math.rad(-Offset) 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 local theta=0 if vdeck>vdeckMax then v=Vmax theta=math.asin(v/(vwind*C))-math.asin(-1/C) elseif vdeckvwind then theta=math.pi/2 v=math.sqrt(vdeck^2-vwind^2) else theta=math.asin(vdeck*math.sin(alpha)/vwind) v=vdeck*math.cos(alpha)-vwind*math.cos(theta) end 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 function AIRBOSS:GetRadial(case,magnetic,offset,inverse) case=case or self.case local radial 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 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 if inverse then radial=radial-180 if radial<0 then radial=radial+360 end end return radial 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 function AIRBOSS:_GetRelativeHeading(unit,runway) local vC=self.carrier:GetOrientationX() if runway then vC=UTILS.Rotate2D(vC,-self.carrierparam.rwyangle) end local vP=unit:GetOrientationX() vC.y=0; vP.y=0 local rhdg=UTILS.VecAngle(vC,vP) return rhdg end 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 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 glideslopeErrorself.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 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=76 then grade="SLOW V/STOL Groove" else grade="LIG" end if t>=16.4 and t<=16.6 then grade="_OK_" end if playerData.actype==AIRBOSS.AircraftCarrier.AV8B and(t>=60.0 and t<=65.0)then grade="_OK_ V/STOL" end return grade end 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 local G=GXX.." "..GIM.." ".." "..GIC.." "..GAR local N=nXX+nIM+nIC+nAR local nL=count(G,'_')/2 local nS=count(G,'%(') local nN=N-nS-nL 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 grade local points if N==0 and(TgrooveUnicorn or TgrooveVstolUnicorn or playerData.case==3)then grade="_OK_" points=5.0 G="Unicorn" else 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 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" local text="LSO 打分:\n" text=text..G.."\n" text=text.."成绩 = "..grade.." 得分 = "..points.."\n" text=text.."# 的总偏移相对于 = "..N.."\n" text=text.."# 的较大偏移相对于 _ = "..nL.."\n" text=text.."# 的偏移相对于 = "..nN.."\n" text=text.."# 的较小偏移相对于 ( = "..nS.."\n" self:T2(self.lid..text) if playerData.wop then 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 if playerData.landed then grade="CUT" points=0.0 else grade="WOFD" points=-1.0 end G="n/a" elseif playerData.owo then grade="OWO" points=2.0 if N==0 then G="n/a" end elseif playerData.waveoff then if playerData.landed then grade="CUT" points=0.0 else grade="WO" points=1.0 end elseif playerData.boltered then 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 end return grade,points,G end function AIRBOSS:_Flightdata2Text(playerData,groovestep) local function little(text) return string.format("(%s)",text) end local function underline(text) return string.format("_%s_",text) end local fdata=playerData.groove[groovestep] if fdata==nil then self:T3(self.lid.."Flight data is nil.") return"",0 end 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 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 LUEpos.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 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 if xtext and ztext then -- text=text..xtext.." and "..ztext text=text..xtext.." 而且 "..ztext elseif xtext then text=text..xtext elseif ztext then text=text..ztext end -- 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 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 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 function AIRBOSS:_PlayerHint(playerData,delay,soundoff) if not playerData.showhints then return end 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 end if hintAoA and hintAoA~=""then hint=hint.."\n"..hintAoA end if hintDist and hintDist~=""then hint=hint.."\n"..hintDist end local debrief="" if debriefAlt and debriefAlt~=""then debrief=debrief.."\n- "..debriefAlt end if debriefSpeed and debriefSpeed~=""then debrief=debrief.."\n- "..debriefSpeed end if debriefAoA and debriefAoA~=""then debrief=debrief.."\n- "..debriefAoA end if debriefDist and debriefDist~=""then debrief=debrief.."\n- "..debriefDist end if debrief~=""then self:_AddToDebrief(playerData,debrief) end 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 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 -- hint=hint..string.format("\nTurn %s and select TACAN %03d°.",turn,radial) hint=hint..string.format("\n%s转 设置TACAN航线 %03d°.",turn,radial) end 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=hint.."\nDirty up! Hook, gear and flaps down." hint=hint.."\nDirty up! 放下尾钩、起落架以及襟翼." end end end 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=hint..string.format("\nIntercept glideslope.") hint=hint..string.format("\nn截获下滑道.") end end end 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=hint.."\nDirty up! Gear DOWN, flaps DOWN. Check hook down." hint=hint.."\n开始构型! 放轮, 放襟翼. 检查尾勾放出." end end 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 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. ") 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)) hint=hint..string.format("最佳高度是 %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)) local debrief=string.format("高度 %d ft = %d%% 偏移量相对于 %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. " 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 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)) hint=hint..string.format("最佳 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)) local debrief=string.format("AoA %.1f = %d%% 偏移量相对于 %.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. ") hint=string.format("速度好. ") end 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 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)) local debrief=string.format("Speed %d knots = %d%% 偏移量相对于 %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("你离航母稍微有点远.") else -- hint=string.format("Good distance to the boat.") hint=string.format("离航母距离刚好.") end if playerData.difficulty==AIRBOSS.Difficulty.EASY then -- 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 hint="" elseif playerData.difficulty==AIRBOSS.Difficulty.HARD then hint="" end -- 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%% 偏移量相对于 %.1f NM.",UTILS.MetersToNM(distance),_error,UTILS.MetersToNM(optdist)) return hint,debrief,nil end 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)) self:F(self.lid..string.format("玩家总结 %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 Points=points end 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" if os then mygrade.osdate=os.date() end playerData.grade=mygrade if playerData.trapon and self.trapsheet then self:_SaveTrapSheet(playerData,mygrade) end 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 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 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 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 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 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 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 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 if playerData.unit:InAir()then playerData.step=AIRBOSS.PatternStep.BOLTER end elseif playerData.landed then if not playerData.unit:InAir()then self:Sound2Player(playerData,self.LSORadio,self.LSOCall.WELCOMEABOARD) end else -- self:MessageToPlayer(playerData,"Undefined state after landing! Please report.","ERROR",nil,20) self:MessageToPlayer(playerData,"未被定义的着陆后状态! 请联系服务器管理员汇报错误.","ERROR",nil,20) playerData.step=AIRBOSS.PatternStep.UNDEFINED end if playerData.landed and not playerData.unit:InAir()then self:_RecoveredElement(playerData.unit) self:_CheckSectionRecovered(playerData) end 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) end end function AIRBOSS:_CheckCollisionCoord(coordto,coordfrom) local dx=100 local d=0 if coordfrom then d=0 else d=250 coordfrom=self:GetCoordinate():Translate(d,self:GetHeading()) end 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 local st=cp:GetSurfaceType() cp:MarkToAll(string.format("Collision check surface type %d",st)) end 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) 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 Csoo=Cv:Translate(1200,hdg-90):Translate(1000,hiw) local hsw=self:GetHeadingIntoWind(vdeck,false,Csoo) Ctiw=Csoo:Translate(dist,hsw) end self.Creturnto=self:GetCoordinate() local nextwp=self:_GetNextWaypoint() local vdownwind=UTILS.MpsToKnots(nextwp:GetVelocity()) if vdownwind<1 then vdownwind=10 end self:CarrierDetour(Ctiw,speedknots,uturn,vdownwind,Csoo) self.turnintowind=true return self end function AIRBOSS:_GetNextWaypoint() local Nextwp=nil if self.currentwp==#self.waypoints then Nextwp=1 else 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 end return self end 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 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 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 local FB=self:GetFinalBearing(true) self:_MarshalCallNewFinalBearing(FB) end if turning and not self.turning then 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 hdg=hdg-self.magvar if hdg<0 then hdg=360+hdg end self:_MarshalCallCarrierTurnTo(hdg) end 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 if Hchange or Dchange then for _,_flight in pairs(self.Qmarshal)do local flight=_flight if flight.ai then self:_MarshalAI(flight,flight.flag) end 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)) end 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 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 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 local wp1=gotocoord:WaypointGround(speedkmh) table.insert(waypoints,wp1) end 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) end if flight then flight.holding=true flight.time=timer.getAbsTime() end 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 airboss:_MarshalAI(flight,stack) else if not airboss:_InQueue(airboss.Qwaiting,flight.group)then airboss:_WaitAI(flight) end end 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 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={} if template then 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 end return numbers end 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 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 else return false end end 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) local text=string.format("Marshal, %s, 相对航母 %d 距离 %d, 高度 %d, 油量 %.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) local text=string.format("%s, 开始进近",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.") local text=string.format("油量低! 前往加油机加油.") 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) local text=string.format("油量低! 去备降机场加油 %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) local text=string.format("Case %d 回收作业停止. 甲板关闭.",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) local text=string.format("航空器回收作业暂停, 预计重启时间为 %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) local text=string.format("你已准许进行 Case %d 回收.",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) local text=string.format("新的最终航向(FB) %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) local text=string.format("航母现在开始转向航向 %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. ") local text=string.format("调度队列已满. 请在 10 NM 区域外等待进一步指示. ") 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("在你前面还有 %d 队飞机.",nwaiting) else text=text..string.format("下一个就轮到你了.") 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) 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) 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) local text=string.format("Case %d 回收, 预期 BRC %03d°, 保持高度 %d. 预计 Charlie 时间 %s. 大气压 %.2f. 目视后报.",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.." 暂无数据." 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() end 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 if path~=nil then filename=path.."\\"..filename end 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 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 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ _SETTINGS:SetPlayerMenuOff() -- Set rescue helo takeoff on USS Arleigh Burke rescueHelo_Roosevelt = RESCUEHELO:New('USS Theodore Roosevelt','RescueHelo Roosevelt') rescueHelo_Roosevelt:SetHomeBase('USS Arleigh Burke lla-1') rescueHelo_Roosevelt:SetUseUncontrolledAircraft() rescueHelo_Roosevelt:SetTakeoffCold() rescueHelo_Roosevelt:SetAltitude(100) rescueHelo_Roosevelt:SetOffsetZ(50) rescueHelo_Roosevelt:__Start(1) -- Set Recovery tanker RecoveryTanker_Roosevelt = RECOVERYTANKER:New("USS Theodore Roosevelt", "Texcao Group") RecoveryTanker_Roosevelt:SetUseUncontrolledAircraft() RecoveryTanker_Roosevelt:SetAltitude(8000) RecoveryTanker_Roosevelt:SetRadio(250) RecoveryTanker_Roosevelt:SetModex(511) RecoveryTanker_Roosevelt:SetTACAN(2, "TEX") RecoveryTanker_Roosevelt:__Start(2) -- E-2D awacs_Roosevelt spawning on CVN-71 Roosevelt. awacs_Roosevelt=RECOVERYTANKER:New("USS Theodore Roosevelt", "awacs_Roosevelt") awacs_Roosevelt:SetUseUncontrolledAircraft() awacs_Roosevelt:SetAWACS() awacs_Roosevelt:SetTakeoffCold() awacs_Roosevelt:SetRadio(251) awacs_Roosevelt:SetAltitude(20000) awacs_Roosevelt:SetCallsign(CALLSIGN.AWACS.Wizard) awacs_Roosevelt:SetRacetrackDistances(30, 15) awacs_Roosevelt:SetModex(611) awacs_Roosevelt:SetTACAN(3, "WIZ") awacs_Roosevelt:__Start(1) -- Create AIRBOSS object. AirbossRoosevelt = AIRBOSS:New('USS Theodore Roosevelt','Roosevelt') AirbossRoosevelt:SetMenuSingleCarrier() AirbossRoosevelt:Load() -- AirbossRoosevelt:SetAutoSave() -- -- Add recovery windows: -- -- Case I from 9 to 10 am. AirbossRoosevelt:AddRecoveryWindow( "9:00", "21:00", 1, nil, true, 25) -- AirbossRoosevelt:AddRecoveryWindow( "10:05", "11:05", 1, nil, true, 25) -- AirbossRoosevelt:AddRecoveryWindow( "11:10", "12:10", 1, nil, true, 25) -- Set Init Channels -- TACAN AirbossRoosevelt:SetTACAN(71, "X", "RSV") -- Set folder of airboss sound files within miz file. AirbossRoosevelt:SetSoundfilesFolder("Airboss Soundfiles/") --not strictly following the rules AirbossRoosevelt:SetAirbossNiceGuy() --Set CCA to 50NM AirbossRoosevelt:SetCarrierControlledArea() --Allow emergency landings AirbossRoosevelt:SetEmergencyLandings() AirbossRoosevelt:SetMenuRecovery() AirbossRoosevelt:SetDespawnOnEngineShutdown() --Will play the inbound calls, commencing, initial, etc. AirbossRoosevelt:SetExtraVoiceOvers(true) --Set AI inbound call AirbossRoosevelt:SetExtraVoiceOversAI() -- Set handle AI On AirbossRoosevelt:SetHandleAION() AirbossRoosevelt:SetPatrolAdInfinitum() AirbossRoosevelt:Start() --- Function called when recovery tanker is started. function RecoveryTanker_Roosevelt:OnAfterStart(From,Event,To) -- Set recovery tanker. AirbossRoosevelt:SetRecoveryTanker(RecoveryTanker_Roosevelt) -- Use tanker as radio relay unit for LSO transmissions. AirbossRoosevelt:SetRadioRelayLSO(self:GetUnitName()) end --- Function called when AWACS is started. function awacs_Roosevelt:OnAfterStart(From,Event,To) -- Set AWACS. AirbossRoosevelt:SetRecoveryTanker(awacs_Roosevelt) end --- Function called when rescue helo is started. function rescueHelo_Roosevelt:OnAfterStart(From,Event,To) -- Use rescue helo as radio relay for Marshal. AirbossRoosevelt:SetRadioRelayMarshal(self:GetUnitName()) end