mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Updates
This commit is contained in:
parent
9c523cad52
commit
1e0e67c13d
@ -270,36 +270,8 @@ function AI_ESCORT:New( EscortUnit, EscortGroupSet, EscortName, EscortBriefing )
|
||||
return self
|
||||
end
|
||||
|
||||
--- @param #AI_ESCORT self
|
||||
-- @param Core.Set#SET_GROUP EscortGroupSet
|
||||
function AI_ESCORT:onafterStart( EscortGroupSet )
|
||||
|
||||
EscortGroupSet:ForEachGroup(
|
||||
--- @param Core.Group#GROUP EscortGroup
|
||||
function( EscortGroup )
|
||||
EscortGroup:WayPointInitialize()
|
||||
|
||||
EscortGroup:OptionROTVertical()
|
||||
EscortGroup:OptionROEOpenFire()
|
||||
end
|
||||
)
|
||||
|
||||
local LeaderEscort = EscortGroupSet:GetFirst() -- Wrapper.Group#GROUP
|
||||
|
||||
local Report = REPORT:New( "Escort reporting:" )
|
||||
Report:Add( "Joining Up " .. EscortGroupSet:GetUnitTypeNames():Text( ", " ) .. " from " .. LeaderEscort:GetCoordinate():ToString( self.PlayerUnit ) )
|
||||
|
||||
LeaderEscort:MessageTypeToGroup( Report:Text(), MESSAGE.Type.Information, self.PlayerUnit )
|
||||
|
||||
self.Detection = DETECTION_AREAS:New( EscortGroupSet, 5000 )
|
||||
|
||||
self.Detection:__Start( 30 )
|
||||
|
||||
self:HandleEvent( EVENTS.Dead, OnEventDeadOrCrash )
|
||||
self:HandleEvent( EVENTS.Crash, OnEventDeadOrCrash )
|
||||
|
||||
self.MainMenu = MENU_GROUP:New( self.PlayerGroup, self.EscortName )
|
||||
self.FlightMenu = MENU_GROUP:New( self.PlayerGroup, "Flight", self.MainMenu )
|
||||
function AI_ESCORT:_InitFlightMenus()
|
||||
|
||||
self:SetFlightMenuJoinUp()
|
||||
self:SetFlightMenuFormation( "Trail" )
|
||||
@ -322,25 +294,77 @@ function AI_ESCORT:onafterStart( EscortGroupSet )
|
||||
|
||||
self:SetFlightMenuTargets()
|
||||
|
||||
end
|
||||
|
||||
function AI_ESCORT:_InitEscortMenus( EscortGroup )
|
||||
|
||||
EscortGroup.EscortMenu = MENU_GROUP:New( self.PlayerGroup, EscortGroup:GetCallsign(), self.MainMenu )
|
||||
|
||||
self:SetEscortMenuJoinUp( EscortGroup )
|
||||
self:SetEscortMenuResumeMission( EscortGroup )
|
||||
|
||||
self:SetEscortMenuHoldAtEscortPosition( EscortGroup )
|
||||
self:SetEscortMenuHoldAtLeaderPosition( EscortGroup )
|
||||
|
||||
self:SetEscortMenuFlare( EscortGroup )
|
||||
self:SetEscortMenuSmoke( EscortGroup )
|
||||
|
||||
self:SetEscortMenuROE( EscortGroup )
|
||||
self:SetEscortMenuROT( EscortGroup )
|
||||
|
||||
self:SetEscortMenuTargets( EscortGroup )
|
||||
|
||||
end
|
||||
|
||||
function AI_ESCORT:_InitEscortRoute( EscortGroup )
|
||||
|
||||
EscortGroup.MissionRoute = EscortGroup:GetTaskRoute()
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- @param #AI_ESCORT self
|
||||
-- @param Core.Set#SET_GROUP EscortGroupSet
|
||||
function AI_ESCORT:onafterStart( EscortGroupSet )
|
||||
|
||||
self:F()
|
||||
|
||||
EscortGroupSet:ForEachGroup(
|
||||
--- @param Core.Group#GROUP EscortGroup
|
||||
function( EscortGroup )
|
||||
EscortGroup:WayPointInitialize()
|
||||
|
||||
EscortGroup:OptionROTVertical()
|
||||
EscortGroup:OptionROEOpenFire()
|
||||
end
|
||||
)
|
||||
|
||||
-- TODO:Revise this...
|
||||
local LeaderEscort = EscortGroupSet:GetFirst() -- Wrapper.Group#GROUP
|
||||
if LeaderEscort then
|
||||
local Report = REPORT:New( "Escort reporting:" )
|
||||
Report:Add( "Joining Up " .. EscortGroupSet:GetUnitTypeNames():Text( ", " ) .. " from " .. LeaderEscort:GetCoordinate():ToString( self.PlayerUnit ) )
|
||||
LeaderEscort:MessageTypeToGroup( Report:Text(), MESSAGE.Type.Information, self.PlayerUnit )
|
||||
end
|
||||
|
||||
self.Detection = DETECTION_AREAS:New( EscortGroupSet, 5000 )
|
||||
|
||||
self.Detection:__Start( 30 )
|
||||
|
||||
self:HandleEvent( EVENTS.Dead, OnEventDeadOrCrash )
|
||||
self:HandleEvent( EVENTS.Crash, OnEventDeadOrCrash )
|
||||
|
||||
self.MainMenu = MENU_GROUP:New( self.PlayerGroup, self.EscortName )
|
||||
self.FlightMenu = MENU_GROUP:New( self.PlayerGroup, "Flight", self.MainMenu )
|
||||
|
||||
self:_InitFlightMenus()
|
||||
|
||||
self.EscortGroupSet:ForSomeGroupAlive(
|
||||
--- @param Core.Group#GROUP EscortGroup
|
||||
function( EscortGroup )
|
||||
|
||||
EscortGroup.EscortMenu = MENU_GROUP:New( self.PlayerGroup, EscortGroup:GetCallsign(), self.MainMenu )
|
||||
|
||||
self:SetEscortMenuJoinUp( EscortGroup )
|
||||
self:SetEscortMenuResumeMission( EscortGroup )
|
||||
|
||||
self:SetEscortMenuHoldAtEscortPosition( EscortGroup )
|
||||
self:SetEscortMenuHoldAtLeaderPosition( EscortGroup )
|
||||
|
||||
self:SetEscortMenuFlare( EscortGroup )
|
||||
self:SetEscortMenuSmoke( EscortGroup )
|
||||
|
||||
self:SetEscortMenuROE( EscortGroup )
|
||||
self:SetEscortMenuROT( EscortGroup )
|
||||
|
||||
self:SetEscortMenuTargets( EscortGroup )
|
||||
self:_InitEscortMenus( EscortGroup )
|
||||
self:_InitEscortRoute( EscortGroup )
|
||||
|
||||
end
|
||||
)
|
||||
@ -1086,6 +1110,7 @@ function AI_ESCORT:SetEscortMenuTargets( EscortGroup )
|
||||
local EscortMenuAttackTargets = MENU_GROUP:New( self.PlayerGroup, "Attack targets", EscortGroup.EscortMenu )
|
||||
|
||||
--EscortGroup.ReportTargetsScheduler = SCHEDULER:New( self, self._ReportTargetsScheduler, { EscortGroup }, 1, MenuTargets.Interval )
|
||||
EscortGroup.ResumeScheduler = SCHEDULER:New( self, self._ResumeScheduler, { EscortGroup }, 1, 60 )
|
||||
end
|
||||
end
|
||||
|
||||
@ -1561,8 +1586,10 @@ end
|
||||
function AI_ESCORT:_ResumeMission( EscortGroup, WayPoint )
|
||||
|
||||
--self.FollowScheduler:Stop( self.FollowSchedule )
|
||||
|
||||
self:ModeMission( EscortGroup )
|
||||
|
||||
local WayPoints = EscortGroup:GetTaskRoute()
|
||||
local WayPoints = EscortGroup.MissionRoute
|
||||
self:T( WayPoint, WayPoints )
|
||||
|
||||
for WayPointIgnore = 1, WayPoint do
|
||||
@ -1788,6 +1815,32 @@ function AI_ESCORT:RegisterRoute()
|
||||
return TaskPoints
|
||||
end
|
||||
|
||||
--- Resume Scheduler.
|
||||
-- @param #AI_ESCORT self
|
||||
-- @param Wrapper.Group#GROUP EscortGroup
|
||||
function AI_ESCORT:_ResumeScheduler( EscortGroup )
|
||||
self:F( EscortGroup:GetName() )
|
||||
|
||||
if EscortGroup:IsAlive() and self.PlayerUnit:IsAlive() then
|
||||
|
||||
|
||||
local EscortGroupName = EscortGroup:GetCallsign()
|
||||
|
||||
if EscortGroup.EscortMenuResumeMission then
|
||||
EscortGroup.EscortMenuResumeMission:RemoveSubMenus()
|
||||
|
||||
local TaskPoints = EscortGroup.MissionRoute
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- Report Targets Scheduler.
|
||||
@ -1861,20 +1914,6 @@ function AI_ESCORT:_ReportTargetsScheduler( EscortGroup )
|
||||
EscortGroup:MessageTypeToGroup( "No targets detected.", MESSAGE.Type.Information, self.PlayerGroup )
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
|
||||
@ -226,43 +226,27 @@ end
|
||||
function AI_ESCORT_REQUEST:SpawnEscort()
|
||||
|
||||
local EscortGroup = self.EscortSpawn:SpawnAtAirbase( self.EscortAirbase, SPAWN.Takeoff.Hot )
|
||||
self.EscortGroupSet:AddGroup( EscortGroup )
|
||||
|
||||
EscortGroup:OptionROTVertical()
|
||||
EscortGroup:OptionROEHoldFire()
|
||||
|
||||
self:ScheduleOnce( 0.1,
|
||||
function( EscortGroup )
|
||||
|
||||
self.EscortGroupSet:AddGroup( EscortGroup )
|
||||
|
||||
local LeaderEscort = self.EscortGroupSet:GetFirst() -- Wrapper.Group#GROUP
|
||||
|
||||
local Report = REPORT:New()
|
||||
|
||||
Report:Add( "Joining Up " .. self.EscortGroupSet:GetUnitTypeNames():Text( ", " ) .. " from " .. LeaderEscort:GetCoordinate():ToString( self.EscortUnit ) )
|
||||
LeaderEscort:MessageTypeToGroup( Report:Text(), MESSAGE.Type.Information, self.PlayerUnit )
|
||||
|
||||
self:FormationTrail( 50, 50, 50 )
|
||||
if self.SpawnMode == self.__Enum.Mode.Formation then
|
||||
self:ModeFormation( EscortGroup )
|
||||
end
|
||||
|
||||
--self:Menus( self.XStart, self.XSpace, self.YStart, self.YSpace, self.ZStart, self.ZSpace, self.ZLevels )
|
||||
|
||||
EscortGroup.EscortMenu = MENU_GROUP:New( self.PlayerGroup, EscortGroup:GetName(), self.MainMenu )
|
||||
|
||||
self:EscortMenuJoinUp( EscortGroup )
|
||||
|
||||
self:EscortMenuHoldAtEscortPosition( EscortGroup )
|
||||
self:EscortMenuHoldAtLeaderPosition( EscortGroup )
|
||||
|
||||
self:MenuFlare()
|
||||
self:MenuSmoke()
|
||||
|
||||
self:MenuReportTargets( 60 )
|
||||
self:MenuAssistedAttack()
|
||||
self:MenuROE()
|
||||
self:MenuROT()
|
||||
|
||||
self:MenuResumeMission()
|
||||
self:_InitFlightMenus()
|
||||
self:_InitEscortMenus( EscortGroup )
|
||||
self:_InitEscortRoute( EscortGroup )
|
||||
|
||||
--- @param #AI_ESCORT self
|
||||
-- @param Core.Event#EVENTDATA EventData
|
||||
@ -283,6 +267,8 @@ end
|
||||
-- @param Core.Set#SET_GROUP EscortGroupSet
|
||||
function AI_ESCORT_REQUEST:onafterStart( EscortGroupSet )
|
||||
|
||||
self:F()
|
||||
|
||||
if not self.MenuRequestEscort then
|
||||
self.MenuRequestEscort = MENU_GROUP_COMMAND:New( self.LeaderGroup, "Request new escort ", self.MainMenu,
|
||||
function()
|
||||
@ -291,6 +277,8 @@ function AI_ESCORT_REQUEST:onafterStart( EscortGroupSet )
|
||||
)
|
||||
end
|
||||
|
||||
self:GetParent( self ).onafterStart( self, EscortGroupSet )
|
||||
|
||||
self:HandleEvent( EVENTS.Dead, self.OnEventDeadOrCrash )
|
||||
self:HandleEvent( EVENTS.Crash, self.OnEventDeadOrCrash )
|
||||
|
||||
|
||||
@ -2839,6 +2839,19 @@ function SPAWN:_Prepare( SpawnTemplatePrefix, SpawnIndex ) --R2.2
|
||||
SpawnTemplate.units[UnitID].unitId = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- Callsign
|
||||
for UnitID = 1, #SpawnTemplate.units do
|
||||
local Callsign = SpawnTemplate.units[UnitID].callsign
|
||||
if Callsign[1] ~= nil then -- blue callsign
|
||||
Callsign[2] = ( ( SpawnIndex - 1 ) % 10 ) + 1
|
||||
local CallsignName = SpawnTemplate.units[UnitID].callsign["name"] -- #string
|
||||
local CallsignLen = CallsignName:len()
|
||||
SpawnTemplate.units[UnitID].callsign["name"] = CallsignName:sub(1,CallsignLen) .. SpawnTemplate.units[UnitID].callsign[2] .. SpawnTemplate.units[UnitID].callsign[3]
|
||||
else
|
||||
SpawnTemplate.units[UnitID].callsign = Callsign + SpawnIndex
|
||||
end
|
||||
end
|
||||
|
||||
self:T3( { "Template:", SpawnTemplate } )
|
||||
return SpawnTemplate
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user