Merge branch 'develop' into FF/Ops

This commit is contained in:
Frank
2021-01-31 00:50:14 +01:00
10 changed files with 190 additions and 141 deletions

View File

@@ -1140,7 +1140,7 @@ end
-- @param DCS#Vec3 CV2 Vec3
function AI_FORMATION:FollowMe(FollowGroup, ClientUnit, CT1, CV1, CT2, CV2)
if FollowGroup:GetState( FollowGroup, "Mode" ) == self.__Enum.Mode.Formation then
if FollowGroup:GetState( FollowGroup, "Mode" ) == self.__Enum.Mode.Formation and not self:Is("Stopped") then
self:T({Mode=FollowGroup:GetState( FollowGroup, "Mode" )})

View File

@@ -122,7 +122,7 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
self.Schedule[Scheduler][CallID].Function = ScheduleFunction
self.Schedule[Scheduler][CallID].Arguments = ScheduleArguments
self.Schedule[Scheduler][CallID].StartTime = timer.getTime() + ( Start or 0 )
self.Schedule[Scheduler][CallID].Start = Start + 0.1
self.Schedule[Scheduler][CallID].Start = Start + 0.001
self.Schedule[Scheduler][CallID].Repeat = Repeat or 0
self.Schedule[Scheduler][CallID].Randomize = Randomize or 0
self.Schedule[Scheduler][CallID].Stop = Stop

View File

@@ -5411,10 +5411,12 @@ do -- SET_ZONE
--- Get a random zone from the set.
-- @param #SET_ZONE self
-- @param #number margin Number of tries to find a zone
-- @return Core.Zone#ZONE_BASE The random Zone.
-- @return #nil if no zone in the collection.
function SET_ZONE:GetRandomZone()
function SET_ZONE:GetRandomZone(margin)
local margin = margin or 100
if self:Count() ~= 0 then
local Index = self.Index
@@ -5423,9 +5425,11 @@ do -- SET_ZONE
-- Loop until a zone has been found.
-- The :GetZoneMaybe() call will evaluate the probability for the zone to be selected.
-- If the zone is not selected, then nil is returned by :GetZoneMaybe() and the loop continues!
while not ZoneFound do
local counter = 0
while (not ZoneFound) or (counter < margin) do
local ZoneRandom = math.random( 1, #Index )
ZoneFound = self.Set[Index[ZoneRandom]]:GetZoneMaybe()
counter = counter + 1
end
return ZoneFound

View File

@@ -1,4 +1,4 @@
--- **Functional** -- Modular, Automatic and Network capable Targeting and Interception System for Air Defenses
--- **Functional** -- Modular, Automatic and Network capable Targeting and Interception System for Air Defenses
--
-- ===
--
@@ -37,7 +37,7 @@
-- @field #table SAM_Table Table of SAM sites
-- @field #string lid Prefix for logging
-- @field @{#Functional.Detection#DETECTION_AREAS} Detection The #DETECTION_AREAS object for EWR
-- @field @{Functional.Detection#DETECTION_AREAS} AWACS_Detection The #DETECTION_AREAS object for AWACS
-- @field @{#Functional.Detection#DETECTION_AREAS} AWACS_Detection The #DETECTION_AREAS object for AWACS
-- @field #boolean debug Switch on extra messages
-- @field #boolean verbose Switch on extra logging
-- @field #number checkradius Radius of the SAM sites
@@ -181,6 +181,26 @@ do
--@param #boolean dynamic Use constant (true) filtering or just filter once (false, default) (optional)
--@param #string awacs Group name of your Awacs (optional)
--@return #MANTIS self
--@usage Start up your MANTIS with a basic setting
--
-- `myredmantis = MANTIS:New("myredmantis","Red SAM","Red EWR",nil,"red",false)`
-- `myredmantis:Start()`
--
-- [optional] Use
--
-- * `MANTIS:SetEWRGrouping(radius)`
-- * `MANTIS:SetEWRRange(radius)`
-- * `MANTIS:SetSAMRadius(radius)`
-- * `MANTIS:SetDetectInterval(interval)`
-- * `MANTIS:SetAutoRelocate(hq, ewr)`
--
-- before starting #MANTIS to fine-tune your setup.
--
-- If you want to use a separate AWACS unit (default detection range: 250km) to support your EWR system, use e.g. the following setup:
--
-- `mybluemantis = MANTIS:New("bluemantis","Blue SAM","Blue EWR",nil,"blue",false,"Blue Awacs")`
-- `mybluemantis:Start()`
--
function MANTIS:New(name,samprefix,ewrprefix,hq,coaltion,dynamic,awacs)
-- DONE: Create some user functions for these
@@ -307,7 +327,7 @@ do
self.engagerange = range
end
--- Function to set a new SAM firing engage range, use this method to adjust range while running MANTIS, e.g. for different setups day and night
--- Function to set a new SAM firing engage range, use this method to adjust range while running MANTIS, e.g. for different setups day and night
-- @param #MANTIS self
-- @param #number range Percent of the max fire range
function MANTIS:SetNewSAMRangeWhileRunning(range)
@@ -535,7 +555,7 @@ do
end
end
--- Function to check if any object is in the given SAM zone
--- (Internal) Function to check if any object is in the given SAM zone
-- @param #MANTIS self
-- @param #table dectset Table of coordinates of detected items
-- @param samcoordinate Core.Point#COORDINATE Coordinate object.
@@ -562,7 +582,7 @@ do
return false
end
--- Function to start the detection via EWR groups
--- (Internal) Function to start the detection via EWR groups
-- @param #MANTIS self
-- @return Functional.Detection #DETECTION_AREAS The running detection set
function MANTIS:StartDetection()
@@ -593,7 +613,7 @@ do
return _MANTISdetection
end
--- Function to start the detection via AWACS if defined as separate
--- (Internal) Function to start the detection via AWACS if defined as separate
-- @param #MANTIS self
-- @return Functional.Detection #DETECTION_AREAS The running detection set
function MANTIS:StartAwacsDetection()
@@ -625,7 +645,7 @@ do
return _MANTISAwacs
end
--- Function to set the SAM start state
--- (Internal) Function to set the SAM start state
-- @param #MANTIS self
-- @return #MANTIS self
function MANTIS:SetSAMStartState()

View File

@@ -1318,6 +1318,10 @@ function ATIS:onafterBroadcast(From, Event, To)
time=time-UTILS.GMTToLocalTimeDifference()*60*60
end
if time < 0 then
time = 24*60*60 + time --avoid negative time around midnight
end
local clock=UTILS.SecondsToClock(time)
local zulu=UTILS.Split(clock, ":")
local ZULU=string.format("%s%s", zulu[1], zulu[2])

View File

@@ -1306,7 +1306,7 @@ function FLIGHTGROUP:onafterElementSpawned(From, Event, To, Element)
-- Set element status.
self:_UpdateStatus(Element, OPSGROUP.ElementStatus.SPAWNED)
if Element.unit:InAir() then
if Element.unit:InAir(true) then
-- Trigger ElementAirborne event. Add a little delay because spawn is also delayed!
self:__ElementAirborne(0.11, Element)
else

View File

@@ -2646,7 +2646,7 @@ function OPSGROUP:onafterTaskExecute(From, Event, To, Task)
local TaskFinal=self.group:TaskCombo({TaskControlled, TaskDone})
-- Set task for group.
self:SetTask(TaskFinal, 1)
self:SetTask(TaskFinal)
end

View File

@@ -1501,3 +1501,23 @@ function UTILS.GetOSTime()
return nil
end
--- Shuffle a table accoring to Fisher Yeates algorithm
--@param #table table to be shuffled
--@return #table
function UTILS.ShuffleTable(t)
if t == nil or type(t) ~= "table" then
BASE:I("Error in ShuffleTable: Missing or wrong tyåe of Argument")
return
end
math.random()
math.random()
math.random()
local TempTable = {}
for i = 1, #t do
local r = math.random(1,#t)
TempTable[i] = t[r]
table.remove(t,r)
end
return TempTable
end

View File

@@ -1894,7 +1894,7 @@ do -- Patrol methods
local ToCoord = COORDINATE:NewFromVec2( { x = Waypoint.x, y = Waypoint.y } )
-- Create a "ground route point", which is a "point" structure that can be given as a parameter to a Task
local Route = {}
Route[#Route+1] = FromCoord:WaypointGround( 0 )
Route[#Route+1] = FromCoord:WaypointGround( Speed, Formation )
Route[#Route+1] = ToCoord:WaypointGround( Speed, Formation )
@@ -1947,7 +1947,7 @@ do -- Patrol methods
-- Create a "ground route point", which is a "point" structure that can be given as a parameter to a Task
local Route = {}
Route[#Route+1] = FromCoord:WaypointGround( 20 )
Route[#Route+1] = FromCoord:WaypointGround( Speed, Formation )
Route[#Route+1] = ToCoord:WaypointGround( Speed, Formation )

View File

@@ -1174,8 +1174,9 @@ end
--- Returns true if the UNIT is in the air.
-- @param #UNIT self
-- @param #boolean NoHeloCheck If true, no additonal checks for helos are performed.
-- @return #boolean Return true if in the air or #nil if the UNIT is not existing or alive.
function UNIT:InAir()
function UNIT:InAir(NoHeloCheck)
self:F2( self.UnitName )
-- Get DCS unit object.
@@ -1192,7 +1193,7 @@ function UNIT:InAir()
-- If DCS says that it is in air, check if this is really the case, since we might have landed on a building where inAir()=true but actually is not.
-- This is a workaround since DCS currently does not acknoledge that helos land on buildings.
-- Note however, that the velocity check will fail if the ground is moving, e.g. on an aircraft carrier!
if UnitInAir==true and UnitCategory == Unit.Category.HELICOPTER then
if UnitInAir==true and UnitCategory == Unit.Category.HELICOPTER and (not NoHeloCheck) then
local VelocityVec3 = DCSUnit:getVelocity()
local Velocity = UTILS.VecNorm(VelocityVec3)
local Coordinate = DCSUnit:getPoint()