mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
OPS
This commit is contained in:
parent
d64de26ded
commit
1a53f58540
@ -2647,6 +2647,25 @@ function WAREHOUSE:_CheckParkingValid(spot)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Check parking ID for an asset.
|
||||||
|
-- @param #WAREHOUSE self
|
||||||
|
-- @param Wrapper.Airbase#AIRBASE.ParkingSpot spot Parking spot.
|
||||||
|
-- @return #boolean If true, parking is valid.
|
||||||
|
function WAREHOUSE:_CheckParkingAsset(spot, asset)
|
||||||
|
|
||||||
|
if asset.parkingIDs==nil then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
for _,id in pairs(asset.parkingIDs or {}) do
|
||||||
|
if spot.TerminalID==id then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Enable auto save of warehouse assets at mission end event.
|
--- Enable auto save of warehouse assets at mission end event.
|
||||||
-- @param #WAREHOUSE self
|
-- @param #WAREHOUSE self
|
||||||
@ -7848,7 +7867,7 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets)
|
|||||||
local parkingspot=_parkingspot --Wrapper.Airbase#AIRBASE.ParkingSpot
|
local parkingspot=_parkingspot --Wrapper.Airbase#AIRBASE.ParkingSpot
|
||||||
|
|
||||||
-- Check correct terminal type for asset. We don't want helos in shelters etc.
|
-- Check correct terminal type for asset. We don't want helos in shelters etc.
|
||||||
if AIRBASE._CheckTerminalType(parkingspot.TerminalType, terminaltype) and self:_CheckParkingValid(parkingspot) and airbase:_CheckParkingLists(parkingspot.TerminalID) then
|
if AIRBASE._CheckTerminalType(parkingspot.TerminalType, terminaltype) and self:_CheckParkingValid(parkingspot) and self:_CheckParkingAsset(parkingspot, asset) and airbase:_CheckParkingLists(parkingspot.TerminalID) then
|
||||||
|
|
||||||
-- Coordinate of the parking spot.
|
-- Coordinate of the parking spot.
|
||||||
local _spot=parkingspot.Coordinate -- Core.Point#COORDINATE
|
local _spot=parkingspot.Coordinate -- Core.Point#COORDINATE
|
||||||
|
|||||||
@ -155,7 +155,7 @@ AIRWING = {
|
|||||||
|
|
||||||
--- AIRWING class version.
|
--- AIRWING class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
AIRWING.version="0.6.0"
|
AIRWING.version="0.7.0"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- ToDo list
|
-- ToDo list
|
||||||
@ -745,6 +745,11 @@ end
|
|||||||
-- @return #AIRWING.PatrolData Patrol point table.
|
-- @return #AIRWING.PatrolData Patrol point table.
|
||||||
function AIRWING:NewPatrolPoint(Type, Coordinate, Altitude, Speed, Heading, LegLength, RefuelSystem)
|
function AIRWING:NewPatrolPoint(Type, Coordinate, Altitude, Speed, Heading, LegLength, RefuelSystem)
|
||||||
|
|
||||||
|
-- Check if a zone was passed instead of a coordinate.
|
||||||
|
if Coordinate:IsInstanceOf("ZONE_BASE") then
|
||||||
|
Coordinate=Coordinate:GetCoordinate()
|
||||||
|
end
|
||||||
|
|
||||||
local patrolpoint={} --#AIRWING.PatrolData
|
local patrolpoint={} --#AIRWING.PatrolData
|
||||||
patrolpoint.type=Type or "Unknown"
|
patrolpoint.type=Type or "Unknown"
|
||||||
patrolpoint.coord=Coordinate or self:GetCoordinate():Translate(UTILS.NMToMeters(math.random(10, 15)), math.random(360))
|
patrolpoint.coord=Coordinate or self:GetCoordinate():Translate(UTILS.NMToMeters(math.random(10, 15)), math.random(360))
|
||||||
@ -994,7 +999,7 @@ function AIRWING:CheckTANKER()
|
|||||||
for _,_mission in pairs(self.missionqueue) do
|
for _,_mission in pairs(self.missionqueue) do
|
||||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||||
|
|
||||||
if mission:IsNotOver() and mission.type==AUFTRAG.Type.TANKER then
|
if mission:IsNotOver() and mission.type==AUFTRAG.Type.TANKER and mission.patroldata then
|
||||||
if mission.refuelSystem==Unit.RefuelingSystem.BOOM_AND_RECEPTACLE then
|
if mission.refuelSystem==Unit.RefuelingSystem.BOOM_AND_RECEPTACLE then
|
||||||
Nboom=Nboom+1
|
Nboom=Nboom+1
|
||||||
elseif mission.refuelSystem==Unit.RefuelingSystem.PROBE_AND_DROGUE then
|
elseif mission.refuelSystem==Unit.RefuelingSystem.PROBE_AND_DROGUE then
|
||||||
@ -1567,6 +1572,9 @@ function AIRWING:onafterNewAsset(From, Event, To, asset, assignment)
|
|||||||
-- Set takeoff type.
|
-- Set takeoff type.
|
||||||
asset.takeoffType=squad.takeoffType
|
asset.takeoffType=squad.takeoffType
|
||||||
|
|
||||||
|
-- Set parking IDs.
|
||||||
|
asset.parkingIDs=squad.parkingIDs
|
||||||
|
|
||||||
-- Create callsign and modex (needs to be after grouping).
|
-- Create callsign and modex (needs to be after grouping).
|
||||||
squad:GetCallsign(asset)
|
squad:GetCallsign(asset)
|
||||||
squad:GetModex(asset)
|
squad:GetModex(asset)
|
||||||
@ -2032,6 +2040,23 @@ function AIRWING:CountAssets()
|
|||||||
return N
|
return N
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Count total number of assets that are in the warehouse stock (not spawned).
|
||||||
|
-- @param #AIRWING self
|
||||||
|
-- @param #table MissionTypes (Optional) Count only assest that can perform certain mission type(s). Default is all types.
|
||||||
|
-- @return #number Amount of asset groups in stock.
|
||||||
|
function AIRWING:CountAssetsInStock(MissionTypes)
|
||||||
|
|
||||||
|
local N=0
|
||||||
|
|
||||||
|
for _,_squad in pairs(self.squadrons) do
|
||||||
|
local squad=_squad --Ops.Squadron#SQUADRON
|
||||||
|
N=N+squad:CountAssetsInStock(MissionTypes)
|
||||||
|
end
|
||||||
|
|
||||||
|
return N
|
||||||
|
end
|
||||||
|
|
||||||
--- Count assets on mission.
|
--- Count assets on mission.
|
||||||
-- @param #AIRWING self
|
-- @param #AIRWING self
|
||||||
-- @param #table MissionTypes Types on mission to be checked. Default all.
|
-- @param #table MissionTypes Types on mission to be checked. Default all.
|
||||||
|
|||||||
@ -3601,36 +3601,39 @@ function AIRBOSS:_CheckAIStatus()
|
|||||||
-- Unit
|
-- Unit
|
||||||
local unit=element.unit
|
local unit=element.unit
|
||||||
|
|
||||||
-- Get lineup and distance to carrier.
|
if unit and unit:IsAlive() then
|
||||||
local lineup=self:_Lineup(unit, true)
|
|
||||||
|
|
||||||
local unitcoord=unit:GetCoord()
|
-- Get lineup and distance to carrier.
|
||||||
|
local lineup=self:_Lineup(unit, true)
|
||||||
|
|
||||||
local dist=unitcoord:Get2DDistance(self:GetCoord())
|
local unitcoord=unit:GetCoord()
|
||||||
|
|
||||||
-- Distance in NM.
|
local dist=unitcoord:Get2DDistance(self:GetCoord())
|
||||||
local distance=UTILS.MetersToNM(dist)
|
|
||||||
|
|
||||||
-- Altitude in ft.
|
-- Distance in NM.
|
||||||
local alt=UTILS.MetersToFeet(unitcoord.y)
|
local distance=UTILS.MetersToNM(dist)
|
||||||
|
|
||||||
-- Check if parameters are right and flight is in the groove.
|
-- Altitude in ft.
|
||||||
if lineup<2 and distance<=0.75 and alt<500 and not element.ballcall then
|
local alt=UTILS.MetersToFeet(unitcoord.y)
|
||||||
|
|
||||||
-- Paddles: Call the ball!
|
-- Check if parameters are right and flight is in the groove.
|
||||||
self:RadioTransmission(self.LSORadio, self.LSOCall.CALLTHEBALL, nil, nil, nil, true)
|
if lineup<2 and distance<=0.75 and alt<500 and not element.ballcall then
|
||||||
|
|
||||||
-- Pilot: "405, Hornet Ball, 3.2"
|
-- Paddles: Call the ball!
|
||||||
self:_LSOCallAircraftBall(element.onboard,self:_GetACNickname(unit:GetTypeName()), self:_GetFuelState(unit)/1000)
|
self:RadioTransmission(self.LSORadio, self.LSOCall.CALLTHEBALL, nil, nil, nil, true)
|
||||||
|
|
||||||
-- Paddles: Roger ball after 0.5 seconds.
|
-- Pilot: "405, Hornet Ball, 3.2"
|
||||||
self:RadioTransmission(self.LSORadio, self.LSOCall.ROGERBALL, nil, nil, 0.5, true)
|
self:_LSOCallAircraftBall(element.onboard,self:_GetACNickname(unit:GetTypeName()), self:_GetFuelState(unit)/1000)
|
||||||
|
|
||||||
-- Flight element called the ball.
|
-- Paddles: Roger ball after 0.5 seconds.
|
||||||
element.ballcall=true
|
self:RadioTransmission(self.LSORadio, self.LSOCall.ROGERBALL, nil, nil, 0.5, true)
|
||||||
|
|
||||||
-- This is for the whole flight. Maybe we need it.
|
-- Flight element called the ball.
|
||||||
flight.ballcall=true
|
element.ballcall=true
|
||||||
|
|
||||||
|
-- This is for the whole flight. Maybe we need it.
|
||||||
|
flight.ballcall=true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -53,8 +53,9 @@
|
|||||||
-- @field #number dTevaluate Time interval in seconds before the mission result is evaluated after mission is over.
|
-- @field #number dTevaluate Time interval in seconds before the mission result is evaluated after mission is over.
|
||||||
-- @field #number Tover Mission abs. time stamp, when mission was over.
|
-- @field #number Tover Mission abs. time stamp, when mission was over.
|
||||||
-- @field #table conditionStart Condition(s) that have to be true, before the mission will be started.
|
-- @field #table conditionStart Condition(s) that have to be true, before the mission will be started.
|
||||||
-- @field #table conditionSuccess If all stop conditions are true, the mission is cancelled.
|
-- @field #table conditionSuccess If all conditions are true, the mission is cancelled.
|
||||||
-- @field #table conditionFailure If all stop conditions are true, the mission is cancelled.
|
-- @field #table conditionFailure If all conditions are true, the mission is cancelled.
|
||||||
|
-- @field #table conditionPush If all conditions are true, the mission is executed. Before, the group(s) wait at the mission execution waypoint.
|
||||||
--
|
--
|
||||||
-- @field #number orbitSpeed Orbit speed in m/s.
|
-- @field #number orbitSpeed Orbit speed in m/s.
|
||||||
-- @field #number orbitAltitude Orbit altitude in meters.
|
-- @field #number orbitAltitude Orbit altitude in meters.
|
||||||
@ -288,6 +289,7 @@ AUFTRAG = {
|
|||||||
conditionStart = {},
|
conditionStart = {},
|
||||||
conditionSuccess = {},
|
conditionSuccess = {},
|
||||||
conditionFailure = {},
|
conditionFailure = {},
|
||||||
|
conditionPush = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Global mission counter.
|
--- Global mission counter.
|
||||||
@ -445,7 +447,7 @@ AUFTRAG.TargetType={
|
|||||||
|
|
||||||
--- AUFTRAG class version.
|
--- AUFTRAG class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
AUFTRAG.version="0.7.0"
|
AUFTRAG.version="0.7.1"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@ -1825,6 +1827,26 @@ function AUFTRAG:AddConditionFailure(ConditionFunction, ...)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Add push condition.
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @param #function ConditionFunction If this function returns `true`, the mission is executed.
|
||||||
|
-- @param ... Condition function arguments if any.
|
||||||
|
-- @return #AUFTRAG self
|
||||||
|
function AUFTRAG:AddConditionPush(ConditionFunction, ...)
|
||||||
|
|
||||||
|
local condition={} --#AUFTRAG.Condition
|
||||||
|
|
||||||
|
condition.func=ConditionFunction
|
||||||
|
condition.arg={}
|
||||||
|
if arg then
|
||||||
|
condition.arg=arg
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(self.conditionPush, condition)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Assign airwing squadron(s) to the mission. Only these squads will be considered for the job.
|
--- Assign airwing squadron(s) to the mission. Only these squads will be considered for the job.
|
||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
@ -1983,12 +2005,12 @@ function AUFTRAG:IsReadyToGo()
|
|||||||
local Tnow=timer.getAbsTime()
|
local Tnow=timer.getAbsTime()
|
||||||
|
|
||||||
-- Start time did not pass yet.
|
-- Start time did not pass yet.
|
||||||
if self.Tstart and Tnow<self.Tstart or false then
|
if self.Tstart and Tnow<self.Tstart then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Stop time already passed.
|
-- Stop time already passed.
|
||||||
if self.Tstop and Tnow>self.Tstop or false then
|
if self.Tstop and Tnow>self.Tstop then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2014,7 +2036,7 @@ function AUFTRAG:IsReadyToCancel()
|
|||||||
local Tnow=timer.getAbsTime()
|
local Tnow=timer.getAbsTime()
|
||||||
|
|
||||||
-- Stop time already passed.
|
-- Stop time already passed.
|
||||||
if self.Tstop and Tnow>self.Tstop then
|
if self.Tstop and Tnow>=self.Tstop then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2038,6 +2060,26 @@ function AUFTRAG:IsReadyToCancel()
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Check if mission is ready to be pushed.
|
||||||
|
-- * Mission push time already passed.
|
||||||
|
-- * All push conditions are true.
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @return #boolean If true, mission groups can push.
|
||||||
|
function AUFTRAG:IsReadyToPush()
|
||||||
|
|
||||||
|
local Tnow=timer.getAbsTime()
|
||||||
|
|
||||||
|
-- Push time passed?
|
||||||
|
if self.Tpush and Tnow<self.Tpush then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Evaluate push condition(s) if any. All need to be true.
|
||||||
|
local push=self:EvalConditionsAll(self.conditionPush)
|
||||||
|
|
||||||
|
return push
|
||||||
|
end
|
||||||
|
|
||||||
--- Check if all given condition are true.
|
--- Check if all given condition are true.
|
||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
-- @param #table Conditions Table of conditions.
|
-- @param #table Conditions Table of conditions.
|
||||||
|
|||||||
@ -823,10 +823,10 @@ function FLIGHTGROUP:onbeforeStatus(From, Event, To)
|
|||||||
|
|
||||||
-- This one is dead.
|
-- This one is dead.
|
||||||
if isdead then
|
if isdead then
|
||||||
local text=string.format("Element %s is dead at t=%.3f! Maybe despawned without notice or landed at a too small airbase. Calling ElementDead in 60 sec to give other events a chance",
|
local text=string.format("Element %s is dead at t=%.3f but has status %s! Maybe despawned without notice or landed at a too small airbase. Calling ElementDead in 60 sec to give other events a chance",
|
||||||
tostring(element.name), timer.getTime())
|
tostring(element.name), timer.getTime(), tostring(element.status))
|
||||||
self:E(self.lid..text)
|
self:E(self.lid..text)
|
||||||
--self:__ElementDead(60, element)
|
self:__ElementDead(60, element)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -925,6 +925,8 @@ function FLIGHTGROUP:onafterStatus(From, Event, To)
|
|||||||
local unit=element.unit
|
local unit=element.unit
|
||||||
local fuel=unit:GetFuel() or 0
|
local fuel=unit:GetFuel() or 0
|
||||||
local life=unit:GetLifeRelative() or 0
|
local life=unit:GetLifeRelative() or 0
|
||||||
|
local lp=unit:GetLife()
|
||||||
|
local lp0=unit:GetLife0()
|
||||||
local parking=element.parking and tostring(element.parking.TerminalID) or "X"
|
local parking=element.parking and tostring(element.parking.TerminalID) or "X"
|
||||||
|
|
||||||
-- Check if element is not dead and we missed an event.
|
-- Check if element is not dead and we missed an event.
|
||||||
@ -936,8 +938,8 @@ function FLIGHTGROUP:onafterStatus(From, Event, To)
|
|||||||
local ammo=self:GetAmmoElement(element)
|
local ammo=self:GetAmmoElement(element)
|
||||||
|
|
||||||
-- Output text for element.
|
-- Output text for element.
|
||||||
text=text..string.format("\n[%d] %s: status=%s, fuel=%.1f, life=%.1f, guns=%d, rockets=%d, bombs=%d, missiles=%d (AA=%d, AG=%d, AS=%s), parking=%s",
|
text=text..string.format("\n[%d] %s: status=%s, fuel=%.1f, life=%.1f [%.1f/%.1f], guns=%d, rockets=%d, bombs=%d, missiles=%d (AA=%d, AG=%d, AS=%s), parking=%s",
|
||||||
i, name, status, fuel*100, life*100, ammo.Guns, ammo.Rockets, ammo.Bombs, ammo.Missiles, ammo.MissilesAA, ammo.MissilesAG, ammo.MissilesAS, parking)
|
i, name, status, fuel*100, life*100, lp, lp0, ammo.Guns, ammo.Rockets, ammo.Bombs, ammo.Missiles, ammo.MissilesAA, ammo.MissilesAG, ammo.MissilesAS, parking)
|
||||||
end
|
end
|
||||||
if #self.elements==0 then
|
if #self.elements==0 then
|
||||||
text=text.." none!"
|
text=text.." none!"
|
||||||
|
|||||||
@ -2932,41 +2932,40 @@ function OPSGROUP:onbeforeTaskExecute(From, Event, To, Task)
|
|||||||
-- Get mission of this task (if any).
|
-- Get mission of this task (if any).
|
||||||
local Mission=self:GetMissionByTaskID(Task.id)
|
local Mission=self:GetMissionByTaskID(Task.id)
|
||||||
|
|
||||||
if Mission then
|
if Mission and (Mission.Tpush or #Mission.conditionPush>0) then
|
||||||
|
|
||||||
if Mission.Tpush then
|
if Mission:IsReadyToPush() then
|
||||||
|
|
||||||
local Tnow=timer.getAbsTime()
|
-- Not waiting any more.
|
||||||
|
self.Twaiting=nil
|
||||||
|
self.dTwait=nil
|
||||||
|
|
||||||
-- Time to push
|
else
|
||||||
local dt=Mission.Tpush-Tnow
|
|
||||||
|
|
||||||
-- Push time not reached.
|
---
|
||||||
if Tnow<Mission.Tpush then
|
-- Not ready to push yet
|
||||||
|
---
|
||||||
|
|
||||||
if self:IsWaiting() then
|
if self:IsWaiting() then
|
||||||
-- Group is already waiting
|
-- Group is already waiting
|
||||||
else
|
|
||||||
self:Wait()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Debug info.
|
|
||||||
self:T(self.lid..string.format("Mission %s task execute suspended for %d seconds", Mission.name, dt))
|
|
||||||
|
|
||||||
-- Reexecute task.
|
|
||||||
self:__TaskExecute(-dt, Task)
|
|
||||||
|
|
||||||
return false
|
|
||||||
else
|
else
|
||||||
-- Not waiting any more.
|
self:Wait()
|
||||||
self.Twaiting=nil
|
|
||||||
self.dTwait=nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Time to for the next try.
|
||||||
|
local dt=Mission.Tpush and Mission.Tpush-timer.getAbsTime() or 20
|
||||||
|
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
self:T(self.lid..string.format("Mission %s task execute suspended for %d seconds", Mission.name, dt))
|
||||||
|
|
||||||
|
-- Reexecute task.
|
||||||
|
self:__TaskExecute(-dt, Task)
|
||||||
|
|
||||||
|
-- Deny transition.
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
|
||||||
--env.info("FF no mission task execute")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|||||||
@ -150,7 +150,7 @@ _OPSTRANSPORTID=0
|
|||||||
|
|
||||||
--- Army Group version.
|
--- Army Group version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
OPSTRANSPORT.version="0.1.0"
|
OPSTRANSPORT.version="0.3.0"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
|
|||||||
@ -46,6 +46,7 @@
|
|||||||
-- @field #number radioFreq Radio frequency in MHz the squad uses.
|
-- @field #number radioFreq Radio frequency in MHz the squad uses.
|
||||||
-- @field #number radioModu Radio modulation the squad uses.
|
-- @field #number radioModu Radio modulation the squad uses.
|
||||||
-- @field #number takeoffType Take of type.
|
-- @field #number takeoffType Take of type.
|
||||||
|
-- @field #table parkingIDs Parking IDs for this squadron.
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
--- *It is unbelievable what a squadron of twelve aircraft did to tip the balance.* -- Adolf Galland
|
--- *It is unbelievable what a squadron of twelve aircraft did to tip the balance.* -- Adolf Galland
|
||||||
@ -88,7 +89,7 @@ SQUADRON = {
|
|||||||
|
|
||||||
--- SQUADRON class version.
|
--- SQUADRON class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
SQUADRON.version="0.5.2"
|
SQUADRON.version="0.7.0"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@ -136,7 +137,6 @@ function SQUADRON:New(TemplateGroupName, Ngroups, SquadronName)
|
|||||||
self.Ngroups=Ngroups or 3
|
self.Ngroups=Ngroups or 3
|
||||||
self:SetMissionRange()
|
self:SetMissionRange()
|
||||||
self:SetSkill(AI.Skill.GOOD)
|
self:SetSkill(AI.Skill.GOOD)
|
||||||
--self:SetVerbosity(0)
|
|
||||||
|
|
||||||
-- Everyone can ORBIT.
|
-- Everyone can ORBIT.
|
||||||
self:AddMissionCapability(AUFTRAG.Type.ORBIT)
|
self:AddMissionCapability(AUFTRAG.Type.ORBIT)
|
||||||
@ -284,6 +284,18 @@ function SQUADRON:SetGrouping(nunits)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set valid parking spot IDs. Assets of this squad are only allowed to be spawned at these parking spots. **Note** that the IDs are different from the ones displayed in the mission editor!
|
||||||
|
-- @param #SQUADRON self
|
||||||
|
-- @param #table ParkingIDs Table of parking ID numbers or a single `#number`.
|
||||||
|
-- @return #SQUADRON self
|
||||||
|
function SQUADRON:SetParkingIDs(ParkingIDs)
|
||||||
|
if type(ParkingIDs)~="table" then
|
||||||
|
ParkingIDs={ParkingIDs}
|
||||||
|
end
|
||||||
|
self.parkingIDs=ParkingIDs
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set takeoff type. All assets of this squadron will be spawned with cold (default) or hot engines.
|
--- Set takeoff type. All assets of this squadron will be spawned with cold (default) or hot engines.
|
||||||
-- Spawning on runways is not supported.
|
-- Spawning on runways is not supported.
|
||||||
@ -876,8 +888,9 @@ end
|
|||||||
|
|
||||||
--- Count assets in airwing (warehous) stock.
|
--- Count assets in airwing (warehous) stock.
|
||||||
-- @param #SQUADRON self
|
-- @param #SQUADRON self
|
||||||
|
-- @param #table MissionTypes (Optional) Count only assest that can perform certain mission type(s). Default is all types.
|
||||||
-- @return #number Assets not spawned.
|
-- @return #number Assets not spawned.
|
||||||
function SQUADRON:CountAssetsInStock()
|
function SQUADRON:CountAssetsInStock(MissionTypes)
|
||||||
|
|
||||||
local N=0
|
local N=0
|
||||||
for _,_asset in pairs(self.assets) do
|
for _,_asset in pairs(self.assets) do
|
||||||
@ -885,7 +898,9 @@ function SQUADRON:CountAssetsInStock()
|
|||||||
if asset.spawned then
|
if asset.spawned then
|
||||||
|
|
||||||
else
|
else
|
||||||
N=N+1
|
if MissionTypes==nil or self:CheckMissionCapability(MissionTypes, self.missiontypes) then
|
||||||
|
N=N+1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1063,15 +1078,21 @@ end
|
|||||||
|
|
||||||
--- Check if a mission type is contained in a list of possible capabilities.
|
--- Check if a mission type is contained in a list of possible capabilities.
|
||||||
-- @param #SQUADRON self
|
-- @param #SQUADRON self
|
||||||
-- @param #string MissionType The requested mission type.
|
-- @param #table MissionTypes The requested mission type. Can also be passed as a single mission type `#string`.
|
||||||
-- @param #table Capabilities A table with possible capabilities.
|
-- @param #table Capabilities A table with possible capabilities.
|
||||||
-- @return #boolean If true, the requested mission type is part of the possible mission types.
|
-- @return #boolean If true, the requested mission type is part of the possible mission types.
|
||||||
function SQUADRON:CheckMissionCapability(MissionType, Capabilities)
|
function SQUADRON:CheckMissionCapability(MissionTypes, Capabilities)
|
||||||
|
|
||||||
|
if type(MissionTypes)~="table" then
|
||||||
|
MissionTypes={MissionTypes}
|
||||||
|
end
|
||||||
|
|
||||||
for _,cap in pairs(Capabilities) do
|
for _,cap in pairs(Capabilities) do
|
||||||
local capability=cap --Ops.Auftrag#AUFTRAG.Capability
|
local capability=cap --Ops.Auftrag#AUFTRAG.Capability
|
||||||
if capability.MissionType==MissionType then
|
for _,MissionType in pairs(MissionTypes) do
|
||||||
return true
|
if capability.MissionType==MissionType then
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -128,7 +128,7 @@ _TARGETID=0
|
|||||||
|
|
||||||
--- TARGET class version.
|
--- TARGET class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
TARGET.version="0.3.1"
|
TARGET.version="0.5.0"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@ -231,12 +231,24 @@ end
|
|||||||
-- User functions
|
-- User functions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- Create target data from a given object.
|
--- Create target data from a given object. Valid objects are:
|
||||||
|
--
|
||||||
|
-- * GROUP
|
||||||
|
-- * UNIT
|
||||||
|
-- * STATIC
|
||||||
|
-- * AIRBASE
|
||||||
|
-- * COORDINATE
|
||||||
|
-- * ZONE
|
||||||
|
-- * SET_GROUP
|
||||||
|
-- * SET_UNIT
|
||||||
|
-- * SET_STATIC
|
||||||
|
-- * SET_OPSGROUP
|
||||||
|
--
|
||||||
-- @param #TARGET self
|
-- @param #TARGET self
|
||||||
-- @param Wrapper.Positionable#POSITIONABLE Object The target GROUP, UNIT, STATIC, AIRBASE or COORDINATE.
|
-- @param Wrapper.Positionable#POSITIONABLE Object The target GROUP, UNIT, STATIC, AIRBASE or COORDINATE.
|
||||||
function TARGET:AddObject(Object)
|
function TARGET:AddObject(Object)
|
||||||
|
|
||||||
if Object:IsInstanceOf("SET_GROUP") or Object:IsInstanceOf("SET_UNIT") then
|
if Object:IsInstanceOf("SET_GROUP") or Object:IsInstanceOf("SET_UNIT") or Object:IsInstanceOf("SET_STATIC") or Object:IsInstanceOf("SET_OPSGROUP") then
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Sets
|
-- Sets
|
||||||
@ -254,7 +266,11 @@ function TARGET:AddObject(Object)
|
|||||||
-- Groups, Units, Statics, Airbases, Coordinates
|
-- Groups, Units, Statics, Airbases, Coordinates
|
||||||
---
|
---
|
||||||
|
|
||||||
self:_AddObject(Object)
|
if Object:IsInstanceOf("OPSGROUP") then
|
||||||
|
self:_AddObject(Object:GetGroup()) -- We add the MOOSE GROUP object not the OPSGROUP object.
|
||||||
|
else
|
||||||
|
self:_AddObject(Object)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user