Merge pull request #13 from FlightControl-Master/Create-ESCORT-class

Create escort class
This commit is contained in:
Sven Van de Velde 2016-04-01 21:34:49 +02:00
commit 0e850f2555
5 changed files with 86 additions and 52 deletions

View File

@ -2585,7 +2585,7 @@ local _TraceClass = {
--SPAWN = true,
--STAGE = true,
--ZONE = true,
--GROUP = true,
GROUP = true,
--UNIT = true,
--CLIENT = true,
--CARGO = true,
@ -2596,7 +2596,7 @@ local _TraceClass = {
--CLEANUP = true,
--MENU_CLIENT = true,
--MENU_CLIENT_COMMAND = true,
--ESCORT = true,
ESCORT = true,
}
--- The BASE Class
@ -3451,6 +3451,20 @@ function GROUP:PushTask( DCSTask )
return self
end
--- Clearing the Task Queue and Setting the Task on the queue from the group.
-- @param #GROUP self
-- @return Group#GROUP self
function GROUP:SetTask( DCSTask )
self:F()
local Controller = self:_GetController()
Controller:setTask( DCSTask )
return self
end
--- Return a condition section for a controlled task
-- @param #GROUP self
-- @param #Time time
@ -3634,7 +3648,7 @@ function GROUP:TaskAttackUnit( AttackUnit )
}
self:T( { DCSTask } )
return self
return DCSTask
end
@ -3992,7 +4006,7 @@ end
--- No evasion on enemy threats.
-- @param #GROUP self
-- @return #GROUP self
function GROUP:OptionEvasionNoReaction()
function GROUP:OptionROTNoReaction()
self:F( { self.GroupName } )
local Controller = self:_GetController()
@ -4009,7 +4023,7 @@ function GROUP:OptionROTPassiveDefense()
local Controller = self:_GetController()
Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.PASSIVE_DEFENSE )
Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.PASSIVE_DEFENCE )
return self
end
@ -10216,6 +10230,7 @@ end
--- Will spawn a group with a specified index number.
-- Uses @{DATABASE} global object defined in MOOSE.
-- @param #SPAWN self
-- @return GROUP#GROUP The group that was spawned. You can use this group for further actions.
function SPAWN:SpawnWithIndex( SpawnIndex )
self:F( { self.SpawnTemplatePrefix, SpawnIndex, self.SpawnMaxGroups } )
@ -10235,7 +10250,7 @@ function SPAWN:SpawnWithIndex( SpawnIndex )
self.SpawnGroups[self.SpawnIndex].Spawned = true
return self.SpawnGroups[self.SpawnIndex].Group
else
env.info( "No more Groups to Spawn" )
self:E( { self.SpawnTemplatePrefix, "No more Groups to Spawn:", SpawnIndex, self.SpawnMaxGroups } )
end
return nil
@ -11338,7 +11353,7 @@ function ESCORT:New( EscortClient, EscortGroup, EscortName )
self.EscortGroup = EscortGroup -- Group#GROUP
self.EscortName = EscortName
self.EscortMenu = MENU_CLIENT:New( self.EscortClient, "Escort" .. self.EscortName )
self.EscortMenu = MENU_CLIENT:New( self.EscortClient, self.EscortName )
-- Escort Navigation
self.EscortMenuReportNavigation = MENU_CLIENT:New( self.EscortClient, "Navigation", self.EscortMenu )
@ -11406,8 +11421,8 @@ function ESCORT._HoldPosition( MenuParam )
routines.removeFunction( self.FollowScheduler )
EscortGroup:PushTask( EscortGroup:TaskHoldPosition( 300 ) )
MESSAGE:New( "Holding Position at ... for 5 minutes.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/TaskHoldPosition" ):ToClient( EscortClient )
EscortGroup:SetTask( EscortGroup:TaskHoldPosition( 300 ) )
EscortGroup:MessageToClient( "Holding Position.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -11443,8 +11458,8 @@ function ESCORT._HoldPositionNearBy( MenuParam )
local Points = { PointFrom, PointTo }
EscortGroup:PushTask( EscortGroup:TaskRoute( Points ) )
MESSAGE:New( "Rejoining to your location. Please hold at your location.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/HoldPositionNearBy" ):ToClient( EscortClient )
EscortGroup:SetTask( EscortGroup:TaskRoute( Points ) )
EscortGroup:MessageToClient( "Rejoining to your location. Please hold at your location.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -11501,7 +11516,7 @@ function ESCORT._ScanTargets30Seconds( MenuParam )
EscortGroup:TaskCondition( nil, nil, nil, nil, 30, nil )
)
)
MESSAGE:New( "Scanning targets for 30 seconds.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ScanTargets30Seconds" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "Scanning targets for 30 seconds.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -11520,7 +11535,7 @@ function ESCORT._ScanTargets60Seconds( MenuParam )
EscortGroup:TaskCondition( nil, nil, nil, nil, 60, nil )
)
)
MESSAGE:New( "Scanning targets for 60 seconds.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ScanTargets60Seconds" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "Scanning targets for 60 seconds.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -11536,8 +11551,11 @@ function ESCORT._AttackTarget( MenuParam )
EscortGroup:OptionROEOpenFire()
EscortGroup:OptionROTVertical()
self:T( AttackUnit )
EscortGroup:PushTask( EscortGroup:TaskAttackUnit( AttackUnit ) )
MESSAGE:New( "Attacking Unit", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackTarget" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "Engaging Designated Unit!", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -11548,7 +11566,7 @@ function ESCORT._ROEHoldFire( MenuParam )
local EscortClient = self.EscortClient
EscortGroup:OptionROEHoldFire()
MESSAGE:New( "Holding weapons.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEHoldFire" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "Holding weapons.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -11559,7 +11577,7 @@ function ESCORT._ROEReturnFire( MenuParam )
local EscortClient = self.EscortClient
EscortGroup:OptionROEReturnFire()
MESSAGE:New( "Returning enemy fire.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEReturnFire" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "Returning enemy fire.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -11570,7 +11588,7 @@ function ESCORT._ROEOpenFire( MenuParam )
local EscortClient = self.EscortClient
EscortGroup:OptionROEOpenFire()
MESSAGE:New( "Open fire on ordered targets.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEOpenFire" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "Open fire on ordered targets.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -11581,7 +11599,7 @@ function ESCORT._ROEWeaponFree( MenuParam )
local EscortClient = self.EscortClient
EscortGroup:OptionROEWeaponFree()
MESSAGE:New( "Engaging targets.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEWeaponFree" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "Engaging nearby targets.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -11591,8 +11609,8 @@ function ESCORT._OptionROTNoReaction( MenuParam )
local EscortGroup = self.EscortGroup
local EscortClient = self.EscortClient
EscortGroup:OptionEvasionNoReaction()
MESSAGE:New( "We'll fight until death.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/OptionEvasionNoReaction" ):ToClient( EscortClient )
EscortGroup:OptionROTNoReaction()
EscortGroup:MessageToClient( "We'll fight until death.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -11603,7 +11621,7 @@ function ESCORT._OptionROTPassiveDefense( MenuParam )
local EscortClient = self.EscortClient
EscortGroup:OptionROTPassiveDefense()
MESSAGE:New( "We will use flares, chaff and jammers.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/OptionROTPassiveDefense" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "We will use flares, chaff and jammers.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -11614,7 +11632,7 @@ function ESCORT._OptionROTEvadeFire( MenuParam )
local EscortClient = self.EscortClient
EscortGroup:OptionROTEvadeFire()
MESSAGE:New( "We'll evade enemy fire.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/OptionROTEvadeFire" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "We'll evade enemy fire.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -11625,7 +11643,7 @@ function ESCORT._OptionROTVertical( MenuParam )
local EscortClient = self.EscortClient
EscortGroup:OptionROTVertical()
MESSAGE:New( "We'll perform vertical evasive manoeuvres.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/OptionROTVertical" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "We'll perform vertical evasive manoeuvres.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -11647,9 +11665,8 @@ function ESCORT._ResumeMission( MenuParam )
table.remove( WayPoints, 1 )
end
EscortGroup:PopCurrentTask()
EscortGroup:PushTask( EscortGroup:TaskRoute( WayPoints ) )
MESSAGE:New( "Resuming mission.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ResumeMission" ):ToClient( EscortClient )
EscortGroup:SetTask( EscortGroup:TaskRoute( WayPoints ) )
EscortGroup:MessageToClient( "Resuming mission from waypoint " .. WayPoint .. ".", 10, EscortClient )
end
function ESCORT:RegisterRoute()

View File

@ -14,7 +14,7 @@ local _TraceClass = {
--SPAWN = true,
--STAGE = true,
--ZONE = true,
--GROUP = true,
GROUP = true,
--UNIT = true,
--CLIENT = true,
--CARGO = true,
@ -25,7 +25,7 @@ local _TraceClass = {
--CLEANUP = true,
--MENU_CLIENT = true,
--MENU_CLIENT_COMMAND = true,
--ESCORT = true,
ESCORT = true,
}
--- The BASE Class

View File

@ -58,7 +58,7 @@ function ESCORT:New( EscortClient, EscortGroup, EscortName )
self.EscortGroup = EscortGroup -- Group#GROUP
self.EscortName = EscortName
self.EscortMenu = MENU_CLIENT:New( self.EscortClient, "Escort" .. self.EscortName )
self.EscortMenu = MENU_CLIENT:New( self.EscortClient, self.EscortName )
-- Escort Navigation
self.EscortMenuReportNavigation = MENU_CLIENT:New( self.EscortClient, "Navigation", self.EscortMenu )
@ -126,8 +126,8 @@ function ESCORT._HoldPosition( MenuParam )
routines.removeFunction( self.FollowScheduler )
EscortGroup:PushTask( EscortGroup:TaskHoldPosition( 300 ) )
MESSAGE:New( "Holding Position at ... for 5 minutes.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/TaskHoldPosition" ):ToClient( EscortClient )
EscortGroup:SetTask( EscortGroup:TaskHoldPosition( 300 ) )
EscortGroup:MessageToClient( "Holding Position.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -163,8 +163,8 @@ function ESCORT._HoldPositionNearBy( MenuParam )
local Points = { PointFrom, PointTo }
EscortGroup:PushTask( EscortGroup:TaskRoute( Points ) )
MESSAGE:New( "Rejoining to your location. Please hold at your location.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/HoldPositionNearBy" ):ToClient( EscortClient )
EscortGroup:SetTask( EscortGroup:TaskRoute( Points ) )
EscortGroup:MessageToClient( "Rejoining to your location. Please hold at your location.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -221,7 +221,7 @@ function ESCORT._ScanTargets30Seconds( MenuParam )
EscortGroup:TaskCondition( nil, nil, nil, nil, 30, nil )
)
)
MESSAGE:New( "Scanning targets for 30 seconds.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ScanTargets30Seconds" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "Scanning targets for 30 seconds.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -240,7 +240,7 @@ function ESCORT._ScanTargets60Seconds( MenuParam )
EscortGroup:TaskCondition( nil, nil, nil, nil, 60, nil )
)
)
MESSAGE:New( "Scanning targets for 60 seconds.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ScanTargets60Seconds" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "Scanning targets for 60 seconds.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -256,8 +256,11 @@ function ESCORT._AttackTarget( MenuParam )
EscortGroup:OptionROEOpenFire()
EscortGroup:OptionROTVertical()
self:T( AttackUnit )
EscortGroup:PushTask( EscortGroup:TaskAttackUnit( AttackUnit ) )
MESSAGE:New( "Attacking Unit", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackTarget" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "Engaging Designated Unit!", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -268,7 +271,7 @@ function ESCORT._ROEHoldFire( MenuParam )
local EscortClient = self.EscortClient
EscortGroup:OptionROEHoldFire()
MESSAGE:New( "Holding weapons.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEHoldFire" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "Holding weapons.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -279,7 +282,7 @@ function ESCORT._ROEReturnFire( MenuParam )
local EscortClient = self.EscortClient
EscortGroup:OptionROEReturnFire()
MESSAGE:New( "Returning enemy fire.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEReturnFire" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "Returning enemy fire.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -290,7 +293,7 @@ function ESCORT._ROEOpenFire( MenuParam )
local EscortClient = self.EscortClient
EscortGroup:OptionROEOpenFire()
MESSAGE:New( "Open fire on ordered targets.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEOpenFire" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "Open fire on ordered targets.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -301,7 +304,7 @@ function ESCORT._ROEWeaponFree( MenuParam )
local EscortClient = self.EscortClient
EscortGroup:OptionROEWeaponFree()
MESSAGE:New( "Engaging targets.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ROEWeaponFree" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "Engaging nearby targets.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -311,8 +314,8 @@ function ESCORT._OptionROTNoReaction( MenuParam )
local EscortGroup = self.EscortGroup
local EscortClient = self.EscortClient
EscortGroup:OptionEvasionNoReaction()
MESSAGE:New( "We'll fight until death.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/OptionEvasionNoReaction" ):ToClient( EscortClient )
EscortGroup:OptionROTNoReaction()
EscortGroup:MessageToClient( "We'll fight until death.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -323,7 +326,7 @@ function ESCORT._OptionROTPassiveDefense( MenuParam )
local EscortClient = self.EscortClient
EscortGroup:OptionROTPassiveDefense()
MESSAGE:New( "We will use flares, chaff and jammers.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/OptionROTPassiveDefense" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "We will use flares, chaff and jammers.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -334,7 +337,7 @@ function ESCORT._OptionROTEvadeFire( MenuParam )
local EscortClient = self.EscortClient
EscortGroup:OptionROTEvadeFire()
MESSAGE:New( "We'll evade enemy fire.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/OptionROTEvadeFire" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "We'll evade enemy fire.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -345,7 +348,7 @@ function ESCORT._OptionROTVertical( MenuParam )
local EscortClient = self.EscortClient
EscortGroup:OptionROTVertical()
MESSAGE:New( "We'll perform vertical evasive manoeuvres.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/OptionROTVertical" ):ToClient( EscortClient )
EscortGroup:MessageToClient( "We'll perform vertical evasive manoeuvres.", 10, EscortClient )
end
--- @param #MENUPARAM MenuParam
@ -367,9 +370,8 @@ function ESCORT._ResumeMission( MenuParam )
table.remove( WayPoints, 1 )
end
EscortGroup:PopCurrentTask()
EscortGroup:PushTask( EscortGroup:TaskRoute( WayPoints ) )
MESSAGE:New( "Resuming mission.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/ResumeMission" ):ToClient( EscortClient )
EscortGroup:SetTask( EscortGroup:TaskRoute( WayPoints ) )
EscortGroup:MessageToClient( "Resuming mission from waypoint " .. WayPoint .. ".", 10, EscortClient )
end
function ESCORT:RegisterRoute()

View File

@ -330,6 +330,20 @@ function GROUP:PushTask( DCSTask )
return self
end
--- Clearing the Task Queue and Setting the Task on the queue from the group.
-- @param #GROUP self
-- @return Group#GROUP self
function GROUP:SetTask( DCSTask )
self:F()
local Controller = self:_GetController()
Controller:setTask( DCSTask )
return self
end
--- Return a condition section for a controlled task
-- @param #GROUP self
-- @param #Time time
@ -513,7 +527,7 @@ function GROUP:TaskAttackUnit( AttackUnit )
}
self:T( { DCSTask } )
return self
return DCSTask
end
@ -871,7 +885,7 @@ end
--- No evasion on enemy threats.
-- @param #GROUP self
-- @return #GROUP self
function GROUP:OptionEvasionNoReaction()
function GROUP:OptionROTNoReaction()
self:F( { self.GroupName } )
local Controller = self:_GetController()
@ -888,7 +902,7 @@ function GROUP:OptionROTPassiveDefense()
local Controller = self:_GetController()
Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.PASSIVE_DEFENSE )
Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.PASSIVE_DEFENCE )
return self
end

View File

@ -424,6 +424,7 @@ end
--- Will spawn a group with a specified index number.
-- Uses @{DATABASE} global object defined in MOOSE.
-- @param #SPAWN self
-- @return GROUP#GROUP The group that was spawned. You can use this group for further actions.
function SPAWN:SpawnWithIndex( SpawnIndex )
self:F( { self.SpawnTemplatePrefix, SpawnIndex, self.SpawnMaxGroups } )
@ -443,7 +444,7 @@ function SPAWN:SpawnWithIndex( SpawnIndex )
self.SpawnGroups[self.SpawnIndex].Spawned = true
return self.SpawnGroups[self.SpawnIndex].Group
else
env.info( "No more Groups to Spawn" )
self:E( { self.SpawnTemplatePrefix, "No more Groups to Spawn:", SpawnIndex, self.SpawnMaxGroups } )
end
return nil