mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-23 02:08:17 +00:00
RAT
This commit is contained in:
@@ -102,10 +102,13 @@ end
|
|||||||
function RAT2:_CheckQueueSpawn()
|
function RAT2:_CheckQueueSpawn()
|
||||||
|
|
||||||
for i,_ratcraft in pairs(self.Qspawn) do
|
for i,_ratcraft in pairs(self.Qspawn) do
|
||||||
local ratcraft=_ratcraft --#RATAC
|
local ratcraft=_ratcraft --Functional.RatCraft#RATCRAFT
|
||||||
|
|
||||||
--ratcraft.actype
|
--ratcraft.actype
|
||||||
|
|
||||||
|
local departure, parking=ratcraft:GetDeparture()
|
||||||
|
local destination=ratcraft:GetDestination(departure)
|
||||||
|
|
||||||
--- Check if
|
--- Check if
|
||||||
-- Time has passed.
|
-- Time has passed.
|
||||||
-- Already enough aircraft are alive
|
-- Already enough aircraft are alive
|
||||||
@@ -126,45 +129,6 @@ end
|
|||||||
-- Spawn functions
|
-- 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.
|
--- Spawn an aircraft asset (plane or helo) at the airbase associated with the warehouse.
|
||||||
-- @param #RAT2 self
|
-- @param #RAT2 self
|
||||||
-- @param #RATAC ratcraft Ratcraft to spawn.
|
-- @param #RATAC ratcraft Ratcraft to spawn.
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ RATCRAFT = {
|
|||||||
commute = nil,
|
commute = nil,
|
||||||
takeoff = nil,
|
takeoff = nil,
|
||||||
landing = 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.
|
--- 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
|
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
|
if #parking>=#group:GetUnits() then
|
||||||
|
|
||||||
@@ -264,6 +266,71 @@ function RATCRAFT:GetDeparture()
|
|||||||
|
|
||||||
end
|
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
|
-- Status Functions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -1223,7 +1223,6 @@ end
|
|||||||
-- @param #FLIGHTCONTROL self
|
-- @param #FLIGHTCONTROL self
|
||||||
-- @return Core.Set#SET_UNIT Set of scanned units.
|
-- @return Core.Set#SET_UNIT Set of scanned units.
|
||||||
-- @return Core.Set#SET_STATIC Set of scanned static objects.
|
-- @return Core.Set#SET_STATIC Set of scanned static objects.
|
||||||
-- @return #tabe Table of scenery objects.
|
|
||||||
function FLIGHTCONTROL:_CheckAirbase()
|
function FLIGHTCONTROL:_CheckAirbase()
|
||||||
|
|
||||||
-- Airbase position.
|
-- Airbase position.
|
||||||
@@ -1426,7 +1425,6 @@ function FLIGHTCONTROL:_LandAI(flight, parking)
|
|||||||
element.parking=spot
|
element.parking=spot
|
||||||
unit.parking_landing=spot.TerminalID
|
unit.parking_landing=spot.TerminalID
|
||||||
local text=string.format("FF Reserving parking spot %d for unit %s", spot.TerminalID, tostring(unit.name))
|
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)
|
self:I(self.lid..text)
|
||||||
else
|
else
|
||||||
env.info("FF error could not get element to assign parking!")
|
env.info("FF error could not get element to assign parking!")
|
||||||
|
|||||||
Reference in New Issue
Block a user