diff --git a/Moose Development/Moose/Ops/CTLD.lua b/Moose Development/Moose/Ops/CTLD.lua index 62c0a445b..3e2f92ef5 100644 --- a/Moose Development/Moose/Ops/CTLD.lua +++ b/Moose Development/Moose/Ops/CTLD.lua @@ -2106,6 +2106,7 @@ function CTLD:_GetCrates(Group, Unit, Cargo, number, drop) self.CargoCounter = self.CargoCounter + 1 local realcargo = nil if drop then + --CTLD_CARGO:New(ID, Name, Templates, Sorte, HasBeenMoved, LoadDirectly, CratesNeeded, Positionable, Dropped, PerCrateMass, Stock, Subcategory) realcargo = CTLD_CARGO:New(self.CargoCounter,cratename,templ,sorte,true,false,cratesneeded,self.Spawned_Crates[self.CrateCounter],true,cargotype.PerCrateMass,nil,subcat) table.insert(droppedcargo,realcargo) else @@ -4778,7 +4779,7 @@ end for _,_cargo in pairs (stcstable) do local cargo = _cargo -- #CTLD_CARGO local object = cargo:GetPositionable() -- Wrapper.Static#STATIC - if object and object:IsAlive() and cargo:WasDropped() then + if object and object:IsAlive() and (cargo:WasDropped() or not cargo:HasMoved()) then statics[#statics+1] = cargo end end diff --git a/Moose Development/Moose/Wrapper/Unit.lua b/Moose Development/Moose/Wrapper/Unit.lua index 59474de9c..428676ec7 100644 --- a/Moose Development/Moose/Wrapper/Unit.lua +++ b/Moose Development/Moose/Wrapper/Unit.lua @@ -325,14 +325,19 @@ function UNIT:IsAlive() local DCSUnit = self:GetDCSObject() -- DCS#Unit if DCSUnit then - local UnitIsAlive = DCSUnit:isExist() and DCSUnit:isActive() + local UnitIsAlive = DCSUnit:isExist() and DCSUnit:isActive() and DCSUnit:getLife() > 1 return UnitIsAlive end return nil end - +--- Returns if the Unit is dead. +-- @param #UNIT self +-- @return #boolean `true` if Unit is dead, else false or nil if the unit does not exist +function UNIT:IsDead() + return not self:IsAlive() +end --- Returns the Unit's callsign - the localized string. -- @param #UNIT self @@ -626,7 +631,7 @@ function UNIT:IsFuelSupply() return false end ---- Returns the unit's group if it exist and nil otherwise. +--- Returns the unit's group if it exists and nil otherwise. -- @param Wrapper.Unit#UNIT self -- @return Wrapper.Group#GROUP The Group of the Unit or `nil` if the unit does not exist. function UNIT:GetGroup() @@ -635,8 +640,14 @@ function UNIT:GetGroup() local DCSUnit = self:GetDCSObject() if DCSUnit then - local UnitGroup = GROUP:FindByName( DCSUnit:getGroup():getName() ) - return UnitGroup + local grp = DCSUnit:getGroup() + if grp then + local UnitGroup = GROUP:FindByName( grp:getName() ) + return UnitGroup + else + local UnitGroup = GROUP:FindByName(self.GroupName) + return UnitGroup + end end return nil