Updates for mission mode.

This commit is contained in:
FlightControl 2019-05-27 17:10:19 +02:00
parent 6be56b1b86
commit d3ecbac40a
2 changed files with 65 additions and 33 deletions

View File

@ -274,7 +274,7 @@ function AI_ESCORT:onafterStart( EscortGroupSet )
--- @param Core.Group#GROUP EscortGroup --- @param Core.Group#GROUP EscortGroup
function( EscortGroup ) function( EscortGroup )
EscortGroup.EscortMenu = MENU_GROUP:New( self.PlayerGroup, EscortGroup:GetName(), self.MainMenu ) EscortGroup.EscortMenu = MENU_GROUP:New( self.PlayerGroup, EscortGroup:GetName(), self.MainMenu )
EscortGroup:WayPointInitialize( 1 ) EscortGroup:WayPointInitialize()
EscortGroup:OptionROTVertical() EscortGroup:OptionROTVertical()
EscortGroup:OptionROEOpenFire() EscortGroup:OptionROEOpenFire()
@ -361,7 +361,7 @@ function AI_ESCORT:Menus( XStart, XSpace, YStart, YSpace, ZStart, ZSpace, ZLevel
self:MenuROE() self:MenuROE()
self:MenuROT() self:MenuROT()
-- self:MenuResumeMission() self:MenuResumeMission()
return self return self
@ -1047,10 +1047,16 @@ end
function AI_ESCORT:MenuResumeMission() function AI_ESCORT:MenuResumeMission()
self:F() self:F()
if not self.EscortMenuResumeMission then self.EscortGroupSet:ForSomeGroupAlive(
-- Mission Resume Menu Root --- @param Core.Group#GROUP EscortGroup
self.EscortMenuResumeMission = MENU_GROUP:New( self.PlayerGroup, "Resume mission from", self.EscortMenu ) function( EscortGroup )
end if EscortGroup:IsAir() then
local EscortGroupName = EscortGroup:GetName()
local EscortMenu = MENU_GROUP:New( self.PlayerGroup, EscortGroupName, self.MainMenu )
EscortGroup.EscortMenuResumeMission = MENU_GROUP:New( self.PlayerGroup, "Resume from", EscortMenu )
end
end
)
return self return self
end end
@ -1324,10 +1330,12 @@ function AI_ESCORT:_ScanTargets( ScanDuration )
end end
--- @param #AI_ESCORT self --- @param Wrapper.Group#GROUP EscortGroup
-- @param Wrapper.Group#GROUP EscortGroup -- @param #AI_ESCORT self
function AI_ESCORT.___Resume( EscortGroup, self ) function AI_ESCORT.___Resume( EscortGroup, self )
self:F( { self=self } )
local PlayerGroup = self.PlayerGroup local PlayerGroup = self.PlayerGroup
self:JoinFormation( EscortGroup ) self:JoinFormation( EscortGroup )
@ -1336,6 +1344,26 @@ function AI_ESCORT.___Resume( EscortGroup, self )
end end
--- @param #AI_ESCORT self
-- @param Wrapper.Group#GROUP EscortGroup
-- @param #number WayPoint
function AI_ESCORT._ResumeMission( EscortGroup, WayPoint )
--self.FollowScheduler:Stop( self.FollowSchedule )
local WayPoints = EscortGroup:GetTaskRoute()
self:T( WayPoint, WayPoints )
for WayPointIgnore = 1, WayPoint do
table.remove( WayPoints, 1 )
end
EscortGroup:SetTask( EscortGroup:TaskRoute( WayPoints ), 1 )
EscortGroup:MessageTypeToClient( "Resuming mission from waypoint ", MESSAGE.Type.Information, self.PlayerGroup )
end
--- @param #AI_ESCORT self --- @param #AI_ESCORT self
-- @param Wrapper.Group#GROUP EscortGroup The escort group that will attack the detected item. -- @param Wrapper.Group#GROUP EscortGroup The escort group that will attack the detected item.
-- @param Functional.Detection#DETECTION_BASE.DetectedItem DetectedItem -- @param Functional.Detection#DETECTION_BASE.DetectedItem DetectedItem
@ -1481,26 +1509,6 @@ end
function AI_ESCORT:_ResumeMission( WayPoint )
local EscortGroup = self.EscortGroup
local EscortUnit = self.PlayerUnit
self.FollowScheduler:Stop( self.FollowSchedule )
local WayPoints = EscortGroup:GetTaskRoute()
self:T( WayPoint, WayPoints )
for WayPointIgnore = 1, WayPoint do
table.remove( WayPoints, 1 )
end
SCHEDULER:New( EscortGroup, EscortGroup.SetTask, { EscortGroup:TaskRoute( WayPoints ) }, 1 )
EscortGroup:MessageToClient( "Resuming mission from waypoint " .. WayPoint .. ".", 10, EscortUnit )
end
--- Registers the waypoints --- Registers the waypoints
-- @param #AI_ESCORT self -- @param #AI_ESCORT self
-- @return #table -- @return #table
@ -1580,6 +1588,20 @@ function AI_ESCORT:_ReportTargetsScheduler( EscortGroup )
EscortMenuAttackTargets:RemoveSubMenus( TimeUpdate, "Esort" ) EscortMenuAttackTargets:RemoveSubMenus( TimeUpdate, "Esort" )
if EscortGroup.EscortMenuResumeMission then
EscortGroup.EscortMenuResumeMission:RemoveSubMenus()
local TaskPoints = EscortGroup:GetTaskRoute()
for WayPointID, WayPoint in pairs( TaskPoints ) do
local EscortVec3 = EscortGroup:GetVec3()
local Distance = ( ( WayPoint.x - EscortVec3.x )^2 +
( WayPoint.y - EscortVec3.z )^2
) ^ 0.5 / 1000
MENU_GROUP_COMMAND:New( self.PlayerGroup, "Waypoint " .. WayPointID .. " at " .. string.format( "%.2f", Distance ).. "km", EscortGroup.EscortMenuResumeMission, AI_ESCORT._ResumeMission, self, EscortGroup, WayPointID )
end
end
return true return true
else else
end end

View File

@ -149,7 +149,7 @@
--- @type AI_ESCORT_REQUEST --- @type AI_ESCORT_REQUEST
-- @extends AI.AI_Formation#AI_FORMATION -- @extends AI.AI_Escort#AI_ESCORT
--- AI_ESCORT_REQUEST class --- AI_ESCORT_REQUEST class
-- --
@ -217,6 +217,7 @@ function AI_ESCORT_REQUEST:New( EscortUnit, EscortSpawn, EscortAirbase, EscortNa
self.Detection = DETECTION_AREAS:New( self.EscortGroupSet, 5000 ) self.Detection = DETECTION_AREAS:New( self.EscortGroupSet, 5000 )
self.Detection:__Start( 30 ) self.Detection:__Start( 30 )
self.SpawnMode = self.__Enum.Mode.Mission
return self return self
end end
@ -240,8 +241,10 @@ function AI_ESCORT_REQUEST:SpawnEscort()
Report:Add( "Joining Up " .. self.EscortGroupSet:GetUnitTypeNames():Text( ", " ) .. " from " .. LeaderEscort:GetCoordinate():ToString( self.EscortUnit ) ) Report:Add( "Joining Up " .. self.EscortGroupSet:GetUnitTypeNames():Text( ", " ) .. " from " .. LeaderEscort:GetCoordinate():ToString( self.EscortUnit ) )
LeaderEscort:MessageTypeToGroup( Report:Text(), MESSAGE.Type.Information, self.PlayerUnit ) LeaderEscort:MessageTypeToGroup( Report:Text(), MESSAGE.Type.Information, self.PlayerUnit )
self:FormationTrail( 50, 50, 50 ) if self.SpawnMode == self.__Enum.Mode.Formation then
self:JoinFormation( EscortGroup ) self:FormationTrail( 50, 50, 50 )
self:JoinFormation( EscortGroup )
end
self:Menus( self.XStart, self.XSpace, self.YStart, self.YSpace, self.ZStart, self.ZSpace, self.ZLevels ) self:Menus( self.XStart, self.XSpace, self.YStart, self.YSpace, self.ZStart, self.ZSpace, self.ZLevels )
end end
) )
@ -253,7 +256,7 @@ end
function AI_ESCORT_REQUEST:onafterStart( EscortGroupSet ) function AI_ESCORT_REQUEST:onafterStart( EscortGroupSet )
if not self.MenuRequestEscort then if not self.MenuRequestEscort then
self.MenuRequestEscort = MENU_GROUP_COMMAND:New( self.LeaderGroup, "Request A2G Escort", self.MainMenu, self.MenuRequestEscort = MENU_GROUP_COMMAND:New( self.LeaderGroup, "Request new escort ", self.MainMenu,
function() function()
self:SpawnEscort() self:SpawnEscort()
end end
@ -262,3 +265,10 @@ function AI_ESCORT_REQUEST:onafterStart( EscortGroupSet )
end end
--- Set the spawn mode to be mission execution.
-- @param #AI_ESCORT_REQUEST self
function AI_ESCORT_REQUEST:SetEscortSpawnMission()
self.SpawnMode = self.__Enum.Mode.Mission
end