This commit is contained in:
Frank
2019-11-27 16:46:03 +01:00
parent 75a7f05761
commit 5ad927d20c
3 changed files with 73 additions and 44 deletions
+4 -40
View File
@@ -102,10 +102,13 @@ end
function RAT2:_CheckQueueSpawn()
for i,_ratcraft in pairs(self.Qspawn) do
local ratcraft=_ratcraft --#RATAC
local ratcraft=_ratcraft --Functional.RatCraft#RATCRAFT
--ratcraft.actype
local departure, parking=ratcraft:GetDeparture()
local destination=ratcraft:GetDestination(departure)
--- Check if
-- Time has passed.
-- Already enough aircraft are alive
@@ -126,45 +129,6 @@ end
-- Spawn functions
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- Spawn an aircraft asset (plane or helo) at the airbase associated with the warehouse.
-- @param #RAT2 self
-- @param #RATAC ratcraft
-- @return #boolean If true, ratcraft was spawned.
function RAT2:_TrySpawnRatcraft(ratcraft)
-- TODO: loop over departure airbases.
for _,_departure in pairs(ratcraft.departures) do
local departure=_departure --#RATAC.Departure
local parking=nil
if departure.type==RATAC.DeType.AIRBASE then
-- Get parking data.
local parking=self:_FindParking(departure.airbase, ratcraft)
-- Check if enough parking is available.
if parking then
self:_SpawnRatcraft()
return true
end
elseif departure.type==RATAC.DeType.ZONE then
end
end
return false
end
--- Spawn an aircraft asset (plane or helo) at the airbase associated with the warehouse.
-- @param #RAT2 self
-- @param #RATAC ratcraft Ratcraft to spawn.
@@ -59,6 +59,7 @@ RATCRAFT = {
commute = nil,
takeoff = nil,
landing = nil,
flights = {},
}
--- Generalized asset attributes. Can be used to request assets with certain general characteristics. See [DCS attributes](https://wiki.hoggitworld.com/view/DCS_enum_attributes) on hoggit.
@@ -233,9 +234,10 @@ function RATCRAFT:GetDeparture()
if airbase then
local group=nil --Wrapper.Group#GROUP
local group=self.templategroup --Wrapper.Group#GROUP
local parking=airbase:FindFreeParkingSpotForAircraft(group,terminaltype,scanradius,scanunits,scanstatics,scanscenery,verysafe,nspots,parkingdata)
-- Get number of free parking spots.
local parking=airbase:FindFreeParkingSpotForAircraft(group)
if #parking>=#group:GetUnits() then
@@ -264,6 +266,71 @@ function RATCRAFT:GetDeparture()
end
--- Get destination.
-- @param #RATCRAFT self
-- @param #RATCRAFT.Departure departure The chosen departure.
-- @return #RATCRAFT.Departure
function RATCRAFT:GetDestination(departure)
-- Create copy of all destinations.
local destinations=UTILS.DeepCopy(self.destinations)
-- Try each departure in random order.
for i=1,#destinations do
-- Roll dice.
local r=math.random(#destinations)
-- Get random departure
local destination=destinations[r] --#RATCRAFT.Departure
-- Check if airbase or zone.
if destination.type==RATCRAFT.DeType.AIRBASE then
---
-- Airbase
---
-- Get airbase.
local airbase=AIRBASE:FindByName(destination.name)
local dest=AIRBASE:FindByName(departure.name)
if airbase then
-- TODO: check
-- coalition, terminal type, distance
local distance=dest:GetCoordinate():Get2DDistance(airbase:GetCoordinate())
if distance then
return departure
else
-- Remove from table so it does not get selected again.
table.remove(destinations, r)
end
else
self:E("ERROR: Could not find airbase!")
end
else
---
-- Zone
---
end
end
end
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Status Functions
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -1223,7 +1223,6 @@ end
-- @param #FLIGHTCONTROL self
-- @return Core.Set#SET_UNIT Set of scanned units.
-- @return Core.Set#SET_STATIC Set of scanned static objects.
-- @return #tabe Table of scenery objects.
function FLIGHTCONTROL:_CheckAirbase()
-- Airbase position.
@@ -1426,7 +1425,6 @@ function FLIGHTCONTROL:_LandAI(flight, parking)
element.parking=spot
unit.parking_landing=spot.TerminalID
local text=string.format("FF Reserving parking spot %d for unit %s", spot.TerminalID, tostring(unit.name))
--spot.Coordinate:MarkToAll(text)
self:I(self.lid..text)
else
env.info("FF error could not get element to assign parking!")