mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Merge branch 'develop' into FF/Develop
This commit is contained in:
commit
cc920682fd
@ -2431,92 +2431,98 @@ do -- SET_UNIT
|
|||||||
-- @return #SET_UNIT self
|
-- @return #SET_UNIT self
|
||||||
function SET_UNIT:IsIncludeObject( MUnit )
|
function SET_UNIT:IsIncludeObject( MUnit )
|
||||||
self:F2( MUnit )
|
self:F2( MUnit )
|
||||||
local MUnitInclude = true
|
|
||||||
|
local MUnitInclude = false
|
||||||
|
|
||||||
|
if MUnit:IsAlive() ~= nil then
|
||||||
|
|
||||||
if self.Filter.Active ~= nil then
|
MUnitInclude = true
|
||||||
local MUnitActive = false
|
|
||||||
if self.Filter.Active == false or ( self.Filter.Active == true and MUnit:IsActive() == true ) then
|
|
||||||
MUnitActive = true
|
|
||||||
end
|
|
||||||
MUnitInclude = MUnitInclude and MUnitActive
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.Filter.Coalitions then
|
if self.Filter.Active ~= nil then
|
||||||
local MUnitCoalition = false
|
local MUnitActive = false
|
||||||
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
if self.Filter.Active == false or ( self.Filter.Active == true and MUnit:IsActive() == true ) then
|
||||||
self:F( { "Coalition:", MUnit:GetCoalition(), self.FilterMeta.Coalitions[CoalitionName], CoalitionName } )
|
MUnitActive = true
|
||||||
if self.FilterMeta.Coalitions[CoalitionName] and self.FilterMeta.Coalitions[CoalitionName] == MUnit:GetCoalition() then
|
|
||||||
MUnitCoalition = true
|
|
||||||
end
|
end
|
||||||
|
MUnitInclude = MUnitInclude and MUnitActive
|
||||||
end
|
end
|
||||||
MUnitInclude = MUnitInclude and MUnitCoalition
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.Filter.Categories then
|
if self.Filter.Coalitions then
|
||||||
local MUnitCategory = false
|
local MUnitCoalition = false
|
||||||
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
||||||
self:T3( { "Category:", MUnit:GetDesc().category, self.FilterMeta.Categories[CategoryName], CategoryName } )
|
self:F( { "Coalition:", MUnit:GetCoalition(), self.FilterMeta.Coalitions[CoalitionName], CoalitionName } )
|
||||||
if self.FilterMeta.Categories[CategoryName] and self.FilterMeta.Categories[CategoryName] == MUnit:GetDesc().category then
|
if self.FilterMeta.Coalitions[CoalitionName] and self.FilterMeta.Coalitions[CoalitionName] == MUnit:GetCoalition() then
|
||||||
MUnitCategory = true
|
MUnitCoalition = true
|
||||||
end
|
|
||||||
end
|
|
||||||
MUnitInclude = MUnitInclude and MUnitCategory
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.Filter.Types then
|
|
||||||
local MUnitType = false
|
|
||||||
for TypeID, TypeName in pairs( self.Filter.Types ) do
|
|
||||||
self:T3( { "Type:", MUnit:GetTypeName(), TypeName } )
|
|
||||||
if TypeName == MUnit:GetTypeName() then
|
|
||||||
MUnitType = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
MUnitInclude = MUnitInclude and MUnitType
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.Filter.Countries then
|
|
||||||
local MUnitCountry = false
|
|
||||||
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
|
||||||
self:T3( { "Country:", MUnit:GetCountry(), CountryName } )
|
|
||||||
if country.id[CountryName] == MUnit:GetCountry() then
|
|
||||||
MUnitCountry = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
MUnitInclude = MUnitInclude and MUnitCountry
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.Filter.UnitPrefixes then
|
|
||||||
local MUnitPrefix = false
|
|
||||||
for UnitPrefixId, UnitPrefix in pairs( self.Filter.UnitPrefixes ) do
|
|
||||||
self:T3( { "Prefix:", string.find( MUnit:GetName(), UnitPrefix, 1 ), UnitPrefix } )
|
|
||||||
if string.find( MUnit:GetName(), UnitPrefix, 1 ) then
|
|
||||||
MUnitPrefix = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
MUnitInclude = MUnitInclude and MUnitPrefix
|
|
||||||
end
|
|
||||||
|
|
||||||
if self.Filter.RadarTypes then
|
|
||||||
local MUnitRadar = false
|
|
||||||
for RadarTypeID, RadarType in pairs( self.Filter.RadarTypes ) do
|
|
||||||
self:T3( { "Radar:", RadarType } )
|
|
||||||
if MUnit:HasSensors( Unit.SensorType.RADAR, RadarType ) == true then
|
|
||||||
if MUnit:GetRadar() == true then -- This call is necessary to evaluate the SEAD capability.
|
|
||||||
self:T3( "RADAR Found" )
|
|
||||||
end
|
end
|
||||||
MUnitRadar = true
|
|
||||||
end
|
end
|
||||||
|
MUnitInclude = MUnitInclude and MUnitCoalition
|
||||||
end
|
end
|
||||||
MUnitInclude = MUnitInclude and MUnitRadar
|
|
||||||
end
|
if self.Filter.Categories then
|
||||||
|
local MUnitCategory = false
|
||||||
if self.Filter.SEAD then
|
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
||||||
local MUnitSEAD = false
|
self:T3( { "Category:", MUnit:GetDesc().category, self.FilterMeta.Categories[CategoryName], CategoryName } )
|
||||||
if MUnit:HasSEAD() == true then
|
if self.FilterMeta.Categories[CategoryName] and self.FilterMeta.Categories[CategoryName] == MUnit:GetDesc().category then
|
||||||
self:T3( "SEAD Found" )
|
MUnitCategory = true
|
||||||
MUnitSEAD = true
|
end
|
||||||
|
end
|
||||||
|
MUnitInclude = MUnitInclude and MUnitCategory
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.Filter.Types then
|
||||||
|
local MUnitType = false
|
||||||
|
for TypeID, TypeName in pairs( self.Filter.Types ) do
|
||||||
|
self:T3( { "Type:", MUnit:GetTypeName(), TypeName } )
|
||||||
|
if TypeName == MUnit:GetTypeName() then
|
||||||
|
MUnitType = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
MUnitInclude = MUnitInclude and MUnitType
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.Filter.Countries then
|
||||||
|
local MUnitCountry = false
|
||||||
|
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
||||||
|
self:T3( { "Country:", MUnit:GetCountry(), CountryName } )
|
||||||
|
if country.id[CountryName] == MUnit:GetCountry() then
|
||||||
|
MUnitCountry = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
MUnitInclude = MUnitInclude and MUnitCountry
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.Filter.UnitPrefixes then
|
||||||
|
local MUnitPrefix = false
|
||||||
|
for UnitPrefixId, UnitPrefix in pairs( self.Filter.UnitPrefixes ) do
|
||||||
|
self:T3( { "Prefix:", string.find( MUnit:GetName(), UnitPrefix, 1 ), UnitPrefix } )
|
||||||
|
if string.find( MUnit:GetName(), UnitPrefix, 1 ) then
|
||||||
|
MUnitPrefix = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
MUnitInclude = MUnitInclude and MUnitPrefix
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.Filter.RadarTypes then
|
||||||
|
local MUnitRadar = false
|
||||||
|
for RadarTypeID, RadarType in pairs( self.Filter.RadarTypes ) do
|
||||||
|
self:T3( { "Radar:", RadarType } )
|
||||||
|
if MUnit:HasSensors( Unit.SensorType.RADAR, RadarType ) == true then
|
||||||
|
if MUnit:GetRadar() == true then -- This call is necessary to evaluate the SEAD capability.
|
||||||
|
self:T3( "RADAR Found" )
|
||||||
|
end
|
||||||
|
MUnitRadar = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
MUnitInclude = MUnitInclude and MUnitRadar
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.Filter.SEAD then
|
||||||
|
local MUnitSEAD = false
|
||||||
|
if MUnit:HasSEAD() == true then
|
||||||
|
self:T3( "SEAD Found" )
|
||||||
|
MUnitSEAD = true
|
||||||
|
end
|
||||||
|
MUnitInclude = MUnitInclude and MUnitSEAD
|
||||||
end
|
end
|
||||||
MUnitInclude = MUnitInclude and MUnitSEAD
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self:T2( MUnitInclude )
|
self:T2( MUnitInclude )
|
||||||
|
|||||||
@ -112,6 +112,20 @@ function CLEANUP_AIRBASE:New( AirbaseNames )
|
|||||||
self:HandleEvent( EVENTS.PilotDead, self.__.OnEventCrash )
|
self:HandleEvent( EVENTS.PilotDead, self.__.OnEventCrash )
|
||||||
self:HandleEvent( EVENTS.Dead, self.__.OnEventCrash )
|
self:HandleEvent( EVENTS.Dead, self.__.OnEventCrash )
|
||||||
self:HandleEvent( EVENTS.Crash, self.__.OnEventCrash )
|
self:HandleEvent( EVENTS.Crash, self.__.OnEventCrash )
|
||||||
|
|
||||||
|
for UnitName, Unit in pairs( _DATABASE.UNITS ) do
|
||||||
|
local Unit = Unit -- Wrapper.Unit#UNIT
|
||||||
|
if Unit:IsAlive() ~= nil then
|
||||||
|
if self:IsInAirbase( Unit:GetVec2() ) then
|
||||||
|
self:F( { UnitName = UnitName } )
|
||||||
|
self.CleanUpList[UnitName] = {}
|
||||||
|
self.CleanUpList[UnitName].CleanUpUnit = Unit
|
||||||
|
self.CleanUpList[UnitName].CleanUpGroup = Unit:GetGroup()
|
||||||
|
self.CleanUpList[UnitName].CleanUpGroupName = Unit:GetGroup():GetName()
|
||||||
|
self.CleanUpList[UnitName].CleanUpUnitName = Unit:GetName()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -213,11 +227,15 @@ end
|
|||||||
function CLEANUP_AIRBASE.__:OnEventBirth( EventData )
|
function CLEANUP_AIRBASE.__:OnEventBirth( EventData )
|
||||||
self:F( { EventData } )
|
self:F( { EventData } )
|
||||||
|
|
||||||
self.CleanUpList[EventData.IniDCSUnitName] = {}
|
if EventData.IniUnit:IsAlive() ~= nil then
|
||||||
self.CleanUpList[EventData.IniDCSUnitName].CleanUpUnit = EventData.IniUnit
|
if self:IsInAirbase( EventData.IniUnit:GetVec2() ) then
|
||||||
self.CleanUpList[EventData.IniDCSUnitName].CleanUpGroup = EventData.IniGroup
|
self.CleanUpList[EventData.IniDCSUnitName] = {}
|
||||||
self.CleanUpList[EventData.IniDCSUnitName].CleanUpGroupName = EventData.IniDCSGroupName
|
self.CleanUpList[EventData.IniDCSUnitName].CleanUpUnit = EventData.IniUnit
|
||||||
self.CleanUpList[EventData.IniDCSUnitName].CleanUpUnitName = EventData.IniDCSUnitName
|
self.CleanUpList[EventData.IniDCSUnitName].CleanUpGroup = EventData.IniGroup
|
||||||
|
self.CleanUpList[EventData.IniDCSUnitName].CleanUpGroupName = EventData.IniDCSGroupName
|
||||||
|
self.CleanUpList[EventData.IniDCSUnitName].CleanUpUnitName = EventData.IniDCSUnitName
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -349,45 +367,50 @@ function CLEANUP_AIRBASE.__:CleanUpSchedule()
|
|||||||
local CleanUpGroupName = CleanUpListData.CleanUpGroupName
|
local CleanUpGroupName = CleanUpListData.CleanUpGroupName
|
||||||
|
|
||||||
if CleanUpUnit:IsAlive() ~= nil then
|
if CleanUpUnit:IsAlive() ~= nil then
|
||||||
|
|
||||||
|
if self:IsInAirbase( CleanUpUnit:GetVec2() ) then
|
||||||
|
|
||||||
if _DATABASE:GetStatusGroup( CleanUpGroupName ) ~= "ReSpawn" then
|
if _DATABASE:GetStatusGroup( CleanUpGroupName ) ~= "ReSpawn" then
|
||||||
|
|
||||||
local CleanUpCoordinate = CleanUpUnit:GetCoordinate()
|
local CleanUpCoordinate = CleanUpUnit:GetCoordinate()
|
||||||
|
|
||||||
self:T( { "CleanUp Scheduler", CleanUpUnitName } )
|
self:T( { "CleanUp Scheduler", CleanUpUnitName } )
|
||||||
if CleanUpUnit:GetLife() <= CleanUpUnit:GetLife0() * 0.95 then
|
if CleanUpUnit:GetLife() <= CleanUpUnit:GetLife0() * 0.95 then
|
||||||
if CleanUpUnit:IsAboveRunway() then
|
if CleanUpUnit:IsAboveRunway() then
|
||||||
if CleanUpUnit:InAir() then
|
if CleanUpUnit:InAir() then
|
||||||
|
|
||||||
local CleanUpLandHeight = CleanUpCoordinate:GetLandHeight()
|
local CleanUpLandHeight = CleanUpCoordinate:GetLandHeight()
|
||||||
local CleanUpUnitHeight = CleanUpCoordinate.y - CleanUpLandHeight
|
local CleanUpUnitHeight = CleanUpCoordinate.y - CleanUpLandHeight
|
||||||
|
|
||||||
if CleanUpUnitHeight < 100 then
|
if CleanUpUnitHeight < 100 then
|
||||||
self:T( { "CleanUp Scheduler", "Destroy " .. CleanUpUnitName .. " because below safe height and damaged." } )
|
self:T( { "CleanUp Scheduler", "Destroy " .. CleanUpUnitName .. " because below safe height and damaged." } )
|
||||||
self:DestroyUnit( CleanUpUnit )
|
self:DestroyUnit( CleanUpUnit )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self:T( { "CleanUp Scheduler", "Destroy " .. CleanUpUnitName .. " because on runway and damaged." } )
|
self:T( { "CleanUp Scheduler", "Destroy " .. CleanUpUnitName .. " because on runway and damaged." } )
|
||||||
self:DestroyUnit( CleanUpUnit )
|
self:DestroyUnit( CleanUpUnit )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Clean Units which are waiting for a very long time in the CleanUpZone.
|
-- Clean Units which are waiting for a very long time in the CleanUpZone.
|
||||||
if CleanUpUnit then
|
if CleanUpUnit and not CleanUpUnit:GetPlayerName() then
|
||||||
local CleanUpUnitVelocity = CleanUpUnit:GetVelocityKMH()
|
local CleanUpUnitVelocity = CleanUpUnit:GetVelocityKMH()
|
||||||
if CleanUpUnitVelocity < 1 then
|
if CleanUpUnitVelocity < 1 then
|
||||||
if CleanUpListData.CleanUpMoved then
|
if CleanUpListData.CleanUpMoved then
|
||||||
if CleanUpListData.CleanUpTime + 180 <= timer.getTime() then
|
if CleanUpListData.CleanUpTime + 180 <= timer.getTime() then
|
||||||
self:T( { "CleanUp Scheduler", "Destroy due to not moving anymore " .. CleanUpUnitName } )
|
self:T( { "CleanUp Scheduler", "Destroy due to not moving anymore " .. CleanUpUnitName } )
|
||||||
self:DestroyUnit( CleanUpUnit )
|
self:DestroyUnit( CleanUpUnit )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
CleanUpListData.CleanUpTime = timer.getTime()
|
CleanUpListData.CleanUpTime = timer.getTime()
|
||||||
CleanUpListData.CleanUpMoved = true
|
CleanUpListData.CleanUpMoved = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
-- not anymore in an airbase zone, remove from cleanup list.
|
||||||
|
self.CleanUpList[CleanUpUnitName] = nil
|
||||||
|
end
|
||||||
else
|
else
|
||||||
-- Do nothing ...
|
-- Do nothing ...
|
||||||
self.CleanUpList[CleanUpUnitName] = nil
|
self.CleanUpList[CleanUpUnitName] = nil
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user