mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Fixed AI_BALANCER problem with AI not patrolling...
-- Need to redo a video, because I gave the wrong example ...
This commit is contained in:
parent
2453fb6780
commit
6716f2907b
@ -345,8 +345,8 @@ function AI_PATROLZONE:onenterRoute()
|
|||||||
self.Controllable:SetState( self.Controllable, "PatrolZone", self )
|
self.Controllable:SetState( self.Controllable, "PatrolZone", self )
|
||||||
self.Controllable:WayPointFunction( #PatrolRoute, 1, "_NewPatrolRoute" )
|
self.Controllable:WayPointFunction( #PatrolRoute, 1, "_NewPatrolRoute" )
|
||||||
|
|
||||||
--- NOW ACT_ROUTE THE GROUP!
|
--- NOW ROUTE THE GROUP!
|
||||||
self.Controllable:WayPointExecute( 1 )
|
self.Controllable:WayPointExecute( 1, 5 )
|
||||||
|
|
||||||
self:__Patrol( 30 )
|
self:__Patrol( 30 )
|
||||||
end
|
end
|
||||||
|
|||||||
@ -66,9 +66,9 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
|||||||
-- If the object used as the key is nil, then the garbage collector will remove the item from the Functions array.
|
-- If the object used as the key is nil, then the garbage collector will remove the item from the Functions array.
|
||||||
self.ObjectSchedulers = self.ObjectSchedulers or setmetatable( {}, { __mode = "v" } )
|
self.ObjectSchedulers = self.ObjectSchedulers or setmetatable( {}, { __mode = "v" } )
|
||||||
|
|
||||||
if Scheduler.SchedulerObject then
|
if Scheduler.MasterObject then
|
||||||
self.ObjectSchedulers[self.CallID] = Scheduler
|
self.ObjectSchedulers[self.CallID] = Scheduler
|
||||||
self:E( { CallID = self.CallID, ObjectScheduler = tostring(self.ObjectSchedulers[self.CallID]), SchedulerObject = tostring(Scheduler.SchedulerObject) } )
|
self:E( { CallID = self.CallID, ObjectScheduler = tostring(self.ObjectSchedulers[self.CallID]), MasterObject = tostring(Scheduler.MasterObject) } )
|
||||||
else
|
else
|
||||||
self.PersistentSchedulers[self.CallID] = Scheduler
|
self.PersistentSchedulers[self.CallID] = Scheduler
|
||||||
self:E( { CallID = self.CallID, PersistentScheduler = self.PersistentSchedulers[self.CallID] } )
|
self:E( { CallID = self.CallID, PersistentScheduler = self.PersistentSchedulers[self.CallID] } )
|
||||||
@ -80,7 +80,7 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
|||||||
self.Schedule[Scheduler][self.CallID].Function = ScheduleFunction
|
self.Schedule[Scheduler][self.CallID].Function = ScheduleFunction
|
||||||
self.Schedule[Scheduler][self.CallID].Arguments = ScheduleArguments
|
self.Schedule[Scheduler][self.CallID].Arguments = ScheduleArguments
|
||||||
self.Schedule[Scheduler][self.CallID].StartTime = timer.getTime() + ( Start or 0 )
|
self.Schedule[Scheduler][self.CallID].StartTime = timer.getTime() + ( Start or 0 )
|
||||||
self.Schedule[Scheduler][self.CallID].Start = Start + .001
|
self.Schedule[Scheduler][self.CallID].Start = Start + .1
|
||||||
self.Schedule[Scheduler][self.CallID].Repeat = Repeat
|
self.Schedule[Scheduler][self.CallID].Repeat = Repeat
|
||||||
self.Schedule[Scheduler][self.CallID].Randomize = Randomize
|
self.Schedule[Scheduler][self.CallID].Randomize = Randomize
|
||||||
self.Schedule[Scheduler][self.CallID].Stop = Stop
|
self.Schedule[Scheduler][self.CallID].Stop = Stop
|
||||||
@ -156,7 +156,7 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
|||||||
self:Stop( Scheduler, CallID )
|
self:Stop( Scheduler, CallID )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
--self:E( "Scheduled obscolete call for CallID: " .. CallID )
|
self:E( "Scheduled obscolete call for CallID: " .. CallID )
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -69,6 +69,8 @@ function SCHEDULER:New( SchedulerObject, SchedulerFunction, SchedulerArguments,
|
|||||||
|
|
||||||
local ScheduleID = nil
|
local ScheduleID = nil
|
||||||
|
|
||||||
|
self.MasterObject = SchedulerObject
|
||||||
|
|
||||||
if SchedulerFunction then
|
if SchedulerFunction then
|
||||||
ScheduleID = self:Schedule( SchedulerObject, SchedulerFunction, SchedulerArguments, Start, Repeat, RandomizeFactor, Stop )
|
ScheduleID = self:Schedule( SchedulerObject, SchedulerFunction, SchedulerArguments, Start, Repeat, RandomizeFactor, Stop )
|
||||||
end
|
end
|
||||||
|
|||||||
@ -591,6 +591,7 @@ function SPAWN:ReSpawn( SpawnIndex )
|
|||||||
|
|
||||||
-- TODO: This logic makes DCS crash and i don't know why (yet).
|
-- TODO: This logic makes DCS crash and i don't know why (yet).
|
||||||
local SpawnGroup = self:GetGroupFromIndex( SpawnIndex )
|
local SpawnGroup = self:GetGroupFromIndex( SpawnIndex )
|
||||||
|
local WayPoints = SpawnGroup and SpawnGroup.WayPoints or nil
|
||||||
if SpawnGroup then
|
if SpawnGroup then
|
||||||
local SpawnDCSGroup = SpawnGroup:GetDCSObject()
|
local SpawnDCSGroup = SpawnGroup:GetDCSObject()
|
||||||
if SpawnDCSGroup then
|
if SpawnDCSGroup then
|
||||||
@ -598,7 +599,15 @@ function SPAWN:ReSpawn( SpawnIndex )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return self:SpawnWithIndex( SpawnIndex )
|
local SpawnGroup = self:SpawnWithIndex( SpawnIndex )
|
||||||
|
if SpawnGroup and WayPoints then
|
||||||
|
-- If there were WayPoints set, then Re-Execute those WayPoints!
|
||||||
|
self:E( WayPoints )
|
||||||
|
SpawnGroup:WayPointInitialize( WayPoints )
|
||||||
|
SpawnGroup:WayPointExecute( 1, 5 )
|
||||||
|
end
|
||||||
|
|
||||||
|
return SpawnGroup
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Will spawn a group with a specified index number.
|
--- Will spawn a group with a specified index number.
|
||||||
|
|||||||
@ -144,6 +144,8 @@ function CONTROLLABLE:New( ControllableName )
|
|||||||
local self = BASE:Inherit( self, POSITIONABLE:New( ControllableName ) )
|
local self = BASE:Inherit( self, POSITIONABLE:New( ControllableName ) )
|
||||||
self:F2( ControllableName )
|
self:F2( ControllableName )
|
||||||
self.ControllableName = ControllableName
|
self.ControllableName = ControllableName
|
||||||
|
|
||||||
|
self.TaskScheduler = SCHEDULER:New( self )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -202,7 +204,7 @@ function CONTROLLABLE:PushTask( DCSTask, WaitTime )
|
|||||||
-- Controller:pushTask( DCSTask )
|
-- Controller:pushTask( DCSTask )
|
||||||
|
|
||||||
if WaitTime then
|
if WaitTime then
|
||||||
SCHEDULER:New( Controller, Controller.pushTask, { DCSTask }, WaitTime )
|
self.TaskScheduler:Schedule( Controller, Controller.pushTask, { DCSTask }, WaitTime )
|
||||||
else
|
else
|
||||||
Controller:pushTask( DCSTask )
|
Controller:pushTask( DCSTask )
|
||||||
end
|
end
|
||||||
@ -233,7 +235,7 @@ function CONTROLLABLE:SetTask( DCSTask, WaitTime )
|
|||||||
if not WaitTime then
|
if not WaitTime then
|
||||||
Controller:setTask( DCSTask )
|
Controller:setTask( DCSTask )
|
||||||
else
|
else
|
||||||
SCHEDULER:New( Controller, Controller.setTask, { DCSTask }, WaitTime )
|
self.TaskScheduler:Schedule( Controller, Controller.setTask, { DCSTask }, WaitTime )
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -1494,7 +1496,7 @@ function CONTROLLABLE:Route( GoPoints )
|
|||||||
local MissionTask = { id = 'Mission', params = { route = { points = Points, }, }, }
|
local MissionTask = { id = 'Mission', params = { route = { points = Points, }, }, }
|
||||||
local Controller = self:_GetController()
|
local Controller = self:_GetController()
|
||||||
--Controller.setTask( Controller, MissionTask )
|
--Controller.setTask( Controller, MissionTask )
|
||||||
SCHEDULER:New( Controller, Controller.setTask, { MissionTask }, 1 )
|
self.TaskScheduler:Schedule( Controller, Controller.setTask, { MissionTask }, 1 )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2122,7 +2124,7 @@ end
|
|||||||
-- @param #table WayPoints If WayPoints is given, then use the route.
|
-- @param #table WayPoints If WayPoints is given, then use the route.
|
||||||
-- @return #CONTROLLABLE
|
-- @return #CONTROLLABLE
|
||||||
function CONTROLLABLE:WayPointInitialize( WayPoints )
|
function CONTROLLABLE:WayPointInitialize( WayPoints )
|
||||||
self:F( { WayPoint, WayPointIndex, WayPointFunction } )
|
self:F( { WayPoints } )
|
||||||
|
|
||||||
if WayPoints then
|
if WayPoints then
|
||||||
self.WayPoints = WayPoints
|
self.WayPoints = WayPoints
|
||||||
@ -2133,6 +2135,18 @@ function CONTROLLABLE:WayPointInitialize( WayPoints )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get the current WayPoints set with the WayPoint functions( Note that the WayPoints can be nil, although there ARE waypoints).
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @return #table WayPoints If WayPoints is given, then return the WayPoints structure.
|
||||||
|
function CONTROLLABLE:GetWayPoints()
|
||||||
|
self:F( )
|
||||||
|
|
||||||
|
if self.WayPoints then
|
||||||
|
return self.WayPoints
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
--- Registers a waypoint function that will be executed when the controllable moves over the WayPoint.
|
--- Registers a waypoint function that will be executed when the controllable moves over the WayPoint.
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
env.info( '*** MOOSE STATIC INCLUDE START *** ' )
|
env.info( '*** MOOSE STATIC INCLUDE START *** ' )
|
||||||
env.info( 'Moose Generation Timestamp: 20170110_1254' )
|
env.info( 'Moose Generation Timestamp: 20170112_1201' )
|
||||||
local base = _G
|
local base = _G
|
||||||
|
|
||||||
Include = {}
|
Include = {}
|
||||||
@ -3857,6 +3857,8 @@ function SCHEDULER:New( SchedulerObject, SchedulerFunction, SchedulerArguments,
|
|||||||
|
|
||||||
local ScheduleID = nil
|
local ScheduleID = nil
|
||||||
|
|
||||||
|
self.MasterObject = SchedulerObject
|
||||||
|
|
||||||
if SchedulerFunction then
|
if SchedulerFunction then
|
||||||
ScheduleID = self:Schedule( SchedulerObject, SchedulerFunction, SchedulerArguments, Start, Repeat, RandomizeFactor, Stop )
|
ScheduleID = self:Schedule( SchedulerObject, SchedulerFunction, SchedulerArguments, Start, Repeat, RandomizeFactor, Stop )
|
||||||
end
|
end
|
||||||
@ -4015,9 +4017,9 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
|||||||
-- If the object used as the key is nil, then the garbage collector will remove the item from the Functions array.
|
-- If the object used as the key is nil, then the garbage collector will remove the item from the Functions array.
|
||||||
self.ObjectSchedulers = self.ObjectSchedulers or setmetatable( {}, { __mode = "v" } )
|
self.ObjectSchedulers = self.ObjectSchedulers or setmetatable( {}, { __mode = "v" } )
|
||||||
|
|
||||||
if Scheduler.SchedulerObject then
|
if Scheduler.MasterObject then
|
||||||
self.ObjectSchedulers[self.CallID] = Scheduler
|
self.ObjectSchedulers[self.CallID] = Scheduler
|
||||||
self:E( { CallID = self.CallID, ObjectScheduler = tostring(self.ObjectSchedulers[self.CallID]), SchedulerObject = tostring(Scheduler.SchedulerObject) } )
|
self:E( { CallID = self.CallID, ObjectScheduler = tostring(self.ObjectSchedulers[self.CallID]), MasterObject = tostring(Scheduler.MasterObject) } )
|
||||||
else
|
else
|
||||||
self.PersistentSchedulers[self.CallID] = Scheduler
|
self.PersistentSchedulers[self.CallID] = Scheduler
|
||||||
self:E( { CallID = self.CallID, PersistentScheduler = self.PersistentSchedulers[self.CallID] } )
|
self:E( { CallID = self.CallID, PersistentScheduler = self.PersistentSchedulers[self.CallID] } )
|
||||||
@ -4029,7 +4031,7 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
|||||||
self.Schedule[Scheduler][self.CallID].Function = ScheduleFunction
|
self.Schedule[Scheduler][self.CallID].Function = ScheduleFunction
|
||||||
self.Schedule[Scheduler][self.CallID].Arguments = ScheduleArguments
|
self.Schedule[Scheduler][self.CallID].Arguments = ScheduleArguments
|
||||||
self.Schedule[Scheduler][self.CallID].StartTime = timer.getTime() + ( Start or 0 )
|
self.Schedule[Scheduler][self.CallID].StartTime = timer.getTime() + ( Start or 0 )
|
||||||
self.Schedule[Scheduler][self.CallID].Start = Start + .001
|
self.Schedule[Scheduler][self.CallID].Start = Start + .1
|
||||||
self.Schedule[Scheduler][self.CallID].Repeat = Repeat
|
self.Schedule[Scheduler][self.CallID].Repeat = Repeat
|
||||||
self.Schedule[Scheduler][self.CallID].Randomize = Randomize
|
self.Schedule[Scheduler][self.CallID].Randomize = Randomize
|
||||||
self.Schedule[Scheduler][self.CallID].Stop = Stop
|
self.Schedule[Scheduler][self.CallID].Stop = Stop
|
||||||
@ -4105,7 +4107,7 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
|||||||
self:Stop( Scheduler, CallID )
|
self:Stop( Scheduler, CallID )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
--self:E( "Scheduled obscolete call for CallID: " .. CallID )
|
self:E( "Scheduled obscolete call for CallID: " .. CallID )
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -12627,6 +12629,8 @@ function CONTROLLABLE:New( ControllableName )
|
|||||||
local self = BASE:Inherit( self, POSITIONABLE:New( ControllableName ) )
|
local self = BASE:Inherit( self, POSITIONABLE:New( ControllableName ) )
|
||||||
self:F2( ControllableName )
|
self:F2( ControllableName )
|
||||||
self.ControllableName = ControllableName
|
self.ControllableName = ControllableName
|
||||||
|
|
||||||
|
self.TaskScheduler = SCHEDULER:New( self )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -12685,7 +12689,7 @@ function CONTROLLABLE:PushTask( DCSTask, WaitTime )
|
|||||||
-- Controller:pushTask( DCSTask )
|
-- Controller:pushTask( DCSTask )
|
||||||
|
|
||||||
if WaitTime then
|
if WaitTime then
|
||||||
SCHEDULER:New( Controller, Controller.pushTask, { DCSTask }, WaitTime )
|
self.TaskScheduler:Schedule( Controller, Controller.pushTask, { DCSTask }, WaitTime )
|
||||||
else
|
else
|
||||||
Controller:pushTask( DCSTask )
|
Controller:pushTask( DCSTask )
|
||||||
end
|
end
|
||||||
@ -12716,7 +12720,7 @@ function CONTROLLABLE:SetTask( DCSTask, WaitTime )
|
|||||||
if not WaitTime then
|
if not WaitTime then
|
||||||
Controller:setTask( DCSTask )
|
Controller:setTask( DCSTask )
|
||||||
else
|
else
|
||||||
SCHEDULER:New( Controller, Controller.setTask, { DCSTask }, WaitTime )
|
self.TaskScheduler:Schedule( Controller, Controller.setTask, { DCSTask }, WaitTime )
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -13977,7 +13981,7 @@ function CONTROLLABLE:Route( GoPoints )
|
|||||||
local MissionTask = { id = 'Mission', params = { route = { points = Points, }, }, }
|
local MissionTask = { id = 'Mission', params = { route = { points = Points, }, }, }
|
||||||
local Controller = self:_GetController()
|
local Controller = self:_GetController()
|
||||||
--Controller.setTask( Controller, MissionTask )
|
--Controller.setTask( Controller, MissionTask )
|
||||||
SCHEDULER:New( Controller, Controller.setTask, { MissionTask }, 1 )
|
self.TaskScheduler:Schedule( Controller, Controller.setTask, { MissionTask }, 1 )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -14605,7 +14609,7 @@ end
|
|||||||
-- @param #table WayPoints If WayPoints is given, then use the route.
|
-- @param #table WayPoints If WayPoints is given, then use the route.
|
||||||
-- @return #CONTROLLABLE
|
-- @return #CONTROLLABLE
|
||||||
function CONTROLLABLE:WayPointInitialize( WayPoints )
|
function CONTROLLABLE:WayPointInitialize( WayPoints )
|
||||||
self:F( { WayPoint, WayPointIndex, WayPointFunction } )
|
self:F( { WayPoints } )
|
||||||
|
|
||||||
if WayPoints then
|
if WayPoints then
|
||||||
self.WayPoints = WayPoints
|
self.WayPoints = WayPoints
|
||||||
@ -14616,6 +14620,18 @@ function CONTROLLABLE:WayPointInitialize( WayPoints )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get the current WayPoints set with the WayPoint functions( Note that the WayPoints can be nil, although there ARE waypoints).
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @return #table WayPoints If WayPoints is given, then return the WayPoints structure.
|
||||||
|
function CONTROLLABLE:GetWayPoints()
|
||||||
|
self:F( )
|
||||||
|
|
||||||
|
if self.WayPoints then
|
||||||
|
return self.WayPoints
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
--- Registers a waypoint function that will be executed when the controllable moves over the WayPoint.
|
--- Registers a waypoint function that will be executed when the controllable moves over the WayPoint.
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
@ -18775,6 +18791,7 @@ function SPAWN:ReSpawn( SpawnIndex )
|
|||||||
|
|
||||||
-- TODO: This logic makes DCS crash and i don't know why (yet).
|
-- TODO: This logic makes DCS crash and i don't know why (yet).
|
||||||
local SpawnGroup = self:GetGroupFromIndex( SpawnIndex )
|
local SpawnGroup = self:GetGroupFromIndex( SpawnIndex )
|
||||||
|
local WayPoints = SpawnGroup and SpawnGroup.WayPoints or nil
|
||||||
if SpawnGroup then
|
if SpawnGroup then
|
||||||
local SpawnDCSGroup = SpawnGroup:GetDCSObject()
|
local SpawnDCSGroup = SpawnGroup:GetDCSObject()
|
||||||
if SpawnDCSGroup then
|
if SpawnDCSGroup then
|
||||||
@ -18782,7 +18799,15 @@ function SPAWN:ReSpawn( SpawnIndex )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return self:SpawnWithIndex( SpawnIndex )
|
local SpawnGroup = self:SpawnWithIndex( SpawnIndex )
|
||||||
|
if SpawnGroup and WayPoints then
|
||||||
|
-- If there were WayPoints set, then Re-Execute those WayPoints!
|
||||||
|
self:E( WayPoints )
|
||||||
|
SpawnGroup:WayPointInitialize( WayPoints )
|
||||||
|
SpawnGroup:WayPointExecute( 1, 5 )
|
||||||
|
end
|
||||||
|
|
||||||
|
return SpawnGroup
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Will spawn a group with a specified index number.
|
--- Will spawn a group with a specified index number.
|
||||||
@ -24834,8 +24859,8 @@ function AI_PATROLZONE:onenterRoute()
|
|||||||
self.Controllable:SetState( self.Controllable, "PatrolZone", self )
|
self.Controllable:SetState( self.Controllable, "PatrolZone", self )
|
||||||
self.Controllable:WayPointFunction( #PatrolRoute, 1, "_NewPatrolRoute" )
|
self.Controllable:WayPointFunction( #PatrolRoute, 1, "_NewPatrolRoute" )
|
||||||
|
|
||||||
--- NOW ACT_ROUTE THE GROUP!
|
--- NOW ROUTE THE GROUP!
|
||||||
self.Controllable:WayPointExecute( 1 )
|
self.Controllable:WayPointExecute( 1, 5 )
|
||||||
|
|
||||||
self:__Patrol( 30 )
|
self:__Patrol( 30 )
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
env.info( '*** MOOSE STATIC INCLUDE START *** ' )
|
env.info( '*** MOOSE STATIC INCLUDE START *** ' )
|
||||||
env.info( 'Moose Generation Timestamp: 20170110_1254' )
|
env.info( 'Moose Generation Timestamp: 20170112_1201' )
|
||||||
local base = _G
|
local base = _G
|
||||||
|
|
||||||
Include = {}
|
Include = {}
|
||||||
@ -3857,6 +3857,8 @@ function SCHEDULER:New( SchedulerObject, SchedulerFunction, SchedulerArguments,
|
|||||||
|
|
||||||
local ScheduleID = nil
|
local ScheduleID = nil
|
||||||
|
|
||||||
|
self.MasterObject = SchedulerObject
|
||||||
|
|
||||||
if SchedulerFunction then
|
if SchedulerFunction then
|
||||||
ScheduleID = self:Schedule( SchedulerObject, SchedulerFunction, SchedulerArguments, Start, Repeat, RandomizeFactor, Stop )
|
ScheduleID = self:Schedule( SchedulerObject, SchedulerFunction, SchedulerArguments, Start, Repeat, RandomizeFactor, Stop )
|
||||||
end
|
end
|
||||||
@ -4015,9 +4017,9 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
|||||||
-- If the object used as the key is nil, then the garbage collector will remove the item from the Functions array.
|
-- If the object used as the key is nil, then the garbage collector will remove the item from the Functions array.
|
||||||
self.ObjectSchedulers = self.ObjectSchedulers or setmetatable( {}, { __mode = "v" } )
|
self.ObjectSchedulers = self.ObjectSchedulers or setmetatable( {}, { __mode = "v" } )
|
||||||
|
|
||||||
if Scheduler.SchedulerObject then
|
if Scheduler.MasterObject then
|
||||||
self.ObjectSchedulers[self.CallID] = Scheduler
|
self.ObjectSchedulers[self.CallID] = Scheduler
|
||||||
self:E( { CallID = self.CallID, ObjectScheduler = tostring(self.ObjectSchedulers[self.CallID]), SchedulerObject = tostring(Scheduler.SchedulerObject) } )
|
self:E( { CallID = self.CallID, ObjectScheduler = tostring(self.ObjectSchedulers[self.CallID]), MasterObject = tostring(Scheduler.MasterObject) } )
|
||||||
else
|
else
|
||||||
self.PersistentSchedulers[self.CallID] = Scheduler
|
self.PersistentSchedulers[self.CallID] = Scheduler
|
||||||
self:E( { CallID = self.CallID, PersistentScheduler = self.PersistentSchedulers[self.CallID] } )
|
self:E( { CallID = self.CallID, PersistentScheduler = self.PersistentSchedulers[self.CallID] } )
|
||||||
@ -4029,7 +4031,7 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
|||||||
self.Schedule[Scheduler][self.CallID].Function = ScheduleFunction
|
self.Schedule[Scheduler][self.CallID].Function = ScheduleFunction
|
||||||
self.Schedule[Scheduler][self.CallID].Arguments = ScheduleArguments
|
self.Schedule[Scheduler][self.CallID].Arguments = ScheduleArguments
|
||||||
self.Schedule[Scheduler][self.CallID].StartTime = timer.getTime() + ( Start or 0 )
|
self.Schedule[Scheduler][self.CallID].StartTime = timer.getTime() + ( Start or 0 )
|
||||||
self.Schedule[Scheduler][self.CallID].Start = Start + .001
|
self.Schedule[Scheduler][self.CallID].Start = Start + .1
|
||||||
self.Schedule[Scheduler][self.CallID].Repeat = Repeat
|
self.Schedule[Scheduler][self.CallID].Repeat = Repeat
|
||||||
self.Schedule[Scheduler][self.CallID].Randomize = Randomize
|
self.Schedule[Scheduler][self.CallID].Randomize = Randomize
|
||||||
self.Schedule[Scheduler][self.CallID].Stop = Stop
|
self.Schedule[Scheduler][self.CallID].Stop = Stop
|
||||||
@ -4105,7 +4107,7 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
|
|||||||
self:Stop( Scheduler, CallID )
|
self:Stop( Scheduler, CallID )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
--self:E( "Scheduled obscolete call for CallID: " .. CallID )
|
self:E( "Scheduled obscolete call for CallID: " .. CallID )
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -12627,6 +12629,8 @@ function CONTROLLABLE:New( ControllableName )
|
|||||||
local self = BASE:Inherit( self, POSITIONABLE:New( ControllableName ) )
|
local self = BASE:Inherit( self, POSITIONABLE:New( ControllableName ) )
|
||||||
self:F2( ControllableName )
|
self:F2( ControllableName )
|
||||||
self.ControllableName = ControllableName
|
self.ControllableName = ControllableName
|
||||||
|
|
||||||
|
self.TaskScheduler = SCHEDULER:New( self )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -12685,7 +12689,7 @@ function CONTROLLABLE:PushTask( DCSTask, WaitTime )
|
|||||||
-- Controller:pushTask( DCSTask )
|
-- Controller:pushTask( DCSTask )
|
||||||
|
|
||||||
if WaitTime then
|
if WaitTime then
|
||||||
SCHEDULER:New( Controller, Controller.pushTask, { DCSTask }, WaitTime )
|
self.TaskScheduler:Schedule( Controller, Controller.pushTask, { DCSTask }, WaitTime )
|
||||||
else
|
else
|
||||||
Controller:pushTask( DCSTask )
|
Controller:pushTask( DCSTask )
|
||||||
end
|
end
|
||||||
@ -12716,7 +12720,7 @@ function CONTROLLABLE:SetTask( DCSTask, WaitTime )
|
|||||||
if not WaitTime then
|
if not WaitTime then
|
||||||
Controller:setTask( DCSTask )
|
Controller:setTask( DCSTask )
|
||||||
else
|
else
|
||||||
SCHEDULER:New( Controller, Controller.setTask, { DCSTask }, WaitTime )
|
self.TaskScheduler:Schedule( Controller, Controller.setTask, { DCSTask }, WaitTime )
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -13977,7 +13981,7 @@ function CONTROLLABLE:Route( GoPoints )
|
|||||||
local MissionTask = { id = 'Mission', params = { route = { points = Points, }, }, }
|
local MissionTask = { id = 'Mission', params = { route = { points = Points, }, }, }
|
||||||
local Controller = self:_GetController()
|
local Controller = self:_GetController()
|
||||||
--Controller.setTask( Controller, MissionTask )
|
--Controller.setTask( Controller, MissionTask )
|
||||||
SCHEDULER:New( Controller, Controller.setTask, { MissionTask }, 1 )
|
self.TaskScheduler:Schedule( Controller, Controller.setTask, { MissionTask }, 1 )
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -14605,7 +14609,7 @@ end
|
|||||||
-- @param #table WayPoints If WayPoints is given, then use the route.
|
-- @param #table WayPoints If WayPoints is given, then use the route.
|
||||||
-- @return #CONTROLLABLE
|
-- @return #CONTROLLABLE
|
||||||
function CONTROLLABLE:WayPointInitialize( WayPoints )
|
function CONTROLLABLE:WayPointInitialize( WayPoints )
|
||||||
self:F( { WayPoint, WayPointIndex, WayPointFunction } )
|
self:F( { WayPoints } )
|
||||||
|
|
||||||
if WayPoints then
|
if WayPoints then
|
||||||
self.WayPoints = WayPoints
|
self.WayPoints = WayPoints
|
||||||
@ -14616,6 +14620,18 @@ function CONTROLLABLE:WayPointInitialize( WayPoints )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get the current WayPoints set with the WayPoint functions( Note that the WayPoints can be nil, although there ARE waypoints).
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @return #table WayPoints If WayPoints is given, then return the WayPoints structure.
|
||||||
|
function CONTROLLABLE:GetWayPoints()
|
||||||
|
self:F( )
|
||||||
|
|
||||||
|
if self.WayPoints then
|
||||||
|
return self.WayPoints
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
--- Registers a waypoint function that will be executed when the controllable moves over the WayPoint.
|
--- Registers a waypoint function that will be executed when the controllable moves over the WayPoint.
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
@ -18775,6 +18791,7 @@ function SPAWN:ReSpawn( SpawnIndex )
|
|||||||
|
|
||||||
-- TODO: This logic makes DCS crash and i don't know why (yet).
|
-- TODO: This logic makes DCS crash and i don't know why (yet).
|
||||||
local SpawnGroup = self:GetGroupFromIndex( SpawnIndex )
|
local SpawnGroup = self:GetGroupFromIndex( SpawnIndex )
|
||||||
|
local WayPoints = SpawnGroup and SpawnGroup.WayPoints or nil
|
||||||
if SpawnGroup then
|
if SpawnGroup then
|
||||||
local SpawnDCSGroup = SpawnGroup:GetDCSObject()
|
local SpawnDCSGroup = SpawnGroup:GetDCSObject()
|
||||||
if SpawnDCSGroup then
|
if SpawnDCSGroup then
|
||||||
@ -18782,7 +18799,15 @@ function SPAWN:ReSpawn( SpawnIndex )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return self:SpawnWithIndex( SpawnIndex )
|
local SpawnGroup = self:SpawnWithIndex( SpawnIndex )
|
||||||
|
if SpawnGroup and WayPoints then
|
||||||
|
-- If there were WayPoints set, then Re-Execute those WayPoints!
|
||||||
|
self:E( WayPoints )
|
||||||
|
SpawnGroup:WayPointInitialize( WayPoints )
|
||||||
|
SpawnGroup:WayPointExecute( 1, 5 )
|
||||||
|
end
|
||||||
|
|
||||||
|
return SpawnGroup
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Will spawn a group with a specified index number.
|
--- Will spawn a group with a specified index number.
|
||||||
@ -24834,8 +24859,8 @@ function AI_PATROLZONE:onenterRoute()
|
|||||||
self.Controllable:SetState( self.Controllable, "PatrolZone", self )
|
self.Controllable:SetState( self.Controllable, "PatrolZone", self )
|
||||||
self.Controllable:WayPointFunction( #PatrolRoute, 1, "_NewPatrolRoute" )
|
self.Controllable:WayPointFunction( #PatrolRoute, 1, "_NewPatrolRoute" )
|
||||||
|
|
||||||
--- NOW ACT_ROUTE THE GROUP!
|
--- NOW ROUTE THE GROUP!
|
||||||
self.Controllable:WayPointExecute( 1 )
|
self.Controllable:WayPointExecute( 1, 5 )
|
||||||
|
|
||||||
self:__Patrol( 30 )
|
self:__Patrol( 30 )
|
||||||
end
|
end
|
||||||
|
|||||||
@ -31,15 +31,17 @@ local RU_PlanesSpawn = SPAWN:New( "AI RU" ):InitCleanUp( 20 )
|
|||||||
-- Start the AI_BALANCER, using the SET of red CLIENTs, and the SPAWN object as a parameter.
|
-- Start the AI_BALANCER, using the SET of red CLIENTs, and the SPAWN object as a parameter.
|
||||||
local RU_AI_Balancer = AI_BALANCER:New( RU_PlanesClientSet, RU_PlanesSpawn )
|
local RU_AI_Balancer = AI_BALANCER:New( RU_PlanesClientSet, RU_PlanesSpawn )
|
||||||
|
|
||||||
|
local PatrolZones = {}
|
||||||
|
|
||||||
function RU_AI_Balancer:OnAfterSpawned( SetGroup, From, Event, To, AIGroup )
|
function RU_AI_Balancer:OnAfterSpawned( SetGroup, From, Event, To, AIGroup )
|
||||||
|
|
||||||
local PatrolZoneGroup = GROUP:FindByName( "PatrolZone" )
|
local PatrolZoneGroup = GROUP:FindByName( "PatrolZone" )
|
||||||
local PatrolZone = ZONE_POLYGON:New( "PatrolZone", PatrolZoneGroup )
|
local PatrolZone = ZONE_POLYGON:New( "PatrolZone", PatrolZoneGroup )
|
||||||
|
|
||||||
|
|
||||||
local Patrol = AI_PATROLZONE:New( PatrolZone, 3000, 6000, 400, 600 )
|
PatrolZones[AIGroup] = AI_PATROLZONE:New( PatrolZone, 3000, 6000, 400, 600 )
|
||||||
Patrol:ManageFuel( 0.2, 60 )
|
PatrolZones[AIGroup]:ManageFuel( 0.2, 60 )
|
||||||
Patrol:SetControllable( AIGroup )
|
PatrolZones[AIGroup]:SetControllable( AIGroup )
|
||||||
Patrol:__Start( 5 )
|
PatrolZones[AIGroup]:__Start( 5 )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Binary file not shown.
@ -25,7 +25,7 @@ local RU_PlanesClientSet = SET_CLIENT:New():FilterCountries( "RUSSIA" ):FilterCa
|
|||||||
-- Define the SPAWN object for the red AI plane template.
|
-- Define the SPAWN object for the red AI plane template.
|
||||||
-- We use InitCleanUp to check every 20 seconds, if there are no planes blocked at the airbase, waithing for take-off.
|
-- We use InitCleanUp to check every 20 seconds, if there are no planes blocked at the airbase, waithing for take-off.
|
||||||
-- If a blocked plane exists, this red plane will be ReSpawned.
|
-- If a blocked plane exists, this red plane will be ReSpawned.
|
||||||
local RU_PlanesSpawn = SPAWN:New( "AI RU" )
|
local RU_PlanesSpawn = SPAWN:New( "AI RU" ):InitCleanUp( 60 )
|
||||||
|
|
||||||
-- Start the AI_BALANCER, using the SET of red CLIENTs, and the SPAWN object as a parameter.
|
-- Start the AI_BALANCER, using the SET of red CLIENTs, and the SPAWN object as a parameter.
|
||||||
local RU_AI_Balancer = AI_BALANCER:New( RU_PlanesClientSet, RU_PlanesSpawn )
|
local RU_AI_Balancer = AI_BALANCER:New( RU_PlanesClientSet, RU_PlanesSpawn )
|
||||||
|
|||||||
@ -24,7 +24,7 @@ local RU_PlanesClientSet = SET_CLIENT:New():FilterCountries( "RUSSIA" ):FilterCa
|
|||||||
-- Define the SPAWN object for the red AI plane template.
|
-- Define the SPAWN object for the red AI plane template.
|
||||||
-- We use InitCleanUp to check every 20 seconds, if there are no planes blocked at the airbase, waithing for take-off.
|
-- We use InitCleanUp to check every 20 seconds, if there are no planes blocked at the airbase, waithing for take-off.
|
||||||
-- If a blocked plane exists, this red plane will be ReSpawned.
|
-- If a blocked plane exists, this red plane will be ReSpawned.
|
||||||
local RU_PlanesSpawn = SPAWN:New( "AI RU" ):InitCleanUp( 20 )
|
local RU_PlanesSpawn = SPAWN:New( "AI RU" ):InitCleanUp( 60 )
|
||||||
|
|
||||||
-- Start the AI_BALANCER, using the SET of red CLIENTs, and the SPAWN object as a parameter.
|
-- Start the AI_BALANCER, using the SET of red CLIENTs, and the SPAWN object as a parameter.
|
||||||
local RU_AI_Balancer = AI_BALANCER:New( RU_PlanesClientSet, RU_PlanesSpawn )
|
local RU_AI_Balancer = AI_BALANCER:New( RU_PlanesClientSet, RU_PlanesSpawn )
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user