From 80545fa20816abf26ce3a966fcd632f22f49c255 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Thu, 13 Sep 2018 18:00:48 +0200 Subject: [PATCH] Pushing a fix for the cargo destroys after respawn. --- Moose Development/Moose/Cargo/CargoGroup.lua | 2 +- Moose Development/Moose/Wrapper/Group.lua | 10 +++++++++- .../Moose/Wrapper/Positionable.lua | 20 +++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Cargo/CargoGroup.lua b/Moose Development/Moose/Cargo/CargoGroup.lua index 2ccec351e..90e656d86 100644 --- a/Moose Development/Moose/Cargo/CargoGroup.lua +++ b/Moose Development/Moose/Cargo/CargoGroup.lua @@ -138,7 +138,7 @@ do -- CARGO_GROUP for CargoID, CargoData in pairs( self.CargoSet:GetSet() ) do local Cargo = CargoData -- Cargo.Cargo#CARGO - Cargo:Destroy(false) -- Destroy the cargo and generate a remove unit event to update the sets. + Cargo:Destroy( false ) -- Destroy the cargo and generate a remove unit event to update the sets. Cargo:SetStartState( "UnLoaded" ) end diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index 470de56b4..e8e4e949d 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -274,7 +274,13 @@ end -- @usage -- -- Ship unit example: destroy the Ship silently. -- Ship = GROUP:FindByName( "Ship" ) --- Ship:Destroy( true ) +-- Ship:Destroy() +-- +-- @usage +-- -- Destroy without event generation example. +-- Ship = GROUP:FindByName( "Boat" ) +-- Ship:Destroy( false ) -- Don't generate an event upon destruction. +-- function GROUP:Destroy( GenerateEvent ) self:F2( self.GroupName ) @@ -288,6 +294,8 @@ function GROUP:Destroy( GenerateEvent ) else self:CreateEventDead( timer.getTime(), UnitData ) end + elseif GenerateEvent == false then + -- Do nothing! else self:CreateEventRemoveUnit( timer.getTime(), UnitData ) end diff --git a/Moose Development/Moose/Wrapper/Positionable.lua b/Moose Development/Moose/Wrapper/Positionable.lua index 20bbfe9d2..fc84e5f54 100644 --- a/Moose Development/Moose/Wrapper/Positionable.lua +++ b/Moose Development/Moose/Wrapper/Positionable.lua @@ -73,6 +73,24 @@ end -- @param #POSITIONABLE self -- @param #boolean GenerateEvent (Optional) true if you want to generate a crash or dead event for the unit. -- @return #nil The DCS Unit is not existing or alive. +-- @usage +-- -- Air unit example: destroy the Helicopter and generate a S_EVENT_CRASH for each unit in the Helicopter group. +-- Helicopter = UNIT:FindByName( "Helicopter" ) +-- Helicopter:Destroy( true ) +-- @usage +-- -- Ground unit example: destroy the Tanks and generate a S_EVENT_DEAD for each unit in the Tanks group. +-- Tanks = UNIT:FindByName( "Tanks" ) +-- Tanks:Destroy( true ) +-- @usage +-- -- Ship unit example: destroy the Ship silently. +-- Ship = STATIC:FindByName( "Ship" ) +-- Ship:Destroy() +-- +-- @usage +-- -- Destroy without event generation example. +-- Ship = STATIC:FindByName( "Boat" ) +-- Ship:Destroy( false ) -- Don't generate an event upon destruction. +-- function POSITIONABLE:Destroy( GenerateEvent ) self:F2( self.ObjectName ) @@ -90,6 +108,8 @@ function POSITIONABLE:Destroy( GenerateEvent ) else self:CreateEventDead( timer.getTime(), DCSObject ) end + elseif GenerateEvent == false then + -- Do nothing! else self:CreateEventRemoveUnit( timer.getTime(), DCSObject ) end