mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Ops
- Airboss optimizations WIP
This commit is contained in:
@@ -821,7 +821,7 @@ function AIRWING:onafterStatus(From, Event, To)
|
||||
-- Assets tot
|
||||
local Npq, Np, Nq=self:CountAssetsOnMission()
|
||||
|
||||
local assets=string.format("%d [Mission=%d (Active=%d, Queued=%d)]", self:CountAssets(), Npq, Np, Nq)
|
||||
local assets=string.format("%d (OnMission: Total=%d, Active=%d, Queued=%d)", self:CountAssets(), Npq, Np, Nq)
|
||||
|
||||
-- Output.
|
||||
local text=string.format("%s: Missions=%d, Payloads=%d (%d), Squads=%d, Assets=%s", fsmstate, Nmissions, Npayloads, #self.payloads, #self.squadrons, assets)
|
||||
@@ -836,7 +836,7 @@ function AIRWING:onafterStatus(From, Event, To)
|
||||
for i,_mission in pairs(self.missionqueue) do
|
||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||
|
||||
local prio=string.format("%d/%d", mission.prio, mission.importance) ; if mission.urgent then prio=prio.." (!)" end
|
||||
local prio=string.format("%d/%s", mission.prio, tostring(mission.importance)) ; if mission.urgent then prio=prio.." (!)" end
|
||||
local assets=string.format("%d/%d", mission:CountOpsGroups(), mission.nassets)
|
||||
local target=string.format("%d/%d Damage=%.1f", mission:CountMissionTargets(), mission:GetTargetInitialNumber(), mission:GetTargetDamage())
|
||||
|
||||
@@ -1030,7 +1030,9 @@ function AIRWING:CheckRescuhelo()
|
||||
|
||||
local N=self:CountMissionsInQueue({AUFTRAG.Type.RESCUEHELO})
|
||||
|
||||
local carrier=UNIT:FindByName(self.airbase:GetName())
|
||||
local name=self.airbase:GetName()
|
||||
|
||||
local carrier=UNIT:FindByName(name)
|
||||
|
||||
for i=1,self.nflightsRescueHelo-N do
|
||||
|
||||
@@ -1127,7 +1129,7 @@ function AIRWING:_GetNextMission()
|
||||
local vip=math.huge
|
||||
for _,_mission in pairs(self.missionqueue) do
|
||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||
if mission.importance<vip then
|
||||
if mission.importance and mission.importance<vip then
|
||||
vip=mission.importance
|
||||
end
|
||||
end
|
||||
@@ -1140,7 +1142,7 @@ function AIRWING:_GetNextMission()
|
||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||
|
||||
-- Firstly, check if mission is due?
|
||||
if mission:IsQueued() and mission:IsReadyToGo() and mission.importance<=vip then
|
||||
if mission:IsQueued() and mission:IsReadyToGo() and (mission.importance==nil or mission.importance<=vip) then
|
||||
|
||||
-- Check if airwing can do the mission and gather required assets.
|
||||
local can, assets=self:CanMission(mission)
|
||||
@@ -1571,8 +1573,6 @@ function AIRWING:onafterAssetSpawned(From, Event, To, group, asset, request)
|
||||
-- Create a flight group.
|
||||
local flightgroup=self:_CreateFlightGroup(asset)
|
||||
|
||||
-- Set home base.
|
||||
flightgroup.homebase=self.airbase
|
||||
|
||||
---
|
||||
-- Asset
|
||||
@@ -1765,7 +1765,11 @@ function AIRWING:_CreateFlightGroup(asset)
|
||||
-- Set airwing.
|
||||
flightgroup:SetAirwing(self)
|
||||
|
||||
-- Set squadron.
|
||||
flightgroup.squadron=self:GetSquadronOfAsset(asset)
|
||||
|
||||
-- Set home base.
|
||||
flightgroup.homebase=self.airbase
|
||||
|
||||
--[[
|
||||
|
||||
|
||||
@@ -260,7 +260,7 @@
|
||||
--
|
||||
-- That being said, this script allows you to use any of the three cases to be used at any time. Or, in other words, *you* need to specify when which case is safe and appropriate.
|
||||
--
|
||||
-- This is a lot of responsability. *You* are the boss, but *you* need to make the right decisions or things will go terribly wrong!
|
||||
-- This is a lot of responsibility. *You* are the boss, but *you* need to make the right decisions or things will go terribly wrong!
|
||||
--
|
||||
-- Recovery windows can be set up via the @{#AIRBOSS.AddRecoveryWindow} function as explained below. With this it is possible to seamlessly (within reason!) switch recovery cases in the same mission.
|
||||
--
|
||||
@@ -287,7 +287,7 @@
|
||||
--
|
||||
-- 
|
||||
--
|
||||
-- Once the aircraft reaches the Inital, the landing pattern begins. The important steps of the pattern are shown in the image above.
|
||||
-- Once the aircraft reaches the Initial, the landing pattern begins. The important steps of the pattern are shown in the image above.
|
||||
--
|
||||
--
|
||||
-- ## CASE III
|
||||
@@ -1931,6 +1931,11 @@ function AIRBOSS:New(carriername, alias)
|
||||
|
||||
-- Welcome players.
|
||||
self:SetWelcomePlayers(true)
|
||||
|
||||
-- Coordinates
|
||||
self.landingcoord=COORDINATE:New(0,0,0) --Core.Point#COORDINATE
|
||||
self.sterncoord=COORDINATE:New(0, 0, 0) --Core.Point#COORDINATE
|
||||
self.landingspotcoord=COORDINATE:New(0,0,0) --Core.Point#COORDINATE
|
||||
|
||||
-- Init carrier parameters.
|
||||
if self.carriertype==AIRBOSS.CarrierType.STENNIS then
|
||||
@@ -3391,19 +3396,12 @@ end
|
||||
-- @param #string To To state.
|
||||
function AIRBOSS:onafterStatus(From, Event, To)
|
||||
|
||||
if true then
|
||||
--env.info("FF Status ==> return")
|
||||
--return
|
||||
end
|
||||
|
||||
-- Get current time.
|
||||
local time=timer.getTime()
|
||||
|
||||
-- Update marshal and pattern queue every 30 seconds.
|
||||
if time-self.Tqueue>self.dTqueue then
|
||||
|
||||
--collectgarbage()
|
||||
|
||||
-- Get time.
|
||||
local clock=UTILS.SecondsToClock(timer.getAbsTime())
|
||||
local eta=UTILS.SecondsToClock(self:_GetETAatNextWP())
|
||||
@@ -3414,7 +3412,7 @@ function AIRBOSS:onafterStatus(From, Event, To)
|
||||
local speed=self.carrier:GetVelocityKNOTS()
|
||||
|
||||
-- Check water is ahead.
|
||||
local collision=self:_CheckCollisionCoord(pos:Translate(self.collisiondist, hdg))
|
||||
local collision=false --self:_CheckCollisionCoord(pos:Translate(self.collisiondist, hdg))
|
||||
|
||||
local holdtime=0
|
||||
if self.holdtimestamp then
|
||||
@@ -3470,15 +3468,9 @@ function AIRBOSS:onafterStatus(From, Event, To)
|
||||
-- Disable turn into the wind for this window so that we do not do this all over again.
|
||||
self.recoverywindow.WIND=false
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
-- Find path around the obstacle.
|
||||
if not self.detour then
|
||||
--self:_Pathfinder()
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -10287,24 +10279,25 @@ function AIRBOSS:_GetSternCoord()
|
||||
local FB=self:GetFinalBearing()
|
||||
|
||||
-- Stern coordinate (sterndist<0). Also translate 10 meters starboard wrt Final bearing.
|
||||
local stern=self:GetCoordinate()
|
||||
self.sterncoord:UpdateFromCoordinate(self:GetCoordinate())
|
||||
--local stern=self:GetCoordinate()
|
||||
|
||||
-- Stern coordinate (sterndist<0).
|
||||
if self.carriertype==AIRBOSS.CarrierType.TARAWA then
|
||||
-- Tarawa: Translate 8 meters port.
|
||||
stern=stern:Translate(self.carrierparam.sterndist, hdg):Translate(8, FB-90)
|
||||
self.sterncoord:Translate(self.carrierparam.sterndist, hdg, true, true):Translate(8, FB-90, true, true)
|
||||
elseif self.carriertype==AIRBOSS.CarrierType.STENNIS then
|
||||
-- Stennis: translate 7 meters starboard wrt Final bearing.
|
||||
stern=stern:Translate(self.carrierparam.sterndist, hdg):Translate(7, FB+90)
|
||||
self.sterncoord:Translate(self.carrierparam.sterndist, hdg, true, true):Translate(7, FB+90, true, true)
|
||||
else
|
||||
-- Nimitz SC: translate 8 meters starboard wrt Final bearing.
|
||||
stern=stern:Translate(self.carrierparam.sterndist, hdg):Translate(8.5, FB+90)
|
||||
self.sterncoord:Translate(self.carrierparam.sterndist, hdg, true, true):Translate(8.5, FB+90, true, true)
|
||||
end
|
||||
|
||||
-- Set altitude.
|
||||
stern:SetAltitude(self.carrierparam.deckheight)
|
||||
self.sterncoord:SetAltitude(self.carrierparam.deckheight)
|
||||
|
||||
return stern
|
||||
return self.sterncoord
|
||||
end
|
||||
|
||||
--- Get wire from landing position.
|
||||
@@ -11339,9 +11332,12 @@ end
|
||||
-- @param #AIRBOSS self
|
||||
-- @return Core.Point#COORDINATE Optimal landing coordinate.
|
||||
function AIRBOSS:_GetOptLandingCoordinate()
|
||||
|
||||
-- Start with stern coordiante.
|
||||
self.landingcoord:UpdateFromCoordinate(self:_GetSternCoord())
|
||||
|
||||
-- Stern coordinate.
|
||||
local stern=self:_GetSternCoord()
|
||||
--local stern=self:_GetSternCoord()
|
||||
|
||||
-- Final bearing.
|
||||
local FB=self:GetFinalBearing(false)
|
||||
@@ -11349,10 +11345,11 @@ function AIRBOSS:_GetOptLandingCoordinate()
|
||||
if self.carriertype==AIRBOSS.CarrierType.TARAWA then
|
||||
|
||||
-- Landing 100 ft abeam, 120 ft alt.
|
||||
stern=self:_GetLandingSpotCoordinate():Translate(35, FB-90)
|
||||
self.landingcoord:UpdateFromCoordinate(self:_GetLandingSpotCoordinate()):Translate(35, FB-90, true, true)
|
||||
--stern=self:_GetLandingSpotCoordinate():Translate(35, FB-90)
|
||||
|
||||
-- Alitude 120 ft.
|
||||
stern:SetAltitude(UTILS.FeetToMeters(120))
|
||||
self.landingcoord:SetAltitude(UTILS.FeetToMeters(120))
|
||||
|
||||
else
|
||||
|
||||
@@ -11360,15 +11357,15 @@ function AIRBOSS:_GetOptLandingCoordinate()
|
||||
if self.carrierparam.wire3 then
|
||||
-- We take the position of the 3rd wire to approximately account for the length of the aircraft.
|
||||
local w3=self.carrierparam.wire3
|
||||
stern=stern:Translate(w3, FB, true)
|
||||
self.landingcoord:Translate(w3, FB, true, true)
|
||||
end
|
||||
|
||||
-- Add 2 meters to account for aircraft height.
|
||||
stern.y=stern.y+2
|
||||
self.landingcoord.y=self.landingcoord.y+2
|
||||
|
||||
end
|
||||
|
||||
return stern
|
||||
return self.landingcoord
|
||||
end
|
||||
|
||||
--- Get landing spot on Tarawa.
|
||||
@@ -11376,8 +11373,10 @@ end
|
||||
-- @return Core.Point#COORDINATE Primary landing spot coordinate.
|
||||
function AIRBOSS:_GetLandingSpotCoordinate()
|
||||
|
||||
self.landingspotcoord:UpdateFromCoordinate(self:_GetSternCoord())
|
||||
|
||||
-- Stern coordinate.
|
||||
local stern=self:_GetSternCoord()
|
||||
--local stern=self:_GetSternCoord()
|
||||
|
||||
if self.carriertype==AIRBOSS.CarrierType.TARAWA then
|
||||
|
||||
@@ -11385,11 +11384,11 @@ function AIRBOSS:_GetLandingSpotCoordinate()
|
||||
local hdg=self:GetHeading()
|
||||
|
||||
-- Primary landing spot 7.5
|
||||
stern=stern:Translate(57, hdg):SetAltitude(self.carrierparam.deckheight)
|
||||
self.landingspotcoord:Translate(57, hdg, true, true):SetAltitude(self.carrierparam.deckheight)
|
||||
|
||||
end
|
||||
|
||||
return stern
|
||||
return self.landingspotcoord
|
||||
end
|
||||
|
||||
--- Get true (or magnetic) heading of carrier.
|
||||
@@ -14333,7 +14332,7 @@ end
|
||||
-- @param #AIRBOSS self
|
||||
-- @return Core.Point#COORDINATE Carrier coordinate.
|
||||
function AIRBOSS:GetCoordinate()
|
||||
return self.carrier:GetCoordinate()
|
||||
return self.carrier:GetCoord()
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -1096,7 +1096,9 @@ function AUFTRAG:NewRESCUEHELO(Carrier)
|
||||
|
||||
local mission=AUFTRAG:New(AUFTRAG.Type.RESCUEHELO)
|
||||
|
||||
self.carrier=Carrier
|
||||
--mission.carrier=Carrier
|
||||
|
||||
mission:_TargetFromObject(Carrier)
|
||||
|
||||
-- Mission options:
|
||||
mission.missionTask=ENUMS.MissionTask.NOTHING
|
||||
@@ -1412,12 +1414,12 @@ end
|
||||
-- @param #AUFTRAG self
|
||||
-- @param #number Prio Priority 1=high, 100=low. Default 50.
|
||||
-- @param #boolean Urgent If *true*, another running mission might be cancelled if it has a lower priority.
|
||||
-- @param #number Importance Number 1-10. If missions with lower value are in the queue, these have to be finished first. Default is 5.
|
||||
-- @param #number Importance Number 1-10. If missions with lower value are in the queue, these have to be finished first. Default is `nil`.
|
||||
-- @return #AUFTRAG self
|
||||
function AUFTRAG:SetPriority(Prio, Urgent, Importance)
|
||||
self.prio=Prio or 50
|
||||
self.urgent=Urgent
|
||||
self.importance=Importance or 5
|
||||
self.importance=Importance
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -1665,6 +1667,47 @@ function AUFTRAG:SetICLS(Channel, Morse, UnitName)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Get mission type.
|
||||
-- @param #AUFTRAG self
|
||||
-- @return #string Mission type, e.g. "BAI".
|
||||
function AUFTRAG:GetType()
|
||||
return self.type
|
||||
end
|
||||
|
||||
--- Get mission name.
|
||||
-- @param #AUFTRAG self
|
||||
-- @return #string Mission name, e.g. "Auftrag Nr.1".
|
||||
function AUFTRAG:GetName()
|
||||
return self.name
|
||||
end
|
||||
|
||||
--- Get number of required assets.
|
||||
-- @param #AUFTRAG self
|
||||
-- @return #number Numer of required assets.
|
||||
function AUFTRAG:GetNumberOfRequiredAssets()
|
||||
return self.nassets
|
||||
end
|
||||
|
||||
--- Get mission priority.
|
||||
-- @param #AUFTRAG self
|
||||
-- @return #number Priority. Smaller is higher.
|
||||
function AUFTRAG:GetPriority()
|
||||
return self.prio
|
||||
end
|
||||
|
||||
--- Check if mission is "urgent".
|
||||
-- @param #AUFTRAG self
|
||||
-- @return #boolean If `true`, mission is "urgent".
|
||||
function AUFTRAG:IsUrgent()
|
||||
return self.urgent
|
||||
end
|
||||
|
||||
--- Get mission importance.
|
||||
-- @param #AUFTRAG self
|
||||
-- @return #number Importance. Smaller is higher.
|
||||
function AUFTRAG:GetImportance()
|
||||
return self.importance
|
||||
end
|
||||
|
||||
--- Add start condition.
|
||||
-- @param #AUFTRAG self
|
||||
@@ -2599,7 +2642,7 @@ function AUFTRAG:onafterSuccess(From, Event, To)
|
||||
self.status=AUFTRAG.Status.SUCCESS
|
||||
self:T(self.lid..string.format("New mission status=%s", self.status))
|
||||
|
||||
local repeatme=self.repeatedFailure<self.NrepeatFailure or self.repeated<self.Nrepeat
|
||||
local repeatme=self.repeatedSuccess<self.NrepeatSuccess or self.repeated<self.Nrepeat
|
||||
|
||||
if repeatme then
|
||||
|
||||
@@ -3291,7 +3334,7 @@ function AUFTRAG:GetDCSMissionTask(TaskControllable)
|
||||
|
||||
-- We create a "fake" DCS task and pass the parameters to the FLIGHTGROUP.
|
||||
local param={}
|
||||
param.unitname=self.carrier:GetName()
|
||||
param.unitname=self:GetTargetName() --self.carrier:GetName()
|
||||
param.offsetX=200
|
||||
param.offsetZ=240
|
||||
param.altitude=70
|
||||
|
||||
@@ -890,7 +890,7 @@ end
|
||||
-- @param Core.Event#EVENTDATA EventData Event data.
|
||||
function FLIGHTGROUP:OnEventBirth(EventData)
|
||||
|
||||
env.info(string.format("EVENT: Birth for unit %s", tostring(EventData.IniUnitName)))
|
||||
--env.info(string.format("EVENT: Birth for unit %s", tostring(EventData.IniUnitName)))
|
||||
|
||||
-- Check that this is the right group.
|
||||
if EventData and EventData.IniGroup and EventData.IniUnit and EventData.IniGroupName and EventData.IniGroupName==self.groupname then
|
||||
|
||||
@@ -1791,7 +1791,7 @@ function OPSGROUP:_GetNextMission()
|
||||
local vip=math.huge
|
||||
for _,_mission in pairs(self.missionqueue) do
|
||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||
if mission.importance<vip then
|
||||
if mission.importance and mission.importance<vip then
|
||||
vip=mission.importance
|
||||
end
|
||||
end
|
||||
@@ -1800,7 +1800,7 @@ function OPSGROUP:_GetNextMission()
|
||||
for _,_mission in pairs(self.missionqueue) do
|
||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||
|
||||
if mission:GetGroupStatus(self)==AUFTRAG.Status.SCHEDULED and (mission:IsReadyToGo() or self.airwing) and mission.importance<=vip then
|
||||
if mission:GetGroupStatus(self)==AUFTRAG.Status.SCHEDULED and (mission:IsReadyToGo() or self.airwing) and (mission.importance==nil or mission.importance<=vip) then
|
||||
return mission
|
||||
end
|
||||
end
|
||||
|
||||
@@ -437,6 +437,13 @@ function SQUADRON:DelAsset(Asset)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Get name of the squadron
|
||||
-- @param #SQUADRON self
|
||||
-- @return #sting Name of the squadron.
|
||||
function SQUADRON:GetName()
|
||||
return self.name
|
||||
end
|
||||
|
||||
--- Get radio frequency and modulation.
|
||||
-- @param #SQUADRON self
|
||||
-- @return #number Radio frequency in MHz.
|
||||
@@ -850,7 +857,7 @@ function SQUADRON:RecruitAssets(Mission, Npayloads)
|
||||
if Mission.type==AUFTRAG.Type.INTERCEPT then
|
||||
combatready=flightgroup:CanAirToAir()
|
||||
else
|
||||
local excludeguns=Mission.type==AUFTRAG.Type.BOMBING or Mission.type==AUFTRAG.Type.BOMBRUNWAY or Mission.type==AUFTRAG.Type.BOMBCARPET
|
||||
local excludeguns=Mission.type==AUFTRAG.Type.BOMBING or Mission.type==AUFTRAG.Type.BOMBRUNWAY or Mission.type==AUFTRAG.Type.BOMBCARPET or Mission.type==AUFTRAG.Type.SEAD or Mission.type==AUFTRAG.Type.ANTISHIP
|
||||
combatready=flightgroup:CanAirToGround(excludeguns)
|
||||
end
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ TARGET.ObjectStatus={
|
||||
-- @field #number ID Target unique ID.
|
||||
-- @field #string Name Target name.
|
||||
-- @field #string Type Target type.
|
||||
-- @field Wrapper.Positionable#POSITIONABLE Object.
|
||||
-- @field Wrapper.Positionable#POSITIONABLE Object The object, which can be many things, e.g. a UNIT, GROUP, STATIC, AIRBASE or COORDINATE object.
|
||||
-- @field #number Life Life points on last status update.
|
||||
-- @field #number Life0 Life points of completely healthy target.
|
||||
-- @field #string Status Status "Alive" or "Dead".
|
||||
@@ -137,10 +137,18 @@ function TARGET:New(TargetObject)
|
||||
-- Add object.
|
||||
self:AddObject(TargetObject)
|
||||
|
||||
-- Get first target.
|
||||
local Target=self.targets[1] --#TARGET.Object
|
||||
|
||||
if not Target then
|
||||
self:E(self.lid.."ERROR: No valid TARGET!")
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Target Name.
|
||||
self.name=self:GetTargetName(Target)
|
||||
|
||||
-- Target category.
|
||||
self.category=self:GetTargetCategory(Target)
|
||||
|
||||
-- Log ID.
|
||||
@@ -681,6 +689,7 @@ function TARGET:GetTargetVec3(Target)
|
||||
|
||||
end
|
||||
|
||||
self:E(self.lid.."ERROR: Unknown TARGET type! Cannot get Vec3")
|
||||
end
|
||||
|
||||
|
||||
@@ -780,6 +789,7 @@ function TARGET:GetCoordinate()
|
||||
|
||||
end
|
||||
|
||||
self:E(self.lid..string.format("ERROR: Cannot get coordinate of target %s", self.name))
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user