mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
SCENERY add-ons
This commit is contained in:
parent
290609d581
commit
d5322466e9
@ -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.
|
||||
-- **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.
|
||||
-- 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
|
||||
-- @return #number LifePoints
|
||||
function SET_SCENERY:GetRelativeLife()
|
||||
|
||||
@ -123,16 +123,36 @@ end
|
||||
|
||||
--- Check if SCENERY Object is alive.
|
||||
--@param #SCENERY self
|
||||
--@param #number Threshold (Optional) If given, SCENERY counts as alive above this relative life in percent (1..100).
|
||||
--@return #number life
|
||||
function SCENERY:IsAlive()
|
||||
function SCENERY:IsAlive(Threshold)
|
||||
if not Threshold then
|
||||
return self:GetLife() >= 1 and true or false
|
||||
else
|
||||
return self:GetRelativeLife() > Threshold and true or false
|
||||
end
|
||||
end
|
||||
|
||||
--- Check if SCENERY Object is dead.
|
||||
--@param #SCENERY self
|
||||
--@param #number Threshold (Optional) If given, SCENERY counts as dead below this relative life in percent (1..100).
|
||||
--@return #number life
|
||||
function SCENERY:IsDead()
|
||||
function SCENERY:IsDead(Threshold)
|
||||
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
|
||||
|
||||
--- Get the threat level of a SCENERY object. Always 0 as scenery does not pose a threat to anyone.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user