mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
General documentation and code fixes (#1650)
Documentation updates for correctness and clarity. General code formatting updates. Ajustment to POSITIONABLE:GetCoord to make use of existing POINT:UpdateFromVec3. Added comments about clarifying the difference between POSITIONABLE:GetCoordinate() and POSITIONABLE:GetCoord() and to perhaps consider a renaming or merging the functions with an optional flag.
This commit is contained in:
parent
b0818977cf
commit
6360b8c58f
@ -314,39 +314,38 @@ do -- COORDINATE
|
|||||||
-- @param DCS#Vec3 Vec3 The 3D vector with x,y,z components.
|
-- @param DCS#Vec3 Vec3 The 3D vector with x,y,z components.
|
||||||
-- @return #COORDINATE The modified COORDINATE itself.
|
-- @return #COORDINATE The modified COORDINATE itself.
|
||||||
function COORDINATE:UpdateFromVec3(Vec3)
|
function COORDINATE:UpdateFromVec3(Vec3)
|
||||||
|
|
||||||
self.x=Vec3.x
|
self.x=Vec3.x
|
||||||
self.y=Vec3.y
|
self.y=Vec3.y
|
||||||
self.z=Vec3.z
|
self.z=Vec3.z
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Update x,y,z coordinates from another given COORDINATE.
|
--- Update x,y,z coordinates from another given COORDINATE.
|
||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
-- @param #COORDINATE Coordinate The coordinate with the new x,y,z positions.
|
-- @param #COORDINATE Coordinate The coordinate with the new x,y,z positions.
|
||||||
-- @return #COORDINATE The modified COORDINATE itself.
|
-- @return #COORDINATE The modified COORDINATE itself.
|
||||||
function COORDINATE:UpdateFromCoordinate(Coordinate)
|
function COORDINATE:UpdateFromCoordinate(Coordinate)
|
||||||
|
|
||||||
self.x=Coordinate.x
|
self.x=Coordinate.x
|
||||||
self.y=Coordinate.y
|
self.y=Coordinate.y
|
||||||
self.z=Coordinate.z
|
self.z=Coordinate.z
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Update x and z coordinates from a given 2D vector.
|
--- Update x and z coordinates from a given 2D vector.
|
||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
-- @param DCS#Vec2 Vec2 The 2D vector with x,y components. x is overwriting COORDINATE.x while y is overwriting COORDINATE.z.
|
-- @param DCS#Vec2 Vec2 The 2D vector with x,y components. x is overwriting COORDINATE.x while y is overwriting COORDINATE.z.
|
||||||
-- @return #COORDINATE The modified COORDINATE itself.
|
-- @return #COORDINATE The modified COORDINATE itself.
|
||||||
function COORDINATE:UpdateFromVec2(Vec2)
|
function COORDINATE:UpdateFromVec2(Vec2)
|
||||||
|
|
||||||
self.x=Vec2.x
|
self.x=Vec2.x
|
||||||
self.z=Vec2.y
|
self.z=Vec2.y
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns the coordinate from the latitude and longitude given in decimal degrees.
|
--- Returns the coordinate from the latitude and longitude given in decimal degrees.
|
||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
@ -355,13 +354,13 @@ do -- COORDINATE
|
|||||||
-- @param #number altitude (Optional) Altitude in meters. Default is the land height at the coordinate.
|
-- @param #number altitude (Optional) Altitude in meters. Default is the land height at the coordinate.
|
||||||
-- @return #COORDINATE
|
-- @return #COORDINATE
|
||||||
function COORDINATE:NewFromLLDD( latitude, longitude, altitude)
|
function COORDINATE:NewFromLLDD( latitude, longitude, altitude)
|
||||||
|
|
||||||
-- Returns a point from latitude and longitude in the vec3 format.
|
-- Returns a point from latitude and longitude in the vec3 format.
|
||||||
local vec3=coord.LLtoLO(latitude, longitude)
|
local vec3=coord.LLtoLO(latitude, longitude)
|
||||||
|
|
||||||
-- Convert vec3 to coordinate object.
|
-- Convert vec3 to coordinate object.
|
||||||
local _coord=self:NewFromVec3(vec3)
|
local _coord=self:NewFromVec3(vec3)
|
||||||
|
|
||||||
-- Adjust height
|
-- Adjust height
|
||||||
if altitude==nil then
|
if altitude==nil then
|
||||||
_coord.y=self:GetLandHeight()
|
_coord.y=self:GetLandHeight()
|
||||||
@ -372,23 +371,22 @@ do -- COORDINATE
|
|||||||
return _coord
|
return _coord
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns if the 2 coordinates are at the same 2D position.
|
--- Returns if the 2 coordinates are at the same 2D position.
|
||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
-- @param #COORDINATE Coordinate
|
-- @param #COORDINATE Coordinate
|
||||||
-- @param #number Precision
|
-- @param #number Precision
|
||||||
-- @return #boolean true if at the same position.
|
-- @return #boolean true if at the same position.
|
||||||
function COORDINATE:IsAtCoordinate2D( Coordinate, Precision )
|
function COORDINATE:IsAtCoordinate2D( Coordinate, Precision )
|
||||||
|
|
||||||
self:F( { Coordinate = Coordinate:GetVec2() } )
|
self:F( { Coordinate = Coordinate:GetVec2() } )
|
||||||
self:F( { self = self:GetVec2() } )
|
self:F( { self = self:GetVec2() } )
|
||||||
|
|
||||||
local x = Coordinate.x
|
local x = Coordinate.x
|
||||||
local z = Coordinate.z
|
local z = Coordinate.z
|
||||||
|
|
||||||
return x - Precision <= self.x and x + Precision >= self.x and z - Precision <= self.z and z + Precision >= self.z
|
return x - Precision <= self.x and x + Precision >= self.x and z - Precision <= self.z and z + Precision >= self.z
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Scan/find objects (units, statics, scenery) within a certain radius around the coordinate using the world.searchObjects() DCS API function.
|
--- Scan/find objects (units, statics, scenery) within a certain radius around the coordinate using the world.searchObjects() DCS API function.
|
||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
-- @param #number radius (Optional) Scan radius in meters. Default 100 m.
|
-- @param #number radius (Optional) Scan radius in meters. Default 100 m.
|
||||||
@ -423,7 +421,7 @@ do -- COORDINATE
|
|||||||
if scanscenery==nil then
|
if scanscenery==nil then
|
||||||
scanscenery=false
|
scanscenery=false
|
||||||
end
|
end
|
||||||
|
|
||||||
--{Object.Category.UNIT, Object.Category.STATIC, Object.Category.SCENERY}
|
--{Object.Category.UNIT, Object.Category.STATIC, Object.Category.SCENERY}
|
||||||
local scanobjects={}
|
local scanobjects={}
|
||||||
if scanunits then
|
if scanunits then
|
||||||
@ -435,7 +433,7 @@ do -- COORDINATE
|
|||||||
if scanscenery then
|
if scanscenery then
|
||||||
table.insert(scanobjects, Object.Category.SCENERY)
|
table.insert(scanobjects, Object.Category.SCENERY)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Found stuff.
|
-- Found stuff.
|
||||||
local Units = {}
|
local Units = {}
|
||||||
local Statics = {}
|
local Statics = {}
|
||||||
@ -443,40 +441,40 @@ do -- COORDINATE
|
|||||||
local gotstatics=false
|
local gotstatics=false
|
||||||
local gotunits=false
|
local gotunits=false
|
||||||
local gotscenery=false
|
local gotscenery=false
|
||||||
|
|
||||||
local function EvaluateZone(ZoneObject)
|
local function EvaluateZone(ZoneObject)
|
||||||
|
|
||||||
if ZoneObject then
|
if ZoneObject then
|
||||||
|
|
||||||
-- Get category of scanned object.
|
-- Get category of scanned object.
|
||||||
local ObjectCategory = ZoneObject:getCategory()
|
local ObjectCategory = ZoneObject:getCategory()
|
||||||
|
|
||||||
-- Check for unit or static objects
|
-- Check for unit or static objects
|
||||||
if ObjectCategory==Object.Category.UNIT and ZoneObject:isExist() then
|
if ObjectCategory==Object.Category.UNIT and ZoneObject:isExist() then
|
||||||
|
|
||||||
table.insert(Units, UNIT:Find(ZoneObject))
|
table.insert(Units, UNIT:Find(ZoneObject))
|
||||||
gotunits=true
|
gotunits=true
|
||||||
|
|
||||||
elseif ObjectCategory==Object.Category.STATIC and ZoneObject:isExist() then
|
elseif ObjectCategory==Object.Category.STATIC and ZoneObject:isExist() then
|
||||||
|
|
||||||
table.insert(Statics, ZoneObject)
|
table.insert(Statics, ZoneObject)
|
||||||
gotstatics=true
|
gotstatics=true
|
||||||
|
|
||||||
elseif ObjectCategory==Object.Category.SCENERY then
|
elseif ObjectCategory==Object.Category.SCENERY then
|
||||||
|
|
||||||
table.insert(Scenery, ZoneObject)
|
table.insert(Scenery, ZoneObject)
|
||||||
gotscenery=true
|
gotscenery=true
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Search the world.
|
-- Search the world.
|
||||||
world.searchObjects(scanobjects, SphereSearch, EvaluateZone)
|
world.searchObjects(scanobjects, SphereSearch, EvaluateZone)
|
||||||
|
|
||||||
for _,unit in pairs(Units) do
|
for _,unit in pairs(Units) do
|
||||||
self:T(string.format("Scan found unit %s", unit:GetName()))
|
self:T(string.format("Scan found unit %s", unit:GetName()))
|
||||||
end
|
end
|
||||||
@ -551,7 +549,7 @@ do -- COORDINATE
|
|||||||
-- @param DCS#Distance Distance The Distance to be added in meters.
|
-- @param DCS#Distance Distance The Distance to be added in meters.
|
||||||
-- @param DCS#Angle Angle The Angle in degrees. Defaults to 0 if not specified (nil).
|
-- @param DCS#Angle Angle The Angle in degrees. Defaults to 0 if not specified (nil).
|
||||||
-- @param #boolean Keepalt If true, keep altitude of original coordinate. Default is that the new coordinate is created at the translated land height.
|
-- @param #boolean Keepalt If true, keep altitude of original coordinate. Default is that the new coordinate is created at the translated land height.
|
||||||
-- @param #boolean Overwrite If true, overwrite the original COORDINATE with the translated one. Otherwise, create a new COODINATE.
|
-- @param #boolean Overwrite If true, overwrite the original COORDINATE with the translated one. Otherwise, create a new COORDINATE.
|
||||||
-- @return #COORDINATE The new calculated COORDINATE.
|
-- @return #COORDINATE The new calculated COORDINATE.
|
||||||
function COORDINATE:Translate( Distance, Angle, Keepalt, Overwrite )
|
function COORDINATE:Translate( Distance, Angle, Keepalt, Overwrite )
|
||||||
|
|
||||||
@ -2987,7 +2985,7 @@ do -- POINT_VEC3
|
|||||||
|
|
||||||
local self = BASE:Inherit( self, COORDINATE:New( x, y, z ) ) -- Core.Point#POINT_VEC3
|
local self = BASE:Inherit( self, COORDINATE:New( x, y, z ) ) -- Core.Point#POINT_VEC3
|
||||||
self:F2( self )
|
self:F2( self )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -3004,7 +3002,6 @@ do -- POINT_VEC3
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Create a new POINT_VEC3 object from Vec3 coordinates.
|
--- Create a new POINT_VEC3 object from Vec3 coordinates.
|
||||||
-- @param #POINT_VEC3 self
|
-- @param #POINT_VEC3 self
|
||||||
-- @param DCS#Vec3 Vec3 The Vec3 point.
|
-- @param DCS#Vec3 Vec3 The Vec3 point.
|
||||||
@ -3013,12 +3010,10 @@ do -- POINT_VEC3
|
|||||||
|
|
||||||
local self = BASE:Inherit( self, COORDINATE:NewFromVec3( Vec3 ) ) -- Core.Point#POINT_VEC3
|
local self = BASE:Inherit( self, COORDINATE:NewFromVec3( Vec3 ) ) -- Core.Point#POINT_VEC3
|
||||||
self:F2( self )
|
self:F2( self )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Return the x coordinate of the POINT_VEC3.
|
--- Return the x coordinate of the POINT_VEC3.
|
||||||
-- @param #POINT_VEC3 self
|
-- @param #POINT_VEC3 self
|
||||||
-- @return #number The x coodinate.
|
-- @return #number The x coodinate.
|
||||||
|
|||||||
@ -152,7 +152,7 @@
|
|||||||
--
|
--
|
||||||
-- * The first parameter *targetnames* defines the target or targets. This can be a single item or a Table with the name(s) of @{Wrapper.Unit} or @{Static} objects defined in the mission editor.
|
-- * The first parameter *targetnames* defines the target or targets. This can be a single item or a Table with the name(s) of @{Wrapper.Unit} or @{Static} objects defined in the mission editor.
|
||||||
-- * The (optional) parameter *goodhitrange* specifies the radius in metres around the target within which a bomb/rocket hit is considered to be "good".
|
-- * The (optional) parameter *goodhitrange* specifies the radius in metres around the target within which a bomb/rocket hit is considered to be "good".
|
||||||
-- * If final (optional) parameter "*randommove*" can be enabled to create moving targets. If this parameter is set to true, the units of this bombing target will randomly move within the range zone.
|
-- * If final (optional) parameter *randommove* can be enabled to create moving targets. If this parameter is set to true, the units of this bombing target will randomly move within the range zone.
|
||||||
-- Note that there might be quirks since DCS units can get stuck in buildings etc. So it might be safer to manually define a route for the units in the mission editor if moving targets are desired.
|
-- Note that there might be quirks since DCS units can get stuck in buildings etc. So it might be safer to manually define a route for the units in the mission editor if moving targets are desired.
|
||||||
--
|
--
|
||||||
-- ## Adding Groups
|
-- ## Adding Groups
|
||||||
@ -903,10 +903,10 @@ end
|
|||||||
|
|
||||||
--- Set player setting whether bomb impact points are smoked or not.
|
--- Set player setting whether bomb impact points are smoked or not.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #boolean switch If true nor nil default is to smoke impact points of bombs.
|
-- @param #boolean switch (Optional) If true, impact points of bombs will be smoked. Default is true.
|
||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
function RANGE:SetDefaultPlayerSmokeBomb(switch)
|
function RANGE:SetDefaultPlayerSmokeBomb(switch)
|
||||||
if switch==true or switch==nil then
|
if switch == nil or switch == true then
|
||||||
self.defaultsmokebomb=true
|
self.defaultsmokebomb=true
|
||||||
else
|
else
|
||||||
self.defaultsmokebomb=false
|
self.defaultsmokebomb=false
|
||||||
@ -1249,7 +1249,7 @@ end
|
|||||||
-- @param #number boxlength (Optional) Length of the approach box in meters. Default is 3000 m.
|
-- @param #number boxlength (Optional) Length of the approach box in meters. Default is 3000 m.
|
||||||
-- @param #number boxwidth (Optional) Width of the approach box in meters. Default is 300 m.
|
-- @param #number boxwidth (Optional) Width of the approach box in meters. Default is 300 m.
|
||||||
-- @param #number heading (Optional) Approach heading in Degrees. Default is heading of the unit as defined in the mission editor.
|
-- @param #number heading (Optional) Approach heading in Degrees. Default is heading of the unit as defined in the mission editor.
|
||||||
-- @param #boolean inverseheading (Optional) Take inverse heading (heading --> heading - 180 Degrees). Default is false.
|
-- @param #boolean inverseheading (Optional) Use inverse heading (heading --> heading - 180 Degrees). Default is false.
|
||||||
-- @param #number goodpass (Optional) Number of hits for a "good" strafing pass. Default is 20.
|
-- @param #number goodpass (Optional) Number of hits for a "good" strafing pass. Default is 20.
|
||||||
-- @param #number foulline (Optional) Foul line distance. Hits from closer than this distance are not counted. Default 610 m = 2000 ft. Set to 0 for no foul line.
|
-- @param #number foulline (Optional) Foul line distance. Hits from closer than this distance are not counted. Default 610 m = 2000 ft. Set to 0 for no foul line.
|
||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
@ -1284,8 +1284,8 @@ end
|
|||||||
--- Add bombing target(s) to range.
|
--- Add bombing target(s) to range.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #table targetnames Single or multiple (Table) names of unit or static objects serving as bomb targets.
|
-- @param #table targetnames Single or multiple (Table) names of unit or static objects serving as bomb targets.
|
||||||
-- @param #number goodhitrange (Optional) Max distance from target unit (in meters) which is considered as a good hit. Default is 25 m.
|
-- @param #number goodhitrange (Optional) Max hit distance from target unit in meters which is considered as a good hit. Default is 25 m.
|
||||||
-- @param #boolean randommove If true, unit will move randomly within the range. Default is false.
|
-- @param #boolean randommove (Optional) If true, unit will move randomly within the range. Default is false.
|
||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
function RANGE:AddBombingTargets(targetnames, goodhitrange, randommove)
|
function RANGE:AddBombingTargets(targetnames, goodhitrange, randommove)
|
||||||
self:F({targetnames=targetnames, goodhitrange=goodhitrange, randommove=randommove})
|
self:F({targetnames=targetnames, goodhitrange=goodhitrange, randommove=randommove})
|
||||||
@ -1323,8 +1323,8 @@ end
|
|||||||
--- Add a unit or static object as bombing target.
|
--- Add a unit or static object as bombing target.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param Wrapper.Positionable#POSITIONABLE unit Positionable (unit or static) of the strafe target.
|
-- @param Wrapper.Positionable#POSITIONABLE unit Positionable (unit or static) of the strafe target.
|
||||||
-- @param #number goodhitrange Max distance from unit which is considered as a good hit.
|
-- @param #number goodhitrange (Optional) Max hit distance from target unit in meters which is considered as a good hit. Default is 25 m.
|
||||||
-- @param #boolean randommove If true, unit will move randomly within the range. Default is false.
|
-- @param #boolean randommove (Optional) If true, unit will move randomly within the range. Default is false.
|
||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
function RANGE:AddBombingTargetUnit(unit, goodhitrange, randommove)
|
function RANGE:AddBombingTargetUnit(unit, goodhitrange, randommove)
|
||||||
self:F({unit=unit, goodhitrange=goodhitrange, randommove=randommove})
|
self:F({unit=unit, goodhitrange=goodhitrange, randommove=randommove})
|
||||||
@ -1339,7 +1339,7 @@ function RANGE:AddBombingTargetUnit(unit, goodhitrange, randommove)
|
|||||||
goodhitrange=goodhitrange or RANGE.Defaults.goodhitrange
|
goodhitrange=goodhitrange or RANGE.Defaults.goodhitrange
|
||||||
|
|
||||||
-- Set randommove to false if it was not specified.
|
-- Set randommove to false if it was not specified.
|
||||||
if randommove==nil or _isstatic==true then
|
if randommove == nil or _isstatic == true then
|
||||||
randommove=false
|
randommove=false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1354,7 +1354,7 @@ function RANGE:AddBombingTargetUnit(unit, goodhitrange, randommove)
|
|||||||
|
|
||||||
-- Get max speed of unit in km/h.
|
-- Get max speed of unit in km/h.
|
||||||
local speed=0
|
local speed=0
|
||||||
if _isstatic==false then
|
if _isstatic == false then
|
||||||
speed=self:_GetSpeed(unit)
|
speed=self:_GetSpeed(unit)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1377,12 +1377,23 @@ function RANGE:AddBombingTargetUnit(unit, goodhitrange, randommove)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Add a coordinate of a bombing target. This
|
--- Add a coordinate of a bombing target.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param Core.Point#COORDINATE coord The coordinate.
|
-- @param Core.Point#COORDINATE coord The coordinate.
|
||||||
-- @param #string name Name of target.
|
-- @param #string name (Optional) Name of target. Default is "Bomb Target".
|
||||||
-- @param #number goodhitrange Max distance from unit which is considered as a good hit.
|
-- @param #number goodhitrange (Optional) Max hit distance from target unit in meters which is considered as a good hit. Default is 25 m.
|
||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
|
-- @usage
|
||||||
|
--
|
||||||
|
-- -- Setup a Range
|
||||||
|
-- RangeOne = RANGE:New( "Range One" )
|
||||||
|
-- -- Find the STATIC target object as setup in the ME
|
||||||
|
-- RangeOneBombTarget = STATIC:FindByName( "RangeOneBombTarget" ):
|
||||||
|
-- -- Add the coordinate of the STATIC target object as a bomb target (thus keeping the bomb function active, even if the STATIC target is destroyed)
|
||||||
|
-- RangeOne:AddBombingTargetCoordinate( RangeOneBombTarget:GetCoordinate(), "RangeOneBombTarget", 50)
|
||||||
|
-- -- Or, add the coordinate of the STATIC target object as a bomb target using default values (name will be "Bomb Target", goodhitrange will be 25 m)
|
||||||
|
-- RangeOne:AddBombingTargetCoordinate( RangeOneBombTarget:GetCoordinate() )
|
||||||
|
--
|
||||||
function RANGE:AddBombingTargetCoordinate(coord, name, goodhitrange)
|
function RANGE:AddBombingTargetCoordinate(coord, name, goodhitrange)
|
||||||
|
|
||||||
local target={} --#RANGE.BombTarget
|
local target={} --#RANGE.BombTarget
|
||||||
@ -1403,8 +1414,8 @@ end
|
|||||||
--- Add all units of a group as bombing targets.
|
--- Add all units of a group as bombing targets.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param Wrapper.Group#GROUP group Group of bombing targets.
|
-- @param Wrapper.Group#GROUP group Group of bombing targets.
|
||||||
-- @param #number goodhitrange Max distance from unit which is considered as a good hit.
|
-- @param #number goodhitrange (Optional) Max hit distance from target unit in meters which is considered as a good hit. Default is 25 m.
|
||||||
-- @param #boolean randommove If true, unit will move randomly within the range. Default is false.
|
-- @param #boolean randommove (Optional) If true, unit will move randomly within the range. Default is false.
|
||||||
-- @return #RANGE self
|
-- @return #RANGE self
|
||||||
function RANGE:AddBombingTargetGroup(group, goodhitrange, randommove)
|
function RANGE:AddBombingTargetGroup(group, goodhitrange, randommove)
|
||||||
self:F({group=group, goodhitrange=goodhitrange, randommove=randommove})
|
self:F({group=group, goodhitrange=goodhitrange, randommove=randommove})
|
||||||
@ -1423,10 +1434,10 @@ function RANGE:AddBombingTargetGroup(group, goodhitrange, randommove)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Measures the foule line distance between two unit or static objects.
|
--- Returns the foul line distance between strafe pit target and a foul line distance marker object.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #string namepit Name of the strafe pit target object.
|
-- @param #string namepit Name of the strafe pit target object.
|
||||||
-- @param #string namefoulline Name of the fould line distance marker object.
|
-- @param #string namefoulline Name of the foul line distance marker object.
|
||||||
-- @return #number Foul line distance in meters.
|
-- @return #number Foul line distance in meters.
|
||||||
function RANGE:GetFoullineDistance(namepit, namefoulline)
|
function RANGE:GetFoullineDistance(namepit, namefoulline)
|
||||||
self:F({namepit=namepit, namefoulline=namefoulline})
|
self:F({namepit=namepit, namefoulline=namefoulline})
|
||||||
@ -1437,7 +1448,7 @@ function RANGE:GetFoullineDistance(namepit, namefoulline)
|
|||||||
|
|
||||||
-- Get the unit or static pit object.
|
-- Get the unit or static pit object.
|
||||||
local pit=nil
|
local pit=nil
|
||||||
if _staticpit==true then
|
if _staticpit == true then
|
||||||
pit=STATIC:FindByName(namepit, false)
|
pit=STATIC:FindByName(namepit, false)
|
||||||
elseif _staticpit==false then
|
elseif _staticpit==false then
|
||||||
pit=UNIT:FindByName(namepit)
|
pit=UNIT:FindByName(namepit)
|
||||||
@ -1447,9 +1458,9 @@ function RANGE:GetFoullineDistance(namepit, namefoulline)
|
|||||||
|
|
||||||
-- Get the unit or static foul line object.
|
-- Get the unit or static foul line object.
|
||||||
local foul=nil
|
local foul=nil
|
||||||
if _staticfoul==true then
|
if _staticfoul == true then
|
||||||
foul=STATIC:FindByName(namefoulline, false)
|
foul=STATIC:FindByName(namefoulline, false)
|
||||||
elseif _staticfoul==false then
|
elseif _staticfoul == false then
|
||||||
foul=UNIT:FindByName(namefoulline)
|
foul=UNIT:FindByName(namefoulline)
|
||||||
else
|
else
|
||||||
self:E(self.id..string.format("ERROR! Foul line object %s could not be found in GetFoullineDistance function. Check the name in the ME.", namefoulline))
|
self:E(self.id..string.format("ERROR! Foul line object %s could not be found in GetFoullineDistance function. Check the name in the ME.", namefoulline))
|
||||||
@ -1457,7 +1468,7 @@ function RANGE:GetFoullineDistance(namepit, namefoulline)
|
|||||||
|
|
||||||
-- Get the distance between the two objects.
|
-- Get the distance between the two objects.
|
||||||
local fouldist=0
|
local fouldist=0
|
||||||
if pit~=nil and foul~=nil then
|
if pit ~= nil and foul ~= nil then
|
||||||
fouldist=pit:GetCoordinate():Get2DDistance(foul:GetCoordinate())
|
fouldist=pit:GetCoordinate():Get2DDistance(foul:GetCoordinate())
|
||||||
else
|
else
|
||||||
self:E(self.id..string.format("ERROR! Foul line distance could not be determined. Check pit object name %s and foul line object name %s in the ME.", namepit, namefoulline))
|
self:E(self.id..string.format("ERROR! Foul line distance could not be determined. Check pit object name %s and foul line object name %s in the ME.", namepit, namefoulline))
|
||||||
@ -1552,7 +1563,6 @@ function RANGE:OnEventBirth(EventData)
|
|||||||
self:T3(self.id.."BIRTH: player = "..tostring(_playername))
|
self:T3(self.id.."BIRTH: player = "..tostring(_playername))
|
||||||
|
|
||||||
if _unit and _playername then
|
if _unit and _playername then
|
||||||
|
|
||||||
local _uid=_unit:GetID()
|
local _uid=_unit:GetID()
|
||||||
local _group=_unit:GetGroup()
|
local _group=_unit:GetGroup()
|
||||||
local _gid=_group:GetID()
|
local _gid=_group:GetID()
|
||||||
@ -1589,8 +1599,8 @@ function RANGE:OnEventBirth(EventData)
|
|||||||
self.timerCheckZone=TIMER:New(self._CheckInZone, self, EventData.IniUnitName):Start(1, 1)
|
self.timerCheckZone=TIMER:New(self._CheckInZone, self, EventData.IniUnitName):Start(1, 1)
|
||||||
self.planes[_uid] = true
|
self.planes[_uid] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Range event handler for event hit.
|
--- Range event handler for event hit.
|
||||||
@ -1607,7 +1617,7 @@ function RANGE:OnEventHit(EventData)
|
|||||||
-- Player info
|
-- Player info
|
||||||
local _unitName = EventData.IniUnitName
|
local _unitName = EventData.IniUnitName
|
||||||
local _unit, _playername = self:_GetPlayerUnitAndName(_unitName)
|
local _unit, _playername = self:_GetPlayerUnitAndName(_unitName)
|
||||||
if _unit==nil or _playername==nil then
|
if _unit == nil or _playername == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1681,6 +1691,7 @@ function RANGE:OnEventHit(EventData)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Range event handler for event shot (when a unit releases a rocket or bomb (but not a fast firing gun).
|
--- Range event handler for event shot (when a unit releases a rocket or bomb (but not a fast firing gun).
|
||||||
@ -1690,10 +1701,10 @@ function RANGE:OnEventShot(EventData)
|
|||||||
self:F({eventshot = EventData})
|
self:F({eventshot = EventData})
|
||||||
|
|
||||||
-- Nil checks.
|
-- Nil checks.
|
||||||
if EventData.Weapon==nil then
|
if EventData.Weapon == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if EventData.IniDCSUnit==nil then
|
if EventData.IniDCSUnit == nil then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1741,7 +1752,6 @@ function RANGE:OnEventShot(EventData)
|
|||||||
|
|
||||||
-- Only track if distance player to range is < 25 km. Also check that a player shot. No need to track AI weapons.
|
-- Only track if distance player to range is < 25 km. Also check that a player shot. No need to track AI weapons.
|
||||||
if _track and dPR<=self.BombtrackThreshold and _unit and _playername then
|
if _track and dPR<=self.BombtrackThreshold and _unit and _playername then
|
||||||
|
|
||||||
-- Player data.
|
-- Player data.
|
||||||
local playerData=self.PlayerSettings[_playername] --#RANGE.PlayerData
|
local playerData=self.PlayerSettings[_playername] --#RANGE.PlayerData
|
||||||
|
|
||||||
@ -1911,7 +1921,7 @@ function RANGE:onafterStatus(From, Event, To)
|
|||||||
|
|
||||||
local text=string.format("Range status: %s", fsmstate)
|
local text=string.format("Range status: %s", fsmstate)
|
||||||
|
|
||||||
if self.instructor then
|
if self.instructor then
|
||||||
local alive="N/A"
|
local alive="N/A"
|
||||||
if self.instructorrelayname then
|
if self.instructorrelayname then
|
||||||
local relay=UNIT:FindByName(self.instructorrelayname)
|
local relay=UNIT:FindByName(self.instructorrelayname)
|
||||||
@ -2363,7 +2373,7 @@ function RANGE:_DisplayMyBombingResults(_unitName)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Best 10 runs only.
|
-- Best 10 runs only.
|
||||||
if i==self.ndisplayresult then
|
if i == self.ndisplayresult then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2694,7 +2704,7 @@ function RANGE:_CheckPlayers()
|
|||||||
|
|
||||||
if not playersettings.inzone then
|
if not playersettings.inzone then
|
||||||
playersettings.inzone=true
|
playersettings.inzone=true
|
||||||
self:EnterRange(playersettings)
|
self:EnterRange(playersettings)
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -2705,7 +2715,7 @@ function RANGE:_CheckPlayers()
|
|||||||
|
|
||||||
if playersettings.inzone==true then
|
if playersettings.inzone==true then
|
||||||
playersettings.inzone=false
|
playersettings.inzone=false
|
||||||
self:ExitRange(playersettings)
|
self:ExitRange(playersettings)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -2738,12 +2748,12 @@ function RANGE:_CheckInZone(_unitName)
|
|||||||
if towardspit then
|
if towardspit then
|
||||||
|
|
||||||
local vec3=_unit:GetVec3()
|
local vec3=_unit:GetVec3()
|
||||||
local vec2={x=vec3.x, y=vec3.z} --DCS#Vec2
|
local vec2={x=vec3.x, y=vec3.z} --DCS#Vec2
|
||||||
local landheight=land.getHeight(vec2)
|
local landheight=land.getHeight(vec2)
|
||||||
local unitalt=vec3.y-landheight
|
local unitalt=vec3.y-landheight
|
||||||
|
|
||||||
if unitalt<=self.strafemaxalt then
|
if unitalt<=self.strafemaxalt then
|
||||||
local unitinzone=zone:IsVec2InZone(vec2)
|
local unitinzone=zone:IsVec2InZone(vec2)
|
||||||
return unitinzone
|
return unitinzone
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -3008,7 +3018,7 @@ end
|
|||||||
-- Helper Functions
|
-- Helper Functions
|
||||||
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- Get the number of shells a unit currently has.
|
--- Get the coordinate of a Bomb target.
|
||||||
-- @param #RANGE self
|
-- @param #RANGE self
|
||||||
-- @param #RANGE.BombTarget target Bomb target data.
|
-- @param #RANGE.BombTarget target Bomb target data.
|
||||||
-- @return Core.Point#COORDINATE Target coordinate.
|
-- @return Core.Point#COORDINATE Target coordinate.
|
||||||
@ -3016,7 +3026,7 @@ function RANGE:_GetBombTargetCoordinate(target)
|
|||||||
|
|
||||||
local coord=nil --Core.Point#COORDINATE
|
local coord=nil --Core.Point#COORDINATE
|
||||||
|
|
||||||
if target.type==RANGE.TargetType.UNIT then
|
if target.type == RANGE.TargetType.UNIT then
|
||||||
|
|
||||||
if not target.move then
|
if not target.move then
|
||||||
-- Target should not move.
|
-- Target should not move.
|
||||||
@ -3028,12 +3038,12 @@ function RANGE:_GetBombTargetCoordinate(target)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif target.type==RANGE.TargetType.STATIC then
|
elseif target.type == RANGE.TargetType.STATIC then
|
||||||
|
|
||||||
-- Static targets dont move.
|
-- Static targets dont move.
|
||||||
coord=target.coordinate
|
coord=target.coordinate
|
||||||
|
|
||||||
elseif target.type==RANGE.TargetType.COORD then
|
elseif target.type == RANGE.TargetType.COORD then
|
||||||
|
|
||||||
-- Coordinates dont move.
|
-- Coordinates dont move.
|
||||||
coord=target.coordinate
|
coord=target.coordinate
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,52 +1,46 @@
|
|||||||
--- **Wrapper** -- STATIC wraps the DCS StaticObject class.
|
--- **Wrapper** -- STATIC wraps the DCS StaticObject class.
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- ### Author: **FlightControl**
|
-- ### Author: **FlightControl**
|
||||||
--
|
--
|
||||||
-- ### Contributions: **funkyfranky**
|
-- ### Contributions: **funkyfranky**
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
-- @module Wrapper.Static
|
-- @module Wrapper.Static
|
||||||
-- @image Wrapper_Static.JPG
|
-- @image Wrapper_Static.JPG
|
||||||
|
|
||||||
|
|
||||||
--- @type STATIC
|
--- @type STATIC
|
||||||
-- @extends Wrapper.Positionable#POSITIONABLE
|
-- @extends Wrapper.Positionable#POSITIONABLE
|
||||||
|
|
||||||
--- Wrapper class to handle Static objects.
|
--- Wrapper class to handle Static objects.
|
||||||
--
|
--
|
||||||
-- Note that Statics are almost the same as Units, but they don't have a controller.
|
-- Note that Statics are almost the same as Units, but they don't have a controller.
|
||||||
-- The @{Wrapper.Static#STATIC} class is a wrapper class to handle the DCS Static objects:
|
-- The @{Wrapper.Static#STATIC} class is a wrapper class to handle the DCS Static objects:
|
||||||
--
|
--
|
||||||
-- * Wraps the DCS Static objects.
|
-- * Wraps the DCS Static objects.
|
||||||
-- * Support all DCS Static APIs.
|
-- * Support all DCS Static APIs.
|
||||||
-- * Enhance with Static specific APIs not in the DCS API set.
|
-- * Enhance with Static specific APIs not in the DCS API set.
|
||||||
--
|
--
|
||||||
-- ## STATIC reference methods
|
-- ## STATIC reference methods
|
||||||
--
|
--
|
||||||
-- For each DCS Static will have a STATIC wrapper object (instance) within the _@{DATABASE} object.
|
-- For each DCS Static will have a STATIC wrapper object (instance) within the _@{DATABASE} object.
|
||||||
-- This is done at the beginning of the mission (when the mission starts).
|
-- This is done at the beginning of the mission (when the mission starts).
|
||||||
--
|
--
|
||||||
-- The STATIC class does not contain a :New() method, rather it provides :Find() methods to retrieve the object reference
|
-- The STATIC class does not contain a :New() method, rather it provides :Find() methods to retrieve the object reference
|
||||||
-- using the Static Name.
|
-- using the Static Name.
|
||||||
--
|
--
|
||||||
-- Another thing to know is that STATIC objects do not "contain" the DCS Static object.
|
-- Another thing to know is that STATIC objects do not "contain" the DCS Static object.
|
||||||
-- The STATIc methods will reference the DCS Static object by name when it is needed during API execution.
|
-- The STATIc methods will reference the DCS Static object by name when it is needed during API execution.
|
||||||
-- If the DCS Static object does not exist or is nil, the STATIC methods will return nil and log an exception in the DCS.log file.
|
-- If the DCS Static object does not exist or is nil, the STATIC methods will return nil and log an exception in the DCS.log file.
|
||||||
--
|
--
|
||||||
-- The STATIc class provides the following functions to retrieve quickly the relevant STATIC instance:
|
-- The STATIc class provides the following functions to retrieve quickly the relevant STATIC instance:
|
||||||
--
|
--
|
||||||
-- * @{#STATIC.FindByName}(): Find a STATIC instance from the _DATABASE object using a DCS Static name.
|
-- * @{#STATIC.FindByName}(): Find a STATIC instance from the _DATABASE object using a DCS Static name.
|
||||||
--
|
--
|
||||||
-- IMPORTANT: ONE SHOULD NEVER SANATIZE these STATIC OBJECT REFERENCES! (make the STATIC object references nil).
|
-- IMPORTANT: ONE SHOULD NEVER SANITIZE these STATIC OBJECT REFERENCES! (make the STATIC object references nil).
|
||||||
--
|
--
|
||||||
-- @field #STATIC
|
-- @field #STATIC
|
||||||
STATIC = {
|
STATIC = { ClassName = "STATIC" }
|
||||||
ClassName = "STATIC",
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
--- Register a static object.
|
--- Register a static object.
|
||||||
-- @param #STATIC self
|
-- @param #STATIC self
|
||||||
@ -58,7 +52,6 @@ function STATIC:Register( StaticName )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Finds a STATIC from the _DATABASE using a DCSStatic object.
|
--- Finds a STATIC from the _DATABASE using a DCSStatic object.
|
||||||
-- @param #STATIC self
|
-- @param #STATIC self
|
||||||
-- @param DCS#StaticObject DCSStatic An existing DCS Static object reference.
|
-- @param DCS#StaticObject DCSStatic An existing DCS Static object reference.
|
||||||
@ -83,13 +76,13 @@ function STATIC:FindByName( StaticName, RaiseError )
|
|||||||
|
|
||||||
-- Set static name.
|
-- Set static name.
|
||||||
self.StaticName = StaticName
|
self.StaticName = StaticName
|
||||||
|
|
||||||
if StaticFound then
|
if StaticFound then
|
||||||
return StaticFound
|
return StaticFound
|
||||||
end
|
end
|
||||||
|
|
||||||
if RaiseError == nil or RaiseError == true then
|
if RaiseError == nil or RaiseError == true then
|
||||||
error( "STATIC not found for: " .. StaticName )
|
error( "STATIC not found for: " .. StaticName )
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -97,38 +90,39 @@ end
|
|||||||
|
|
||||||
--- Destroys the STATIC.
|
--- Destroys the STATIC.
|
||||||
-- @param #STATIC self
|
-- @param #STATIC self
|
||||||
-- @param #boolean GenerateEvent (Optional) true if you want to generate a crash or dead event for the static.
|
-- @param #boolean GenerateEvent (Optional) true to generate a crash or dead event, false to not generate any event. `nil` (default) creates a remove event.
|
||||||
-- @return #nil The DCS StaticObject is not existing or alive.
|
-- @return #nil The DCS StaticObject is not existing or alive.
|
||||||
|
--
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- Air static example: destroy the static Helicopter and generate a S_EVENT_CRASH.
|
-- -- Air static example: destroy the static Helicopter and generate a S_EVENT_CRASH.
|
||||||
-- Helicopter = STATIC:FindByName( "Helicopter" )
|
-- Helicopter = STATIC:FindByName( "Helicopter" )
|
||||||
-- Helicopter:Destroy( true )
|
-- Helicopter:Destroy( true )
|
||||||
--
|
--
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- Ground static example: destroy the static Tank and generate a S_EVENT_DEAD.
|
-- -- Ground static example: destroy the static Tank and generate a S_EVENT_DEAD.
|
||||||
-- Tanks = UNIT:FindByName( "Tank" )
|
-- Tanks = UNIT:FindByName( "Tank" )
|
||||||
-- Tanks:Destroy( true )
|
-- Tanks:Destroy( true )
|
||||||
--
|
--
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- Ship static example: destroy the Ship silently.
|
-- -- Ship static example: destroy the Ship silently.
|
||||||
-- Ship = STATIC:FindByName( "Ship" )
|
-- Ship = STATIC:FindByName( "Ship" )
|
||||||
-- Ship:Destroy()
|
-- Ship:Destroy()
|
||||||
--
|
--
|
||||||
-- @usage
|
-- @usage
|
||||||
-- -- Destroy without event generation example.
|
-- -- Destroy without event generation example.
|
||||||
-- Ship = STATIC:FindByName( "Boat" )
|
-- Ship = STATIC:FindByName( "Boat" )
|
||||||
-- Ship:Destroy( false ) -- Don't generate an event upon destruction.
|
-- Ship:Destroy( false ) -- Don't generate any event upon destruction.
|
||||||
--
|
--
|
||||||
function STATIC:Destroy( GenerateEvent )
|
function STATIC:Destroy( GenerateEvent )
|
||||||
self:F2( self.ObjectName )
|
self:F2( self.ObjectName )
|
||||||
|
|
||||||
local DCSObject = self:GetDCSObject()
|
local DCSObject = self:GetDCSObject()
|
||||||
|
|
||||||
if DCSObject then
|
if DCSObject then
|
||||||
|
|
||||||
local StaticName = DCSObject:getName()
|
local StaticName = DCSObject:getName()
|
||||||
self:F( { StaticName = StaticName } )
|
self:F( { StaticName = StaticName } )
|
||||||
|
|
||||||
if GenerateEvent and GenerateEvent == true then
|
if GenerateEvent and GenerateEvent == true then
|
||||||
if self:IsAir() then
|
if self:IsAir() then
|
||||||
self:CreateEventCrash( timer.getTime(), DCSObject )
|
self:CreateEventCrash( timer.getTime(), DCSObject )
|
||||||
@ -140,7 +134,7 @@ function STATIC:Destroy( GenerateEvent )
|
|||||||
else
|
else
|
||||||
self:CreateEventRemoveUnit( timer.getTime(), DCSObject )
|
self:CreateEventRemoveUnit( timer.getTime(), DCSObject )
|
||||||
end
|
end
|
||||||
|
|
||||||
DCSObject:destroy()
|
DCSObject:destroy()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -148,17 +142,16 @@ function STATIC:Destroy( GenerateEvent )
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get DCS object of static of static.
|
--- Get DCS object of static of static.
|
||||||
-- @param #STATIC self
|
-- @param #STATIC self
|
||||||
-- @return DCS static object
|
-- @return DCS static object
|
||||||
function STATIC:GetDCSObject()
|
function STATIC:GetDCSObject()
|
||||||
local DCSStatic = StaticObject.getByName( self.StaticName )
|
local DCSStatic = StaticObject.getByName( self.StaticName )
|
||||||
|
|
||||||
if DCSStatic then
|
if DCSStatic then
|
||||||
return DCSStatic
|
return DCSStatic
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -170,7 +163,7 @@ function STATIC:GetUnits()
|
|||||||
local DCSStatic = self:GetDCSObject()
|
local DCSStatic = self:GetDCSObject()
|
||||||
|
|
||||||
local Statics = {}
|
local Statics = {}
|
||||||
|
|
||||||
if DCSStatic then
|
if DCSStatic then
|
||||||
Statics[1] = STATIC:Find( DCSStatic )
|
Statics[1] = STATIC:Find( DCSStatic )
|
||||||
self:T3( Statics )
|
self:T3( Statics )
|
||||||
@ -180,7 +173,6 @@ function STATIC:GetUnits()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get threat level of static.
|
--- Get threat level of static.
|
||||||
-- @param #STATIC self
|
-- @param #STATIC self
|
||||||
-- @return #number Threat level 1.
|
-- @return #number Threat level 1.
|
||||||
@ -194,66 +186,62 @@ end
|
|||||||
-- @param Core.Point#COORDINATE Coordinate The coordinate where to spawn the new Static.
|
-- @param Core.Point#COORDINATE Coordinate The coordinate where to spawn the new Static.
|
||||||
-- @param #number Heading The heading of the static respawn in degrees. Default is 0 deg.
|
-- @param #number Heading The heading of the static respawn in degrees. Default is 0 deg.
|
||||||
-- @param #number Delay Delay in seconds before the static is spawned.
|
-- @param #number Delay Delay in seconds before the static is spawned.
|
||||||
function STATIC:SpawnAt(Coordinate, Heading, Delay)
|
function STATIC:SpawnAt( Coordinate, Heading, Delay )
|
||||||
|
|
||||||
Heading=Heading or 0
|
Heading = Heading or 0
|
||||||
|
|
||||||
if Delay and Delay>0 then
|
if Delay and Delay > 0 then
|
||||||
SCHEDULER:New(nil, self.SpawnAt, {self, Coordinate, Heading}, Delay)
|
SCHEDULER:New( nil, self.SpawnAt, { self, Coordinate, Heading }, Delay )
|
||||||
else
|
else
|
||||||
|
|
||||||
local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName)
|
local SpawnStatic = SPAWNSTATIC:NewFromStatic( self.StaticName )
|
||||||
|
|
||||||
SpawnStatic:SpawnFromPointVec2( Coordinate, Heading, self.StaticName )
|
SpawnStatic:SpawnFromPointVec2( Coordinate, Heading, self.StaticName )
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Respawn the @{Wrapper.Unit} at the same location with the same properties.
|
--- Respawn the @{Wrapper.Unit} at the same location with the same properties.
|
||||||
-- This is useful to respawn a cargo after it has been destroyed.
|
-- This is useful to respawn a cargo after it has been destroyed.
|
||||||
-- @param #STATIC self
|
-- @param #STATIC self
|
||||||
-- @param DCS#country.id CountryID (Optional) The country ID used for spawning the new static. Default is same as currently.
|
-- @param DCS#country.id CountryID (Optional) The country ID used for spawning the new static. Default is same as currently.
|
||||||
-- @param #number Delay (Optional) Delay in seconds before static is respawned. Default now.
|
-- @param #number Delay (Optional) Delay in seconds before static is respawned. Default now.
|
||||||
function STATIC:ReSpawn(CountryID, Delay)
|
function STATIC:ReSpawn( CountryID, Delay )
|
||||||
|
|
||||||
if Delay and Delay>0 then
|
if Delay and Delay > 0 then
|
||||||
SCHEDULER:New(nil, self.ReSpawn, {self, CountryID}, Delay)
|
SCHEDULER:New( nil, self.ReSpawn, { self, CountryID }, Delay )
|
||||||
else
|
else
|
||||||
|
|
||||||
CountryID=CountryID or self:GetCountry()
|
CountryID = CountryID or self:GetCountry()
|
||||||
|
|
||||||
|
local SpawnStatic = SPAWNSTATIC:NewFromStatic( self.StaticName, CountryID )
|
||||||
|
|
||||||
|
SpawnStatic:Spawn( nil, self.StaticName )
|
||||||
|
|
||||||
local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName, CountryID)
|
|
||||||
|
|
||||||
SpawnStatic:Spawn(nil, self.StaticName)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Respawn the @{Wrapper.Unit} at a defined Coordinate with an optional heading.
|
--- Respawn the @{Wrapper.Unit} at a defined Coordinate with an optional heading.
|
||||||
-- @param #STATIC self
|
-- @param #STATIC self
|
||||||
-- @param Core.Point#COORDINATE Coordinate The coordinate where to spawn the new Static.
|
-- @param Core.Point#COORDINATE Coordinate The coordinate where to spawn the new Static.
|
||||||
-- @param #number Heading (Optional) The heading of the static respawn in degrees. Default the current heading.
|
-- @param #number Heading (Optional) The heading of the static respawn in degrees. Default is the current heading.
|
||||||
-- @param #number Delay (Optional) Delay in seconds before static is respawned. Default now.
|
-- @param #number Delay (Optional) Delay in seconds before static is respawned. Default is now.
|
||||||
function STATIC:ReSpawnAt(Coordinate, Heading, Delay)
|
function STATIC:ReSpawnAt( Coordinate, Heading, Delay )
|
||||||
|
|
||||||
--Heading=Heading or 0
|
-- Heading=Heading or 0
|
||||||
|
|
||||||
if Delay and Delay>0 then
|
if Delay and Delay > 0 then
|
||||||
SCHEDULER:New(nil, self.ReSpawnAt, {self, Coordinate, Heading}, Delay)
|
SCHEDULER:New( nil, self.ReSpawnAt, { self, Coordinate, Heading }, Delay )
|
||||||
else
|
else
|
||||||
|
local SpawnStatic = SPAWNSTATIC:NewFromStatic( self.StaticName, self:GetCountry() )
|
||||||
local SpawnStatic=SPAWNSTATIC:NewFromStatic(self.StaticName, self:GetCountry())
|
|
||||||
|
SpawnStatic:SpawnFromCoordinate( Coordinate, Heading, self.StaticName )
|
||||||
SpawnStatic:SpawnFromCoordinate(Coordinate, Heading, self.StaticName)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -168,9 +168,6 @@ function UNIT:GetDCSObject()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Respawn the @{Wrapper.Unit} using a (tweaked) template of the parent Group.
|
--- Respawn the @{Wrapper.Unit} using a (tweaked) template of the parent Group.
|
||||||
--
|
--
|
||||||
-- This function will:
|
-- This function will:
|
||||||
@ -263,8 +260,6 @@ function UNIT:ReSpawnAt( Coordinate, Heading )
|
|||||||
_DATABASE:Spawn( SpawnGroupTemplate )
|
_DATABASE:Spawn( SpawnGroupTemplate )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Returns if the unit is activated.
|
--- Returns if the unit is activated.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @return #boolean `true` if Unit is activated. `nil` The DCS Unit is not existing or alive.
|
-- @return #boolean `true` if Unit is activated. `nil` The DCS Unit is not existing or alive.
|
||||||
@ -301,8 +296,6 @@ function UNIT:IsAlive()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Returns the Unit's callsign - the localized string.
|
--- Returns the Unit's callsign - the localized string.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @return #string The Callsign of the Unit.
|
-- @return #string The Callsign of the Unit.
|
||||||
@ -961,7 +954,6 @@ end
|
|||||||
-- @return #string Some text.
|
-- @return #string Some text.
|
||||||
function UNIT:GetThreatLevel()
|
function UNIT:GetThreatLevel()
|
||||||
|
|
||||||
|
|
||||||
local ThreatLevel = 0
|
local ThreatLevel = 0
|
||||||
local ThreatText = ""
|
local ThreatText = ""
|
||||||
|
|
||||||
@ -987,7 +979,6 @@ function UNIT:GetThreatLevel()
|
|||||||
"LR SAMs"
|
"LR SAMs"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if Attributes["LR SAM"] then ThreatLevel = 10
|
if Attributes["LR SAM"] then ThreatLevel = 10
|
||||||
elseif Attributes["MR SAM"] then ThreatLevel = 9
|
elseif Attributes["MR SAM"] then ThreatLevel = 9
|
||||||
elseif Attributes["SR SAM"] and
|
elseif Attributes["SR SAM"] and
|
||||||
@ -1023,7 +1014,6 @@ function UNIT:GetThreatLevel()
|
|||||||
"Fighter"
|
"Fighter"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if Attributes["Fighters"] then ThreatLevel = 10
|
if Attributes["Fighters"] then ThreatLevel = 10
|
||||||
elseif Attributes["Multirole fighters"] then ThreatLevel = 9
|
elseif Attributes["Multirole fighters"] then ThreatLevel = 9
|
||||||
elseif Attributes["Battleplanes"] then ThreatLevel = 8
|
elseif Attributes["Battleplanes"] then ThreatLevel = 8
|
||||||
@ -1141,12 +1131,6 @@ function UNIT:OtherUnitInRadius( AwaitUnit, Radius )
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Returns if the unit is a friendly unit.
|
--- Returns if the unit is a friendly unit.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @return #boolean IsFriendly evaluation result.
|
-- @return #boolean IsFriendly evaluation result.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user