mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
#SCENERY
* Added update of Life0 value if `GetLife()`is called #SET_SCENERY * Added Documentation
This commit is contained in:
@@ -63,12 +63,18 @@ function SCENERY:GetDCSObject()
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Get current life points from the SCENERY Object.
|
--- 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
|
--@param #SCENERY self
|
||||||
--@return #number life
|
--@return #number life
|
||||||
function SCENERY:GetLife()
|
function SCENERY:GetLife()
|
||||||
local life = 0
|
local life = 0
|
||||||
if self.SceneryObject then
|
if self.SceneryObject then
|
||||||
life = self.SceneryObject:getLife()
|
life = self.SceneryObject:getLife()
|
||||||
|
if life > self.Life0 then
|
||||||
|
self.Life0 = math.floor(life * 1.2)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return life
|
return life
|
||||||
end
|
end
|
||||||
@@ -110,11 +116,13 @@ end
|
|||||||
--@param #number Radius (optional) Search radius around coordinate, defaults to 100
|
--@param #number Radius (optional) Search radius around coordinate, defaults to 100
|
||||||
--@return #SCENERY Scenery Object or `nil` if it cannot be found
|
--@return #SCENERY Scenery Object or `nil` if it cannot be found
|
||||||
function SCENERY:FindByName(Name, Coordinate, Radius)
|
function SCENERY:FindByName(Name, Coordinate, Radius)
|
||||||
|
|
||||||
local radius = Radius or 100
|
local radius = Radius or 100
|
||||||
local name = Name or "unknown"
|
local name = Name or "unknown"
|
||||||
local scenery = nil
|
local scenery = nil
|
||||||
|
|
||||||
|
BASE:T({name, radius, Coordinate:GetVec2()})
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @param Core.Point#COORDINATE coordinate
|
-- @param Core.Point#COORDINATE coordinate
|
||||||
-- @param #number radius
|
-- @param #number radius
|
||||||
@@ -170,6 +178,7 @@ function SCENERY:FindByZoneName( ZoneName )
|
|||||||
zone = ZONE:FindByName(ZoneName)
|
zone = ZONE:FindByName(ZoneName)
|
||||||
end
|
end
|
||||||
local _id = zone:GetProperty('OBJECT ID')
|
local _id = zone:GetProperty('OBJECT ID')
|
||||||
|
BASE:T("Object ID ".._id)
|
||||||
if not _id then
|
if not _id then
|
||||||
-- this zone has no object ID
|
-- this zone has no object ID
|
||||||
BASE:E("**** Zone without object ID: "..ZoneName.." | Type: "..tostring(zone.ClassName))
|
BASE:E("**** Zone without object ID: "..ZoneName.." | Type: "..tostring(zone.ClassName))
|
||||||
@@ -235,4 +244,4 @@ end
|
|||||||
--@return #SCENERY self
|
--@return #SCENERY self
|
||||||
function SCENERY:Destroy()
|
function SCENERY:Destroy()
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user