Merge remote-tracking branch 'refs/remotes/origin/master' into Detection

This commit is contained in:
FlightControl 2016-06-26 07:45:34 +02:00
commit 4056e5d66d
40 changed files with 183 additions and 368 deletions

View File

@ -440,7 +440,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:_F( Arguments, DebugInfoCurrentParam, DebugInfoFromParam ) function BASE:_F( Arguments, DebugInfoCurrentParam, DebugInfoFromParam )
if ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then if debug and ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then
local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" ) local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" )
local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" ) local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" )
@ -469,7 +469,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:F( Arguments ) function BASE:F( Arguments )
if _TraceOnOff then if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoFrom = debug.getinfo( 3, "l" )
@ -485,7 +485,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:F2( Arguments ) function BASE:F2( Arguments )
if _TraceOnOff then if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoFrom = debug.getinfo( 3, "l" )
@ -500,7 +500,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:F3( Arguments ) function BASE:F3( Arguments )
if _TraceOnOff then if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoFrom = debug.getinfo( 3, "l" )
@ -515,7 +515,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:_T( Arguments, DebugInfoCurrentParam, DebugInfoFromParam ) function BASE:_T( Arguments, DebugInfoCurrentParam, DebugInfoFromParam )
if ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then if debug and ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then
local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" ) local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" )
local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" ) local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" )
@ -544,7 +544,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:T( Arguments ) function BASE:T( Arguments )
if _TraceOnOff then if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoFrom = debug.getinfo( 3, "l" )
@ -560,7 +560,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:T2( Arguments ) function BASE:T2( Arguments )
if _TraceOnOff then if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoFrom = debug.getinfo( 3, "l" )
@ -575,7 +575,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:T3( Arguments ) function BASE:T3( Arguments )
if _TraceOnOff then if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoFrom = debug.getinfo( 3, "l" )
@ -590,21 +590,24 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:E( Arguments ) function BASE:E( Arguments )
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) if debug then
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" )
local Function = "function"
if DebugInfoCurrent.name then local Function = "function"
Function = DebugInfoCurrent.name if DebugInfoCurrent.name then
end Function = DebugInfoCurrent.name
end
local LineCurrent = DebugInfoCurrent.currentline
local LineFrom = -1 local LineCurrent = DebugInfoCurrent.currentline
if DebugInfoFrom then local LineFrom = -1
LineFrom = DebugInfoFrom.currentline if DebugInfoFrom then
end LineFrom = DebugInfoFrom.currentline
end
env.info( string.format( "%6d(%6d)/%1s:%20s%05d.%s(%s)" , LineCurrent, LineFrom, "E", self.ClassName, self.ClassID, Function, routines.utils.oneLineSerialize( Arguments ) ) )
env.info( string.format( "%6d(%6d)/%1s:%20s%05d.%s(%s)" , LineCurrent, LineFrom, "E", self.ClassName, self.ClassID, Function, routines.utils.oneLineSerialize( Arguments ) ) )
end
end end

View File

@ -887,7 +887,6 @@ function CARGO_PACKAGE:OnBoard( Client, LandingZone, OnBoardSide )
end end
self:T( "Routing " .. CargoHostName ) self:T( "Routing " .. CargoHostName )
--routines.scheduleFunction( routines.goRoute, { CargoHostName, Points}, timer.getTime() + 4 )
SCHEDULER:New( self, routines.goRoute, { CargoHostName, Points }, 4 ) SCHEDULER:New( self, routines.goRoute, { CargoHostName, Points }, 4 )
return Valid return Valid

View File

@ -43,7 +43,6 @@ function CLEANUP:New( ZoneNames, TimeInterval ) local self = BASE:Inherit( self,
_EVENTDISPATCHER:OnBirth( self._OnEventBirth, self ) _EVENTDISPATCHER:OnBirth( self._OnEventBirth, self )
--self.CleanUpScheduler = routines.scheduleFunction( self._CleanUpScheduler, { self }, timer.getTime() + 1, TimeInterval )
self.CleanUpScheduler = SCHEDULER:New( self, self._CleanUpScheduler, {}, 1, TimeInterval ) self.CleanUpScheduler = SCHEDULER:New( self, self._CleanUpScheduler, {}, 1, TimeInterval )
return self return self
@ -168,7 +167,6 @@ function CLEANUP:_EventShot( Event )
if ( CurrentLandingZoneID ) then if ( CurrentLandingZoneID ) then
-- Okay, the missile was fired within the CLEANUP.ZoneNames, destroy the fired weapon. -- Okay, the missile was fired within the CLEANUP.ZoneNames, destroy the fired weapon.
--_SEADmissile:destroy() --_SEADmissile:destroy()
--routines.scheduleFunction( CLEANUP._DestroyMissile, { self, Event.Weapon }, timer.getTime() + 0.1)
SCHEDULER:New( self, CLEANUP._DestroyMissile, { Event.Weapon }, 0.1 ) SCHEDULER:New( self, CLEANUP._DestroyMissile, { Event.Weapon }, 0.1 )
end end
end end
@ -185,7 +183,6 @@ function CLEANUP:_EventHitCleanUp( Event )
self:T( { "Life: ", Event.IniDCSUnitName, ' = ', Event.IniDCSUnit:getLife(), "/", Event.IniDCSUnit:getLife0() } ) self:T( { "Life: ", Event.IniDCSUnitName, ' = ', Event.IniDCSUnit:getLife(), "/", Event.IniDCSUnit:getLife0() } )
if Event.IniDCSUnit:getLife() < Event.IniDCSUnit:getLife0() then if Event.IniDCSUnit:getLife() < Event.IniDCSUnit:getLife0() then
self:T( "CleanUp: Destroy: " .. Event.IniDCSUnitName ) self:T( "CleanUp: Destroy: " .. Event.IniDCSUnitName )
--routines.scheduleFunction( CLEANUP._DestroyUnit, { self, Event.IniDCSUnit }, timer.getTime() + 0.1)
SCHEDULER:New( self, CLEANUP._DestroyUnit, { Event.IniDCSUnit }, 0.1 ) SCHEDULER:New( self, CLEANUP._DestroyUnit, { Event.IniDCSUnit }, 0.1 )
end end
end end
@ -196,7 +193,6 @@ function CLEANUP:_EventHitCleanUp( Event )
self:T( { "Life: ", Event.TgtDCSUnitName, ' = ', Event.TgtDCSUnit:getLife(), "/", Event.TgtDCSUnit:getLife0() } ) self:T( { "Life: ", Event.TgtDCSUnitName, ' = ', Event.TgtDCSUnit:getLife(), "/", Event.TgtDCSUnit:getLife0() } )
if Event.TgtDCSUnit:getLife() < Event.TgtDCSUnit:getLife0() then if Event.TgtDCSUnit:getLife() < Event.TgtDCSUnit:getLife0() then
self:T( "CleanUp: Destroy: " .. Event.TgtDCSUnitName ) self:T( "CleanUp: Destroy: " .. Event.TgtDCSUnitName )
--routines.scheduleFunction( CLEANUP._DestroyUnit, { self, Event.TgtDCSUnit }, timer.getTime() + 0.1 )
SCHEDULER:New( self, CLEANUP._DestroyUnit, { Event.TgtDCSUnit }, 0.1 ) SCHEDULER:New( self, CLEANUP._DestroyUnit, { Event.TgtDCSUnit }, 0.1 )
end end
end end

View File

@ -202,7 +202,6 @@ function CONTROLLABLE:PushTask( DCSTask, WaitTime )
-- Controller:pushTask( DCSTask ) -- Controller:pushTask( DCSTask )
if WaitTime then if WaitTime then
--routines.scheduleFunction( Controller.pushTask, { Controller, DCSTask }, timer.getTime() + WaitTime )
SCHEDULER:New( Controller, Controller.pushTask, { DCSTask }, WaitTime ) SCHEDULER:New( Controller, Controller.pushTask, { DCSTask }, WaitTime )
else else
Controller:pushTask( DCSTask ) Controller:pushTask( DCSTask )
@ -233,7 +232,6 @@ function CONTROLLABLE:SetTask( DCSTask, WaitTime )
if not WaitTime then if not WaitTime then
WaitTime = 1 WaitTime = 1
end end
--routines.scheduleFunction( Controller.setTask, { Controller, DCSTask }, timer.getTime() + WaitTime )
SCHEDULER:New( Controller, Controller.setTask, { DCSTask }, WaitTime ) SCHEDULER:New( Controller, Controller.setTask, { DCSTask }, WaitTime )
return self return self
@ -1481,7 +1479,6 @@ 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 )
--routines.scheduleFunction( Controller.setTask, { Controller, MissionTask}, timer.getTime() + 1 )
SCHEDULER:New( Controller, Controller.setTask, { MissionTask }, 1 ) SCHEDULER:New( Controller, Controller.setTask, { MissionTask }, 1 )
return self return self
end end

View File

@ -8,7 +8,7 @@
-- --
-- 1.1) DETECTION_BASE constructor -- 1.1) DETECTION_BASE constructor
-- ------------------------------- -- -------------------------------
-- Construct a new DETECTION_BASE instance using the @{Detection#DETECTION.New}() method. -- Construct a new DETECTION_BASE instance using the @{Detection#DETECTION_BASE.New}() method.
-- --
-- 1.2) DETECTION_BASE initialization -- 1.2) DETECTION_BASE initialization
-- ---------------------------------- -- ----------------------------------
@ -394,15 +394,17 @@ function DETECTION_UNITGROUPS:SmokeDetectedUnits()
self:F2() self:F2()
self._SmokeDetectedUnits = true self._SmokeDetectedUnits = true
return self
end end
--- Flare the detected units --- Flare the detected units
-- @param #DETECTION_UNITGROUPS self -- @param #DETECTION_UNITGROUPS self
-- @return #DETECTION_UNITGROUPS self -- @return #DETECTION_UNITGROUPS self
function DETECTION_UNITGROUPS:SmokeDetectedUnits() function DETECTION_UNITGROUPS:FlareDetectedUnits()
self:F2() self:F2()
self._FlareDetectedUnits = true self._FlareDetectedUnits = true
return self
end end
--- Smoke the detected zones --- Smoke the detected zones
@ -412,6 +414,7 @@ function DETECTION_UNITGROUPS:SmokeDetectedZones()
self:F2() self:F2()
self._SmokeDetectedZones = true self._SmokeDetectedZones = true
return self
end end
--- Flare the detected zones --- Flare the detected zones
@ -421,6 +424,7 @@ function DETECTION_UNITGROUPS:FlareDetectedZones()
self:F2() self:F2()
self._FlareDetectedZones = true self._FlareDetectedZones = true
return self
end end
@ -445,7 +449,6 @@ function DETECTION_UNITGROUPS:CreateDetectionSets()
for DetectedZoneIndex = 1, #self.DetectedZones do for DetectedZoneIndex = 1, #self.DetectedZones do
self:T( "Detected Unit Set #" .. DetectedZoneIndex ) self:T( "Detected Unit Set #" .. DetectedZoneIndex )
local DetectedUnitSet = self.DetectedSets[DetectedZoneIndex] -- Set#SET_BASE local DetectedUnitSet = self.DetectedSets[DetectedZoneIndex] -- Set#SET_BASE
DetectedUnitSet:Flush()
local DetectedZone = self.DetectedZones[DetectedZoneIndex] -- Zone#ZONE_UNIT local DetectedZone = self.DetectedZones[DetectedZoneIndex] -- Zone#ZONE_UNIT
if DetectedUnit:IsInZone( DetectedZone ) then if DetectedUnit:IsInZone( DetectedZone ) then
self:T( "Adding to Unit Set #" .. DetectedZoneIndex ) self:T( "Adding to Unit Set #" .. DetectedZoneIndex )

View File

@ -557,7 +557,6 @@ function ESCORT:MenuReportTargets( Seconds )
self.EscortMenuAttackNearbyTargets = MENU_CLIENT:New( self.EscortClient, "Attack targets", self.EscortMenu ) self.EscortMenuAttackNearbyTargets = MENU_CLIENT:New( self.EscortClient, "Attack targets", self.EscortMenu )
--self.ReportTargetsScheduler = routines.scheduleFunction( self._ReportTargetsScheduler, { self }, timer.getTime() + 1, Seconds )
self.ReportTargetsScheduler = SCHEDULER:New( self, self._ReportTargetsScheduler, {}, 1, Seconds ) self.ReportTargetsScheduler = SCHEDULER:New( self, self._ReportTargetsScheduler, {}, 1, Seconds )
return self return self
@ -779,7 +778,6 @@ function ESCORT._SwitchReportNearbyTargets( MenuParam )
if self.ReportTargets then if self.ReportTargets then
if not self.ReportTargetsScheduler then if not self.ReportTargetsScheduler then
--self.ReportTargetsScheduler = routines.scheduleFunction( self._ReportTargetsScheduler, { self }, timer.getTime() + 1, 30 )
self.ReportTargetsScheduler = SCHEDULER:New( self, self._ReportTargetsScheduler, {}, 1, 30 ) self.ReportTargetsScheduler = SCHEDULER:New( self, self._ReportTargetsScheduler, {}, 1, 30 )
end end
else else
@ -856,16 +854,6 @@ function ESCORT._AttackTarget( MenuParam )
EscortGroup:OptionROEOpenFire() EscortGroup:OptionROEOpenFire()
EscortGroup:OptionROTPassiveDefense() EscortGroup:OptionROTPassiveDefense()
EscortGroup:SetState( EscortGroup, "Escort", self ) EscortGroup:SetState( EscortGroup, "Escort", self )
-- routines.scheduleFunction(
-- EscortGroup.PushTask,
-- { EscortGroup,
-- EscortGroup:TaskCombo(
-- { EscortGroup:TaskAttackUnit( AttackUnit ),
-- EscortGroup:TaskFunction( 1, 2, "_Resume", {"''"} )
-- }
-- )
-- }, timer.getTime() + 10
-- )
SCHEDULER:New( EscortGroup, SCHEDULER:New( EscortGroup,
EscortGroup.PushTask, EscortGroup.PushTask,
{ EscortGroup:TaskCombo( { EscortGroup:TaskCombo(
@ -876,15 +864,6 @@ function ESCORT._AttackTarget( MenuParam )
}, 10 }, 10
) )
else else
-- routines.scheduleFunction(
-- EscortGroup.PushTask,
-- { EscortGroup,
-- EscortGroup:TaskCombo(
-- { EscortGroup:TaskFireAtPoint( AttackUnit:GetPointVec2(), 50 )
-- }
-- )
-- }, timer.getTime() + 10
-- )
SCHEDULER:New( EscortGroup, SCHEDULER:New( EscortGroup,
EscortGroup.PushTask, EscortGroup.PushTask,
{ EscortGroup:TaskCombo( { EscortGroup:TaskCombo(
@ -915,16 +894,6 @@ function ESCORT._AssistTarget( MenuParam )
if EscortGroupAttack:IsAir() then if EscortGroupAttack:IsAir() then
EscortGroupAttack:OptionROEOpenFire() EscortGroupAttack:OptionROEOpenFire()
EscortGroupAttack:OptionROTVertical() EscortGroupAttack:OptionROTVertical()
-- routines.scheduleFunction(
-- EscortGroupAttack.PushTask,
-- { EscortGroupAttack,
-- EscortGroupAttack:TaskCombo(
-- { EscortGroupAttack:TaskAttackUnit( AttackUnit ),
-- EscortGroupAttack:TaskOrbitCircle( 500, 350 )
-- }
-- )
-- }, timer.getTime() + 10
-- )
SCHDULER:New( EscortGroupAttack, SCHDULER:New( EscortGroupAttack,
EscortGroupAttack.PushTask, EscortGroupAttack.PushTask,
{ EscortGroupAttack:TaskCombo( { EscortGroupAttack:TaskCombo(
@ -935,15 +904,6 @@ function ESCORT._AssistTarget( MenuParam )
}, 10 }, 10
) )
else else
-- routines.scheduleFunction(
-- EscortGroupAttack.PushTask,
-- { EscortGroupAttack,
-- EscortGroupAttack:TaskCombo(
-- { EscortGroupAttack:TaskFireAtPoint( AttackUnit:GetPointVec2(), 50 )
-- }
-- )
-- }, timer.getTime() + 10
-- )
SCHEDULER:New( EscortGroupAttack, SCHEDULER:New( EscortGroupAttack,
EscortGroupAttack.PushTask, EscortGroupAttack.PushTask,
{ EscortGroupAttack:TaskCombo( { EscortGroupAttack:TaskCombo(
@ -1003,7 +963,6 @@ function ESCORT._ResumeMission( MenuParam )
table.remove( WayPoints, 1 ) table.remove( WayPoints, 1 )
end end
--routines.scheduleFunction( EscortGroup.SetTask, {EscortGroup, EscortGroup:TaskRoute( WayPoints ) }, timer.getTime() + 1 )
SCHEDULER:New( EscortGroup, EscortGroup.SetTask, { EscortGroup:TaskRoute( WayPoints ) }, 1 ) SCHEDULER:New( EscortGroup, EscortGroup.SetTask, { EscortGroup:TaskRoute( WayPoints ) }, 1 )
EscortGroup:MessageToClient( "Resuming mission from waypoint " .. WayPoint .. ".", 10, EscortClient ) EscortGroup:MessageToClient( "Resuming mission from waypoint " .. WayPoint .. ".", 10, EscortClient )

View File

@ -465,7 +465,8 @@ function EVENT:OnPlayerLeaveUnit( EventFunction, EventSelf )
end end
--- @param #EVENT self
-- @param #EVENTDATA Event
function EVENT:onEvent( Event ) function EVENT:onEvent( Event )
self:F2( { _EVENTCODES[Event.id], Event } ) self:F2( { _EVENTCODES[Event.id], Event } )
@ -499,7 +500,7 @@ function EVENT:onEvent( Event )
Event.WeaponName = Event.Weapon:getTypeName() Event.WeaponName = Event.Weapon:getTypeName()
--Event.WeaponTgtDCSUnit = Event.Weapon:getTarget() --Event.WeaponTgtDCSUnit = Event.Weapon:getTarget()
end end
self:E( { _EVENTCODES[Event.id], Event } ) self:E( { _EVENTCODES[Event.id], Event.IniUnitName, Event.TgtUnitName, Event.WeaponName } )
for ClassName, EventData in pairs( self.Events[Event.id] ) do for ClassName, EventData in pairs( self.Events[Event.id] ) do
if Event.IniDCSUnitName and EventData.IniUnit and EventData.IniUnit[Event.IniDCSUnitName] then if Event.IniDCSUnitName and EventData.IniUnit and EventData.IniUnit[Event.IniDCSUnitName] then
self:E( { "Calling event function for class ", ClassName, " unit ", Event.IniDCSUnitName } ) self:E( { "Calling event function for class ", ClassName, " unit ", Event.IniDCSUnitName } )

View File

@ -441,22 +441,6 @@ routines.getNorthCorrection = function(point) --gets the correction needed for
end end
-- the main area
do
-- THE MAIN FUNCTION -- Accessed 100 times/sec.
routines.main = function()
timer.scheduleFunction(routines.main, {}, timer.getTime() + 2) --reschedule first in case of Lua error
----------------------------------------------------------------------------------------------------------
--area to add new stuff in
routines.do_scheduled_functions()
end -- end of routines.main
timer.scheduleFunction(routines.main, {}, timer.getTime() + 2)
end
do do
local idNum = 0 local idNum = 0

View File

@ -111,8 +111,10 @@ function SCHEDULER:_Scheduler()
local ErrorHandler = function( errmsg ) local ErrorHandler = function( errmsg )
env.info( "Error in SCHEDULER function:" .. errmsg ) env.info( "Error in SCHEDULER function:" .. errmsg )
env.info( debug.traceback() ) if debug ~= nil then
env.info( debug.traceback() )
end
return errmsg return errmsg
end end

View File

@ -50,7 +50,6 @@ function SEAD:EventShot( Event )
local SEADUnitName = Event.IniDCSUnitName local SEADUnitName = Event.IniDCSUnitName
local SEADWeapon = Event.Weapon -- Identify the weapon fired local SEADWeapon = Event.Weapon -- Identify the weapon fired
local SEADWeaponName = Event.WeaponName -- return weapon type local SEADWeaponName = Event.WeaponName -- return weapon type
--trigger.action.outText( string.format("Alerte, depart missile " ..string.format(SEADWeaponName)), 20) --debug message
-- Start of the 2nd loop -- Start of the 2nd loop
self:T( "Missile Launched = " .. SEADWeaponName ) self:T( "Missile Launched = " .. SEADWeaponName )
if SEADWeaponName == "KH-58" or SEADWeaponName == "KH-25MPU" or SEADWeaponName == "AGM-88" or SEADWeaponName == "KH-31A" or SEADWeaponName == "KH-31P" then -- Check if the missile is a SEAD if SEADWeaponName == "KH-58" or SEADWeaponName == "KH-25MPU" or SEADWeaponName == "AGM-88" or SEADWeaponName == "KH-31A" or SEADWeaponName == "KH-31P" then -- Check if the missile is a SEAD
@ -76,10 +75,10 @@ function SEAD:EventShot( Event )
local Skills = { "Average", "Good", "High", "Excellent" } local Skills = { "Average", "Good", "High", "Excellent" }
_targetskill = Skills[ math.random(1,4) ] _targetskill = Skills[ math.random(1,4) ]
end end
self:T( _targetskill ) -- debug message for skill check self:T( _targetskill )
if self.TargetSkill[_targetskill] then if self.TargetSkill[_targetskill] then
if (_evade > self.TargetSkill[_targetskill].Evade) then if (_evade > self.TargetSkill[_targetskill].Evade) then
self:T( string.format("Evading, target skill " ..string.format(_targetskill)) ) --debug message self:T( string.format("Evading, target skill " ..string.format(_targetskill)) )
local _targetMim = Weapon.getTarget(SEADWeapon) local _targetMim = Weapon.getTarget(SEADWeapon)
local _targetMimname = Unit.getName(_targetMim) local _targetMimname = Unit.getName(_targetMim)
local _targetMimgroup = Unit.getGroup(Weapon.getTarget(SEADWeapon)) local _targetMimgroup = Unit.getGroup(Weapon.getTarget(SEADWeapon))

View File

@ -399,7 +399,7 @@ end
-- @param #SET_BASE self -- @param #SET_BASE self
-- @param Event#EVENTDATA Event -- @param Event#EVENTDATA Event
function SET_BASE:_EventOnDeadOrCrash( Event ) function SET_BASE:_EventOnDeadOrCrash( Event )
self:F2( { Event } ) self:F3( { Event } )
if Event.IniDCSUnit then if Event.IniDCSUnit then
local ObjectName, Object = self:FindInDatabase( Event ) local ObjectName, Object = self:FindInDatabase( Event )
@ -455,7 +455,7 @@ function SET_BASE:ForEach( IteratorFunction, arg, Set, Function, FunctionArgumen
local function CoRoutine() local function CoRoutine()
local Count = 0 local Count = 0
for ObjectID, Object in pairs( Set ) do for ObjectID, Object in pairs( Set ) do
self:T2( Object ) self:T3( Object )
if Function then if Function then
if Function( unpack( FunctionArguments ), Object ) == true then if Function( unpack( FunctionArguments ), Object ) == true then
IteratorFunction( Object, unpack( arg ) ) IteratorFunction( Object, unpack( arg ) )
@ -544,7 +544,7 @@ function SET_BASE:IsIncludeObject( Object )
return true return true
end end
--- Flushes the current SET_BASE contents in the log ... (for debug reasons). --- Flushes the current SET_BASE contents in the log ... (for debugging reasons).
-- @param #SET_BASE self -- @param #SET_BASE self
-- @return #string A string with the names of the objects. -- @return #string A string with the names of the objects.
function SET_BASE:Flush() function SET_BASE:Flush()
@ -1165,7 +1165,6 @@ end
function SET_UNIT:FindInDatabase( Event ) function SET_UNIT:FindInDatabase( Event )
self:F3( { Event } ) self:F3( { Event } )
self:E( { Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName] } )
return Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName] return Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName]
end end

View File

@ -490,33 +490,34 @@ end
--- Returns if a location is within the zone. --- Returns if a location is within the zone.
-- Source learned and taken from: https://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
-- @param #ZONE_POLYGON_BASE self -- @param #ZONE_POLYGON_BASE self
-- @param DCSTypes#Vec2 PointVec2 The location to test. -- @param DCSTypes#Vec2 PointVec2 The location to test.
-- @return #boolean true if the location is within the zone. -- @return #boolean true if the location is within the zone.
function ZONE_POLYGON_BASE:IsPointVec2InZone( PointVec2 ) function ZONE_POLYGON_BASE:IsPointVec2InZone( PointVec2 )
self:F2( PointVec2 ) self:F2( PointVec2 )
local i local Next
local j local Prev
local c = false local InPolygon = false
i = 1 Next = 1
j = #self.Polygon Prev = #self.Polygon
while i < #self.Polygon do while Next <= #self.Polygon do
j = i self:T( { Next, Prev, self.Polygon[Next], self.Polygon[Prev] } )
i = i + 1 if ( ( ( self.Polygon[Next].y > PointVec2.y ) ~= ( self.Polygon[Prev].y > PointVec2.y ) ) and
self:T( { i, j, self.Polygon[i], self.Polygon[j] } ) ( PointVec2.x < ( self.Polygon[Prev].x - self.Polygon[Next].x ) * ( PointVec2.y - self.Polygon[Next].y ) / ( self.Polygon[Prev].y - self.Polygon[Next].y ) + self.Polygon[Next].x )
if ( ( ( self.Polygon[i].y > PointVec2.y ) ~= ( self.Polygon[j].y > PointVec2.y ) ) and
( PointVec2.x < ( self.Polygon[j].x - self.Polygon[i].x ) * ( PointVec2.y - self.Polygon[i].y ) / ( self.Polygon[j].y - self.Polygon[i].y ) + self.Polygon[i].x )
) then ) then
c = not c InPolygon = not InPolygon
end end
self:T2( { "c = ", c } ) self:T2( { InPolygon = InPolygon } )
Prev = Next
Next = Next + 1
end end
self:T( { "c = ", c } ) self:T( { InPolygon = InPolygon } )
return c return InPolygon
end end
--- Define a random @{DCSTypes#Vec2} within the zone. --- Define a random @{DCSTypes#Vec2} within the zone.

View File

@ -3,25 +3,13 @@ local base = _G
Include = {} Include = {}
Include.Path = function()
local str = debug.getinfo(2, "S").source
return str:match("(.*/)"):sub(1,-2):gsub("\\","/")
end
Include.File = function( IncludeFile ) Include.File = function( IncludeFile )
if not Include.Files[ IncludeFile ] then if not Include.Files[ IncludeFile ] then
Include.Files[IncludeFile] = IncludeFile Include.Files[IncludeFile] = IncludeFile
env.info( "Include:" .. IncludeFile .. " from " .. Include.ProgramPath ) env.info( "Include:" .. IncludeFile .. " from " .. Include.ProgramPath )
local f = assert( base.loadfile( Include.ProgramPath .. IncludeFile .. ".lua" ) ) local f = assert( base.loadfile( Include.ProgramPath .. IncludeFile .. ".lua" ) )
if f == nil then if f == nil then
env.info( "Include:" .. IncludeFile .. " from " .. Include.MissionPath ) error ("Could not load MOOSE file " .. IncludeFile .. ".lua" )
local f = assert( base.loadfile( Include.MissionPath .. IncludeFile .. ".lua" ) )
if f == nil then
error ("Could not load MOOSE file " .. IncludeFile .. ".lua" )
else
env.info( "Include:" .. IncludeFile .. " loaded from " .. Include.MissionPath )
return f()
end
else else
env.info( "Include:" .. IncludeFile .. " loaded from " .. Include.ProgramPath ) env.info( "Include:" .. IncludeFile .. " loaded from " .. Include.ProgramPath )
return f() return f()
@ -30,10 +18,8 @@ Include.File = function( IncludeFile )
end end
Include.ProgramPath = "Scripts/Moose/" Include.ProgramPath = "Scripts/Moose/"
Include.MissionPath = Include.Path()
env.info( "Include.ProgramPath = " .. Include.ProgramPath) env.info( "Include.ProgramPath = " .. Include.ProgramPath)
env.info( "Include.MissionPath = " .. Include.MissionPath)
Include.Files = {} Include.Files = {}

View File

@ -1,5 +1,5 @@
env.info( '*** MOOSE STATIC INCLUDE START *** ' ) env.info( '*** MOOSE STATIC INCLUDE START *** ' )
env.info( 'Moose Generation Timestamp: 20160625_0851' ) env.info( 'Moose Generation Timestamp: 20160626_0740' )
local base = _G local base = _G
Include = {} Include = {}
@ -450,22 +450,6 @@ routines.getNorthCorrection = function(point) --gets the correction needed for
end end
-- the main area
do
-- THE MAIN FUNCTION -- Accessed 100 times/sec.
routines.main = function()
timer.scheduleFunction(routines.main, {}, timer.getTime() + 2) --reschedule first in case of Lua error
----------------------------------------------------------------------------------------------------------
--area to add new stuff in
routines.do_scheduled_functions()
end -- end of routines.main
timer.scheduleFunction(routines.main, {}, timer.getTime() + 2)
end
do do
local idNum = 0 local idNum = 0
@ -2969,7 +2953,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:_F( Arguments, DebugInfoCurrentParam, DebugInfoFromParam ) function BASE:_F( Arguments, DebugInfoCurrentParam, DebugInfoFromParam )
if ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then if debug and ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then
local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" ) local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" )
local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" ) local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" )
@ -2998,7 +2982,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:F( Arguments ) function BASE:F( Arguments )
if _TraceOnOff then if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoFrom = debug.getinfo( 3, "l" )
@ -3014,7 +2998,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:F2( Arguments ) function BASE:F2( Arguments )
if _TraceOnOff then if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoFrom = debug.getinfo( 3, "l" )
@ -3029,7 +3013,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:F3( Arguments ) function BASE:F3( Arguments )
if _TraceOnOff then if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoFrom = debug.getinfo( 3, "l" )
@ -3044,7 +3028,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:_T( Arguments, DebugInfoCurrentParam, DebugInfoFromParam ) function BASE:_T( Arguments, DebugInfoCurrentParam, DebugInfoFromParam )
if ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then if debug and ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then
local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" ) local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" )
local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" ) local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" )
@ -3073,7 +3057,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:T( Arguments ) function BASE:T( Arguments )
if _TraceOnOff then if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoFrom = debug.getinfo( 3, "l" )
@ -3089,7 +3073,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:T2( Arguments ) function BASE:T2( Arguments )
if _TraceOnOff then if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoFrom = debug.getinfo( 3, "l" )
@ -3104,7 +3088,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:T3( Arguments ) function BASE:T3( Arguments )
if _TraceOnOff then if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoFrom = debug.getinfo( 3, "l" )
@ -3119,21 +3103,24 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:E( Arguments ) function BASE:E( Arguments )
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) if debug then
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" )
local Function = "function"
if DebugInfoCurrent.name then local Function = "function"
Function = DebugInfoCurrent.name if DebugInfoCurrent.name then
end Function = DebugInfoCurrent.name
end
local LineCurrent = DebugInfoCurrent.currentline
local LineFrom = -1 local LineCurrent = DebugInfoCurrent.currentline
if DebugInfoFrom then local LineFrom = -1
LineFrom = DebugInfoFrom.currentline if DebugInfoFrom then
end LineFrom = DebugInfoFrom.currentline
end
env.info( string.format( "%6d(%6d)/%1s:%20s%05d.%s(%s)" , LineCurrent, LineFrom, "E", self.ClassName, self.ClassID, Function, routines.utils.oneLineSerialize( Arguments ) ) )
env.info( string.format( "%6d(%6d)/%1s:%20s%05d.%s(%s)" , LineCurrent, LineFrom, "E", self.ClassName, self.ClassID, Function, routines.utils.oneLineSerialize( Arguments ) ) )
end
end end
@ -3973,7 +3960,6 @@ function CONTROLLABLE:PushTask( DCSTask, WaitTime )
-- Controller:pushTask( DCSTask ) -- Controller:pushTask( DCSTask )
if WaitTime then if WaitTime then
--routines.scheduleFunction( Controller.pushTask, { Controller, DCSTask }, timer.getTime() + WaitTime )
SCHEDULER:New( Controller, Controller.pushTask, { DCSTask }, WaitTime ) SCHEDULER:New( Controller, Controller.pushTask, { DCSTask }, WaitTime )
else else
Controller:pushTask( DCSTask ) Controller:pushTask( DCSTask )
@ -4004,7 +3990,6 @@ function CONTROLLABLE:SetTask( DCSTask, WaitTime )
if not WaitTime then if not WaitTime then
WaitTime = 1 WaitTime = 1
end end
--routines.scheduleFunction( Controller.setTask, { Controller, DCSTask }, timer.getTime() + WaitTime )
SCHEDULER:New( Controller, Controller.setTask, { DCSTask }, WaitTime ) SCHEDULER:New( Controller, Controller.setTask, { DCSTask }, WaitTime )
return self return self
@ -5252,7 +5237,6 @@ 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 )
--routines.scheduleFunction( Controller.setTask, { Controller, MissionTask}, timer.getTime() + 1 )
SCHEDULER:New( Controller, Controller.setTask, { MissionTask }, 1 ) SCHEDULER:New( Controller, Controller.setTask, { MissionTask }, 1 )
return self return self
end end
@ -6072,8 +6056,10 @@ function SCHEDULER:_Scheduler()
local ErrorHandler = function( errmsg ) local ErrorHandler = function( errmsg )
env.info( "Error in SCHEDULER function:" .. errmsg ) env.info( "Error in SCHEDULER function:" .. errmsg )
env.info( debug.traceback() ) if debug ~= nil then
env.info( debug.traceback() )
end
return errmsg return errmsg
end end
@ -6592,7 +6578,8 @@ function EVENT:OnPlayerLeaveUnit( EventFunction, EventSelf )
end end
--- @param #EVENT self
-- @param #EVENTDATA Event
function EVENT:onEvent( Event ) function EVENT:onEvent( Event )
self:F2( { _EVENTCODES[Event.id], Event } ) self:F2( { _EVENTCODES[Event.id], Event } )
@ -6626,7 +6613,7 @@ function EVENT:onEvent( Event )
Event.WeaponName = Event.Weapon:getTypeName() Event.WeaponName = Event.Weapon:getTypeName()
--Event.WeaponTgtDCSUnit = Event.Weapon:getTarget() --Event.WeaponTgtDCSUnit = Event.Weapon:getTarget()
end end
self:E( { _EVENTCODES[Event.id], Event } ) self:E( { _EVENTCODES[Event.id], Event.IniUnitName, Event.TgtUnitName, Event.WeaponName } )
for ClassName, EventData in pairs( self.Events[Event.id] ) do for ClassName, EventData in pairs( self.Events[Event.id] ) do
if Event.IniDCSUnitName and EventData.IniUnit and EventData.IniUnit[Event.IniDCSUnitName] then if Event.IniDCSUnitName and EventData.IniUnit and EventData.IniUnit[Event.IniDCSUnitName] then
self:E( { "Calling event function for class ", ClassName, " unit ", Event.IniDCSUnitName } ) self:E( { "Calling event function for class ", ClassName, " unit ", Event.IniDCSUnitName } )
@ -8951,33 +8938,34 @@ end
--- Returns if a location is within the zone. --- Returns if a location is within the zone.
-- Source learned and taken from: https://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
-- @param #ZONE_POLYGON_BASE self -- @param #ZONE_POLYGON_BASE self
-- @param DCSTypes#Vec2 PointVec2 The location to test. -- @param DCSTypes#Vec2 PointVec2 The location to test.
-- @return #boolean true if the location is within the zone. -- @return #boolean true if the location is within the zone.
function ZONE_POLYGON_BASE:IsPointVec2InZone( PointVec2 ) function ZONE_POLYGON_BASE:IsPointVec2InZone( PointVec2 )
self:F2( PointVec2 ) self:F2( PointVec2 )
local i local Next
local j local Prev
local c = false local InPolygon = false
i = 1 Next = 1
j = #self.Polygon Prev = #self.Polygon
while i < #self.Polygon do while Next <= #self.Polygon do
j = i self:T( { Next, Prev, self.Polygon[Next], self.Polygon[Prev] } )
i = i + 1 if ( ( ( self.Polygon[Next].y > PointVec2.y ) ~= ( self.Polygon[Prev].y > PointVec2.y ) ) and
self:T( { i, j, self.Polygon[i], self.Polygon[j] } ) ( PointVec2.x < ( self.Polygon[Prev].x - self.Polygon[Next].x ) * ( PointVec2.y - self.Polygon[Next].y ) / ( self.Polygon[Prev].y - self.Polygon[Next].y ) + self.Polygon[Next].x )
if ( ( ( self.Polygon[i].y > PointVec2.y ) ~= ( self.Polygon[j].y > PointVec2.y ) ) and
( PointVec2.x < ( self.Polygon[j].x - self.Polygon[i].x ) * ( PointVec2.y - self.Polygon[i].y ) / ( self.Polygon[j].y - self.Polygon[i].y ) + self.Polygon[i].x )
) then ) then
c = not c InPolygon = not InPolygon
end end
self:T2( { "c = ", c } ) self:T2( { InPolygon = InPolygon } )
Prev = Next
Next = Next + 1
end end
self:T( { "c = ", c } ) self:T( { InPolygon = InPolygon } )
return c return InPolygon
end end
--- Define a random @{DCSTypes#Vec2} within the zone. --- Define a random @{DCSTypes#Vec2} within the zone.
@ -11078,7 +11066,7 @@ end
-- @param #SET_BASE self -- @param #SET_BASE self
-- @param Event#EVENTDATA Event -- @param Event#EVENTDATA Event
function SET_BASE:_EventOnDeadOrCrash( Event ) function SET_BASE:_EventOnDeadOrCrash( Event )
self:F2( { Event } ) self:F3( { Event } )
if Event.IniDCSUnit then if Event.IniDCSUnit then
local ObjectName, Object = self:FindInDatabase( Event ) local ObjectName, Object = self:FindInDatabase( Event )
@ -11134,7 +11122,7 @@ function SET_BASE:ForEach( IteratorFunction, arg, Set, Function, FunctionArgumen
local function CoRoutine() local function CoRoutine()
local Count = 0 local Count = 0
for ObjectID, Object in pairs( Set ) do for ObjectID, Object in pairs( Set ) do
self:T2( Object ) self:T3( Object )
if Function then if Function then
if Function( unpack( FunctionArguments ), Object ) == true then if Function( unpack( FunctionArguments ), Object ) == true then
IteratorFunction( Object, unpack( arg ) ) IteratorFunction( Object, unpack( arg ) )
@ -11223,7 +11211,7 @@ function SET_BASE:IsIncludeObject( Object )
return true return true
end end
--- Flushes the current SET_BASE contents in the log ... (for debug reasons). --- Flushes the current SET_BASE contents in the log ... (for debugging reasons).
-- @param #SET_BASE self -- @param #SET_BASE self
-- @return #string A string with the names of the objects. -- @return #string A string with the names of the objects.
function SET_BASE:Flush() function SET_BASE:Flush()
@ -11844,7 +11832,6 @@ end
function SET_UNIT:FindInDatabase( Event ) function SET_UNIT:FindInDatabase( Event )
self:F3( { Event } ) self:F3( { Event } )
self:E( { Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName] } )
return Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName] return Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName]
end end
@ -14627,7 +14614,6 @@ function CARGO_PACKAGE:OnBoard( Client, LandingZone, OnBoardSide )
end end
self:T( "Routing " .. CargoHostName ) self:T( "Routing " .. CargoHostName )
--routines.scheduleFunction( routines.goRoute, { CargoHostName, Points}, timer.getTime() + 4 )
SCHEDULER:New( self, routines.goRoute, { CargoHostName, Points }, 4 ) SCHEDULER:New( self, routines.goRoute, { CargoHostName, Points }, 4 )
return Valid return Valid
@ -17863,7 +17849,6 @@ function CLEANUP:New( ZoneNames, TimeInterval ) local self = BASE:Inherit( self,
_EVENTDISPATCHER:OnBirth( self._OnEventBirth, self ) _EVENTDISPATCHER:OnBirth( self._OnEventBirth, self )
--self.CleanUpScheduler = routines.scheduleFunction( self._CleanUpScheduler, { self }, timer.getTime() + 1, TimeInterval )
self.CleanUpScheduler = SCHEDULER:New( self, self._CleanUpScheduler, {}, 1, TimeInterval ) self.CleanUpScheduler = SCHEDULER:New( self, self._CleanUpScheduler, {}, 1, TimeInterval )
return self return self
@ -17988,7 +17973,6 @@ function CLEANUP:_EventShot( Event )
if ( CurrentLandingZoneID ) then if ( CurrentLandingZoneID ) then
-- Okay, the missile was fired within the CLEANUP.ZoneNames, destroy the fired weapon. -- Okay, the missile was fired within the CLEANUP.ZoneNames, destroy the fired weapon.
--_SEADmissile:destroy() --_SEADmissile:destroy()
--routines.scheduleFunction( CLEANUP._DestroyMissile, { self, Event.Weapon }, timer.getTime() + 0.1)
SCHEDULER:New( self, CLEANUP._DestroyMissile, { Event.Weapon }, 0.1 ) SCHEDULER:New( self, CLEANUP._DestroyMissile, { Event.Weapon }, 0.1 )
end end
end end
@ -18005,7 +17989,6 @@ function CLEANUP:_EventHitCleanUp( Event )
self:T( { "Life: ", Event.IniDCSUnitName, ' = ', Event.IniDCSUnit:getLife(), "/", Event.IniDCSUnit:getLife0() } ) self:T( { "Life: ", Event.IniDCSUnitName, ' = ', Event.IniDCSUnit:getLife(), "/", Event.IniDCSUnit:getLife0() } )
if Event.IniDCSUnit:getLife() < Event.IniDCSUnit:getLife0() then if Event.IniDCSUnit:getLife() < Event.IniDCSUnit:getLife0() then
self:T( "CleanUp: Destroy: " .. Event.IniDCSUnitName ) self:T( "CleanUp: Destroy: " .. Event.IniDCSUnitName )
--routines.scheduleFunction( CLEANUP._DestroyUnit, { self, Event.IniDCSUnit }, timer.getTime() + 0.1)
SCHEDULER:New( self, CLEANUP._DestroyUnit, { Event.IniDCSUnit }, 0.1 ) SCHEDULER:New( self, CLEANUP._DestroyUnit, { Event.IniDCSUnit }, 0.1 )
end end
end end
@ -18016,7 +17999,6 @@ function CLEANUP:_EventHitCleanUp( Event )
self:T( { "Life: ", Event.TgtDCSUnitName, ' = ', Event.TgtDCSUnit:getLife(), "/", Event.TgtDCSUnit:getLife0() } ) self:T( { "Life: ", Event.TgtDCSUnitName, ' = ', Event.TgtDCSUnit:getLife(), "/", Event.TgtDCSUnit:getLife0() } )
if Event.TgtDCSUnit:getLife() < Event.TgtDCSUnit:getLife0() then if Event.TgtDCSUnit:getLife() < Event.TgtDCSUnit:getLife0() then
self:T( "CleanUp: Destroy: " .. Event.TgtDCSUnitName ) self:T( "CleanUp: Destroy: " .. Event.TgtDCSUnitName )
--routines.scheduleFunction( CLEANUP._DestroyUnit, { self, Event.TgtDCSUnit }, timer.getTime() + 0.1 )
SCHEDULER:New( self, CLEANUP._DestroyUnit, { Event.TgtDCSUnit }, 0.1 ) SCHEDULER:New( self, CLEANUP._DestroyUnit, { Event.TgtDCSUnit }, 0.1 )
end end
end end
@ -19578,7 +19560,6 @@ function SEAD:EventShot( Event )
local SEADUnitName = Event.IniDCSUnitName local SEADUnitName = Event.IniDCSUnitName
local SEADWeapon = Event.Weapon -- Identify the weapon fired local SEADWeapon = Event.Weapon -- Identify the weapon fired
local SEADWeaponName = Event.WeaponName -- return weapon type local SEADWeaponName = Event.WeaponName -- return weapon type
--trigger.action.outText( string.format("Alerte, depart missile " ..string.format(SEADWeaponName)), 20) --debug message
-- Start of the 2nd loop -- Start of the 2nd loop
self:T( "Missile Launched = " .. SEADWeaponName ) self:T( "Missile Launched = " .. SEADWeaponName )
if SEADWeaponName == "KH-58" or SEADWeaponName == "KH-25MPU" or SEADWeaponName == "AGM-88" or SEADWeaponName == "KH-31A" or SEADWeaponName == "KH-31P" then -- Check if the missile is a SEAD if SEADWeaponName == "KH-58" or SEADWeaponName == "KH-25MPU" or SEADWeaponName == "AGM-88" or SEADWeaponName == "KH-31A" or SEADWeaponName == "KH-31P" then -- Check if the missile is a SEAD
@ -19604,10 +19585,10 @@ function SEAD:EventShot( Event )
local Skills = { "Average", "Good", "High", "Excellent" } local Skills = { "Average", "Good", "High", "Excellent" }
_targetskill = Skills[ math.random(1,4) ] _targetskill = Skills[ math.random(1,4) ]
end end
self:T( _targetskill ) -- debug message for skill check self:T( _targetskill )
if self.TargetSkill[_targetskill] then if self.TargetSkill[_targetskill] then
if (_evade > self.TargetSkill[_targetskill].Evade) then if (_evade > self.TargetSkill[_targetskill].Evade) then
self:T( string.format("Evading, target skill " ..string.format(_targetskill)) ) --debug message self:T( string.format("Evading, target skill " ..string.format(_targetskill)) )
local _targetMim = Weapon.getTarget(SEADWeapon) local _targetMim = Weapon.getTarget(SEADWeapon)
local _targetMimname = Unit.getName(_targetMim) local _targetMimname = Unit.getName(_targetMim)
local _targetMimgroup = Unit.getGroup(Weapon.getTarget(SEADWeapon)) local _targetMimgroup = Unit.getGroup(Weapon.getTarget(SEADWeapon))
@ -20215,7 +20196,6 @@ function ESCORT:MenuReportTargets( Seconds )
self.EscortMenuAttackNearbyTargets = MENU_CLIENT:New( self.EscortClient, "Attack targets", self.EscortMenu ) self.EscortMenuAttackNearbyTargets = MENU_CLIENT:New( self.EscortClient, "Attack targets", self.EscortMenu )
--self.ReportTargetsScheduler = routines.scheduleFunction( self._ReportTargetsScheduler, { self }, timer.getTime() + 1, Seconds )
self.ReportTargetsScheduler = SCHEDULER:New( self, self._ReportTargetsScheduler, {}, 1, Seconds ) self.ReportTargetsScheduler = SCHEDULER:New( self, self._ReportTargetsScheduler, {}, 1, Seconds )
return self return self
@ -20437,7 +20417,6 @@ function ESCORT._SwitchReportNearbyTargets( MenuParam )
if self.ReportTargets then if self.ReportTargets then
if not self.ReportTargetsScheduler then if not self.ReportTargetsScheduler then
--self.ReportTargetsScheduler = routines.scheduleFunction( self._ReportTargetsScheduler, { self }, timer.getTime() + 1, 30 )
self.ReportTargetsScheduler = SCHEDULER:New( self, self._ReportTargetsScheduler, {}, 1, 30 ) self.ReportTargetsScheduler = SCHEDULER:New( self, self._ReportTargetsScheduler, {}, 1, 30 )
end end
else else
@ -20514,16 +20493,6 @@ function ESCORT._AttackTarget( MenuParam )
EscortGroup:OptionROEOpenFire() EscortGroup:OptionROEOpenFire()
EscortGroup:OptionROTPassiveDefense() EscortGroup:OptionROTPassiveDefense()
EscortGroup:SetState( EscortGroup, "Escort", self ) EscortGroup:SetState( EscortGroup, "Escort", self )
-- routines.scheduleFunction(
-- EscortGroup.PushTask,
-- { EscortGroup,
-- EscortGroup:TaskCombo(
-- { EscortGroup:TaskAttackUnit( AttackUnit ),
-- EscortGroup:TaskFunction( 1, 2, "_Resume", {"''"} )
-- }
-- )
-- }, timer.getTime() + 10
-- )
SCHEDULER:New( EscortGroup, SCHEDULER:New( EscortGroup,
EscortGroup.PushTask, EscortGroup.PushTask,
{ EscortGroup:TaskCombo( { EscortGroup:TaskCombo(
@ -20534,15 +20503,6 @@ function ESCORT._AttackTarget( MenuParam )
}, 10 }, 10
) )
else else
-- routines.scheduleFunction(
-- EscortGroup.PushTask,
-- { EscortGroup,
-- EscortGroup:TaskCombo(
-- { EscortGroup:TaskFireAtPoint( AttackUnit:GetPointVec2(), 50 )
-- }
-- )
-- }, timer.getTime() + 10
-- )
SCHEDULER:New( EscortGroup, SCHEDULER:New( EscortGroup,
EscortGroup.PushTask, EscortGroup.PushTask,
{ EscortGroup:TaskCombo( { EscortGroup:TaskCombo(
@ -20573,16 +20533,6 @@ function ESCORT._AssistTarget( MenuParam )
if EscortGroupAttack:IsAir() then if EscortGroupAttack:IsAir() then
EscortGroupAttack:OptionROEOpenFire() EscortGroupAttack:OptionROEOpenFire()
EscortGroupAttack:OptionROTVertical() EscortGroupAttack:OptionROTVertical()
-- routines.scheduleFunction(
-- EscortGroupAttack.PushTask,
-- { EscortGroupAttack,
-- EscortGroupAttack:TaskCombo(
-- { EscortGroupAttack:TaskAttackUnit( AttackUnit ),
-- EscortGroupAttack:TaskOrbitCircle( 500, 350 )
-- }
-- )
-- }, timer.getTime() + 10
-- )
SCHDULER:New( EscortGroupAttack, SCHDULER:New( EscortGroupAttack,
EscortGroupAttack.PushTask, EscortGroupAttack.PushTask,
{ EscortGroupAttack:TaskCombo( { EscortGroupAttack:TaskCombo(
@ -20593,15 +20543,6 @@ function ESCORT._AssistTarget( MenuParam )
}, 10 }, 10
) )
else else
-- routines.scheduleFunction(
-- EscortGroupAttack.PushTask,
-- { EscortGroupAttack,
-- EscortGroupAttack:TaskCombo(
-- { EscortGroupAttack:TaskFireAtPoint( AttackUnit:GetPointVec2(), 50 )
-- }
-- )
-- }, timer.getTime() + 10
-- )
SCHEDULER:New( EscortGroupAttack, SCHEDULER:New( EscortGroupAttack,
EscortGroupAttack.PushTask, EscortGroupAttack.PushTask,
{ EscortGroupAttack:TaskCombo( { EscortGroupAttack:TaskCombo(
@ -20661,7 +20602,6 @@ function ESCORT._ResumeMission( MenuParam )
table.remove( WayPoints, 1 ) table.remove( WayPoints, 1 )
end end
--routines.scheduleFunction( EscortGroup.SetTask, {EscortGroup, EscortGroup:TaskRoute( WayPoints ) }, timer.getTime() + 1 )
SCHEDULER:New( EscortGroup, EscortGroup.SetTask, { EscortGroup:TaskRoute( WayPoints ) }, 1 ) SCHEDULER:New( EscortGroup, EscortGroup.SetTask, { EscortGroup:TaskRoute( WayPoints ) }, 1 )
EscortGroup:MessageToClient( "Resuming mission from waypoint " .. WayPoint .. ".", 10, EscortClient ) EscortGroup:MessageToClient( "Resuming mission from waypoint " .. WayPoint .. ".", 10, EscortClient )
@ -23109,7 +23049,7 @@ end
-- --
-- 1.1) DETECTION_BASE constructor -- 1.1) DETECTION_BASE constructor
-- ------------------------------- -- -------------------------------
-- Construct a new DETECTION_BASE instance using the @{Detection#DETECTION.New}() method. -- Construct a new DETECTION_BASE instance using the @{Detection#DETECTION_BASE.New}() method.
-- --
-- 1.2) DETECTION_BASE initialization -- 1.2) DETECTION_BASE initialization
-- ---------------------------------- -- ----------------------------------
@ -23495,15 +23435,17 @@ function DETECTION_UNITGROUPS:SmokeDetectedUnits()
self:F2() self:F2()
self._SmokeDetectedUnits = true self._SmokeDetectedUnits = true
return self
end end
--- Flare the detected units --- Flare the detected units
-- @param #DETECTION_UNITGROUPS self -- @param #DETECTION_UNITGROUPS self
-- @return #DETECTION_UNITGROUPS self -- @return #DETECTION_UNITGROUPS self
function DETECTION_UNITGROUPS:SmokeDetectedUnits() function DETECTION_UNITGROUPS:FlareDetectedUnits()
self:F2() self:F2()
self._FlareDetectedUnits = true self._FlareDetectedUnits = true
return self
end end
--- Smoke the detected zones --- Smoke the detected zones
@ -23513,6 +23455,7 @@ function DETECTION_UNITGROUPS:SmokeDetectedZones()
self:F2() self:F2()
self._SmokeDetectedZones = true self._SmokeDetectedZones = true
return self
end end
--- Flare the detected zones --- Flare the detected zones
@ -23522,6 +23465,7 @@ function DETECTION_UNITGROUPS:FlareDetectedZones()
self:F2() self:F2()
self._FlareDetectedZones = true self._FlareDetectedZones = true
return self
end end
@ -23546,7 +23490,6 @@ function DETECTION_UNITGROUPS:CreateDetectionSets()
for DetectedZoneIndex = 1, #self.DetectedZones do for DetectedZoneIndex = 1, #self.DetectedZones do
self:T( "Detected Unit Set #" .. DetectedZoneIndex ) self:T( "Detected Unit Set #" .. DetectedZoneIndex )
local DetectedUnitSet = self.DetectedSets[DetectedZoneIndex] -- Set#SET_BASE local DetectedUnitSet = self.DetectedSets[DetectedZoneIndex] -- Set#SET_BASE
DetectedUnitSet:Flush()
local DetectedZone = self.DetectedZones[DetectedZoneIndex] -- Zone#ZONE_UNIT local DetectedZone = self.DetectedZones[DetectedZoneIndex] -- Zone#ZONE_UNIT
if DetectedUnit:IsInZone( DetectedZone ) then if DetectedUnit:IsInZone( DetectedZone ) then
self:T( "Adding to Unit Set #" .. DetectedZoneIndex ) self:T( "Adding to Unit Set #" .. DetectedZoneIndex )

View File

@ -1,5 +1,5 @@
env.info( '*** MOOSE STATIC INCLUDE START *** ' ) env.info( '*** MOOSE STATIC INCLUDE START *** ' )
env.info( 'Moose Generation Timestamp: 20160625_0851' ) env.info( 'Moose Generation Timestamp: 20160626_0740' )
local base = _G local base = _G
Include = {} Include = {}
@ -450,22 +450,6 @@ routines.getNorthCorrection = function(point) --gets the correction needed for
end end
-- the main area
do
-- THE MAIN FUNCTION -- Accessed 100 times/sec.
routines.main = function()
timer.scheduleFunction(routines.main, {}, timer.getTime() + 2) --reschedule first in case of Lua error
----------------------------------------------------------------------------------------------------------
--area to add new stuff in
routines.do_scheduled_functions()
end -- end of routines.main
timer.scheduleFunction(routines.main, {}, timer.getTime() + 2)
end
do do
local idNum = 0 local idNum = 0
@ -2969,7 +2953,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:_F( Arguments, DebugInfoCurrentParam, DebugInfoFromParam ) function BASE:_F( Arguments, DebugInfoCurrentParam, DebugInfoFromParam )
if ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then if debug and ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then
local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" ) local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" )
local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" ) local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" )
@ -2998,7 +2982,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:F( Arguments ) function BASE:F( Arguments )
if _TraceOnOff then if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoFrom = debug.getinfo( 3, "l" )
@ -3014,7 +2998,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:F2( Arguments ) function BASE:F2( Arguments )
if _TraceOnOff then if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoFrom = debug.getinfo( 3, "l" )
@ -3029,7 +3013,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:F3( Arguments ) function BASE:F3( Arguments )
if _TraceOnOff then if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoFrom = debug.getinfo( 3, "l" )
@ -3044,7 +3028,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:_T( Arguments, DebugInfoCurrentParam, DebugInfoFromParam ) function BASE:_T( Arguments, DebugInfoCurrentParam, DebugInfoFromParam )
if ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then if debug and ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then
local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" ) local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" )
local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" ) local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" )
@ -3073,7 +3057,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:T( Arguments ) function BASE:T( Arguments )
if _TraceOnOff then if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoFrom = debug.getinfo( 3, "l" )
@ -3089,7 +3073,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:T2( Arguments ) function BASE:T2( Arguments )
if _TraceOnOff then if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoFrom = debug.getinfo( 3, "l" )
@ -3104,7 +3088,7 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:T3( Arguments ) function BASE:T3( Arguments )
if _TraceOnOff then if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoFrom = debug.getinfo( 3, "l" )
@ -3119,21 +3103,24 @@ end
-- @param Arguments A #table or any field. -- @param Arguments A #table or any field.
function BASE:E( Arguments ) function BASE:E( Arguments )
local DebugInfoCurrent = debug.getinfo( 2, "nl" ) if debug then
local DebugInfoFrom = debug.getinfo( 3, "l" ) local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" )
local Function = "function"
if DebugInfoCurrent.name then local Function = "function"
Function = DebugInfoCurrent.name if DebugInfoCurrent.name then
end Function = DebugInfoCurrent.name
end
local LineCurrent = DebugInfoCurrent.currentline
local LineFrom = -1 local LineCurrent = DebugInfoCurrent.currentline
if DebugInfoFrom then local LineFrom = -1
LineFrom = DebugInfoFrom.currentline if DebugInfoFrom then
end LineFrom = DebugInfoFrom.currentline
end
env.info( string.format( "%6d(%6d)/%1s:%20s%05d.%s(%s)" , LineCurrent, LineFrom, "E", self.ClassName, self.ClassID, Function, routines.utils.oneLineSerialize( Arguments ) ) )
env.info( string.format( "%6d(%6d)/%1s:%20s%05d.%s(%s)" , LineCurrent, LineFrom, "E", self.ClassName, self.ClassID, Function, routines.utils.oneLineSerialize( Arguments ) ) )
end
end end
@ -3973,7 +3960,6 @@ function CONTROLLABLE:PushTask( DCSTask, WaitTime )
-- Controller:pushTask( DCSTask ) -- Controller:pushTask( DCSTask )
if WaitTime then if WaitTime then
--routines.scheduleFunction( Controller.pushTask, { Controller, DCSTask }, timer.getTime() + WaitTime )
SCHEDULER:New( Controller, Controller.pushTask, { DCSTask }, WaitTime ) SCHEDULER:New( Controller, Controller.pushTask, { DCSTask }, WaitTime )
else else
Controller:pushTask( DCSTask ) Controller:pushTask( DCSTask )
@ -4004,7 +3990,6 @@ function CONTROLLABLE:SetTask( DCSTask, WaitTime )
if not WaitTime then if not WaitTime then
WaitTime = 1 WaitTime = 1
end end
--routines.scheduleFunction( Controller.setTask, { Controller, DCSTask }, timer.getTime() + WaitTime )
SCHEDULER:New( Controller, Controller.setTask, { DCSTask }, WaitTime ) SCHEDULER:New( Controller, Controller.setTask, { DCSTask }, WaitTime )
return self return self
@ -5252,7 +5237,6 @@ 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 )
--routines.scheduleFunction( Controller.setTask, { Controller, MissionTask}, timer.getTime() + 1 )
SCHEDULER:New( Controller, Controller.setTask, { MissionTask }, 1 ) SCHEDULER:New( Controller, Controller.setTask, { MissionTask }, 1 )
return self return self
end end
@ -6072,8 +6056,10 @@ function SCHEDULER:_Scheduler()
local ErrorHandler = function( errmsg ) local ErrorHandler = function( errmsg )
env.info( "Error in SCHEDULER function:" .. errmsg ) env.info( "Error in SCHEDULER function:" .. errmsg )
env.info( debug.traceback() ) if debug ~= nil then
env.info( debug.traceback() )
end
return errmsg return errmsg
end end
@ -6592,7 +6578,8 @@ function EVENT:OnPlayerLeaveUnit( EventFunction, EventSelf )
end end
--- @param #EVENT self
-- @param #EVENTDATA Event
function EVENT:onEvent( Event ) function EVENT:onEvent( Event )
self:F2( { _EVENTCODES[Event.id], Event } ) self:F2( { _EVENTCODES[Event.id], Event } )
@ -6626,7 +6613,7 @@ function EVENT:onEvent( Event )
Event.WeaponName = Event.Weapon:getTypeName() Event.WeaponName = Event.Weapon:getTypeName()
--Event.WeaponTgtDCSUnit = Event.Weapon:getTarget() --Event.WeaponTgtDCSUnit = Event.Weapon:getTarget()
end end
self:E( { _EVENTCODES[Event.id], Event } ) self:E( { _EVENTCODES[Event.id], Event.IniUnitName, Event.TgtUnitName, Event.WeaponName } )
for ClassName, EventData in pairs( self.Events[Event.id] ) do for ClassName, EventData in pairs( self.Events[Event.id] ) do
if Event.IniDCSUnitName and EventData.IniUnit and EventData.IniUnit[Event.IniDCSUnitName] then if Event.IniDCSUnitName and EventData.IniUnit and EventData.IniUnit[Event.IniDCSUnitName] then
self:E( { "Calling event function for class ", ClassName, " unit ", Event.IniDCSUnitName } ) self:E( { "Calling event function for class ", ClassName, " unit ", Event.IniDCSUnitName } )
@ -8951,33 +8938,34 @@ end
--- Returns if a location is within the zone. --- Returns if a location is within the zone.
-- Source learned and taken from: https://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
-- @param #ZONE_POLYGON_BASE self -- @param #ZONE_POLYGON_BASE self
-- @param DCSTypes#Vec2 PointVec2 The location to test. -- @param DCSTypes#Vec2 PointVec2 The location to test.
-- @return #boolean true if the location is within the zone. -- @return #boolean true if the location is within the zone.
function ZONE_POLYGON_BASE:IsPointVec2InZone( PointVec2 ) function ZONE_POLYGON_BASE:IsPointVec2InZone( PointVec2 )
self:F2( PointVec2 ) self:F2( PointVec2 )
local i local Next
local j local Prev
local c = false local InPolygon = false
i = 1 Next = 1
j = #self.Polygon Prev = #self.Polygon
while i < #self.Polygon do while Next <= #self.Polygon do
j = i self:T( { Next, Prev, self.Polygon[Next], self.Polygon[Prev] } )
i = i + 1 if ( ( ( self.Polygon[Next].y > PointVec2.y ) ~= ( self.Polygon[Prev].y > PointVec2.y ) ) and
self:T( { i, j, self.Polygon[i], self.Polygon[j] } ) ( PointVec2.x < ( self.Polygon[Prev].x - self.Polygon[Next].x ) * ( PointVec2.y - self.Polygon[Next].y ) / ( self.Polygon[Prev].y - self.Polygon[Next].y ) + self.Polygon[Next].x )
if ( ( ( self.Polygon[i].y > PointVec2.y ) ~= ( self.Polygon[j].y > PointVec2.y ) ) and
( PointVec2.x < ( self.Polygon[j].x - self.Polygon[i].x ) * ( PointVec2.y - self.Polygon[i].y ) / ( self.Polygon[j].y - self.Polygon[i].y ) + self.Polygon[i].x )
) then ) then
c = not c InPolygon = not InPolygon
end end
self:T2( { "c = ", c } ) self:T2( { InPolygon = InPolygon } )
Prev = Next
Next = Next + 1
end end
self:T( { "c = ", c } ) self:T( { InPolygon = InPolygon } )
return c return InPolygon
end end
--- Define a random @{DCSTypes#Vec2} within the zone. --- Define a random @{DCSTypes#Vec2} within the zone.
@ -11078,7 +11066,7 @@ end
-- @param #SET_BASE self -- @param #SET_BASE self
-- @param Event#EVENTDATA Event -- @param Event#EVENTDATA Event
function SET_BASE:_EventOnDeadOrCrash( Event ) function SET_BASE:_EventOnDeadOrCrash( Event )
self:F2( { Event } ) self:F3( { Event } )
if Event.IniDCSUnit then if Event.IniDCSUnit then
local ObjectName, Object = self:FindInDatabase( Event ) local ObjectName, Object = self:FindInDatabase( Event )
@ -11134,7 +11122,7 @@ function SET_BASE:ForEach( IteratorFunction, arg, Set, Function, FunctionArgumen
local function CoRoutine() local function CoRoutine()
local Count = 0 local Count = 0
for ObjectID, Object in pairs( Set ) do for ObjectID, Object in pairs( Set ) do
self:T2( Object ) self:T3( Object )
if Function then if Function then
if Function( unpack( FunctionArguments ), Object ) == true then if Function( unpack( FunctionArguments ), Object ) == true then
IteratorFunction( Object, unpack( arg ) ) IteratorFunction( Object, unpack( arg ) )
@ -11223,7 +11211,7 @@ function SET_BASE:IsIncludeObject( Object )
return true return true
end end
--- Flushes the current SET_BASE contents in the log ... (for debug reasons). --- Flushes the current SET_BASE contents in the log ... (for debugging reasons).
-- @param #SET_BASE self -- @param #SET_BASE self
-- @return #string A string with the names of the objects. -- @return #string A string with the names of the objects.
function SET_BASE:Flush() function SET_BASE:Flush()
@ -11844,7 +11832,6 @@ end
function SET_UNIT:FindInDatabase( Event ) function SET_UNIT:FindInDatabase( Event )
self:F3( { Event } ) self:F3( { Event } )
self:E( { Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName] } )
return Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName] return Event.IniDCSUnitName, self.Database[Event.IniDCSUnitName]
end end
@ -14627,7 +14614,6 @@ function CARGO_PACKAGE:OnBoard( Client, LandingZone, OnBoardSide )
end end
self:T( "Routing " .. CargoHostName ) self:T( "Routing " .. CargoHostName )
--routines.scheduleFunction( routines.goRoute, { CargoHostName, Points}, timer.getTime() + 4 )
SCHEDULER:New( self, routines.goRoute, { CargoHostName, Points }, 4 ) SCHEDULER:New( self, routines.goRoute, { CargoHostName, Points }, 4 )
return Valid return Valid
@ -17863,7 +17849,6 @@ function CLEANUP:New( ZoneNames, TimeInterval ) local self = BASE:Inherit( self,
_EVENTDISPATCHER:OnBirth( self._OnEventBirth, self ) _EVENTDISPATCHER:OnBirth( self._OnEventBirth, self )
--self.CleanUpScheduler = routines.scheduleFunction( self._CleanUpScheduler, { self }, timer.getTime() + 1, TimeInterval )
self.CleanUpScheduler = SCHEDULER:New( self, self._CleanUpScheduler, {}, 1, TimeInterval ) self.CleanUpScheduler = SCHEDULER:New( self, self._CleanUpScheduler, {}, 1, TimeInterval )
return self return self
@ -17988,7 +17973,6 @@ function CLEANUP:_EventShot( Event )
if ( CurrentLandingZoneID ) then if ( CurrentLandingZoneID ) then
-- Okay, the missile was fired within the CLEANUP.ZoneNames, destroy the fired weapon. -- Okay, the missile was fired within the CLEANUP.ZoneNames, destroy the fired weapon.
--_SEADmissile:destroy() --_SEADmissile:destroy()
--routines.scheduleFunction( CLEANUP._DestroyMissile, { self, Event.Weapon }, timer.getTime() + 0.1)
SCHEDULER:New( self, CLEANUP._DestroyMissile, { Event.Weapon }, 0.1 ) SCHEDULER:New( self, CLEANUP._DestroyMissile, { Event.Weapon }, 0.1 )
end end
end end
@ -18005,7 +17989,6 @@ function CLEANUP:_EventHitCleanUp( Event )
self:T( { "Life: ", Event.IniDCSUnitName, ' = ', Event.IniDCSUnit:getLife(), "/", Event.IniDCSUnit:getLife0() } ) self:T( { "Life: ", Event.IniDCSUnitName, ' = ', Event.IniDCSUnit:getLife(), "/", Event.IniDCSUnit:getLife0() } )
if Event.IniDCSUnit:getLife() < Event.IniDCSUnit:getLife0() then if Event.IniDCSUnit:getLife() < Event.IniDCSUnit:getLife0() then
self:T( "CleanUp: Destroy: " .. Event.IniDCSUnitName ) self:T( "CleanUp: Destroy: " .. Event.IniDCSUnitName )
--routines.scheduleFunction( CLEANUP._DestroyUnit, { self, Event.IniDCSUnit }, timer.getTime() + 0.1)
SCHEDULER:New( self, CLEANUP._DestroyUnit, { Event.IniDCSUnit }, 0.1 ) SCHEDULER:New( self, CLEANUP._DestroyUnit, { Event.IniDCSUnit }, 0.1 )
end end
end end
@ -18016,7 +17999,6 @@ function CLEANUP:_EventHitCleanUp( Event )
self:T( { "Life: ", Event.TgtDCSUnitName, ' = ', Event.TgtDCSUnit:getLife(), "/", Event.TgtDCSUnit:getLife0() } ) self:T( { "Life: ", Event.TgtDCSUnitName, ' = ', Event.TgtDCSUnit:getLife(), "/", Event.TgtDCSUnit:getLife0() } )
if Event.TgtDCSUnit:getLife() < Event.TgtDCSUnit:getLife0() then if Event.TgtDCSUnit:getLife() < Event.TgtDCSUnit:getLife0() then
self:T( "CleanUp: Destroy: " .. Event.TgtDCSUnitName ) self:T( "CleanUp: Destroy: " .. Event.TgtDCSUnitName )
--routines.scheduleFunction( CLEANUP._DestroyUnit, { self, Event.TgtDCSUnit }, timer.getTime() + 0.1 )
SCHEDULER:New( self, CLEANUP._DestroyUnit, { Event.TgtDCSUnit }, 0.1 ) SCHEDULER:New( self, CLEANUP._DestroyUnit, { Event.TgtDCSUnit }, 0.1 )
end end
end end
@ -19578,7 +19560,6 @@ function SEAD:EventShot( Event )
local SEADUnitName = Event.IniDCSUnitName local SEADUnitName = Event.IniDCSUnitName
local SEADWeapon = Event.Weapon -- Identify the weapon fired local SEADWeapon = Event.Weapon -- Identify the weapon fired
local SEADWeaponName = Event.WeaponName -- return weapon type local SEADWeaponName = Event.WeaponName -- return weapon type
--trigger.action.outText( string.format("Alerte, depart missile " ..string.format(SEADWeaponName)), 20) --debug message
-- Start of the 2nd loop -- Start of the 2nd loop
self:T( "Missile Launched = " .. SEADWeaponName ) self:T( "Missile Launched = " .. SEADWeaponName )
if SEADWeaponName == "KH-58" or SEADWeaponName == "KH-25MPU" or SEADWeaponName == "AGM-88" or SEADWeaponName == "KH-31A" or SEADWeaponName == "KH-31P" then -- Check if the missile is a SEAD if SEADWeaponName == "KH-58" or SEADWeaponName == "KH-25MPU" or SEADWeaponName == "AGM-88" or SEADWeaponName == "KH-31A" or SEADWeaponName == "KH-31P" then -- Check if the missile is a SEAD
@ -19604,10 +19585,10 @@ function SEAD:EventShot( Event )
local Skills = { "Average", "Good", "High", "Excellent" } local Skills = { "Average", "Good", "High", "Excellent" }
_targetskill = Skills[ math.random(1,4) ] _targetskill = Skills[ math.random(1,4) ]
end end
self:T( _targetskill ) -- debug message for skill check self:T( _targetskill )
if self.TargetSkill[_targetskill] then if self.TargetSkill[_targetskill] then
if (_evade > self.TargetSkill[_targetskill].Evade) then if (_evade > self.TargetSkill[_targetskill].Evade) then
self:T( string.format("Evading, target skill " ..string.format(_targetskill)) ) --debug message self:T( string.format("Evading, target skill " ..string.format(_targetskill)) )
local _targetMim = Weapon.getTarget(SEADWeapon) local _targetMim = Weapon.getTarget(SEADWeapon)
local _targetMimname = Unit.getName(_targetMim) local _targetMimname = Unit.getName(_targetMim)
local _targetMimgroup = Unit.getGroup(Weapon.getTarget(SEADWeapon)) local _targetMimgroup = Unit.getGroup(Weapon.getTarget(SEADWeapon))
@ -20215,7 +20196,6 @@ function ESCORT:MenuReportTargets( Seconds )
self.EscortMenuAttackNearbyTargets = MENU_CLIENT:New( self.EscortClient, "Attack targets", self.EscortMenu ) self.EscortMenuAttackNearbyTargets = MENU_CLIENT:New( self.EscortClient, "Attack targets", self.EscortMenu )
--self.ReportTargetsScheduler = routines.scheduleFunction( self._ReportTargetsScheduler, { self }, timer.getTime() + 1, Seconds )
self.ReportTargetsScheduler = SCHEDULER:New( self, self._ReportTargetsScheduler, {}, 1, Seconds ) self.ReportTargetsScheduler = SCHEDULER:New( self, self._ReportTargetsScheduler, {}, 1, Seconds )
return self return self
@ -20437,7 +20417,6 @@ function ESCORT._SwitchReportNearbyTargets( MenuParam )
if self.ReportTargets then if self.ReportTargets then
if not self.ReportTargetsScheduler then if not self.ReportTargetsScheduler then
--self.ReportTargetsScheduler = routines.scheduleFunction( self._ReportTargetsScheduler, { self }, timer.getTime() + 1, 30 )
self.ReportTargetsScheduler = SCHEDULER:New( self, self._ReportTargetsScheduler, {}, 1, 30 ) self.ReportTargetsScheduler = SCHEDULER:New( self, self._ReportTargetsScheduler, {}, 1, 30 )
end end
else else
@ -20514,16 +20493,6 @@ function ESCORT._AttackTarget( MenuParam )
EscortGroup:OptionROEOpenFire() EscortGroup:OptionROEOpenFire()
EscortGroup:OptionROTPassiveDefense() EscortGroup:OptionROTPassiveDefense()
EscortGroup:SetState( EscortGroup, "Escort", self ) EscortGroup:SetState( EscortGroup, "Escort", self )
-- routines.scheduleFunction(
-- EscortGroup.PushTask,
-- { EscortGroup,
-- EscortGroup:TaskCombo(
-- { EscortGroup:TaskAttackUnit( AttackUnit ),
-- EscortGroup:TaskFunction( 1, 2, "_Resume", {"''"} )
-- }
-- )
-- }, timer.getTime() + 10
-- )
SCHEDULER:New( EscortGroup, SCHEDULER:New( EscortGroup,
EscortGroup.PushTask, EscortGroup.PushTask,
{ EscortGroup:TaskCombo( { EscortGroup:TaskCombo(
@ -20534,15 +20503,6 @@ function ESCORT._AttackTarget( MenuParam )
}, 10 }, 10
) )
else else
-- routines.scheduleFunction(
-- EscortGroup.PushTask,
-- { EscortGroup,
-- EscortGroup:TaskCombo(
-- { EscortGroup:TaskFireAtPoint( AttackUnit:GetPointVec2(), 50 )
-- }
-- )
-- }, timer.getTime() + 10
-- )
SCHEDULER:New( EscortGroup, SCHEDULER:New( EscortGroup,
EscortGroup.PushTask, EscortGroup.PushTask,
{ EscortGroup:TaskCombo( { EscortGroup:TaskCombo(
@ -20573,16 +20533,6 @@ function ESCORT._AssistTarget( MenuParam )
if EscortGroupAttack:IsAir() then if EscortGroupAttack:IsAir() then
EscortGroupAttack:OptionROEOpenFire() EscortGroupAttack:OptionROEOpenFire()
EscortGroupAttack:OptionROTVertical() EscortGroupAttack:OptionROTVertical()
-- routines.scheduleFunction(
-- EscortGroupAttack.PushTask,
-- { EscortGroupAttack,
-- EscortGroupAttack:TaskCombo(
-- { EscortGroupAttack:TaskAttackUnit( AttackUnit ),
-- EscortGroupAttack:TaskOrbitCircle( 500, 350 )
-- }
-- )
-- }, timer.getTime() + 10
-- )
SCHDULER:New( EscortGroupAttack, SCHDULER:New( EscortGroupAttack,
EscortGroupAttack.PushTask, EscortGroupAttack.PushTask,
{ EscortGroupAttack:TaskCombo( { EscortGroupAttack:TaskCombo(
@ -20593,15 +20543,6 @@ function ESCORT._AssistTarget( MenuParam )
}, 10 }, 10
) )
else else
-- routines.scheduleFunction(
-- EscortGroupAttack.PushTask,
-- { EscortGroupAttack,
-- EscortGroupAttack:TaskCombo(
-- { EscortGroupAttack:TaskFireAtPoint( AttackUnit:GetPointVec2(), 50 )
-- }
-- )
-- }, timer.getTime() + 10
-- )
SCHEDULER:New( EscortGroupAttack, SCHEDULER:New( EscortGroupAttack,
EscortGroupAttack.PushTask, EscortGroupAttack.PushTask,
{ EscortGroupAttack:TaskCombo( { EscortGroupAttack:TaskCombo(
@ -20661,7 +20602,6 @@ function ESCORT._ResumeMission( MenuParam )
table.remove( WayPoints, 1 ) table.remove( WayPoints, 1 )
end end
--routines.scheduleFunction( EscortGroup.SetTask, {EscortGroup, EscortGroup:TaskRoute( WayPoints ) }, timer.getTime() + 1 )
SCHEDULER:New( EscortGroup, EscortGroup.SetTask, { EscortGroup:TaskRoute( WayPoints ) }, 1 ) SCHEDULER:New( EscortGroup, EscortGroup.SetTask, { EscortGroup:TaskRoute( WayPoints ) }, 1 )
EscortGroup:MessageToClient( "Resuming mission from waypoint " .. WayPoint .. ".", 10, EscortClient ) EscortGroup:MessageToClient( "Resuming mission from waypoint " .. WayPoint .. ".", 10, EscortClient )
@ -23109,7 +23049,7 @@ end
-- --
-- 1.1) DETECTION_BASE constructor -- 1.1) DETECTION_BASE constructor
-- ------------------------------- -- -------------------------------
-- Construct a new DETECTION_BASE instance using the @{Detection#DETECTION.New}() method. -- Construct a new DETECTION_BASE instance using the @{Detection#DETECTION_BASE.New}() method.
-- --
-- 1.2) DETECTION_BASE initialization -- 1.2) DETECTION_BASE initialization
-- ---------------------------------- -- ----------------------------------
@ -23495,15 +23435,17 @@ function DETECTION_UNITGROUPS:SmokeDetectedUnits()
self:F2() self:F2()
self._SmokeDetectedUnits = true self._SmokeDetectedUnits = true
return self
end end
--- Flare the detected units --- Flare the detected units
-- @param #DETECTION_UNITGROUPS self -- @param #DETECTION_UNITGROUPS self
-- @return #DETECTION_UNITGROUPS self -- @return #DETECTION_UNITGROUPS self
function DETECTION_UNITGROUPS:SmokeDetectedUnits() function DETECTION_UNITGROUPS:FlareDetectedUnits()
self:F2() self:F2()
self._FlareDetectedUnits = true self._FlareDetectedUnits = true
return self
end end
--- Smoke the detected zones --- Smoke the detected zones
@ -23513,6 +23455,7 @@ function DETECTION_UNITGROUPS:SmokeDetectedZones()
self:F2() self:F2()
self._SmokeDetectedZones = true self._SmokeDetectedZones = true
return self
end end
--- Flare the detected zones --- Flare the detected zones
@ -23522,6 +23465,7 @@ function DETECTION_UNITGROUPS:FlareDetectedZones()
self:F2() self:F2()
self._FlareDetectedZones = true self._FlareDetectedZones = true
return self
end end
@ -23546,7 +23490,6 @@ function DETECTION_UNITGROUPS:CreateDetectionSets()
for DetectedZoneIndex = 1, #self.DetectedZones do for DetectedZoneIndex = 1, #self.DetectedZones do
self:T( "Detected Unit Set #" .. DetectedZoneIndex ) self:T( "Detected Unit Set #" .. DetectedZoneIndex )
local DetectedUnitSet = self.DetectedSets[DetectedZoneIndex] -- Set#SET_BASE local DetectedUnitSet = self.DetectedSets[DetectedZoneIndex] -- Set#SET_BASE
DetectedUnitSet:Flush()
local DetectedZone = self.DetectedZones[DetectedZoneIndex] -- Zone#ZONE_UNIT local DetectedZone = self.DetectedZones[DetectedZoneIndex] -- Zone#ZONE_UNIT
if DetectedUnit:IsInZone( DetectedZone ) then if DetectedUnit:IsInZone( DetectedZone ) then
self:T( "Adding to Unit Set #" .. DetectedZoneIndex ) self:T( "Adding to Unit Set #" .. DetectedZoneIndex )