ZCC, ATIS, CONTROLLABLE

This commit is contained in:
Frank 2020-01-07 23:34:36 +01:00
parent 6000421957
commit 3e8455410e
3 changed files with 19 additions and 11 deletions

View File

@ -875,8 +875,8 @@ do -- ZONE_CAPTURE_COALITION
end
-- Get red and blue unit sets.
local unitsetRed=self:GetScannedSetUnit():FilterCoalitions(coalition.side.RED):FilterActive(true):FilterOnce()
local unitsetBlu=self:GetScannedSetUnit():FilterCoalitions(coalition.side.BLUE):FilterActive(true):FilterOnce()
local unitsetRed=self:GetScannedSetUnit():FilterCoalitions("red"):FilterActive(true):FilterOnce()
local unitsetBlu=self:GetScannedSetUnit():FilterCoalitions("blue"):FilterActive(true):FilterOnce()
-- Count number of units.
local nRed=unitsetRed:Count()

View File

@ -515,7 +515,7 @@ _ATIS={}
--- ATIS class version.
-- @field #string version
ATIS.version="0.6.1"
ATIS.version="0.6.2"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list
@ -1000,7 +1000,9 @@ function ATIS:onafterStatus(From, Event, To)
local relayunitstatus="N/A"
if self.relayunitname then
local ru=UNIT:FindByName(self.relayunitname)
relayunitstatus=tostring(ru:IsAlive())
if ru then
relayunitstatus=tostring(ru:IsAlive())
end
end
-- Info text.

View File

@ -2136,8 +2136,10 @@ do -- Patrol methods
-- @param #table ZoneList Table of zones.
-- @param #number Speed Speed in km/h the group moves at.
-- @param #string Formation (Optional) Formation the group should use.
-- @param #number DelayMin Delay in seconds before the group progresses to the next route point. Default 1 sec.
-- @param #number DelayMax Max. delay in seconds. Actual delay is randomly chosen between DelayMin and DelayMax. Default equal to DelayMin.
-- @return #CONTROLLABLE
function CONTROLLABLE:PatrolZones( ZoneList, Speed, Formation )
function CONTROLLABLE:PatrolZones( ZoneList, Speed, Formation, DelayMin, DelayMax )
if not type( ZoneList ) == "table" then
ZoneList = { ZoneList }
@ -2148,14 +2150,18 @@ do -- Patrol methods
if not self:IsInstanceOf( "GROUP" ) then
PatrolGroup = self:GetGroup() -- Wrapper.Group#GROUP
end
DelayMin=DelayMin or 1
if not DelayMax or DelayMax<DelayMin then
DelayMax=DelayMin
end
local Delay=math.random(DelayMin, DelayMax)
self:F( { PatrolGroup = PatrolGroup:GetName() } )
if PatrolGroup:IsGround() or PatrolGroup:IsShip() then
local Waypoints = PatrolGroup:GetTemplateRoutePoints()
local Waypoint = Waypoints[math.random( 1, #Waypoints )] -- Select random waypoint.
-- Calculate the new Route.
local FromCoord = PatrolGroup:GetCoordinate()
@ -2169,11 +2175,11 @@ do -- Patrol methods
Route[#Route+1] = ToCoord:WaypointGround( Speed, Formation )
local TaskRouteToZone = PatrolGroup:TaskFunction( "CONTROLLABLE.PatrolZones", ZoneList, Speed, Formation )
local TaskRouteToZone = PatrolGroup:TaskFunction( "CONTROLLABLE.PatrolZones", ZoneList, Speed, Formation, DelayMin, DelayMax )
PatrolGroup:SetTaskWaypoint( Route[#Route], TaskRouteToZone ) -- Set for the given Route at Waypoint 2 the TaskRouteToZone.
PatrolGroup:Route( Route, 1 ) -- Move after a random seconds to the Route. See the Route method for details.
PatrolGroup:Route( Route, Delay ) -- Move after a random seconds to the Route. See the Route method for details.
end
end
@ -2374,7 +2380,7 @@ do -- Route methods
local FromCoordinate = self:GetCoordinate()
local FromWP = FromCoordinate:WaypointGround()
local FromWP = FromCoordinate:WaypointGround(Speed, Formation)
local ToWP = ToCoordinate:WaypointGround( Speed, Formation )
self:Route( { FromWP, ToWP }, DelaySeconds )