Updated CleanUp to clean more units from airbase

This commit is contained in:
svenvandevelde 2015-11-03 10:16:35 +01:00
parent 0894d4ee40
commit e411ed50cf
4 changed files with 23 additions and 11 deletions

View File

@ -116,7 +116,6 @@ trace.f(self.ClassName, event )
--env.info( 'onEvent EventObject.Event = ' .. tostring(EventObject.Event) )
if event.id == EventObject.Event then
if self == EventObject.Self then
--env.info( 'onEvent Call EventFunction' )
EventObject.EventFunction( self, event )
end
end

View File

@ -96,22 +96,34 @@ end
function CLEANUP:_Scheduler()
for GroupName, ListData in pairs( self.CleanUpList ) do
env.info( "CleanUp: GroupName = " .. GroupName )
env.info( "CleanUp: UnitName = " .. ListData )
env.info( "CleanUp: GroupName = " .. GroupName .. " UnitName = " .. ListData )
local CleanUpGroup = Group.getByName( GroupName )
local CleanUpUnit = Unit.getByName( ListData )
if CleanUpUnit and CleanUpGroup then
env.info( "CleanUp: Check Database" )
if _Database:GetStatusGroup( GroupName ) ~= "ReSpawn" then
env.info( "CleanUp: Database OK" )
local CleanUpUnitVelocity = CleanUpUnit:getVelocity()
local CleanUpUnitVelocityTotal = math.abs(CleanUpUnitVelocity.x) + math.abs(CleanUpUnitVelocity.y) + math.abs(CleanUpUnitVelocity.z)
if CleanUpUnitVelocityTotal < 1 then
env.info( "CleanUp: Destroy: " .. GroupName )
CleanUpGroup:destroy()
if CleanUpGroup:isExist() and CleanUpUnit:isExist() then
env.info( "CleanUp: Group Existing" )
if _Database:GetStatusGroup( GroupName ) ~= "ReSpawn" then
env.info( "CleanUp: Database OK" )
local CleanUpUnitVelocity = CleanUpUnit:getVelocity()
local CleanUpUnitVelocityTotal = math.abs(CleanUpUnitVelocity.x) + math.abs(CleanUpUnitVelocity.y) + math.abs(CleanUpUnitVelocity.z)
if CleanUpUnitVelocityTotal < 1 then
env.info( "CleanUp: Destroy: " .. GroupName )
trigger.action.deactivateGroup(CleanUpGroup)
ListData = nil
end
else
ListData = nil
end
else
env.info( "CleanUp: Not Existing anymore, cleaning: " .. GroupName )
Event = {
id = 8,
time = Time,
initiator = CleanUpUnit,
}
world.onEvent(Event)
trigger.action.deactivateGroup(CleanUpGroup)
ListData = nil
end
else

View File

@ -182,7 +182,7 @@ end
--- When a Group got SPAWNed, it has a life within the DCSRTE. For planes and helicopters, when these Units go home and land on their home airbases and farps, they normally would taxi to the parking spot, shut-down their engines and wait forever until the Group is removed by the DCSRTE.
-- This function is used to Re-Spawn automatically (so no extra call is needed anymore) the same Group after it landed. This will enable a SPAWNed group to be Re-SPAWNed after it lands, until it is destroyed...
-- Note: When the Group is respawned, it will @{ReSpawn} at the original airbase where it took off. So ensure that the paths for Groups that ReSpawn, always return to the orignal airbase.
-- Note: When the Group is respawned, it will @{ReSpawn} at the original airbase where it took off. So ensure that the paths for Groups that ReSpawn, always return to the original airbase.
-- @treturn SPAWN
-- @usage
-- -- RU Su-34 - AI Ship Attack

View File

@ -60,6 +60,7 @@ trace.names._GetTemplate = false
trace.names.FollowPlayers = false
trace.names.AddPlayerFromUnit = false
trace.names.FromCarrier = false
trace.names.OnDeadOrCrash = true
trace.cache = {}
trace.tracefunction = function( functionname )