mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Worked on DCS function prototyping
Found in LDT the means to create using luadoc function prototypes using a documentation mechanism. Am reworking now the DCS function manual to a luadoc structure.
This commit is contained in:
@@ -13,15 +13,17 @@ _TraceClass = {
|
||||
--SPAWN = true,
|
||||
--STAGE = true,
|
||||
--ZONE = true,
|
||||
--GROUP = true,
|
||||
GROUP = true,
|
||||
--UNIT = true,
|
||||
--CLIENT = true,
|
||||
CLIENT = true,
|
||||
--CARGO = true,
|
||||
--CARGO_GROUP = true,
|
||||
--CARGO_PACKAGE = true,
|
||||
--CARGO_SLINGLOAD = true,
|
||||
--CARGO_ZONE = true,
|
||||
--CLEANUP = true,
|
||||
MENU_SUB_GROUP = true,
|
||||
MENU_COMMAND_GROUP = true,
|
||||
ESCORT = true,
|
||||
}
|
||||
|
||||
@@ -247,13 +249,14 @@ function BASE:T( Arguments )
|
||||
end
|
||||
|
||||
local LineCurrent = DebugInfoCurrent.currentline
|
||||
local LineFrom = DebugInfoFrom.currentline
|
||||
|
||||
local LineFrom = 0
|
||||
if DebugInfoFrom then
|
||||
LineFrom = DebugInfoFrom.currentline
|
||||
end
|
||||
env.info( string.format( "%6d\(%6d\)/%1s:%20s%05d.%s\(%s\)" , LineCurrent, LineFrom, "T", self.ClassName, self.ClassID, Function, routines.utils.oneLineSerialize( Arguments ) ) )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Log an exception
|
||||
function BASE:E( Arguments )
|
||||
|
||||
@@ -270,3 +273,6 @@ function BASE:E( 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
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -480,7 +480,7 @@ function CARGO_GROUP:Spawn( Client )
|
||||
elseif self:IsStatusLoading() then
|
||||
|
||||
local Client = self:IsLoadingToClient()
|
||||
if Client and Client:ClientGroup() then
|
||||
if Client and Client:GetDCSGroup() then
|
||||
SpawnCargo = false
|
||||
else
|
||||
local CargoGroup = Group.getByName( self.CargoName )
|
||||
@@ -494,7 +494,7 @@ function CARGO_GROUP:Spawn( Client )
|
||||
local ClientLoaded = self:IsLoadedInClient()
|
||||
-- Now test if another Client is alive (not this one), and it has the CARGO, then this cargo does not need to be initialized and spawned.
|
||||
if ClientLoaded and ClientLoaded ~= Client then
|
||||
local ClientGroup = Client:ClientGroup()
|
||||
local ClientGroup = Client:GetDCSGroup()
|
||||
if ClientLoaded:GetClientGroupDCSUnit() and ClientLoaded:GetClientGroupDCSUnit():isExist() then
|
||||
SpawnCargo = false
|
||||
else
|
||||
@@ -680,7 +680,7 @@ function CARGO_PACKAGE:Spawn( Client )
|
||||
|
||||
-- this needs to be checked thoroughly
|
||||
|
||||
local CargoClientGroup = self.CargoClient:ClientGroup()
|
||||
local CargoClientGroup = self.CargoClient:GetDCSGroup()
|
||||
if not CargoClientGroup then
|
||||
if not self.CargoClientSpawn then
|
||||
self.CargoClientSpawn = SPAWN:New( self.CargoClient:GetClientGroupName() ):Limit( 1, 1 )
|
||||
@@ -695,7 +695,7 @@ function CARGO_PACKAGE:Spawn( Client )
|
||||
elseif self:IsStatusLoading() or self:IsStatusLoaded() then
|
||||
|
||||
local CargoClientLoaded = self:IsLoadedInClient()
|
||||
if CargoClientLoaded and CargoClientLoaded:ClientGroup() then
|
||||
if CargoClientLoaded and CargoClientLoaded:GetDCSGroup() then
|
||||
SpawnCargo = false
|
||||
end
|
||||
|
||||
@@ -720,7 +720,7 @@ self:T()
|
||||
|
||||
local Near = false
|
||||
|
||||
if self.CargoClient and self.CargoClient:ClientGroup() then
|
||||
if self.CargoClient and self.CargoClient:GetDCSGroup() then
|
||||
self:T( self.CargoClient.ClientName )
|
||||
self:T( 'Client Exists.' )
|
||||
|
||||
@@ -746,8 +746,8 @@ self:T()
|
||||
local CarrierPosOnBoard = ClientUnit:getPoint()
|
||||
local CarrierPosMoveAway = ClientUnit:getPoint()
|
||||
|
||||
local CargoHostGroup = self.CargoClient:ClientGroup()
|
||||
local CargoHostName = self.CargoClient:ClientGroup():getName()
|
||||
local CargoHostGroup = self.CargoClient:GetDCSGroup()
|
||||
local CargoHostName = self.CargoClient:GetDCSGroup():getName()
|
||||
|
||||
local CargoHostUnits = CargoHostGroup:getUnits()
|
||||
local CargoPos = CargoHostUnits[1]:getPoint()
|
||||
@@ -830,7 +830,7 @@ self:T()
|
||||
|
||||
local OnBoarded = false
|
||||
|
||||
if self.CargoClient and self.CargoClient:ClientGroup() then
|
||||
if self.CargoClient and self.CargoClient:GetDCSGroup() then
|
||||
if routines.IsUnitInRadius( self.CargoClient:GetClientGroupDCSUnit(), self.CargoClient:ClientPosition(), 10 ) then
|
||||
|
||||
-- Switch Cargo from self.CargoClient to Client ... Each cargo can have only one client. So assigning the new client for the cargo is enough.
|
||||
@@ -851,7 +851,7 @@ self:T()
|
||||
self:T( 'self.CargoName = ' .. self.CargoName )
|
||||
--self:T( 'self.CargoHostName = ' .. self.CargoHostName )
|
||||
|
||||
--self.CargoSpawn:FromCarrier( Client:ClientGroup(), TargetZoneName, self.CargoHostName )
|
||||
--self.CargoSpawn:FromCarrier( Client:GetDCSGroup(), TargetZoneName, self.CargoHostName )
|
||||
self:StatusUnLoaded()
|
||||
|
||||
return Cargo
|
||||
|
||||
@@ -46,7 +46,7 @@ CLIENT = {
|
||||
-- Mission:AddClient( CLIENT:New( 'RU MI-8MTV2*RAMP-Deploy Troops 4' ):Transport() )
|
||||
function CLIENT:New( ClientName, ClientBriefing )
|
||||
local self = BASE:Inherit( self, BASE:New() )
|
||||
self:T()
|
||||
self:T( ClientName, ClientBriefing )
|
||||
|
||||
self.ClientName = ClientName
|
||||
self:AddBriefing( ClientBriefing )
|
||||
@@ -62,10 +62,22 @@ self:T()
|
||||
self._Menus = {}
|
||||
end
|
||||
|
||||
--- ClientGroup returns the Group of a Client.
|
||||
--- Return the Group of a Client.
|
||||
-- This function is modified to deal with a couple of bugs in DCS 1.5.3
|
||||
-- @return Group
|
||||
function CLIENT:ClientGroup()
|
||||
-- @return #GROUP
|
||||
function CLIENT:GetGroup()
|
||||
|
||||
if not self.ClientGroup then
|
||||
self.ClientGroup = GROUP:New( self:GetDCSGroup() )
|
||||
end
|
||||
|
||||
return self.ClientGroup
|
||||
end
|
||||
|
||||
--- Return the DCSGroup of a Client.
|
||||
-- This function is modified to deal with a couple of bugs in DCS 1.5.3
|
||||
-- @return DCSGroup
|
||||
function CLIENT:GetDCSGroup()
|
||||
--self:T()
|
||||
|
||||
-- local ClientData = Group.getByName( self.ClientName )
|
||||
@@ -102,7 +114,7 @@ function CLIENT:ClientGroup()
|
||||
self:T( { tonumber(UnitData:getID()), ClientUnitData.unitId } )
|
||||
if tonumber(UnitData:getID()) == ClientUnitData.unitId then
|
||||
local ClientGroupTemplate = _Database.Groups[self.ClientName].Template
|
||||
self.ClientGroupID = ClientGroupTemplate.groupId
|
||||
self.ClientID = ClientGroupTemplate.groupId
|
||||
self.ClientGroupUnit = UnitData
|
||||
self:T( self.ClientName .. " : group found in bug 1.5 resolvement logic!" )
|
||||
return ClientGroup
|
||||
@@ -127,7 +139,7 @@ function CLIENT:ClientGroup()
|
||||
end
|
||||
end
|
||||
|
||||
self.ClientGroupID = nil
|
||||
self.ClientID = nil
|
||||
self.ClientGroupUnit = nil
|
||||
|
||||
return nil
|
||||
@@ -135,46 +147,48 @@ end
|
||||
|
||||
|
||||
function CLIENT:GetClientGroupID()
|
||||
self:T()
|
||||
|
||||
ClientGroup = self:ClientGroup()
|
||||
|
||||
if ClientGroup then
|
||||
if ClientGroup:isExist() then
|
||||
return ClientGroup:getID()
|
||||
else
|
||||
return self.ClientGroupID
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
if not self.ClientID then
|
||||
if not self.ClientGroup then
|
||||
self.ClientGroup = GROUP:New( self:GetDCSGroup() )
|
||||
end
|
||||
if self.ClientGroup:IsAlive() then
|
||||
self.ClientGroupID = self.ClientGroup:GetID()
|
||||
else
|
||||
self.ClientGroupID = self.ClientID
|
||||
self.ClientGroup.GroupID = self.ClientID
|
||||
end
|
||||
end
|
||||
|
||||
self:T( self.ClientGroupID )
|
||||
return self.ClientGroupID
|
||||
end
|
||||
|
||||
|
||||
function CLIENT:GetClientGroupName()
|
||||
self:T()
|
||||
|
||||
ClientGroup = self:ClientGroup()
|
||||
|
||||
if ClientGroup then
|
||||
if ClientGroup:isExist() then
|
||||
self:T( ClientGroup:getName() )
|
||||
return ClientGroup:getName()
|
||||
else
|
||||
self:T( self.ClientName )
|
||||
return self.ClientName
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
if not self.ClientGroupName then
|
||||
if not self.ClientGroup then
|
||||
self.ClientGroup = GROUP:New( self:GetDCSGroup() )
|
||||
end
|
||||
if self.ClientGroup:IsAlive() then
|
||||
self.ClientGroupName = self.ClientGroup:GetName()
|
||||
else
|
||||
self.ClientGroupName = self.ClientName
|
||||
self.ClientGroup.GroupName = self.ClientGroupName
|
||||
end
|
||||
end
|
||||
|
||||
self:T( self.ClientGroupName )
|
||||
return self.ClientGroupName
|
||||
end
|
||||
|
||||
--- Returns the Unit of the @{CLIENT}.
|
||||
-- @return Unit
|
||||
function CLIENT:GetClientGroupUnit()
|
||||
self:T()
|
||||
self:T()
|
||||
|
||||
local ClientGroup = self:ClientGroup()
|
||||
local ClientGroup = self:GetDCSGroup()
|
||||
|
||||
if ClientGroup then
|
||||
if ClientGroup:isExist() then
|
||||
@@ -192,7 +206,7 @@ end
|
||||
function CLIENT:GetClientGroupDCSUnit()
|
||||
self:T()
|
||||
|
||||
local ClientGroup = self:ClientGroup()
|
||||
local ClientGroup = self:GetDCSGroup()
|
||||
|
||||
if ClientGroup then
|
||||
if ClientGroup:isExist() then
|
||||
@@ -291,9 +305,9 @@ self:T()
|
||||
|
||||
if not self.MenuMessages then
|
||||
if self:GetClientGroupID() then
|
||||
self.MenuMessages = MENU_SUB_GROUP:New( self:GetClientGroupID(), 'Messages' )
|
||||
self.MenuRouteMessageOn = MENU_COMMAND_GROUP:New( self:GetClientGroupID(), 'Messages On', self.MenuMessages, CLIENT.SwitchMessages, { self, true } )
|
||||
self.MenuRouteMessageOff = MENU_COMMAND_GROUP:New( self:GetClientGroupID(),'Messages Off', self.MenuMessages, CLIENT.SwitchMessages, { self, false } )
|
||||
self.MenuMessages = MENU_SUB_GROUP:New( self:GetGroup(), 'Messages' )
|
||||
self.MenuRouteMessageOn = MENU_COMMAND_GROUP:New( self:GetGroup(), 'Messages On', self.MenuMessages, CLIENT.SwitchMessages, { self, true } )
|
||||
self.MenuRouteMessageOff = MENU_COMMAND_GROUP:New( self:GetGroup(),'Messages Off', self.MenuMessages, CLIENT.SwitchMessages, { self, false } )
|
||||
end
|
||||
end
|
||||
|
||||
@@ -307,7 +321,7 @@ self:T()
|
||||
self.Messages[MessageId].MessageTime = timer.getTime()
|
||||
self.Messages[MessageId].MessageDuration = MessageDuration
|
||||
if MessageInterval == nil then
|
||||
self.Messages[MessageId].MessageInterval = 0
|
||||
self.Messages[MessageId].MessageInterval = 600
|
||||
else
|
||||
self.Messages[MessageId].MessageInterval = MessageInterval
|
||||
end
|
||||
|
||||
159
Moose/Escort.lua
159
Moose/Escort.lua
@@ -39,12 +39,112 @@ function ESCORT:New( EscortClient, EscortGroup, EscortName )
|
||||
self.EscortClient = EscortClient
|
||||
self.EscortGroup = EscortGroup
|
||||
self.EscortName = EscortName
|
||||
self.ReportTargets = true
|
||||
|
||||
-- Escort Navigation
|
||||
self.EscortMenu = MENU_SUB_GROUP:New( self.EscortClient:GetGroup(), "Escort" .. self.EscortName )
|
||||
self.EscortMenuHoldPosition = MENU_COMMAND_GROUP:New( self.EscortClient:GetGroup(), "Hold Position and Stay Low", self.EscortMenu, ESCORT._HoldPosition, { ParamSelf = self } )
|
||||
|
||||
-- Report Targets
|
||||
self.EscortMenuReportNearbyTargets = MENU_SUB_GROUP:New( self.EscortClient:GetGroup(), "Report Targets", self.EscortMenu )
|
||||
self.EscortMenuReportNearbyTargetsOn = MENU_COMMAND_GROUP:New( self.EscortClient:GetGroup(), "Report Targets On", self.EscortMenuReportNearbyTargets, ESCORT._ReportNearbyTargets, { ParamSelf = self, ParamReportTargets = true } )
|
||||
self.EscortMenuReportNearbyTargetsOff = MENU_COMMAND_GROUP:New( self.EscortClient:GetGroup(), "Report Targets Off", self.EscortMenuReportNearbyTargets, ESCORT._ReportNearbyTargets, { ParamSelf = self, ParamReportTargets = false, } )
|
||||
|
||||
-- Attack Targets
|
||||
self.EscortMenuAttackNearbyTargets = MENU_SUB_GROUP:New( self.EscortClient:GetGroup(), "Attack nearby targets", self.EscortMenu )
|
||||
self.EscortMenuAttackTargets = {}
|
||||
self.Targets = {}
|
||||
|
||||
-- Rules of Engagement
|
||||
self.EscortMenuROE = MENU_SUB_GROUP:New( self.EscortClient:GetGroup(), "ROE", self.EscortMenu )
|
||||
self.EscortMenuROEHoldFire = MENU_COMMAND_GROUP:New( self.EscortClient:GetGroup(), "Hold Fire", self.EscortMenuROE, ESCORT._ROEHoldFire, { ParamSelf = self, } )
|
||||
self.EscortMenuROEReturnFire = MENU_COMMAND_GROUP:New( self.EscortClient:GetGroup(), "Return Fire", self.EscortMenuROE, ESCORT._ROEReturnFire, { ParamSelf = self, } )
|
||||
self.EscortMenuROEOpenFire = MENU_COMMAND_GROUP:New( self.EscortClient:GetGroup(), "Open Fire", self.EscortMenuROE, ESCORT._ROEOpenFire, { ParamSelf = self, } )
|
||||
self.EscortMenuROEWeaponFree = MENU_COMMAND_GROUP:New( self.EscortClient:GetGroup(), "Weapon Free", self.EscortMenuROE, ESCORT._ROEWeaponFree, { ParamSelf = self, } )
|
||||
|
||||
self.ScanForTargetsFunction = routines.scheduleFunction( self._ScanForTargets, { self }, timer.getTime() + 1, 10 )
|
||||
-- Reaction to Threats
|
||||
self.EscortMenuEvasion = MENU_SUB_GROUP:New( self.EscortClient:GetGroup(), "Evasion", self.EscortMenu )
|
||||
self.EscortMenuEvasionNoReaction = MENU_COMMAND_GROUP:New( self.EscortClient:GetGroup(), "Fight until death", self.EscortMenuEvasion, ESCORT._EvasionNoReaction, { ParamSelf = self, } )
|
||||
self.EscortMenuEvasionPassiveDefense = MENU_COMMAND_GROUP:New( self.EscortClient:GetGroup(), "Use flares, chaff and jammers", self.EscortMenuEvasion, ESCORT._EvasionPassiveDefense, { ParamSelf = self, } )
|
||||
self.EscortMenuEvasionEvadeFire = MENU_COMMAND_GROUP:New( self.EscortClient:GetGroup(), "Evade enemy fire", self.EscortMenuEvasion, ESCORT._EvasionEvadeFire, { ParamSelf = self, } )
|
||||
self.EscortMenuEvasionVertical = MENU_COMMAND_GROUP:New( self.EscortClient:GetGroup(), "Go below radar and evade fire", self.EscortMenuEvasion, ESCORT._EvasionVertical, { ParamSelf = self, } )
|
||||
|
||||
|
||||
self.ScanForTargetsFunction = routines.scheduleFunction( self._ScanForTargets, { self }, timer.getTime() + 1, 30 )
|
||||
end
|
||||
|
||||
function ESCORT._HoldPosition( MenuParam )
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:HoldPosition( 300 )
|
||||
MESSAGE:New( "Holding Position at ... for 5 minutes.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/HoldPosition" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
function ESCORT._ReportNearbyTargets( MenuParam )
|
||||
MenuParam.ParamSelf:T()
|
||||
|
||||
MenuParam.ParamSelf.ReportTargets = MenuParam.ParamReportTargets
|
||||
|
||||
end
|
||||
|
||||
function ESCORT._AttackTarget( MenuParam )
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:AttackUnit( MenuParam.ParamUnit )
|
||||
MESSAGE:New( "Attacking Unit", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackUnit" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
function ESCORT._ROEHoldFire( MenuParam )
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:HoldFire()
|
||||
MESSAGE:New( "Holding weapons.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackUnit" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
function ESCORT._ROEReturnFire( MenuParam )
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:ReturnFire()
|
||||
MESSAGE:New( "Returning enemy fire.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackUnit" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
function ESCORT._ROEOpenFire( MenuParam )
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:OpenFire()
|
||||
MESSAGE:New( "Open fire on ordered targets.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackUnit" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
function ESCORT._ROEWeaponFree( MenuParam )
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:WeaponFree()
|
||||
MESSAGE:New( "Engaging targets.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackUnit" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
function ESCORT._EvasionNoReaction( MenuParam )
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:EvasionNoReaction()
|
||||
MESSAGE:New( "We'll fight until death.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackUnit" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
function ESCORT._EvasionPassiveDefense( MenuParam )
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:EvasionPassiveDefense()
|
||||
MESSAGE:New( "We will use flares, chaff and jammers.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackUnit" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
function ESCORT._EvasionEvadeFire( MenuParam )
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:EvasionEvadeFire()
|
||||
MESSAGE:New( "We'll evade enemy fire.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackUnit" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
function ESCORT._EvasionVertical( MenuParam )
|
||||
|
||||
MenuParam.ParamSelf.EscortGroup:EvasionVertical()
|
||||
MESSAGE:New( "We'll perform vertical evasive manoeuvres.", MenuParam.ParamSelf.EscortName, 10, "ESCORT/AttackUnit" ):ToClient( MenuParam.ParamSelf.EscortClient )
|
||||
end
|
||||
|
||||
|
||||
function ESCORT:_ScanForTargets()
|
||||
self:T()
|
||||
|
||||
self.Targets = {}
|
||||
|
||||
if self.EscortGroup:IsAlive() then
|
||||
local EscortTargets = self.EscortGroup:GetDetectedTargets()
|
||||
@@ -85,12 +185,25 @@ function ESCORT:_ScanForTargets()
|
||||
local EscortPositionVec3 = self.EscortGroup:GetPositionVec3()
|
||||
local Distance = routines.utils.get3DDist( EscortTargetUnitPositionVec3, EscortPositionVec3 ) / 1000
|
||||
self:T( { self.EscortGroup:GetName(), EscortTargetUnit:GetName(), Distance, EscortTarget.visible } )
|
||||
|
||||
if Distance <= 8 then
|
||||
EscortTargetMessage = EscortTargetMessage .. " - " .. EscortTargetCategoryName .. " (" .. EscortTargetCategoryType .. ") "
|
||||
EscortTargetMessage = EscortTargetMessage .. string.format( "%.2f", Distance ) .. " km"
|
||||
if EscortTarget.visible then
|
||||
EscortTargetMessage = EscortTargetMessage .. " visual contact"
|
||||
|
||||
if EscortTarget.type then
|
||||
EscortTargetMessage = EscortTargetMessage .. " - " .. EscortTargetCategoryName .. " (" .. EscortTargetCategoryType .. ") at "
|
||||
else
|
||||
EscortTargetMessage = EscortTargetMessage .. " - Unknown target at "
|
||||
end
|
||||
|
||||
EscortTargetMessage = EscortTargetMessage .. string.format( "%.2f", Distance ) .. " km"
|
||||
|
||||
if EscortTarget.visible then
|
||||
EscortTargetMessage = EscortTargetMessage .. ", visual"
|
||||
end
|
||||
|
||||
local TargetIndex = Distance*1000
|
||||
self.Targets[TargetIndex] = {}
|
||||
self.Targets[TargetIndex].AttackMessage = EscortTargetMessage
|
||||
self.Targets[TargetIndex].AttackUnit = EscortTargetUnit
|
||||
end
|
||||
end
|
||||
|
||||
@@ -100,9 +213,41 @@ function ESCORT:_ScanForTargets()
|
||||
end
|
||||
end
|
||||
|
||||
if EscortTargetMessages ~= "" then
|
||||
self.EscortClient:Message( EscortTargetMessages:gsub("\n$",""), 20, "/ESCORT.DetectedTargets", self.EscortName .. " reporting detected targets within 8 km range:" )
|
||||
if EscortTargetMessages ~= "" and self.ReportTargets == true then
|
||||
self.EscortClient:Message( EscortTargetMessages:gsub("\n$",""), 20, "/ESCORT.DetectedTargets", self.EscortName .. " reporting detected targets within 8 km range:", 0 )
|
||||
end
|
||||
|
||||
self:T()
|
||||
|
||||
self:T( { "Sorting Targets Table:", self.Targets } )
|
||||
table.sort( self.Targets )
|
||||
self:T( { "Sorted Targets Table:", self.Targets } )
|
||||
|
||||
for MenuIndex = 1, #self.EscortMenuAttackTargets do
|
||||
self:T( { "Remove Menu:", self.EscortMenuAttackTargets[MenuIndex] } )
|
||||
self.EscortMenuAttackTargets[MenuIndex] = self.EscortMenuAttackTargets[MenuIndex]:Remove()
|
||||
end
|
||||
|
||||
local MenuIndex = 1
|
||||
for TargetID, TargetData in pairs( self.Targets ) do
|
||||
self:T( { "Adding menu:", TargetID, "for Unit", self.Targets[TargetID].AttackUnit } )
|
||||
if MenuIndex <= 10 then
|
||||
self.EscortMenuAttackTargets[MenuIndex] =
|
||||
MENU_COMMAND_GROUP:New( self.EscortClient:GetGroup(),
|
||||
self.Targets[TargetID].AttackMessage,
|
||||
self.EscortMenuAttackNearbyTargets,
|
||||
ESCORT._AttackTarget,
|
||||
{ ParamSelf = self,
|
||||
ParamUnit = self.Targets[TargetID].AttackUnit
|
||||
}
|
||||
)
|
||||
self:T( { "New Menu:", self.EscortMenuAttackTargets[TargetID] } )
|
||||
MenuIndex = MenuIndex + 1
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
routines.removeFunction( self.ScanForTargetsFunction )
|
||||
end
|
||||
|
||||
185
Moose/Group.lua
185
Moose/Group.lua
@@ -35,12 +35,16 @@ GROUPS = {}
|
||||
-- @return #GROUP self
|
||||
function GROUP:New( DCSGroup )
|
||||
local self = BASE:Inherit( self, BASE:New() )
|
||||
self:T( DCSGroup:getName() )
|
||||
self:T( DCSGroup )
|
||||
|
||||
self.DCSGroup = DCSGroup
|
||||
self.GroupName = DCSGroup:getName()
|
||||
self.GroupID = DCSGroup:getID()
|
||||
self.Controller = DCSGroup:getController()
|
||||
if self.DCSGroup and self.DCSGroup:isExist() then
|
||||
self.GroupName = DCSGroup:getName()
|
||||
self.GroupID = DCSGroup:getID()
|
||||
self.Controller = DCSGroup:getController()
|
||||
else
|
||||
self:E( { "DCSGroup is nil or does not exist, cannot initialize GROUP!", self.DCSGroup } )
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
@@ -111,6 +115,15 @@ function GROUP:Activate()
|
||||
return self:GetDCSGroup()
|
||||
end
|
||||
|
||||
--- Gets the ID of the GROUP.
|
||||
-- @param self
|
||||
-- @return #number The ID of the GROUP.
|
||||
function GROUP:GetID()
|
||||
self:T( self.GroupName )
|
||||
|
||||
return self.GroupID
|
||||
end
|
||||
|
||||
--- Gets the name of the GROUP.
|
||||
-- @param self
|
||||
-- @return #string The name of the GROUP.
|
||||
@@ -253,6 +266,39 @@ self:T()
|
||||
end
|
||||
|
||||
|
||||
--- Hold position at the current position of the first unit of the group.
|
||||
-- @param self
|
||||
-- @param #number Duration The maximum duration in seconds to hold the position.
|
||||
-- @return #GROUP self
|
||||
function GROUP:HoldPosition( Duration )
|
||||
trace.f( self.ClassName, { self.GroupName, Duration } )
|
||||
|
||||
local Controller = self:_GetController()
|
||||
|
||||
-- pattern = enum AI.Task.OribtPattern,
|
||||
-- point = Vec2,
|
||||
-- point2 = Vec2,
|
||||
-- speed = Distance,
|
||||
-- altitude = Distance
|
||||
|
||||
local GroupPoint = self:GetPoint()
|
||||
--id = 'Orbit', params = { pattern = AI.Task.OrbitPattern.RACE_TRACK } }, stopCondition = { duration = 600 } }
|
||||
Controller:pushTask( { id = 'ControlledTask',
|
||||
params = { task = { id = 'Orbit',
|
||||
params = { pattern = AI.Task.OrbitPattern.CIRCLE,
|
||||
point = GroupPoint,
|
||||
speed = 0,
|
||||
altitude = 30
|
||||
}
|
||||
},
|
||||
stopCondition = { duration = Duration
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Land the group at a Vec2Point.
|
||||
-- @param self
|
||||
-- @param #Vec2 Point The point where to land.
|
||||
@@ -272,6 +318,137 @@ trace.f( self.ClassName, { self.GroupName, Point, Duration } )
|
||||
return self
|
||||
end
|
||||
|
||||
--- Attack the Unit.
|
||||
-- @param self
|
||||
-- @param #UNIT The unit.
|
||||
-- @return #GROUP self
|
||||
function GROUP:AttackUnit( AttackUnit )
|
||||
self:T( { self.GroupName, AttackUnit } )
|
||||
|
||||
local Controller = self:_GetController()
|
||||
|
||||
-- AttackUnit = {
|
||||
-- id = 'AttackUnit',
|
||||
-- params = {
|
||||
-- unitId = Unit.ID,
|
||||
-- weaponType = number,
|
||||
-- expend = enum AI.Task.WeaponExpend
|
||||
-- attackQty = number,
|
||||
-- direction = Azimuth,
|
||||
-- attackQtyLimit = boolean,
|
||||
-- groupAttack = boolean,
|
||||
-- }
|
||||
-- }
|
||||
Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.OPEN_FIRE )
|
||||
Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.EVADE_FIRE )
|
||||
|
||||
Controller:pushTask( { id = 'AttackUnit',
|
||||
params = { unitId = AttackUnit:GetID(),
|
||||
expend = AI.Task.WeaponExpend.TWO,
|
||||
groupAttack = true,
|
||||
}
|
||||
}
|
||||
)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Holding weapons.
|
||||
-- @param self
|
||||
-- @return #GROUP self
|
||||
function GROUP:HoldFire()
|
||||
self:T( { self.GroupName } )
|
||||
|
||||
local Controller = self:_GetController()
|
||||
|
||||
Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPONS_HOLD )
|
||||
return self
|
||||
end
|
||||
|
||||
--- Return fire.
|
||||
-- @param self
|
||||
-- @return #GROUP self
|
||||
function GROUP:ReturnFire()
|
||||
self:T( { self.GroupName } )
|
||||
|
||||
local Controller = self:_GetController()
|
||||
|
||||
Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.RETURN_FIRE )
|
||||
return self
|
||||
end
|
||||
|
||||
--- Openfire.
|
||||
-- @param self
|
||||
-- @return #GROUP self
|
||||
function GROUP:OpenFire()
|
||||
self:T( { self.GroupName } )
|
||||
|
||||
local Controller = self:_GetController()
|
||||
|
||||
Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.OPEN_FIRE )
|
||||
return self
|
||||
end
|
||||
|
||||
--- Weapon free.
|
||||
-- @param self
|
||||
-- @return #GROUP self
|
||||
function GROUP:WeaponFree()
|
||||
self:T( { self.GroupName } )
|
||||
|
||||
local Controller = self:_GetController()
|
||||
|
||||
Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_FREE )
|
||||
return self
|
||||
end
|
||||
|
||||
--- No evasion on enemy threats.
|
||||
-- @param self
|
||||
-- @return #GROUP self
|
||||
function GROUP:EvasionNoReaction()
|
||||
self:T( { self.GroupName } )
|
||||
|
||||
local Controller = self:_GetController()
|
||||
|
||||
Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.NO_REACTION )
|
||||
return self
|
||||
end
|
||||
|
||||
--- Evasion passive defense.
|
||||
-- @param self
|
||||
-- @return #GROUP self
|
||||
function GROUP:EvasionPassiveDefense()
|
||||
self:T( { self.GroupName } )
|
||||
|
||||
local Controller = self:_GetController()
|
||||
|
||||
Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.PASSIVE_DEFENSE )
|
||||
return self
|
||||
end
|
||||
|
||||
--- Evade fire.
|
||||
-- @param self
|
||||
-- @return #GROUP self
|
||||
function GROUP:EvasionEvadeFire()
|
||||
self:T( { self.GroupName } )
|
||||
|
||||
local Controller = self:_GetController()
|
||||
|
||||
Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.EVADE_FIRE )
|
||||
return self
|
||||
end
|
||||
|
||||
--- Vertical manoeuvres.
|
||||
-- @param self
|
||||
-- @return #GROUP self
|
||||
function GROUP:EvasionVertical()
|
||||
self:T( { self.GroupName } )
|
||||
|
||||
local Controller = self:_GetController()
|
||||
|
||||
Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.BYPASS_AND_ESCAPE )
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Move the group to a Vec2 Point, wait for a defined duration and embark a group.
|
||||
-- @param self
|
||||
-- @param #Vec2 Point The point where to wait.
|
||||
|
||||
@@ -76,7 +76,13 @@ MENU_SUB_GROUP = {
|
||||
ClassName = "MENU_SUB_GROUP"
|
||||
}
|
||||
|
||||
function MENU_SUB_GROUP:New( GroupID, MenuText, ParentMenu )
|
||||
--- Creates a new menu item for a group
|
||||
-- @param self
|
||||
-- @param MenuGroup The group owning the menu.
|
||||
-- @param MenuText The text for the menu.
|
||||
-- @param ParentMenu The parent menu.
|
||||
-- @return #MENU_SUB_GROUP self
|
||||
function MENU_SUB_GROUP:New( MenuGroup, MenuText, ParentMenu )
|
||||
|
||||
-- Arrange meta tables
|
||||
local MenuParentPath = nil
|
||||
@@ -86,7 +92,10 @@ function MENU_SUB_GROUP:New( GroupID, MenuText, ParentMenu )
|
||||
|
||||
local self = BASE:Inherit( self, MENU:New( MenuText, MenuParentPath ) )
|
||||
|
||||
self.MenuPath = missionCommands.addSubMenuForGroup( GroupID, MenuText, MenuParentPath )
|
||||
self:T( { MenuGroup, MenuText, ParentMenu } )
|
||||
|
||||
self.MenuGroup = MenuGroup
|
||||
self.MenuPath = missionCommands.addSubMenuForGroup( self.MenuGroup:GetID(), MenuText, MenuParentPath )
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -96,7 +105,15 @@ MENU_COMMAND_GROUP = {
|
||||
ClassName = "MENU_COMMAND_GROUP"
|
||||
}
|
||||
|
||||
function MENU_COMMAND_GROUP:New( GroupID, MenuText, ParentMenu, CommandMenuFunction, CommandMenuArgument )
|
||||
--- Creates a new radio command item for a group
|
||||
-- @param self
|
||||
-- @param MenuGroup The group 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_COMMAND_GROUP self
|
||||
function MENU_COMMAND_GROUP:New( MenuGroup, MenuText, ParentMenu, CommandMenuFunction, CommandMenuArgument )
|
||||
|
||||
-- Arrange meta tables
|
||||
|
||||
@@ -106,9 +123,18 @@ function MENU_COMMAND_GROUP:New( GroupID, MenuText, ParentMenu, CommandMenuFunct
|
||||
end
|
||||
|
||||
local self = BASE:Inherit( self, MENU:New( MenuText, MenuParentPath ) )
|
||||
|
||||
self:T( { MenuGroup, MenuText, ParentMenu, CommandMenuFunction, CommandMenuArgument } )
|
||||
|
||||
self.MenuPath = missionCommands.addCommandForGroup( GroupID, MenuText, MenuParentPath, CommandMenuFunction, CommandMenuArgument )
|
||||
self.MenuGroup = MenuGroup
|
||||
self.MenuPath = missionCommands.addCommandForGroup( self.MenuGroup:GetID(), MenuText, MenuParentPath, CommandMenuFunction, CommandMenuArgument )
|
||||
self.CommandMenuFunction = CommandMenuFunction
|
||||
self.CommandMenuArgument = CommandMenuArgument
|
||||
return self
|
||||
end
|
||||
|
||||
function MENU_COMMAND_GROUP:Remove()
|
||||
|
||||
missionCommands.removeItemForGroup( self.MenuGroup:GetID(), self.MenuPath )
|
||||
return nil
|
||||
end
|
||||
|
||||
@@ -21,11 +21,12 @@ MESSAGE = {
|
||||
|
||||
|
||||
--- Creates a new MESSAGE object. Note that these MESSAGE objects are not yet displayed on the display panel. You must use the functions @{ToClient} or @{ToCoalition} or @{ToAll} to send these Messages to the respective recipients.
|
||||
-- @param string MessageText is the text of the Message.
|
||||
-- @param string MessageCategory is a string expressing the Category of the Message. Messages are grouped on the display panel per Category to improve readability.
|
||||
-- @param number MessageDuration is a number in seconds of how long the MESSAGE should be shown on the display panel.
|
||||
-- @param string MessageID is a string expressing the ID of the Message.
|
||||
-- @return MESSAGE
|
||||
-- @param self
|
||||
-- @param #string MessageText is the text of the Message.
|
||||
-- @param #string MessageCategory is a string expressing the Category of the Message. Messages are grouped on the display panel per Category to improve readability.
|
||||
-- @param #number MessageDuration is a number in seconds of how long the MESSAGE should be shown on the display panel.
|
||||
-- @param #string MessageID is a string expressing the ID of the Message.
|
||||
-- @return #MESSAGE
|
||||
-- @usage
|
||||
-- -- Create a series of new Messages.
|
||||
-- -- MessageAll is meant to be sent to all players, for 25 seconds, and is classified as "Score".
|
||||
|
||||
@@ -174,7 +174,7 @@ function MISSION:ReportToAll()
|
||||
|
||||
local AlivePlayers = ''
|
||||
for ClientID, Client in pairs( self._Clients ) do
|
||||
if Client:ClientGroup() then
|
||||
if Client:GetDCSGroup() then
|
||||
if Client:GetClientGroupDCSUnit() then
|
||||
if Client:GetClientGroupDCSUnit():getLife() > 0.0 then
|
||||
if AlivePlayers == '' then
|
||||
@@ -407,7 +407,7 @@ trace.scheduled("MISSIONSCHEDULER","Scheduler")
|
||||
|
||||
trace.i( "MISSIONSCHEDULER", "Client: " .. Client.ClientName )
|
||||
|
||||
if Client:ClientGroup() then
|
||||
if Client:GetDCSGroup() then
|
||||
|
||||
-- There is at least one Client that is alive... So the Mission status is set to Ongoing.
|
||||
ClientsAlive = true
|
||||
|
||||
Reference in New Issue
Block a user