This commit is contained in:
Sven Van de Velde 2016-05-06 19:12:02 +02:00
parent 4704afdc6c
commit c68e4cd257
3 changed files with 172 additions and 4 deletions

View File

@ -767,8 +767,41 @@ function GROUP:TaskAttackUnit( AttackUnit )
params = { unitId = AttackUnit:GetID(), params = { unitId = AttackUnit:GetID(),
expend = AI.Task.WeaponExpend.TWO, expend = AI.Task.WeaponExpend.TWO,
groupAttack = true, groupAttack = true,
} },
} },
self:T( { DCSTask } )
return DCSTask
end
--- Attack a Group.
-- @param #GROUP self
-- @param Group#GROUP AttackGroup The Group to be attacked.
-- @return DCSTask#Task The DCS task structure.
function GROUP:TaskAttackGroup( AttackGroup )
self:F( { self.GroupName, AttackGroup } )
-- AttackGroup = {
-- id = 'AttackGroup',
-- params = {
-- groupId = Group.ID,
-- weaponType = number,
-- expend = enum AI.Task.WeaponExpend,
-- attackQty = number,
-- directionEnabled = boolean,
-- direction = Azimuth,
-- altitudeEnabled = boolean,
-- altitude = Distance,
-- attackQtyLimit = boolean,
-- }
-- }
local DCSTask
DCSTask = { id = 'AttackGroup',
params = { groupId = AttackGroup:GetID(),
expend = AI.Task.WeaponExpend.TWO,
},
},
self:T( { DCSTask } ) self:T( { DCSTask } )
return DCSTask return DCSTask

View File

@ -245,3 +245,127 @@ function MENU_CLIENT_COMMAND:Remove()
self.ParentMenu.Menus[self.MenuPath] = nil self.ParentMenu.Menus[self.MenuPath] = nil
return nil return nil
end end
--- The MENU_COALITION class
-- @type MENU_COALITION
-- @extends Menu#MENU
MENU_COALITION = {
ClassName = "MENU_COALITION"
}
--- Creates a new coalition menu item
-- @param #MENU_COALITION self
-- @param DCSCoalition#coalition.side MenuCoalition The coalition owning the menu.
-- @param #string MenuText The text for the menu.
-- @param #table ParentMenu The parent menu.
-- @return #MENU_COALITION self
function MENU_COALITION:New( MenuCoalition, MenuText, ParentMenu )
-- Arrange meta tables
local MenuParentPath = {}
if ParentMenu ~= nil then
MenuParentPath = ParentMenu.MenuPath
end
local self = BASE:Inherit( self, MENU:New( MenuText, MenuParentPath ) )
self:F( { MenuCoalition, MenuText, ParentMenu } )
self.MenuCoalition = MenuCoalition
self.MenuParentPath = MenuParentPath
self.MenuText = MenuText
self.ParentMenu = ParentMenu
self.Menus = {}
self:T( { MenuParentPath, MenuText } )
self.MenuPath = missionCommands.addSubMenuForCoalition( self.MenuCoalition, MenuText, MenuParentPath )
self:T( { self.MenuPath } )
if ParentMenu and ParentMenu.Menus then
ParentMenu.Menus[self.MenuPath] = self
end
return self
end
--- Removes the sub menus recursively of this MENU_COALITION.
-- @param #MENU_COALITION self
-- @return #MENU_COALITION self
function MENU_COALITION:RemoveSubMenus()
self:F( self.MenuPath )
for MenuID, Menu in pairs( self.Menus ) do
Menu:Remove()
end
end
--- Removes the sub menus recursively of this MENU_COALITION.
-- @param #MENU_COALITION self
-- @return #MENU_COALITION self
function MENU_COALITION:Remove()
self:F( self.MenuPath )
self:RemoveSubMenus()
missionCommands.removeItemForCoalition( self.MenuCoalition, self.MenuPath )
self.ParentMenu.Menus[self.MenuPath] = nil
return nil
end
--- The MENU_COALITION_COMMAND class
-- @type MENU_COALITION_COMMAND
-- @extends Menu#MENU
MENU_COALITION_COMMAND = {
ClassName = "MENU_COALITION_COMMAND"
}
--- Creates a new radio command item for a group
-- @param #MENU_COALITION_COMMAND self
-- @param DCSCoalition#coalition.side MenuCoalition The coalition owning the menu.
-- @param MenuText The text for the menu.
-- @param ParentMenu The parent menu.
-- @param CommandMenuFunction A function that is called when the menu key is pressed.
-- @param CommandMenuArgument An argument for the function.
-- @return #MENU_COALITION_COMMAND self
function MENU_COALITION_COMMAND:New( MenuCoalition, MenuText, ParentMenu, CommandMenuFunction, CommandMenuArgument )
-- Arrange meta tables
local MenuParentPath = {}
if ParentMenu ~= nil then
MenuParentPath = ParentMenu.MenuPath
end
local self = BASE:Inherit( self, MENU:New( MenuText, MenuParentPath ) )
self.MenuCoalition = MenuCoalition
self.MenuParentPath = MenuParentPath
self.MenuText = MenuText
self.ParentMenu = ParentMenu
self:T( { MenuParentPath, MenuText, CommandMenuFunction, CommandMenuArgument } )
self.MenuPath = missionCommands.addCommandForCoalition( self.MenuCoalition, MenuText, MenuParentPath, CommandMenuFunction, CommandMenuArgument )
self.CommandMenuFunction = CommandMenuFunction
self.CommandMenuArgument = CommandMenuArgument
ParentMenu.Menus[self.MenuPath] = self
return self
end
--- Removes a radio command item for a coalition
-- @param #MENU_COALITION_COMMAND self
-- @return #MENU_COALITION_COMMAND self
function MENU_COALITION_COMMAND:Remove()
self:F( self.MenuPath )
missionCommands.removeItemForCoalition( self.MenuCoalition, self.MenuPath )
self.ParentMenu.Menus[self.MenuPath] = nil
return nil
end

View File

@ -63,7 +63,18 @@ end
function TIMETRIGGER:Scheduler() function TIMETRIGGER:Scheduler()
self:F( self.TimeEventFunctionArguments ) self:F( self.TimeEventFunctionArguments )
local Result = self.TimeEventFunction( self.TimeEventObject, unpack( self.TimeEventFunctionArguments ) ) local ErrorHandler = function( errmsg )
env.info( "Error in TIMETRIGGER 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)
end
if Result and Result == true then if Result and Result == true then
if not self.StopSeconds or ( self.StopSeconds and timer.getTime() <= self.StartTime + self.StopSeconds ) then if not self.StopSeconds or ( self.StopSeconds and timer.getTime() <= self.StartTime + self.StopSeconds ) then