mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-22 16:05:25 +00:00
RAT
This commit is contained in:
@@ -133,7 +133,7 @@ function RAT2:_CheckQueueSpawn()
|
|||||||
|
|
||||||
if flight:IsInUtero() or flight:IsArrived() or flight:IsDead() then
|
if flight:IsInUtero() or flight:IsArrived() or flight:IsDead() then
|
||||||
|
|
||||||
self:I(string.format("Spawning new flight group %s in status %s", flight.groupname, flight:GetState()))
|
self:I(string.format("Try Spawning new flight group %s in status %s", flight.groupname, flight:GetState()))
|
||||||
|
|
||||||
-- Get departure and parking.
|
-- Get departure and parking.
|
||||||
local departure, parking=ratcraft:GetDeparture()
|
local departure, parking=ratcraft:GetDeparture()
|
||||||
@@ -141,9 +141,9 @@ function RAT2:_CheckQueueSpawn()
|
|||||||
-- Get destination depending on departure.
|
-- Get destination depending on departure.
|
||||||
local destination=ratcraft:GetDestination(departure)
|
local destination=ratcraft:GetDestination(departure)
|
||||||
|
|
||||||
if departure and destination then
|
if departure and destination and parking then
|
||||||
|
|
||||||
parking=departure.parking or parking
|
self:I(string.format("Spawning new flight group %s in status %s", flight.groupname, flight:GetState()))
|
||||||
|
|
||||||
-- Try to spawn a ratcraft group.
|
-- Try to spawn a ratcraft group.
|
||||||
local group=self:_SpawnRatcraft(ratcraft, flight, departure, destination, parking)
|
local group=self:_SpawnRatcraft(ratcraft, flight, departure, destination, parking)
|
||||||
@@ -836,7 +836,7 @@ function RAT2:_GetFlightplan(ratcraft, departure, destination)
|
|||||||
|
|
||||||
|
|
||||||
-- Mark points at waypoints for debugging.
|
-- Mark points at waypoints for debugging.
|
||||||
if self.Debug then
|
if self.Debug or true then
|
||||||
for i,coord in pairs(c) do
|
for i,coord in pairs(c) do
|
||||||
local coord=coord --Core.Point#COORDINATE
|
local coord=coord --Core.Point#COORDINATE
|
||||||
local dist=0
|
local dist=0
|
||||||
|
|||||||
@@ -1341,9 +1341,9 @@ function RANGE:AddBombingTargetUnit(unit, goodhitrange, randommove)
|
|||||||
|
|
||||||
-- Debug or error output.
|
-- Debug or error output.
|
||||||
if _isstatic==true then
|
if _isstatic==true then
|
||||||
self:T(self.id..string.format("Adding STATIC bombing target %s with good hit range %d. Random move = %s.", name, goodhitrange, tostring(randommove)))
|
self:I(self.id..string.format("Adding STATIC bombing target %s with good hit range %d. Random move = %s.", name, goodhitrange, tostring(randommove)))
|
||||||
elseif _isstatic==false then
|
elseif _isstatic==false then
|
||||||
self:T(self.id..string.format("Adding UNIT bombing target %s with good hit range %d. Random move = %s.", name, goodhitrange, tostring(randommove)))
|
self:I(self.id..string.format("Adding UNIT bombing target %s with good hit range %d. Random move = %s.", name, goodhitrange, tostring(randommove)))
|
||||||
else
|
else
|
||||||
self:E(self.id..string.format("ERROR! No bombing target with name %s could be found. Carefully check all UNIT and STATIC names defined in the mission editor!", name))
|
self:E(self.id..string.format("ERROR! No bombing target with name %s could be found. Carefully check all UNIT and STATIC names defined in the mission editor!", name))
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
-- @field #string landing Landing type.
|
-- @field #string landing Landing type.
|
||||||
-- @field #table flights Table of flight groups.
|
-- @field #table flights Table of flight groups.
|
||||||
-- @field #number Nspawn Number of max spawned aircraft groups.
|
-- @field #number Nspawn Number of max spawned aircraft groups.
|
||||||
|
-- @field #number Nunits Number of units in group.
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
RATCRAFT = {
|
RATCRAFT = {
|
||||||
ClassName = "RATCRAFT",
|
ClassName = "RATCRAFT",
|
||||||
@@ -83,6 +84,7 @@ RATCRAFT = {
|
|||||||
landing = nil,
|
landing = nil,
|
||||||
flights = {},
|
flights = {},
|
||||||
Nspawn = 2,
|
Nspawn = 2,
|
||||||
|
Nunits = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- 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.
|
||||||
@@ -191,6 +193,9 @@ function RATCRAFT:_Init(groupname)
|
|||||||
self.country=self.templategroup:GetUnit(1):GetCountry()
|
self.country=self.templategroup:GetUnit(1):GetCountry()
|
||||||
|
|
||||||
self.category=self.templategroup:GetUnit(1):GetCategory()
|
self.category=self.templategroup:GetUnit(1):GetCategory()
|
||||||
|
|
||||||
|
|
||||||
|
self.Nunits=#self.templategroup:GetUnits()
|
||||||
|
|
||||||
-- aircraft dimensions
|
-- aircraft dimensions
|
||||||
self.sizex=self.DCSdesc.box.max.x
|
self.sizex=self.DCSdesc.box.max.x
|
||||||
@@ -225,6 +230,7 @@ function RATCRAFT:AddDepartureAirbase(airbasename, parking)
|
|||||||
for _,TerminalID in pairs(parking) do
|
for _,TerminalID in pairs(parking) do
|
||||||
local spot=airbase:GetParkingSpotData(TerminalID)
|
local spot=airbase:GetParkingSpotData(TerminalID)
|
||||||
if spot then
|
if spot then
|
||||||
|
self:I(string.format("Add in parking spot %d", spot.TerminalID))
|
||||||
table.insert(spots, spot)
|
table.insert(spots, spot)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -232,7 +238,7 @@ function RATCRAFT:AddDepartureAirbase(airbasename, parking)
|
|||||||
|
|
||||||
departure.name=airbasename
|
departure.name=airbasename
|
||||||
departure.type=RATCRAFT.DeType.AIRBASE
|
departure.type=RATCRAFT.DeType.AIRBASE
|
||||||
departure.parking=parking
|
departure.parking=spots
|
||||||
table.insert(self.departures, departure)
|
table.insert(self.departures, departure)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@@ -353,10 +359,12 @@ function RATCRAFT:GetDeparture()
|
|||||||
local group=self.templategroup --Wrapper.Group#GROUP
|
local group=self.templategroup --Wrapper.Group#GROUP
|
||||||
|
|
||||||
-- Get number of free parking spots.
|
-- Get number of free parking spots.
|
||||||
local parking=airbase:FindFreeParkingSpotForAircraft(group)
|
--local parking=airbase:FindFreeParkingSpotForAircraft(group)
|
||||||
|
local parking=self:GetParkingDeparture(departure)
|
||||||
|
|
||||||
|
|
||||||
-- Check if parking is sufficient.
|
-- Check if parking is sufficient.
|
||||||
if #parking>=#group:GetUnits() then
|
if parking and #parking>=self.Nunits then
|
||||||
|
|
||||||
self:I(string.format("Returning departure %s", departure.name))
|
self:I(string.format("Returning departure %s", departure.name))
|
||||||
return departure, parking
|
return departure, parking
|
||||||
@@ -386,6 +394,84 @@ function RATCRAFT:GetDeparture()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get parking at departure.
|
||||||
|
-- @param #RATCRAFT self
|
||||||
|
-- @param #RATCRAFT.Departure departure The chosen departure.
|
||||||
|
-- @return #table Parking data table or nil if not enough spots.
|
||||||
|
function RATCRAFT:GetParkingDeparture(departure)
|
||||||
|
|
||||||
|
if departure.type==RATCRAFT.DeType.AIRBASE then
|
||||||
|
|
||||||
|
local airbase=AIRBASE:FindByName(departure.name)
|
||||||
|
|
||||||
|
if airbase then
|
||||||
|
|
||||||
|
local parkingdata=airbase:GetParkingSpotsTable()
|
||||||
|
|
||||||
|
if departure.parking then
|
||||||
|
---
|
||||||
|
-- User specified parking spots
|
||||||
|
---
|
||||||
|
|
||||||
|
-- Check if free?
|
||||||
|
local parking={}
|
||||||
|
for _,_spot in pairs(parkingdata) do
|
||||||
|
local spot=_spot --Wrapper.Airbase#AIRBASE.ParkingSpot
|
||||||
|
self:I(string.format("Checking spot %d", spot.TerminalID))
|
||||||
|
-- Check if spot if free?
|
||||||
|
if spot.Free then
|
||||||
|
|
||||||
|
self:I(string.format("Spot %d is FREE", spot.TerminalID))
|
||||||
|
-- Check if spot is in user table?
|
||||||
|
for _,_park in pairs(departure.parking) do
|
||||||
|
local park=_park --Wrapper.Airbase#AIRBASE.ParkingSpot
|
||||||
|
|
||||||
|
if park.TerminalID==spot.TerminalID then
|
||||||
|
self:I(string.format("Adding spot %d to parking", spot.TerminalID))
|
||||||
|
table.insert(parking, spot)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Only return data if sufficient spots available.
|
||||||
|
if #parking>=self.Nunits then
|
||||||
|
self:I(string.format("Found valid parking for %d spots", #parking))
|
||||||
|
return parking
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
---
|
||||||
|
-- Choose parking from what is free
|
||||||
|
---
|
||||||
|
|
||||||
|
local parking={}
|
||||||
|
for _,_spot in pairs(parkingdata) do
|
||||||
|
local spot=_spot --Wrapper.Airbase#AIRBASE.ParkingSpot
|
||||||
|
|
||||||
|
if spot.Free then
|
||||||
|
table.insert(parking, spot)
|
||||||
|
end
|
||||||
|
|
||||||
|
if #parking>=self.Nunits then
|
||||||
|
return parking
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
self:I(string.format("Could not find valid parking data"))
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get destination.
|
--- Get destination.
|
||||||
-- @param #RATCRAFT self
|
-- @param #RATCRAFT self
|
||||||
-- @param #RATCRAFT.Departure departure The chosen departure.
|
-- @param #RATCRAFT.Departure departure The chosen departure.
|
||||||
|
|||||||
@@ -2297,6 +2297,10 @@ end
|
|||||||
-- @return #FLIGHTGROUP self
|
-- @return #FLIGHTGROUP self
|
||||||
function FLIGHTGROUP:_UpdateRoute(n)
|
function FLIGHTGROUP:_UpdateRoute(n)
|
||||||
|
|
||||||
|
if true then
|
||||||
|
--return
|
||||||
|
end
|
||||||
|
|
||||||
-- TODO: what happens if currentwp=#waypoints
|
-- TODO: what happens if currentwp=#waypoints
|
||||||
n=n or self.currentwp+1
|
n=n or self.currentwp+1
|
||||||
|
|
||||||
@@ -2314,7 +2318,8 @@ function FLIGHTGROUP:_UpdateRoute(n)
|
|||||||
else
|
else
|
||||||
if self:IsTaxiing() or self:IsParking() or self:IsSpawned() then
|
if self:IsTaxiing() or self:IsParking() or self:IsSpawned() then
|
||||||
local coord=self.group:GetCoordinate()
|
local coord=self.group:GetCoordinate()
|
||||||
local current=coord:WaypointAirTakeOffParking(nil, 50)
|
--local current=coord:WaypointAirTakeOffParking(nil, 50)
|
||||||
|
local current=coord:WaypointAir( AltType, COORDINATE.WaypointType.TakeOffParkingHot, COORDINATE.WaypointAction.FromParkingAreaHot, 50, true, coord:GetClosestAirbase(), {}, "Takeoff")
|
||||||
table.insert(wp, current)
|
table.insert(wp, current)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -2374,7 +2379,7 @@ function FLIGHTGROUP:_UpdateRoute(n)
|
|||||||
|
|
||||||
if airbase then
|
if airbase then
|
||||||
-- Route flight to destination/home.
|
-- Route flight to destination/home.
|
||||||
self:RTB(airbase)
|
--self:RTB(airbase)
|
||||||
else
|
else
|
||||||
-- Let flight orbit.
|
-- Let flight orbit.
|
||||||
--self:Orbit(self.group:GetCoordinate(), UTILS.FeetToMeters(20000), self.group:GetSpeedMax()*0.4)
|
--self:Orbit(self.group:GetCoordinate(), UTILS.FeetToMeters(20000), self.group:GetSpeedMax()*0.4)
|
||||||
@@ -2410,7 +2415,7 @@ function FLIGHTGROUP:_UpdateWaypointTasks()
|
|||||||
|
|
||||||
if #tasks>0 then
|
if #tasks>0 then
|
||||||
for _,task in pairs(tasks) do
|
for _,task in pairs(tasks) do
|
||||||
local Task=task --#FLIGHTGROUP.Task
|
local Task=task --#FLIGHTGROUP.Task
|
||||||
|
|
||||||
-- Add task execute.
|
-- Add task execute.
|
||||||
table.insert(taskswp, self.group:TaskFunction("FLIGHTGROUP._TaskExecute", self, Task))
|
table.insert(taskswp, self.group:TaskFunction("FLIGHTGROUP._TaskExecute", self, Task))
|
||||||
|
|||||||
@@ -654,6 +654,7 @@ end
|
|||||||
-- @param #AIRBASE self
|
-- @param #AIRBASE self
|
||||||
-- @param #AIRBASE.TerminalType termtype Terminal type for which marks should be placed.
|
-- @param #AIRBASE.TerminalType termtype Terminal type for which marks should be placed.
|
||||||
-- @param #boolean mark If false, do not place markers but only give output to DCS.log file. Default true.
|
-- @param #boolean mark If false, do not place markers but only give output to DCS.log file. Default true.
|
||||||
|
-- @return #table Table with marker IDs.
|
||||||
function AIRBASE:MarkParkingSpots(termtype, mark)
|
function AIRBASE:MarkParkingSpots(termtype, mark)
|
||||||
|
|
||||||
-- Default is true.
|
-- Default is true.
|
||||||
@@ -668,6 +669,8 @@ function AIRBASE:MarkParkingSpots(termtype, mark)
|
|||||||
local airbasename=self:GetName()
|
local airbasename=self:GetName()
|
||||||
self:E(string.format("Parking spots at %s for termial type %s:", airbasename, tostring(termtype)))
|
self:E(string.format("Parking spots at %s for termial type %s:", airbasename, tostring(termtype)))
|
||||||
|
|
||||||
|
self.parkingmarks=self.parkingmarks or {}
|
||||||
|
|
||||||
for _,_spot in pairs(parkingdata) do
|
for _,_spot in pairs(parkingdata) do
|
||||||
|
|
||||||
-- Mark text.
|
-- Mark text.
|
||||||
@@ -676,16 +679,34 @@ function AIRBASE:MarkParkingSpots(termtype, mark)
|
|||||||
|
|
||||||
-- Create mark on the F10 map.
|
-- Create mark on the F10 map.
|
||||||
if mark then
|
if mark then
|
||||||
_spot.Coordinate:MarkToAll(_text)
|
local mid=_spot.Coordinate:MarkToAll(_text)
|
||||||
|
if self.parkingmarks[_spot.TerminalID] then
|
||||||
|
_spot.Coordinate:RemoveMark(self.parkingmarks[_spot.TerminalID])
|
||||||
|
end
|
||||||
|
self.parkingmarks[_spot.TerminalID]=mid
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Info to DCS.log file.
|
-- Info to DCS.log file.
|
||||||
local _text=string.format("%s, Term Index=%3d, Term Type=%03d, Free=%5s, TOAC=%5s, Term ID0=%3d, Dist2Rwy=%.1f m",
|
local _text=string.format("%s, Term Index=%3d, Term Type=%03d, Free=%5s, TOAC=%5s, Term ID0=%3d, Dist2Rwy=%.1f m",
|
||||||
airbasename, _spot.TerminalID, _spot.TerminalType,tostring(_spot.Free),tostring(_spot.TOAC),_spot.TerminalID0,_spot.DistToRwy)
|
airbasename, _spot.TerminalID, _spot.TerminalType,tostring(_spot.Free),tostring(_spot.TOAC),_spot.TerminalID0,_spot.DistToRwy)
|
||||||
self:E(_text)
|
self:I(_text)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return markers
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Place markers of parking spots on the F10 map and update regularly.
|
||||||
|
-- @param #AIRBASE self
|
||||||
|
-- @param #AIRBASE.TerminalType termtype Terminal type for which marks should be placed.
|
||||||
|
-- @param #boolean mark If false, do not place markers but only give output to DCS.log file. Default true.
|
||||||
|
function AIRBASE:MonitorParkingSpots(termtype, mark)
|
||||||
|
|
||||||
|
local sched,shedid=SCHEDULER:New(self, self.MarkParkingSpots, {self,termtype,mark}, 5, 5)
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Seach unoccupied parking spots at the airbase for a specific group of aircraft. The routine also optionally checks for other unit, static and scenery options in a certain radius around the parking spot.
|
--- Seach unoccupied parking spots at the airbase for a specific group of aircraft. The routine also optionally checks for other unit, static and scenery options in a certain radius around the parking spot.
|
||||||
-- The dimension of the spawned aircraft and of the potential obstacle are taken into account. Note that the routine can only return so many spots that are free.
|
-- The dimension of the spawned aircraft and of the potential obstacle are taken into account. Note that the routine can only return so many spots that are free.
|
||||||
-- @param #AIRBASE self
|
-- @param #AIRBASE self
|
||||||
|
|||||||
Reference in New Issue
Block a user