Fix possible DCS Unit not existing in OPSGROUP:onafterElementDamaged(From, Event, To, Element)

This commit is contained in:
Applevangelist 2023-03-24 10:28:36 +01:00
parent 7157836eb1
commit b1e233421e

View File

@ -7236,7 +7236,7 @@ function OPSGROUP:onafterElementDamaged(From, Event, To, Element)
local lifepoints=0
if Element.DCSunit then --and Element.DCSunit:isExist() then
if Element.DCSunit and Element.DCSunit:isExist() then
-- Get life of unit
lifepoints=Element.DCSunit:getLife()
@ -7244,6 +7244,10 @@ function OPSGROUP:onafterElementDamaged(From, Event, To, Element)
-- Debug output.
self:T(self.lid..string.format("Element life %s: %.2f/%.2f", Element.name, lifepoints, Element.life0))
else
self:T(self.lid..string.format("Element.DCSunit %s does not exist!", Element.name))
end
if lifepoints<=1.0 then