mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Updates escort before plane trip.
This commit is contained in:
parent
d985d9a41d
commit
b21ff707ba
@ -286,6 +286,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 )
|
||||
|
||||
self:E("Start")
|
||||
@ -300,6 +302,15 @@ function AI_ESCORT:onafterStart( EscortGroupSet )
|
||||
EscortGroup:OptionROEOpenFire()
|
||||
end
|
||||
)
|
||||
|
||||
local LeaderEscort = EscortGroupSet:GetFirst() -- Wrapper.Group#GROUP
|
||||
|
||||
local Report = REPORT:New( "Escorts Reporting." )
|
||||
Report:Add( "Current coordinate: " .. LeaderEscort:GetCoordinate():ToString( self.EscortUnit ) )
|
||||
Report:Add( "Configuration: " .. EscortGroupSet:GetUnitTypeNames():Text( ", " ) )
|
||||
Report:Add( "Joining Up ..." )
|
||||
|
||||
LeaderEscort:MessageTypeToGroup( Report:Text(), MESSAGE.Type.Information, self.EscortUnit )
|
||||
|
||||
end
|
||||
|
||||
|
||||
@ -740,7 +740,7 @@ end
|
||||
-- @return #AI_FORMATION
|
||||
function AI_FORMATION:onafterFormationLeftLine( FollowGroupSet, From , Event , To, XStart, YStart, ZStart, ZSpace ) --R2.1
|
||||
|
||||
self:onafterFormationLine(FollowGroupSet,From,Event,To,XStart,0,YStart,0,ZStart,ZSpace)
|
||||
self:onafterFormationLine(FollowGroupSet,From,Event,To,XStart,0,YStart,0,-ZStart,-ZSpace)
|
||||
|
||||
return self
|
||||
end
|
||||
@ -759,7 +759,7 @@ end
|
||||
-- @return #AI_FORMATION
|
||||
function AI_FORMATION:onafterFormationRightLine( FollowGroupSet, From , Event , To, XStart, YStart, ZStart, ZSpace ) --R2.1
|
||||
|
||||
self:onafterFormationLine(FollowGroupSet,From,Event,To,XStart,0,YStart,0,-ZStart,-ZSpace)
|
||||
self:onafterFormationLine(FollowGroupSet,From,Event,To,XStart,0,YStart,0,ZStart,ZSpace)
|
||||
|
||||
return self
|
||||
end
|
||||
@ -778,7 +778,7 @@ end
|
||||
-- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group.
|
||||
function AI_FORMATION:onafterFormationLeftWing( FollowGroupSet, From , Event , To, XStart, XSpace, YStart, ZStart, ZSpace ) --R2.1
|
||||
|
||||
self:onafterFormationLine(FollowGroupSet,From,Event,To,XStart,XSpace,YStart,0,ZStart,ZSpace)
|
||||
self:onafterFormationLine(FollowGroupSet,From,Event,To,XStart,XSpace,YStart,0,-ZStart,-ZSpace)
|
||||
|
||||
return self
|
||||
end
|
||||
@ -798,7 +798,7 @@ end
|
||||
-- @param #number ZSpace The space between groups on the Z-axis in meters for each sequent group.
|
||||
function AI_FORMATION:onafterFormationRightWing( FollowGroupSet, From , Event , To, XStart, XSpace, YStart, ZStart, ZSpace ) --R2.1
|
||||
|
||||
self:onafterFormationLine(FollowGroupSet,From,Event,To,XStart,XSpace,YStart,0,-ZStart,-ZSpace)
|
||||
self:onafterFormationLine(FollowGroupSet,From,Event,To,XStart,XSpace,YStart,0,ZStart,ZSpace)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -2050,7 +2050,7 @@ do -- COORDINATE
|
||||
-- * Uses default settings in COORDINATE.
|
||||
-- * Can be overridden if for a GROUP containing x clients, a menu was selected to override the default.
|
||||
-- @param #COORDINATE self
|
||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable
|
||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The controllable to retrieve the settings from, otherwise the default settings will be chosen.
|
||||
-- @param Core.Settings#SETTINGS Settings (optional) The settings. Can be nil, and in this case the default settings are used. If you want to specify your own settings, use the _SETTINGS object.
|
||||
-- @param Tasking.Task#TASK Task The task for which coordinates need to be calculated.
|
||||
-- @return #string The coordinate Text in the configured coordinate system.
|
||||
|
||||
@ -924,7 +924,40 @@ do -- SET_GROUP
|
||||
|
||||
return AliveSet.Set or {}
|
||||
end
|
||||
|
||||
--- Returns a report of of unit types.
|
||||
-- @param #SET_GROUP self
|
||||
-- @return Core.Report#REPORT A report of the unit types found. The key is the UnitTypeName and the value is the amount of unit types found.
|
||||
function SET_GROUP:GetUnitTypeNames()
|
||||
self:F2()
|
||||
|
||||
local MT = {} -- Message Text
|
||||
local UnitTypes = {}
|
||||
|
||||
local ReportUnitTypes = REPORT:New()
|
||||
|
||||
for GroupID, GroupData in pairs( self:GetSet() ) do
|
||||
local Units = GroupData:GetUnits()
|
||||
for UnitID, UnitData in pairs( Units ) do
|
||||
if UnitData:IsAlive() then
|
||||
local UnitType = UnitData:GetTypeName()
|
||||
|
||||
if not UnitTypes[UnitType] then
|
||||
UnitTypes[UnitType] = 1
|
||||
else
|
||||
UnitTypes[UnitType] = UnitTypes[UnitType] + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for UnitTypeID, UnitType in pairs( UnitTypes ) do
|
||||
ReportUnitTypes:Add( UnitType .. " of " .. UnitTypeID )
|
||||
end
|
||||
|
||||
return ReportUnitTypes
|
||||
end
|
||||
|
||||
--- Add a GROUP to SET_GROUP.
|
||||
-- Note that for each unit in the group that is set, a default cargo bay limit is initialized.
|
||||
-- @param Core.Set#SET_GROUP self
|
||||
|
||||
@ -1156,6 +1156,18 @@ function SPAWN:ReSpawn( SpawnIndex )
|
||||
return SpawnGroup
|
||||
end
|
||||
|
||||
|
||||
--- Set the spawn index to a specified index number.
|
||||
-- This method can be used to "reset" the spawn counter to a specific index number.
|
||||
-- This will actually enable a respawn of groups from the specific index.
|
||||
-- @param #SPAWN self
|
||||
-- @param #string SpawnIndex The index of the group from where the spawning will start again. The default value would be 0, which means a complete reset of the spawnindex.
|
||||
-- @return #SPAWN self
|
||||
function SPAWN:SetSpawnIndex( SpawnIndex )
|
||||
self.SpawnIndex = SpawnIndex or 0
|
||||
end
|
||||
|
||||
|
||||
--- Will spawn a group with a specified index number.
|
||||
-- Uses @{DATABASE} global object defined in MOOSE.
|
||||
-- @param #SPAWN self
|
||||
@ -1465,6 +1477,11 @@ function SPAWN:SpawnAtAirbase( SpawnAirbase, Takeoff, TakeoffAltitude, TerminalT
|
||||
local SpawnTemplate = self.SpawnGroups[self.SpawnIndex].SpawnTemplate
|
||||
|
||||
if SpawnTemplate then
|
||||
|
||||
-- Check if the aircraft with the specified SpawnIndex is already spawned.
|
||||
-- If yes, ensure that the aircraft is spawned at the same aircraft spot.
|
||||
|
||||
local GroupAlive = self:GetGroupFromIndex( self.SpawnIndex )
|
||||
|
||||
-- Debug output
|
||||
self:T( { "Current point of ", self.SpawnTemplatePrefix, SpawnAirbase } )
|
||||
@ -1535,7 +1552,8 @@ function SPAWN:SpawnAtAirbase( SpawnAirbase, Takeoff, TakeoffAltitude, TerminalT
|
||||
local spots
|
||||
|
||||
-- Spawn happens on ground, i.e. at an airbase, a FARP or a ship.
|
||||
if spawnonground then
|
||||
if spawnonground and not SpawnTemplate.parked then
|
||||
|
||||
|
||||
-- Number of free parking spots.
|
||||
local nfree=0
|
||||
@ -1708,67 +1726,72 @@ function SPAWN:SpawnAtAirbase( SpawnAirbase, Takeoff, TakeoffAltitude, TerminalT
|
||||
|
||||
end
|
||||
|
||||
-- Translate the position of the Group Template to the Vec3.
|
||||
for UnitID = 1, nunits do
|
||||
self:T2('Before Translation SpawnTemplate.units['..UnitID..'].x = '..SpawnTemplate.units[UnitID].x..', SpawnTemplate.units['..UnitID..'].y = '..SpawnTemplate.units[UnitID].y)
|
||||
|
||||
-- Template of the current unit.
|
||||
local UnitTemplate = SpawnTemplate.units[UnitID]
|
||||
|
||||
-- Tranlate position and preserve the relative position/formation of all aircraft.
|
||||
local SX = UnitTemplate.x
|
||||
local SY = UnitTemplate.y
|
||||
local BX = SpawnTemplate.route.points[1].x
|
||||
local BY = SpawnTemplate.route.points[1].y
|
||||
local TX = PointVec3.x + (SX-BX)
|
||||
local TY = PointVec3.z + (SY-BY)
|
||||
|
||||
if spawnonground then
|
||||
|
||||
-- Ships and FARPS seem to have a build in queue.
|
||||
if spawnonship or spawnonfarp or spawnonrunway then
|
||||
|
||||
self:T(string.format("Group %s spawning at farp, ship or runway %s.", self.SpawnTemplatePrefix, SpawnAirbase:GetName()))
|
||||
if not SpawnTemplate.parked then
|
||||
-- Translate the position of the Group Template to the Vec3.
|
||||
|
||||
-- Spawn on ship. We take only the position of the ship.
|
||||
SpawnTemplate.units[UnitID].x = PointVec3.x --TX
|
||||
SpawnTemplate.units[UnitID].y = PointVec3.z --TY
|
||||
SpawnTemplate.units[UnitID].alt = PointVec3.y
|
||||
|
||||
else
|
||||
SpawnTemplate.parked = true
|
||||
|
||||
self:T(string.format("Group %s spawning at airbase %s on parking spot id %d", self.SpawnTemplatePrefix, SpawnAirbase:GetName(), parkingindex[UnitID]))
|
||||
|
||||
-- Get coordinates of parking spot.
|
||||
SpawnTemplate.units[UnitID].x = parkingspots[UnitID].x
|
||||
SpawnTemplate.units[UnitID].y = parkingspots[UnitID].z
|
||||
SpawnTemplate.units[UnitID].alt = parkingspots[UnitID].y
|
||||
|
||||
--parkingspots[UnitID]:MarkToAll(string.format("Group %s spawning at airbase %s on parking spot id %d", self.SpawnTemplatePrefix, SpawnAirbase:GetName(), parkingindex[UnitID]))
|
||||
end
|
||||
for UnitID = 1, nunits do
|
||||
self:T2('Before Translation SpawnTemplate.units['..UnitID..'].x = '..SpawnTemplate.units[UnitID].x..', SpawnTemplate.units['..UnitID..'].y = '..SpawnTemplate.units[UnitID].y)
|
||||
|
||||
-- Template of the current unit.
|
||||
local UnitTemplate = SpawnTemplate.units[UnitID]
|
||||
|
||||
-- Tranlate position and preserve the relative position/formation of all aircraft.
|
||||
local SX = UnitTemplate.x
|
||||
local SY = UnitTemplate.y
|
||||
local BX = SpawnTemplate.route.points[1].x
|
||||
local BY = SpawnTemplate.route.points[1].y
|
||||
local TX = PointVec3.x + (SX-BX)
|
||||
local TY = PointVec3.z + (SY-BY)
|
||||
|
||||
else
|
||||
|
||||
self:T(string.format("Group %s spawning in air at %s.", self.SpawnTemplatePrefix, SpawnAirbase:GetName()))
|
||||
if spawnonground then
|
||||
|
||||
-- Ships and FARPS seem to have a build in queue.
|
||||
if spawnonship or spawnonfarp or spawnonrunway then
|
||||
|
||||
self:T(string.format("Group %s spawning at farp, ship or runway %s.", self.SpawnTemplatePrefix, SpawnAirbase:GetName()))
|
||||
|
||||
-- Spawn on ship. We take only the position of the ship.
|
||||
SpawnTemplate.units[UnitID].x = PointVec3.x --TX
|
||||
SpawnTemplate.units[UnitID].y = PointVec3.z --TY
|
||||
SpawnTemplate.units[UnitID].alt = PointVec3.y
|
||||
|
||||
else
|
||||
|
||||
self:T(string.format("Group %s spawning at airbase %s on parking spot id %d", self.SpawnTemplatePrefix, SpawnAirbase:GetName(), parkingindex[UnitID]))
|
||||
|
||||
-- Get coordinates of parking spot.
|
||||
SpawnTemplate.units[UnitID].x = parkingspots[UnitID].x
|
||||
SpawnTemplate.units[UnitID].y = parkingspots[UnitID].z
|
||||
SpawnTemplate.units[UnitID].alt = parkingspots[UnitID].y
|
||||
|
||||
--parkingspots[UnitID]:MarkToAll(string.format("Group %s spawning at airbase %s on parking spot id %d", self.SpawnTemplatePrefix, SpawnAirbase:GetName(), parkingindex[UnitID]))
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
-- Spawn in air as requested initially. Original template orientation is perserved, altitude is already correctly set.
|
||||
SpawnTemplate.units[UnitID].x = TX
|
||||
SpawnTemplate.units[UnitID].y = TY
|
||||
SpawnTemplate.units[UnitID].alt = PointVec3.y
|
||||
self:T(string.format("Group %s spawning in air at %s.", self.SpawnTemplatePrefix, SpawnAirbase:GetName()))
|
||||
|
||||
-- Spawn in air as requested initially. Original template orientation is perserved, altitude is already correctly set.
|
||||
SpawnTemplate.units[UnitID].x = TX
|
||||
SpawnTemplate.units[UnitID].y = TY
|
||||
SpawnTemplate.units[UnitID].alt = PointVec3.y
|
||||
|
||||
end
|
||||
|
||||
-- Parking spot id.
|
||||
UnitTemplate.parking = nil
|
||||
UnitTemplate.parking_id = nil
|
||||
if parkingindex[UnitID] then
|
||||
UnitTemplate.parking = parkingindex[UnitID]
|
||||
end
|
||||
|
||||
-- Debug output.
|
||||
self:T2(string.format("Group %s unit number %d: Parking = %s",self.SpawnTemplatePrefix, UnitID, tostring(UnitTemplate.parking)))
|
||||
self:T2(string.format("Group %s unit number %d: Parking ID = %s",self.SpawnTemplatePrefix, UnitID, tostring(UnitTemplate.parking_id)))
|
||||
self:T2('After Translation SpawnTemplate.units['..UnitID..'].x = '..SpawnTemplate.units[UnitID].x..', SpawnTemplate.units['..UnitID..'].y = '..SpawnTemplate.units[UnitID].y)
|
||||
end
|
||||
|
||||
-- Parking spot id.
|
||||
UnitTemplate.parking = nil
|
||||
UnitTemplate.parking_id = nil
|
||||
if parkingindex[UnitID] then
|
||||
UnitTemplate.parking = parkingindex[UnitID]
|
||||
end
|
||||
|
||||
-- Debug output.
|
||||
self:T2(string.format("Group %s unit number %d: Parking = %s",self.SpawnTemplatePrefix, UnitID, tostring(UnitTemplate.parking)))
|
||||
self:T2(string.format("Group %s unit number %d: Parking ID = %s",self.SpawnTemplatePrefix, UnitID, tostring(UnitTemplate.parking_id)))
|
||||
self:T2('After Translation SpawnTemplate.units['..UnitID..'].x = '..SpawnTemplate.units[UnitID].x..', SpawnTemplate.units['..UnitID..'].y = '..SpawnTemplate.units[UnitID].y)
|
||||
end
|
||||
|
||||
-- Set gereral spawnpoint position.
|
||||
@ -2088,7 +2111,7 @@ end
|
||||
function SPAWN:InitUnControlled( UnControlled )
|
||||
self:F2( { self.SpawnTemplatePrefix, UnControlled } )
|
||||
|
||||
self.SpawnUnControlled = UnControlled or true
|
||||
self.SpawnUnControlled = ( UnControlled == true ) and true or nil
|
||||
|
||||
for SpawnGroupID = 1, self.SpawnMaxGroups do
|
||||
self.SpawnGroups[SpawnGroupID].UnControlled = self.SpawnUnControlled
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user