SCENERY add-ons

This commit is contained in:
Applevangelist 2024-01-21 16:44:31 +01:00
parent 290609d581
commit d5322466e9
2 changed files with 25 additions and 5 deletions

View File

@ -8399,7 +8399,7 @@ do -- SET_SCENERY
--- Calculate current relative lifepoints of the SET objects, i.e. Life divided by Life0 as percentage value, eg 75 meaning 75% alive. --- 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. Hence we will adjust the Life0 value to 120% -- **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. -- 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. -- Thus we will get a smooth percentage decrease, if you use this e.g. as success criteria for a bombing task.
-- @param #SET_SCENERY self -- @param #SET_SCENERY self
-- @return #number LifePoints -- @return #number LifePoints
function SET_SCENERY:GetRelativeLife() function SET_SCENERY:GetRelativeLife()

View File

@ -123,16 +123,36 @@ end
--- Check if SCENERY Object is alive. --- Check if SCENERY Object is alive.
--@param #SCENERY self --@param #SCENERY self
--@param #number Threshold (Optional) If given, SCENERY counts as alive above this relative life in percent (1..100).
--@return #number life --@return #number life
function SCENERY:IsAlive() function SCENERY:IsAlive(Threshold)
return self:GetLife() >= 1 and true or false if not Threshold then
return self:GetLife() >= 1 and true or false
else
return self:GetRelativeLife() > Threshold and true or false
end
end end
--- Check if SCENERY Object is dead. --- Check if SCENERY Object is dead.
--@param #SCENERY self --@param #SCENERY self
--@param #number Threshold (Optional) If given, SCENERY counts as dead below this relative life in percent (1..100).
--@return #number life --@return #number life
function SCENERY:IsDead() function SCENERY:IsDead(Threshold)
return self:GetLife() < 1 and true or false if not Threshold then
return self:GetLife() < 1 and true or false
else
return self:GetRelativeLife() <= Threshold and true or false
end
end
--- Get SCENERY relative life in percent, e.g. 75.
--@param #SCENERY self
--@return #number rlife
function SCENERY:GetRelativeLife()
local life = self:GetLife()
local life0 = self:GetLife0()
local rlife = math.floor((life/life0)*100)
return rlife
end end
--- Get the threat level of a SCENERY object. Always 0 as scenery does not pose a threat to anyone. --- Get the threat level of a SCENERY object. Always 0 as scenery does not pose a threat to anyone.