From a0219e4a081d5757178f919c600f63d7b92af7ba Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Tue, 25 Apr 2023 09:12:47 +0200 Subject: [PATCH] #SCENERY * Added update of Life0 value if `GetLife()`is called #SET_SCENERY * Added Documentation --- Moose Development/Moose/Core/Set.lua | 7 +++++-- Moose Development/Moose/Wrapper/Scenery.lua | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index a3e6232b0..454d092f9 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -7835,12 +7835,15 @@ do -- SET_SCENERY end --- Calculate current relative lifepoints of the SET objects, i.e. Life divided by Life0 as percentage value, eg 75 meaning 75% alive. - -- **CAVEAT**: Some objects change their life value or "hitpoints" **after** the first hit. Be aware that thus the relative life value might be > 100 after a hit. + -- **CAVEAT**: Some objects change their life value or "hitpoints" **after** the first hit. Hence we will adjust the Life0 value to 120% + -- of the last life value if life exceeds life0 ata any point. + -- Thus will will get a smooth percentage decrease, if you use this e.g. as success criteria for a bombing task. -- @param #SET_SCENERY self -- @return #number LifePoints function SET_SCENERY:GetRelativeLife() - local life0 = self:GetLife0() local life = self:GetLife() + local life0 = self:GetLife0() + self:T3(string.format("Set Lifepoints: %d life0 | %d life",life0,life)) local rlife = math.floor((life / life0) * 100) return rlife end diff --git a/Moose Development/Moose/Wrapper/Scenery.lua b/Moose Development/Moose/Wrapper/Scenery.lua index bc64dfd15..e66d10586 100644 --- a/Moose Development/Moose/Wrapper/Scenery.lua +++ b/Moose Development/Moose/Wrapper/Scenery.lua @@ -63,12 +63,18 @@ function SCENERY:GetDCSObject() end --- Get current life points from the SCENERY Object. +-- **CAVEAT**: Some objects change their life value or "hitpoints" **after** the first hit. Hence we will adjust the life0 value to 120% +-- of the last life value if life exceeds life0 (initial life) at any point. Thus will will get a smooth percentage decrease, if you use this e.g. as success +-- criteria for a bombing task. --@param #SCENERY self --@return #number life function SCENERY:GetLife() local life = 0 if self.SceneryObject then life = self.SceneryObject:getLife() + if life > self.Life0 then + self.Life0 = math.floor(life * 1.2) + end end return life end