mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Updated the Escort class
- Registering each excort at the client internally. - Each escort known at the client can exchange targets. - Each escort can acquire attack assistance from other escorts known at the client. - Made the MENU class more slick. Now menus are removed recursively for CLIENTS. - Added a few more types and fine tuned the documentation.
This commit is contained in:
390
Moose/Escort.lua
390
Moose/Escort.lua
@@ -67,6 +67,7 @@ Include.File( "Database" )
|
||||
Include.File( "Group" )
|
||||
Include.File( "Zone" )
|
||||
|
||||
|
||||
--- ESCORT class
|
||||
-- @type ESCORT
|
||||
-- @extends Base#BASE
|
||||
@@ -77,6 +78,7 @@ Include.File( "Zone" )
|
||||
-- @field #boolean ReportTargets If true, nearby targets are reported.
|
||||
-- @Field DCSTypes#AI.Option.Air.val.ROE OptionROE Which ROE is set to the EscortGroup.
|
||||
-- @field DCSTypes#AI.Option.Air.val.REACTION_ON_THREAT OptionReactionOnThreat Which REACTION_ON_THREAT is set to the EscortGroup.
|
||||
-- @field Menu#MENU_CLIENT EscortMenuResumeMission
|
||||
ESCORT = {
|
||||
ClassName = "ESCORT",
|
||||
EscortName = nil, -- The Escort Name
|
||||
@@ -97,7 +99,7 @@ ESCORT = {
|
||||
-- @field #string ParamMessage
|
||||
|
||||
--- ESCORT class constructor for an AI group
|
||||
-- @param self
|
||||
-- @param #ESCORT self
|
||||
-- @param Client#CLIENT EscortClient The client escorted by the EscortGroup.
|
||||
-- @param Group#GROUP EscortGroup The group AI escorting the EscortClient.
|
||||
-- @param #string EscortName Name of the escort.
|
||||
@@ -110,7 +112,21 @@ function ESCORT:New( EscortClient, EscortGroup, EscortName, EscortBriefing )
|
||||
self.EscortGroup = EscortGroup -- Group#GROUP
|
||||
self.EscortName = EscortName
|
||||
self.EscortBriefing = EscortBriefing
|
||||
|
||||
-- Set EscortGroup known at EscortClient.
|
||||
if not self.EscortClient._EscortGroups then
|
||||
self.EscortClient._EscortGroups = {}
|
||||
end
|
||||
|
||||
if not self.EscortClient._EscortGroups[EscortGroup:GetName()] then
|
||||
self.EscortClient._EscortGroups[EscortGroup:GetName()] = {}
|
||||
self.EscortClient._EscortGroups[EscortGroup:GetName()].EscortGroup = self.EscortGroup
|
||||
self.EscortClient._EscortGroups[EscortGroup:GetName()].EscortName = self.EscortName
|
||||
self.EscortClient._EscortGroups[EscortGroup:GetName()].Targets = {}
|
||||
|
||||
end
|
||||
|
||||
|
||||
self.EscortMenu = MENU_CLIENT:New( self.EscortClient, self.EscortName )
|
||||
|
||||
self.EscortMenuReportNavigation = MENU_CLIENT:New( self.EscortClient, "Navigation", self.EscortMenu )
|
||||
@@ -155,8 +171,6 @@ function ESCORT:New( EscortClient, EscortGroup, EscortName, EscortBriefing )
|
||||
|
||||
-- Attack Targets
|
||||
self.EscortMenuAttackNearbyTargets = MENU_CLIENT:New( self.EscortClient, "Attack nearby targets", self.EscortMenu )
|
||||
self.EscortMenuAttackTargets = {}
|
||||
self.Targets = {}
|
||||
|
||||
-- Rules of Engagement
|
||||
self.EscortMenuROE = MENU_CLIENT:New( self.EscortClient, "ROE", self.EscortMenu )
|
||||
@@ -188,13 +202,11 @@ function ESCORT:New( EscortClient, EscortGroup, EscortName, EscortBriefing )
|
||||
self.EscortMenuOptionEvasionVertical = MENU_CLIENT_COMMAND:New( self.EscortClient, "Go below radar and evade fire", self.EscortMenuEvasion, ESCORT._ROT, { ParamSelf = self, ParamFunction = EscortGroup:OptionROTVertical(), ParamMessage = "Evading on enemy fire with vertical manoeuvres!" } )
|
||||
end
|
||||
|
||||
-- Cancel current Task
|
||||
self.EscortMenuResumeMission = MENU_CLIENT:New( self.EscortClient, "Resume Mission", self.EscortMenu )
|
||||
self.EscortMenuResumeWayPoints = {}
|
||||
local TaskPoints = self:RegisterRoute()
|
||||
for WayPointID, WayPoint in pairs( TaskPoints ) do
|
||||
self.EscortMenuResumeWayPoints[WayPointID] = MENU_CLIENT_COMMAND:New( self.EscortClient, "Resume from waypoint " .. WayPointID, self.EscortMenuResumeMission, ESCORT._ResumeMission, { ParamSelf = self, ParamWayPoint = WayPointID } )
|
||||
end
|
||||
-- Mission Resume Menu Root
|
||||
self.EscortMenuResumeMission = MENU_CLIENT:New( self.EscortClient, "Resume the escort mission", self.EscortMenu )
|
||||
|
||||
-- Exchange targets with other escorts of the CLIENT. This is very useful to let f.e. an escorting ship attack a target detected by an escorting plane...
|
||||
self.EscortMenuTargetAssistance = MENU_CLIENT:New( self.EscortClient, "Target assistance from other escorts", self.EscortMenu )
|
||||
|
||||
-- Initialize the EscortGroup
|
||||
|
||||
@@ -207,9 +219,7 @@ function ESCORT:New( EscortClient, EscortGroup, EscortName, EscortBriefing )
|
||||
|
||||
EscortGroup:MessageToClient( EscortGroup:GetCategoryName() .. " '" .. EscortName .. "' (" .. EscortGroup:GetCallsign() .. ") reporting! " ..
|
||||
"We're escorting your flight. " ..
|
||||
"You can communicate with us through the radio menu. " ..
|
||||
"Use the Radio Menu and F10 and use the options under + " .. EscortName .. "\n" ..
|
||||
"We are continuing our way, but you can request to join-up your flight under the Navigation menu\n",
|
||||
"Use the Radio Menu and F10 and use the options under + " .. EscortName .. "\n",
|
||||
60, EscortClient
|
||||
)
|
||||
end
|
||||
@@ -351,16 +361,40 @@ function ESCORT._ScanTargets( MenuParam )
|
||||
|
||||
local ScanDuration = MenuParam.ParamScanDuration
|
||||
|
||||
routines.removeFunction( self.FollowScheduler )
|
||||
self.FollowScheduler = nil
|
||||
|
||||
EscortGroup:PushTask(
|
||||
EscortGroup:TaskControlled(
|
||||
EscortGroup:TaskOrbitCircle( 200, 20 ),
|
||||
EscortGroup:TaskCondition( nil, nil, nil, nil, ScanDuration, nil )
|
||||
)
|
||||
)
|
||||
if self.FollowScheduler then
|
||||
routines.removeFunction( self.FollowScheduler )
|
||||
end
|
||||
|
||||
self:T( { "FollowScheduler after removefunction: ", self.FollowScheduler } )
|
||||
|
||||
if EscortGroup:IsHelicopter() then
|
||||
routines.scheduleFunction( EscortGroup.PushTask,
|
||||
{ EscortGroup,
|
||||
EscortGroup:TaskControlled(
|
||||
EscortGroup:TaskOrbitCircle( 200, 20 ),
|
||||
EscortGroup:TaskCondition( nil, nil, nil, nil, ScanDuration, nil )
|
||||
)
|
||||
},
|
||||
timer.getTime() + 1
|
||||
)
|
||||
elseif EscortGroup:IsAirPlane() then
|
||||
routines.scheduleFunction( EscortGroup.PushTask,
|
||||
{ EscortGroup,
|
||||
EscortGroup:TaskControlled(
|
||||
EscortGroup:TaskOrbitCircle( 1000, 500 ),
|
||||
EscortGroup:TaskCondition( nil, nil, nil, nil, ScanDuration, nil )
|
||||
)
|
||||
},
|
||||
timer.getTime() + 1
|
||||
)
|
||||
end
|
||||
|
||||
EscortGroup:MessageToClient( "Scanning targets for " .. ScanDuration .. " seconds.", ScanDuration, EscortClient )
|
||||
|
||||
if self.FollowScheduler then
|
||||
self.FollowScheduler = routines.scheduleFunction( self._FollowScheduler, { self, Distance }, timer.getTime() + ScanDuration, 1 )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--- @param #MENUPARAM MenuParam
|
||||
@@ -369,18 +403,89 @@ function ESCORT._AttackTarget( MenuParam )
|
||||
local self = MenuParam.ParamSelf
|
||||
local EscortGroup = self.EscortGroup
|
||||
local EscortClient = self.EscortClient
|
||||
local AttackUnit = MenuParam.ParamUnit
|
||||
local AttackUnit = MenuParam.ParamUnit -- Unit#UNIT
|
||||
|
||||
routines.removeFunction( self.FollowScheduler )
|
||||
self.FollowScheduler = nil
|
||||
|
||||
EscortGroup:OptionROEOpenFire()
|
||||
EscortGroup:OptionROTVertical()
|
||||
if self.FollowScheduler then
|
||||
routines.removeFunction( self.FollowScheduler )
|
||||
end
|
||||
|
||||
self:T( AttackUnit )
|
||||
|
||||
EscortGroup:PushTask( EscortGroup:TaskAttackUnit( AttackUnit ) )
|
||||
if EscortGroup:IsAir() then
|
||||
EscortGroup:OptionROEOpenFire()
|
||||
EscortGroup:OptionROTVertical()
|
||||
routines.scheduleFunction(
|
||||
EscortGroup.PushTask,
|
||||
{ EscortGroup,
|
||||
EscortGroup:TaskCombo(
|
||||
{ EscortGroup:TaskAttackUnit( AttackUnit ),
|
||||
EscortGroup:TaskOrbitCircle( 500, 350 )
|
||||
}
|
||||
)
|
||||
}, timer.getTime() + 10
|
||||
)
|
||||
else
|
||||
routines.scheduleFunction(
|
||||
EscortGroup.PushTask,
|
||||
{ EscortGroup,
|
||||
EscortGroup:TaskCombo(
|
||||
{ EscortGroup:TaskFireAtPoint( AttackUnit:GetPointVec2(), 50 )
|
||||
}
|
||||
)
|
||||
}, timer.getTime() + 10
|
||||
)
|
||||
end
|
||||
EscortGroup:MessageToClient( "Engaging Designated Unit!", 10, EscortClient )
|
||||
|
||||
|
||||
if self.FollowScheduler then
|
||||
self.FollowScheduler = routines.scheduleFunction( self._FollowScheduler, { self, Distance }, timer.getTime() + ScanDuration, 1 )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--- @param #MENUPARAM MenuParam
|
||||
function ESCORT._AssistTarget( MenuParam )
|
||||
|
||||
local self = MenuParam.ParamSelf
|
||||
local EscortGroup = self.EscortGroup
|
||||
local EscortClient = self.EscortClient
|
||||
local EscortGroupAttack = MenuParam.ParamEscortGroup
|
||||
local AttackUnit = MenuParam.ParamUnit -- Unit#UNIT
|
||||
|
||||
if self.FollowScheduler then
|
||||
routines.removeFunction( self.FollowScheduler )
|
||||
end
|
||||
|
||||
|
||||
self:T( AttackUnit )
|
||||
|
||||
if EscortGroupAttack:IsAir() then
|
||||
EscortGroupAttack:OptionROEOpenFire()
|
||||
EscortGroupAttack:OptionROTVertical()
|
||||
routines.scheduleFunction(
|
||||
EscortGroupAttack.PushTask,
|
||||
{ EscortGroupAttack,
|
||||
EscortGroupAttack:TaskCombo(
|
||||
{ EscortGroupAttack:TaskAttackUnit( AttackUnit ),
|
||||
EscortGroupAttack:TaskOrbitCircle( 500, 350 )
|
||||
}
|
||||
)
|
||||
}, timer.getTime() + 10
|
||||
)
|
||||
else
|
||||
routines.scheduleFunction(
|
||||
EscortGroupAttack.PushTask,
|
||||
{ EscortGroupAttack,
|
||||
EscortGroupAttack:TaskCombo(
|
||||
{ EscortGroupAttack:TaskFireAtPoint( AttackUnit:GetPointVec2(), 50 )
|
||||
}
|
||||
)
|
||||
}, timer.getTime() + 10
|
||||
)
|
||||
end
|
||||
EscortGroupAttack:MessageToClient( "Assisting with the destroying the enemy unit!", 10, EscortClient )
|
||||
|
||||
end
|
||||
|
||||
--- @param #MENUPARAM MenuParam
|
||||
@@ -430,11 +535,15 @@ function ESCORT._ResumeMission( MenuParam )
|
||||
table.remove( WayPoints, 1 )
|
||||
end
|
||||
|
||||
EscortGroup:SetTask( EscortGroup:TaskRoute( WayPoints ) )
|
||||
routines.scheduleFunction( EscortGroup.SetTask, {EscortGroup, EscortGroup:TaskRoute( WayPoints ) }, timer.getTime() + 1 )
|
||||
|
||||
EscortGroup:MessageToClient( "Resuming mission from waypoint " .. WayPoint .. ".", 10, EscortClient )
|
||||
end
|
||||
|
||||
--- Registers the waypoints
|
||||
-- @param #ESCORT self
|
||||
function ESCORT:RegisterRoute()
|
||||
self:F()
|
||||
|
||||
local EscortGroup = self.EscortGroup -- Group#GROUP
|
||||
|
||||
@@ -442,9 +551,11 @@ function ESCORT:RegisterRoute()
|
||||
self:T( TaskPoints )
|
||||
|
||||
for TaskPointID, TaskPoint in pairs( TaskPoints ) do
|
||||
self:T( TaskPointID )
|
||||
TaskPoint.task.params.tasks[#TaskPoint.task.params.tasks+1] = EscortGroup:TaskRegisterWayPoint( TaskPointID )
|
||||
self:T( TaskPoint.task.params.tasks[#TaskPoint.task.params.tasks] )
|
||||
self:T( { "TaskPoint:", TaskPointID, #TaskPoint.task.params.tasks+1, TaskPoint } )
|
||||
if TaskPointID > 1 then
|
||||
TaskPoint.task.params.tasks[#TaskPoint.task.params.tasks+1] = EscortGroup:TaskRegisterWayPoint( TaskPointID )
|
||||
end
|
||||
self:T( TaskPoint )
|
||||
end
|
||||
|
||||
self:T( TaskPoints )
|
||||
@@ -530,7 +641,7 @@ function ESCORT:_FollowScheduler( FollowDistance )
|
||||
|
||||
-- The calculation of the Speed would simulate that the group would take 30 seconds to overcome
|
||||
-- the requested Distance).
|
||||
local Time = 30
|
||||
local Time = 10
|
||||
local CatchUpSpeed = ( CatchUpDistance - ( CS * 2 ) ) / Time
|
||||
|
||||
local Speed = CS + CatchUpSpeed
|
||||
@@ -555,110 +666,165 @@ end
|
||||
function ESCORT:_ReportTargetsScheduler()
|
||||
self:F()
|
||||
|
||||
self.Targets = {}
|
||||
|
||||
if self.EscortGroup:IsAlive() then
|
||||
local EscortGroupName = self.EscortGroup:GetName()
|
||||
local EscortTargets = self.EscortGroup:GetDetectedTargets()
|
||||
|
||||
local ClientEscortTargets = self.EscortClient._EscortGroups[EscortGroupName].Targets
|
||||
|
||||
local EscortTargetMessages = ""
|
||||
for EscortTargetID, EscortTarget in pairs( EscortTargets ) do
|
||||
local EscortObject = EscortTarget.object
|
||||
self:T( EscortObject )
|
||||
if EscortObject and EscortObject:isExist() and EscortObject.id_ < 50000000 then
|
||||
|
||||
local EscortTargetMessage = ""
|
||||
|
||||
local EscortTargetUnit = UNIT:New( EscortObject )
|
||||
|
||||
local EscortTargetCategoryName = EscortTargetUnit:GetCategoryName()
|
||||
local EscortTargetCategoryType = EscortTargetUnit:GetTypeName()
|
||||
local EscortTargetUnitName = EscortTargetUnit:GetName()
|
||||
|
||||
|
||||
-- local EscortTargetIsDetected,
|
||||
-- EscortTargetIsVisible,
|
||||
-- EscortTargetLastTime,
|
||||
-- EscortTargetKnowType,
|
||||
-- EscortTargetKnowDistance,
|
||||
-- EscortTargetLastPos,
|
||||
-- EscortTargetLastVelocity
|
||||
-- = self.EscortGroup:IsTargetDetected( EscortObject )
|
||||
--
|
||||
-- self:T( { EscortTargetIsDetected,
|
||||
-- EscortTargetIsVisible,
|
||||
-- EscortTargetLastTime,
|
||||
-- EscortTargetKnowType,
|
||||
-- EscortTargetKnowDistance,
|
||||
-- EscortTargetLastPos,
|
||||
-- EscortTargetLastVelocity } )
|
||||
|
||||
if EscortTarget.distance then
|
||||
local EscortTargetUnitPositionVec3 = EscortTargetUnit:GetPositionVec3()
|
||||
local EscortPositionVec3 = self.EscortGroup:GetPositionVec3()
|
||||
local Distance = routines.utils.get3DDist( EscortTargetUnitPositionVec3, EscortPositionVec3 ) / 1000
|
||||
self:T( { self.EscortGroup:GetName(), EscortTargetUnit:GetName(), Distance, EscortTarget.visible } )
|
||||
-- local EscortTargetIsDetected,
|
||||
-- EscortTargetIsVisible,
|
||||
-- EscortTargetLastTime,
|
||||
-- EscortTargetKnowType,
|
||||
-- EscortTargetKnowDistance,
|
||||
-- EscortTargetLastPos,
|
||||
-- EscortTargetLastVelocity
|
||||
-- = self.EscortGroup:IsTargetDetected( EscortObject )
|
||||
--
|
||||
-- self:T( { EscortTargetIsDetected,
|
||||
-- EscortTargetIsVisible,
|
||||
-- EscortTargetLastTime,
|
||||
-- EscortTargetKnowType,
|
||||
-- EscortTargetKnowDistance,
|
||||
-- EscortTargetLastPos,
|
||||
-- EscortTargetLastVelocity } )
|
||||
|
||||
|
||||
if Distance <= 8 then
|
||||
local EscortTargetUnitPositionVec3 = EscortTargetUnit:GetPositionVec3()
|
||||
local EscortPositionVec3 = self.EscortGroup:GetPositionVec3()
|
||||
local Distance = ( ( EscortTargetUnitPositionVec3.x - EscortPositionVec3.x )^2 +
|
||||
( EscortTargetUnitPositionVec3.y - EscortPositionVec3.y )^2 +
|
||||
( EscortTargetUnitPositionVec3.z - EscortPositionVec3.z )^2
|
||||
) ^ 0.5 / 1000
|
||||
|
||||
if EscortTarget.type then
|
||||
EscortTargetMessage = EscortTargetMessage .. " - " .. EscortTargetCategoryName .. " (" .. EscortTargetCategoryType .. ") at "
|
||||
else
|
||||
EscortTargetMessage = EscortTargetMessage .. " - Unknown target at "
|
||||
end
|
||||
self:T( { self.EscortGroup:GetName(), EscortTargetUnit:GetName(), Distance, EscortTarget } )
|
||||
|
||||
EscortTargetMessage = EscortTargetMessage .. string.format( "%.2f", Distance ) .. " km"
|
||||
if Distance <= 15 then
|
||||
|
||||
if EscortTarget.visible then
|
||||
EscortTargetMessage = EscortTargetMessage .. ", visual"
|
||||
end
|
||||
if not ClientEscortTargets[EscortTargetUnitName] then
|
||||
ClientEscortTargets[EscortTargetUnitName] = {}
|
||||
end
|
||||
ClientEscortTargets[EscortTargetUnitName].AttackUnit = EscortTargetUnit
|
||||
ClientEscortTargets[EscortTargetUnitName].visible = EscortTarget.visible
|
||||
ClientEscortTargets[EscortTargetUnitName].type = EscortTarget.type
|
||||
ClientEscortTargets[EscortTargetUnitName].distance = EscortTarget.distance
|
||||
|
||||
local TargetIndex = Distance*1000
|
||||
self.Targets[TargetIndex] = {}
|
||||
self.Targets[TargetIndex].AttackMessage = EscortTargetMessage
|
||||
self.Targets[TargetIndex].AttackUnit = EscortTargetUnit
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self:T( { "Sorting Targets Table:", ClientEscortTargets } )
|
||||
table.sort( ClientEscortTargets, function( a, b ) return a.Distance < b.Distance end )
|
||||
self:T( { "Sorted Targets Table:", ClientEscortTargets } )
|
||||
|
||||
-- Remove the sub menus of the Attack menu of the Escort for the EscortGroup.
|
||||
self.EscortMenuAttackNearbyTargets:RemoveSubMenus()
|
||||
self.EscortMenuTargetAssistance:RemoveSubMenus()
|
||||
|
||||
--for MenuIndex = 1, #self.EscortMenuAttackTargets do
|
||||
-- self:T( { "Remove Menu:", self.EscortMenuAttackTargets[MenuIndex] } )
|
||||
-- self.EscortMenuAttackTargets[MenuIndex] = self.EscortMenuAttackTargets[MenuIndex]:Remove()
|
||||
--end
|
||||
|
||||
|
||||
if ClientEscortTargets then
|
||||
for ClientEscortTargetUnitName, ClientEscortTargetData in pairs( ClientEscortTargets ) do
|
||||
|
||||
for ClientEscortGroupName, EscortGroupData in pairs( self.EscortClient._EscortGroups ) do
|
||||
|
||||
if ClientEscortTargetData and ClientEscortTargetData.AttackUnit:IsAlive() then
|
||||
|
||||
local EscortTargetMessage = ""
|
||||
local EscortTargetCategoryName = ClientEscortTargetData.AttackUnit:GetCategoryName()
|
||||
local EscortTargetCategoryType = ClientEscortTargetData.AttackUnit:GetTypeName()
|
||||
if ClientEscortTargetData.type then
|
||||
EscortTargetMessage = EscortTargetMessage .. EscortTargetCategoryName .. " (" .. EscortTargetCategoryType .. ") at "
|
||||
else
|
||||
EscortTargetMessage = EscortTargetMessage .. "Unknown target at "
|
||||
end
|
||||
end
|
||||
|
||||
local EscortTargetUnitPositionVec3 = ClientEscortTargetData.AttackUnit:GetPositionVec3()
|
||||
local EscortPositionVec3 = self.EscortGroup:GetPositionVec3()
|
||||
local Distance = ( ( EscortTargetUnitPositionVec3.x - EscortPositionVec3.x )^2 +
|
||||
( EscortTargetUnitPositionVec3.y - EscortPositionVec3.y )^2 +
|
||||
( EscortTargetUnitPositionVec3.z - EscortPositionVec3.z )^2
|
||||
) ^ 0.5 / 1000
|
||||
|
||||
if EscortTargetMessage ~= "" then
|
||||
EscortTargetMessages = EscortTargetMessages .. EscortTargetMessage .. "\n"
|
||||
self:T( { self.EscortGroup:GetName(), ClientEscortTargetData.AttackUnit:GetName(), Distance, ClientEscortTargetData.AttackUnit } )
|
||||
if ClientEscortTargetData.visible == false then
|
||||
EscortTargetMessage = EscortTargetMessage .. string.format( "%.2f", Distance ) .. " estimated km"
|
||||
else
|
||||
EscortTargetMessage = EscortTargetMessage .. string.format( "%.2f", Distance ) .. " km"
|
||||
end
|
||||
|
||||
if ClientEscortTargetData.visible then
|
||||
EscortTargetMessage = EscortTargetMessage .. ", visual"
|
||||
end
|
||||
|
||||
if ClientEscortGroupName == EscortGroupName then
|
||||
|
||||
MENU_CLIENT_COMMAND:New( self.EscortClient,
|
||||
EscortTargetMessage,
|
||||
self.EscortMenuAttackNearbyTargets,
|
||||
ESCORT._AttackTarget,
|
||||
{ ParamSelf = self,
|
||||
ParamUnit = ClientEscortTargetData.AttackUnit
|
||||
}
|
||||
)
|
||||
EscortTargetMessages = EscortTargetMessages .. "\n - " .. EscortTargetMessage
|
||||
else
|
||||
local MenuTargetAssistance = MENU_CLIENT:New( self.EscortClient, EscortGroupData.EscortName, self.EscortMenuTargetAssistance )
|
||||
MENU_CLIENT_COMMAND:New( self.EscortClient,
|
||||
EscortTargetMessage,
|
||||
MenuTargetAssistance,
|
||||
ESCORT._AssistTarget,
|
||||
{ ParamSelf = self,
|
||||
ParamEscortGroup = EscortGroupData.EscortGroup,
|
||||
ParamUnit = ClientEscortTargetData.AttackUnit
|
||||
}
|
||||
)
|
||||
end
|
||||
else
|
||||
ClientEscortTargetData = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if EscortTargetMessages ~= "" and self.ReportTargets == true then
|
||||
self.EscortGroup:MessageToClient( "Detected targets within 15 km range:" .. EscortTargetMessages:gsub("\n$",""), 20, self.EscortClient )
|
||||
else
|
||||
self.EscortGroup:MessageToClient( "No targets detected!", 20, self.EscortClient )
|
||||
end
|
||||
end
|
||||
|
||||
if EscortTargetMessages ~= "" and self.ReportTargets == true then
|
||||
self.EscortGroup:MessageToClient( EscortTargetMessages:gsub("\n$",""), 20, self.EscortClient )
|
||||
else
|
||||
self.EscortGroup:MessageToClient( "No targets detected!", 20, self.EscortClient )
|
||||
end
|
||||
|
||||
self:T()
|
||||
|
||||
self:T( { "Sorting Targets Table:", self.Targets } )
|
||||
table.sort( self.Targets )
|
||||
self:T( { "Sorted Targets Table:", self.Targets } )
|
||||
self.EscortMenuResumeMission:RemoveSubMenus()
|
||||
|
||||
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_CLIENT_COMMAND:New( self.EscortClient,
|
||||
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
|
||||
-- if self.EscortMenuResumeWayPoints then
|
||||
-- for MenuIndex = 1, #self.EscortMenuResumeWayPoints do
|
||||
-- self:T( { "Remove Menu:", self.EscortMenuResumeWayPoints[MenuIndex] } )
|
||||
-- self.EscortMenuResumeWayPoints[MenuIndex] = self.EscortMenuResumeWayPoints[MenuIndex]:Remove()
|
||||
-- end
|
||||
-- end
|
||||
|
||||
local TaskPoints = self:RegisterRoute()
|
||||
for WayPointID, WayPoint in pairs( TaskPoints ) do
|
||||
local EscortPositionVec3 = self.EscortGroup:GetPositionVec3()
|
||||
local Distance = ( ( WayPoint.x - EscortPositionVec3.x )^2 +
|
||||
( WayPoint.y - EscortPositionVec3.z )^2
|
||||
) ^ 0.5 / 1000
|
||||
MENU_CLIENT_COMMAND:New( self.EscortClient, "Waypoint " .. WayPointID .. " at " .. string.format( "%.2f", Distance ).. "km", self.EscortMenuResumeMission, ESCORT._ResumeMission, { ParamSelf = self, ParamWayPoint = WayPointID } )
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user