Merge branch 'FF/Ops' into FF/Fox2

This commit is contained in:
Frank
2020-06-29 20:58:15 +02:00
3 changed files with 568 additions and 553 deletions
@@ -1263,8 +1263,6 @@ function DATABASE:SetPlayerSettings( PlayerName, Settings )
self.PLAYERSETTINGS[PlayerName] = Settings
end
--- Add a flight group to the data base.
-- @param #DATABASE self
-- @param Ops.FlightGroup#FLIGHTGROUP flightgroup
+24 -7
View File
@@ -229,10 +229,9 @@ FLIGHTGROUP.version="0.5.0"
--- Create a new FLIGHTGROUP object and start the FSM.
-- @param #FLIGHTGROUP self
-- @param Wrapper.Group#GROUP group The group object. Can also be given as #string with the name of the group
-- @param #string autostart (Optional) If `true` or `nil` automatically start the FSM (default). If `false`, use FLIGHTGROUP:Start() manually.
-- @param Wrapper.Group#GROUP group The group object. Can also be given as #string with the name of the group.
-- @return #FLIGHTGROUP self
function FLIGHTGROUP:New(group, autostart)
function FLIGHTGROUP:New(group)
-- First check if we already have a flight group for this group.
local fg=_DATABASE:GetFlightGroup(group)
@@ -338,6 +337,7 @@ function FLIGHTGROUP:New(group, autostart)
self:HandleEvent(EVENTS.Ejection, self.OnEventEjection)
self:HandleEvent(EVENTS.Crash, self.OnEventCrash)
self:HandleEvent(EVENTS.RemoveUnit, self.OnEventRemoveUnit)
self:HandleEvent(EVENTS.UnitLost, self.OnEventUnitLost)
-- Init waypoints.
self:InitWaypoints()
@@ -1155,6 +1155,18 @@ function FLIGHTGROUP:OnEventCrash(EventData)
end
--- Flightgroup event function handling the crash of a unit.
-- @param #FLIGHTGROUP self
-- @param Core.Event#EVENTDATA EventData Event data.
function FLIGHTGROUP:OnEventUnitLost(EventData)
-- Check that this is the right group.
if EventData and EventData.IniGroup and EventData.IniUnit and EventData.IniGroupName and EventData.IniGroupName==self.groupname then
self:I(self.lid..string.format("EVENT: Unit %s lost!", EventData.IniUnitName))
end
end
--- Flightgroup event function handling the crash of a unit.
-- @param #FLIGHTGROUP self
-- @param Core.Event#EVENTDATA EventData Event data.
@@ -3070,7 +3082,7 @@ function FLIGHTGROUP:_SetElementParkingAt(Element, Spot)
if Spot then
env.info(string.format("FF Element %s is parking on spot %d", Element.name, Spot.TerminalID))
self:I(self.lid..string.format("Element %s is parking on spot %d", Element.name, Spot.TerminalID))
if self.flightcontrol then
@@ -3204,10 +3216,13 @@ function FLIGHTGROUP:GetParkingSpot(element, maxdist, airbase)
airbase=airbase or coord:GetClosestAirbase(nil, self:GetCoalition())
-- TODO: replace by airbase.parking if AIRBASE is updated.
local parking=airbase:GetParkingSpotsTable()
local spot=nil --Wrapper.Airbase#AIRBASE.ParkingSpot
local dist=nil
local distmin=math.huge
for _,_parking in pairs(airbase.parking) do
for _,_parking in pairs(parking) do
local parking=_parking --Wrapper.Airbase#AIRBASE.ParkingSpot
dist=coord:Get2DDistance(parking.Coordinate)
if dist<distmin then
@@ -3630,9 +3645,11 @@ function FLIGHTGROUP:SwitchRadioOn(Frequency, Modulation)
Modulation=Modulation or radio.Modulation.AM
self.group:SetOption(AI.Option.Air.id.SILENCE, false)
local group=self.group --Wrapper.Group#GROUP
self.group:CommandSetFrequency(Frequency, Modulation)
group:SetOption(AI.Option.Air.id.SILENCE, false)
group:CommandSetFrequency(Frequency, Modulation)
self.radioFreq=Frequency
self.radioModu=Modulation
@@ -803,7 +803,7 @@ function CONTROLLABLE:CommandSetFrequency(Frequency, Modulation, Delay)
local CommandSetFrequency = {
id = 'SetFrequency',
params = {
frequency = Frequency,
frequency = Frequency*1000000,
modulation = Modulation or radio.modulation.AM,
}
}