Updated Anapa

This commit is contained in:
Sven Van de Velde 2016-05-07 06:59:15 +02:00
parent c68e4cd257
commit 1949d69fa0
3 changed files with 43 additions and 22 deletions

View File

@ -92,6 +92,18 @@ function GROUP:NewFromDCSUnit( DCSUnit )
return self
end
--- Returns the name of the Group.
-- @param #GROUP self
-- @return #string GroupName
function GROUP:GetName()
local GroupName = self.DCSGroup:getName()
return GroupName
end
--- Retrieve the group mission and allow to place function hooks within the mission waypoint plan.
-- Use the method @{Group#GROUP:WayPointFunction} to define the hook functions for specific waypoints.
-- Use the method @{Group@GROUP:WayPointExecute) to start the execution of the new mission plan.
@ -128,7 +140,12 @@ function GROUP:TaskFunction( WayPoint, WayPointIndex, FunctionString, FunctionAr
local DCSScript = {}
DCSScript[#DCSScript+1] = "local MissionGroup = GROUP.FindGroup( ... ) "
DCSScript[#DCSScript+1] = FunctionString .. "( MissionGroup, " .. table.concat( FunctionArguments, "," ) .. ")"
if FunctionArguments.n > 0 then
DCSScript[#DCSScript+1] = FunctionString .. "( MissionGroup, " .. table.concat( FunctionArguments, "," ) .. ")"
else
DCSScript[#DCSScript+1] = FunctionString .. "( MissionGroup )"
end
DCSTask = self:TaskWrappedAction(
self:CommandDoScript(

View File

@ -3,7 +3,7 @@
-- @author FlightControl
Include.File( "Client" )
Include.File( "TimeTrigger" )
Include.File( "Scheduler" )
--- The MISSILETRAINER class
-- @type MISSILETRAINER
@ -13,7 +13,7 @@ MISSILETRAINER = {
}
--- Creates the main object which is handling missile tracking.
-- When a missile is fired a TIMETRIGGER is set off that follows the missile. When near a certain a client player, the missile will be destroyed.
-- When a missile is fired a SCHEDULER is set off that follows the missile. When near a certain a client player, the missile will be destroyed.
-- @param #MISSILETRAINER
-- @param #number Distance The distance in meters when a tracked missile needs to be destroyed when close to a player.
-- @return #MISSILETRAINER
@ -21,8 +21,8 @@ function MISSILETRAINER:New( Distance )
local self = BASE:Inherit( self, BASE:New() )
self:F( Distance )
self.TimeTriggers = {}
self.TimeTriggerID = 0
self.Schedulers = {}
self.SchedulerID = 0
self.Distance = Distance
@ -52,7 +52,7 @@ function MISSILETRAINER:_EventShot( Event )
self:T( TrainerTargetSkill )
if TrainerTargetSkill == "Client" or TrainerTargetSkill == "Player" then
self.TimeTriggers[#self.TimeTriggers+1] = TIMETRIGGER:New( self, self._FollowMissile, { TrainerSourceDCSUnit, TrainerWeapon, TrainerTargetDCSUnit }, 0.5, 0.05, 0 )
self.Schedulers[#self.Schedulers+1] = SCHEDULER:New( self, self._FollowMissile, { TrainerSourceDCSUnit, TrainerWeapon, TrainerTargetDCSUnit }, 0.5, 0.05, 0 )
end
end

View File

@ -1,5 +1,5 @@
--- Models time events calling event handing functions.
-- @module TimeTrigger
-- @module Scheduler
-- @author FlightControl
Include.File( "Routines" )
@ -8,24 +8,24 @@ Include.File( "Cargo" )
Include.File( "Message" )
--- The TIMETRIGGER class
-- @type TIMETRIGGER
--- The SCHEDULER class
-- @type SCHEDULER
-- @extends Base#BASE
TIMETRIGGER = {
ClassName = "TIMETRIGGER",
SCHEDULER = {
ClassName = "SCHEDULER",
}
--- TIMETRIGGER constructor.
-- @param #TIMETRIGGER self
--- SCHEDULER constructor.
-- @param #SCHEDULER self
-- @param #function TimeEventFunction
-- @param #table TimeEventFunctionArguments
-- @param #number StartSeconds
-- @param #number RepeatSecondsInterval
-- @param #number RandomizationFactor
-- @param #number StopSeconds
-- @return #TIMETRIGGER
function TIMETRIGGER:New( TimeEventObject, TimeEventFunction, TimeEventFunctionArguments, StartSeconds, RepeatSecondsInterval, RandomizationFactor, StopSeconds )
-- @return #SCHEDULER
function SCHEDULER:New( TimeEventObject, TimeEventFunction, TimeEventFunctionArguments, StartSeconds, RepeatSecondsInterval, RandomizationFactor, StopSeconds )
local self = BASE:Inherit( self, BASE:New() )
self:F( { TimeEventObject, TimeEventFunction, TimeEventFunctionArguments, StartSeconds, RepeatSecondsInterval, RandomizationFactor, StopSeconds } )
@ -60,23 +60,27 @@ function TIMETRIGGER:New( TimeEventObject, TimeEventFunction, TimeEventFunctionA
return self
end
function TIMETRIGGER:Scheduler()
function SCHEDULER:Scheduler()
self:F( self.TimeEventFunctionArguments )
local ErrorHandler = function( errmsg )
env.info( "Error in TIMETRIGGER function:" .. errmsg )
env.info( "Error in SCHEDULER function:" .. errmsg )
env.info( debug.traceback() )
return errmsg
end
local err, Result = xpcall( function() self.TimeEventFunction( self.TimeEventObject, unpack( self.TimeEventFunctionArguments, 1, table.maxn( self.TimeEventFunctionArguments ) ) ) end, ErrorHandler )
if not err then
--env.info('routines.scheduleFunction, error in scheduled function: ' .. errmsg)
local Status, Result
if self.TimeEventObject then
Status, Result = xpcall( function() return self.TimeEventFunction( self.TimeEventObject, unpack( self.TimeEventFunctionArguments ) ) end, ErrorHandler )
else
Status, Result = xpcall( function() return self.TimeEventFunction( unpack( self.TimeEventFunctionArguments ) ) end, ErrorHandler )
end
if Result and Result == true then
self:T( { Status, Result } )
if Status and Status == true and Result and Result == true then
if not self.StopSeconds or ( self.StopSeconds and timer.getTime() <= self.StartTime + self.StopSeconds ) then
timer.scheduleFunction(
self.Scheduler,