Restored old CleanUp and Scoring

This commit is contained in:
Frank
2020-04-24 16:55:15 +02:00
parent 2745c6c1ca
commit ac975e7e86
2 changed files with 390 additions and 656 deletions
+9 -13
View File
@@ -134,7 +134,7 @@ function CLEANUP_AIRBASE:New( AirbaseNames )
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
if self:IsInAirbase( Unit:GetVec2() ) then
self:F( { UnitName = UnitName } )
self.CleanUpList[UnitName] = {}
self.CleanUpList[UnitName].CleanUpUnit = Unit
@@ -187,10 +187,6 @@ function CLEANUP_AIRBASE:SetCleanMissiles( CleanMissiles )
end
end
--- Check whether a Vec2 is in any cleanup airbase.
-- @param #CLEANUP_AIRBASE self
-- @param DCS#VEC2 Vec2 2D vector.
function CLEANUP_AIRBASE.__:IsInAirbase( Vec2 )
local InAirbase = false
@@ -198,7 +194,7 @@ function CLEANUP_AIRBASE.__:IsInAirbase( Vec2 )
local Airbase = Airbase -- Wrapper.Airbase#AIRBASE
if Airbase:GetZone():IsVec2InZone( Vec2 ) then
InAirbase = true
break
break;
end
end
@@ -250,7 +246,7 @@ function CLEANUP_AIRBASE.__:OnEventBirth( EventData )
self:F( { EventData } )
if EventData.IniUnit:IsAlive() ~= nil then
if self.__:IsInAirbase( EventData.IniUnit:GetVec2() ) then
if self:IsInAirbase( EventData.IniUnit:GetVec2() ) then
self.CleanUpList[EventData.IniDCSUnitName] = {}
self.CleanUpList[EventData.IniDCSUnitName].CleanUpUnit = EventData.IniUnit
self.CleanUpList[EventData.IniDCSUnitName].CleanUpGroup = EventData.IniGroup
@@ -295,7 +291,7 @@ function CLEANUP_AIRBASE.__:OnEventShot( Event )
self:F( { Event } )
-- Test if the missile was fired within one of the CLEANUP_AIRBASE.AirbaseNames.
if self.__:IsInAirbase( Event.IniUnit:GetVec2() ) then
if self:IsInAirbase( Event.IniUnit:GetVec2() ) then
-- Okay, the missile was fired within the CLEANUP_AIRBASE.AirbaseNames, destroy the fired weapon.
self:DestroyMissile( Event.Weapon )
end
@@ -308,7 +304,7 @@ function CLEANUP_AIRBASE.__:OnEventHit( Event )
self:F( { Event } )
if Event.IniUnit then
if self.__:IsInAirbase( Event.IniUnit:GetVec2() ) then
if self:IsInAirbase( Event.IniUnit:GetVec2() ) then
self:T( { "Life: ", Event.IniDCSUnitName, ' = ', Event.IniUnit:GetLife(), "/", Event.IniUnit:GetLife0() } )
if Event.IniUnit:GetLife() < Event.IniUnit:GetLife0() then
self:T( "CleanUp: Destroy: " .. Event.IniDCSUnitName )
@@ -318,7 +314,7 @@ function CLEANUP_AIRBASE.__:OnEventHit( Event )
end
if Event.TgtUnit then
if self.__:IsInAirbase( Event.TgtUnit:GetVec2() ) then
if self:IsInAirbase( Event.TgtUnit:GetVec2() ) then
self:T( { "Life: ", Event.TgtDCSUnitName, ' = ', Event.TgtUnit:GetLife(), "/", Event.TgtUnit:GetLife0() } )
if Event.TgtUnit:GetLife() < Event.TgtUnit:GetLife0() then
self:T( "CleanUp: Destroy: " .. Event.TgtDCSUnitName )
@@ -360,7 +356,7 @@ function CLEANUP_AIRBASE.__:EventAddForCleanUp( Event )
if Event.IniDCSUnit and Event.IniCategory == Object.Category.UNIT then
if self.CleanUpList[Event.IniDCSUnitName] == nil then
if self.__:IsInAirbase( Event.IniUnit:GetVec2() ) then
if self:IsInAirbase( Event.IniUnit:GetVec2() ) then
self:AddForCleanUp( Event.IniUnit, Event.IniDCSUnitName )
end
end
@@ -368,7 +364,7 @@ function CLEANUP_AIRBASE.__:EventAddForCleanUp( Event )
if Event.TgtDCSUnit and Event.TgtCategory == Object.Category.UNIT then
if self.CleanUpList[Event.TgtDCSUnitName] == nil then
if self.__:IsInAirbase( Event.TgtUnit:GetVec2() ) then
if self:IsInAirbase( Event.TgtUnit:GetVec2() ) then
self:AddForCleanUp( Event.TgtUnit, Event.TgtDCSUnitName )
end
end
@@ -390,7 +386,7 @@ function CLEANUP_AIRBASE.__:CleanUpSchedule()
if CleanUpUnit:IsAlive() ~= nil then
if self.__:IsInAirbase( CleanUpUnit:GetVec2() ) then
if self:IsInAirbase( CleanUpUnit:GetVec2() ) then
if _DATABASE:GetStatusGroup( CleanUpGroupName ) ~= "ReSpawn" then
File diff suppressed because it is too large Load Diff