From 04c77e9760854ce8fc4922c124e0d8792c3f445f Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Wed, 4 May 2022 09:51:36 +0200 Subject: [PATCH] Some fixes to make the SpawnScheduled work again --- Moose Development/Moose/Core/Base.lua | 5 +++-- Moose Development/Moose/Core/Database.lua | 17 +++++++++++++++++ Moose Development/Moose/DCS.lua | 3 ++- Moose Development/Moose/Wrapper/Group.lua | 11 ++++++----- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Moose Development/Moose/Core/Base.lua b/Moose Development/Moose/Core/Base.lua index 7751e7d6f..5db00678f 100644 --- a/Moose Development/Moose/Core/Base.lua +++ b/Moose Development/Moose/Core/Base.lua @@ -813,13 +813,14 @@ end -- @param #BASE self -- @param DCS#Time EventTime The time stamp of the event. -- @param DCS#Object Initiator The initiating object of the event. -function BASE:CreateEventDead( EventTime, Initiator ) - self:F( { EventTime, Initiator } ) +function BASE:CreateEventDead( EventTime, Initiator, IniObjectCategory ) + self:F( { EventTime, Initiator, IniObjectCategory } ) local Event = { id = world.event.S_EVENT_DEAD, time = EventTime, initiator = Initiator, + IniObjectCategory = IniObjectCategory, } world.onEvent( Event ) diff --git a/Moose Development/Moose/Core/Database.lua b/Moose Development/Moose/Core/Database.lua index 77d294a3f..0b4fff4c7 100644 --- a/Moose Development/Moose/Core/Database.lua +++ b/Moose Development/Moose/Core/Database.lua @@ -124,6 +124,7 @@ function DATABASE:New() self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash ) self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash ) self:HandleEvent( EVENTS.RemoveUnit, self._EventOnDeadOrCrash ) + --self:HandleEvent( EVENTS.UnitLost, self._EventOnDeadOrCrash ) -- DCS 2.7.1 for Aerial units no dead event ATM self:HandleEvent( EVENTS.Hit, self.AccountHits ) self:HandleEvent( EVENTS.NewCargo ) self:HandleEvent( EVENTS.DeleteCargo ) @@ -1154,6 +1155,22 @@ function DATABASE:_EventOnDeadOrCrash( Event ) if self.STATICS[Event.IniDCSUnitName] then self:DeleteStatic( Event.IniDCSUnitName ) end + + --- + -- Maybe a UNIT? + --- + + -- Delete unit. + if self.UNITS[Event.IniDCSUnitName] then + self:T("STATIC Event for UNIT "..tostring(Event.IniDCSUnitName)) + local DCSUnit = _DATABASE:FindUnit( Event.IniDCSUnitName ) + self:T({DCSUnit}) + if DCSUnit then + --self:I("Creating DEAD Event for UNIT "..tostring(Event.IniDCSUnitName)) + --DCSUnit:Destroy(true) + return + end + end else diff --git a/Moose Development/Moose/DCS.lua b/Moose Development/Moose/DCS.lua index 24d7862d0..8cbe4354d 100644 --- a/Moose Development/Moose/DCS.lua +++ b/Moose Development/Moose/DCS.lua @@ -503,8 +503,9 @@ do -- Object -- @field UNIT -- @field WEAPON -- @field STATIC - -- @field SCENERY -- @field BASE + -- @field SCENERY + -- @field CARGO --- @type Object.Desc -- @extends #Desc diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index 266e4a483..96807c26a 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -1247,13 +1247,14 @@ function GROUP:IsInZone( Zone ) for UnitID, UnitData in pairs(self:GetUnits()) do local Unit = UnitData -- Wrapper.Unit#UNIT - -- Get 2D vector. That's all we need for the zone check. - local vec2=Unit:GetVec2() + local vec2 = nil + if Unit then + -- Get 2D vector. That's all we need for the zone check. + vec2=Unit:GetVec2() + end - if Zone:IsVec2InZone(vec2) then + if vec2 and Zone:IsVec2InZone(vec2) then return true -- At least one unit is in the zone. That is enough. - else - -- This one is not but another could be. end end