mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5260b2b430 | ||
|
|
0213bc7aef | ||
|
|
ca8b0899d0 | ||
|
|
a1f5c0ab9b | ||
|
|
b0e3f82d27 | ||
|
|
327ab4766b | ||
|
|
3aee8a49c1 | ||
|
|
57de0b7351 |
@@ -912,7 +912,7 @@ do -- COORDINATE
|
|||||||
-- The text will reflect the temperature like this:
|
-- The text will reflect the temperature like this:
|
||||||
--
|
--
|
||||||
-- - For Russian and European aircraft using the metric system - Degrees Celcius (°C)
|
-- - For Russian and European aircraft using the metric system - Degrees Celcius (°C)
|
||||||
-- - For American aircraft we link to the imperial system - Degrees Farenheit (°F)
|
-- - For American aircraft we link to the imperial system - Degrees Fahrenheit (°F)
|
||||||
--
|
--
|
||||||
-- A text containing a pressure will look like this:
|
-- A text containing a pressure will look like this:
|
||||||
--
|
--
|
||||||
@@ -932,7 +932,7 @@ do -- COORDINATE
|
|||||||
if Settings:IsMetric() then
|
if Settings:IsMetric() then
|
||||||
return string.format( " %-2.2f °C", DegreesCelcius )
|
return string.format( " %-2.2f °C", DegreesCelcius )
|
||||||
else
|
else
|
||||||
return string.format( " %-2.2f °F", UTILS.CelciusToFarenheit( DegreesCelcius ) )
|
return string.format( " %-2.2f °F", UTILS.CelsiusToFahrenheit( DegreesCelcius ) )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return " no temperature"
|
return " no temperature"
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
-- @module Core.Zone
|
-- @module Core.Zone
|
||||||
-- @image Core_Zones.JPG
|
-- @image Core_Zones.JPG
|
||||||
|
|
||||||
|
|
||||||
--- @type ZONE_BASE
|
--- @type ZONE_BASE
|
||||||
-- @field #string ZoneName Name of the zone.
|
-- @field #string ZoneName Name of the zone.
|
||||||
-- @field #number ZoneProbability A value between 0 and 1. 0 = 0% and 1 = 100% probability.
|
-- @field #number ZoneProbability A value between 0 and 1. 0 = 0% and 1 = 100% probability.
|
||||||
@@ -60,6 +61,7 @@
|
|||||||
-- @field #table Color Table with four entries, e.g. {1, 0, 0, 0.15}. First three are RGB color code. Fourth is the transparency Alpha value.
|
-- @field #table Color Table with four entries, e.g. {1, 0, 0, 0.15}. First three are RGB color code. Fourth is the transparency Alpha value.
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
|
|
||||||
--- This class is an abstract BASE class for derived classes, and is not meant to be instantiated.
|
--- This class is an abstract BASE class for derived classes, and is not meant to be instantiated.
|
||||||
--
|
--
|
||||||
-- ## Each zone has a name:
|
-- ## Each zone has a name:
|
||||||
@@ -106,9 +108,10 @@ ZONE_BASE = {
|
|||||||
ZoneName = "",
|
ZoneName = "",
|
||||||
ZoneProbability = 1,
|
ZoneProbability = 1,
|
||||||
DrawID=nil,
|
DrawID=nil,
|
||||||
Color = {},
|
Color={}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
--- The ZONE_BASE.BoundingSquare
|
--- The ZONE_BASE.BoundingSquare
|
||||||
-- @type ZONE_BASE.BoundingSquare
|
-- @type ZONE_BASE.BoundingSquare
|
||||||
-- @field DCS#Distance x1 The lower x coordinate (left down)
|
-- @field DCS#Distance x1 The lower x coordinate (left down)
|
||||||
@@ -116,6 +119,7 @@ ZONE_BASE = {
|
|||||||
-- @field DCS#Distance x2 The higher x coordinate (right up)
|
-- @field DCS#Distance x2 The higher x coordinate (right up)
|
||||||
-- @field DCS#Distance y2 The higher y coordinate (right up)
|
-- @field DCS#Distance y2 The higher y coordinate (right up)
|
||||||
|
|
||||||
|
|
||||||
--- ZONE_BASE constructor
|
--- ZONE_BASE constructor
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @param #string ZoneName Name of the zone.
|
-- @param #string ZoneName Name of the zone.
|
||||||
@@ -126,9 +130,13 @@ function ZONE_BASE:New( ZoneName )
|
|||||||
|
|
||||||
self.ZoneName = ZoneName
|
self.ZoneName = ZoneName
|
||||||
|
|
||||||
|
--_DATABASE:AddZone(ZoneName,self)
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Returns the name of the zone.
|
--- Returns the name of the zone.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @return #string The name of the zone.
|
-- @return #string The name of the zone.
|
||||||
@@ -138,6 +146,7 @@ function ZONE_BASE:GetName()
|
|||||||
return self.ZoneName
|
return self.ZoneName
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Sets the name of the zone.
|
--- Sets the name of the zone.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @param #string ZoneName The name of the zone.
|
-- @param #string ZoneName The name of the zone.
|
||||||
@@ -194,6 +203,7 @@ function ZONE_BASE:IsPointVec3InZone( PointVec3 )
|
|||||||
return InZone
|
return InZone
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns the @{DCS#Vec2} coordinate of the zone.
|
--- Returns the @{DCS#Vec2} coordinate of the zone.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @return #nil.
|
-- @return #nil.
|
||||||
@@ -217,6 +227,7 @@ function ZONE_BASE:GetPointVec2()
|
|||||||
return PointVec2
|
return PointVec2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns the @{DCS#Vec3} of the zone.
|
--- Returns the @{DCS#Vec3} of the zone.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @param DCS#Distance Height The height to add to the land height where the center of the zone is located.
|
-- @param DCS#Distance Height The height to add to the land height where the center of the zone is located.
|
||||||
@@ -279,6 +290,24 @@ function ZONE_BASE:GetCoordinate( Height ) -- R2.1
|
|||||||
return self.Coordinate
|
return self.Coordinate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get 2D distance to a coordinate.
|
||||||
|
-- @param #ZONE_BASE self
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate Reference coordinate. Can also be a DCS#Vec2 or DCS#Vec3 object.
|
||||||
|
-- @return #number Distance to the reference coordinate in meters.
|
||||||
|
function ZONE_BASE:Get2DDistance(Coordinate)
|
||||||
|
local a=self:GetVec2()
|
||||||
|
local b={}
|
||||||
|
if Coordinate.z then
|
||||||
|
b.x=Coordinate.x
|
||||||
|
b.y=Coordinate.z
|
||||||
|
else
|
||||||
|
b.x=Coordinate.x
|
||||||
|
b.y=Coordinate.y
|
||||||
|
end
|
||||||
|
local dist=UTILS.VecDist2D(a,b)
|
||||||
|
return dist
|
||||||
|
end
|
||||||
|
|
||||||
--- Define a random @{DCS#Vec2} within the zone.
|
--- Define a random @{DCS#Vec2} within the zone.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @return DCS#Vec2 The Vec2 coordinates.
|
-- @return DCS#Vec2 The Vec2 coordinates.
|
||||||
@@ -315,6 +344,7 @@ function ZONE_BASE:BoundZone()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set color of zone.
|
--- Set color of zone.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @param #table RGBcolor RGB color table. Default `{1, 0, 0}`.
|
-- @param #table RGBcolor RGB color table. Default `{1, 0, 0}`.
|
||||||
@@ -383,6 +413,7 @@ function ZONE_BASE:GetDrawID()
|
|||||||
return self.DrawID
|
return self.DrawID
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Smokes the zone boundaries in a color.
|
--- Smokes the zone boundaries in a color.
|
||||||
-- @param #ZONE_BASE self
|
-- @param #ZONE_BASE self
|
||||||
-- @param Utilities.Utils#SMOKECOLOR SmokeColor The smoke color.
|
-- @param Utilities.Utils#SMOKECOLOR SmokeColor The smoke color.
|
||||||
@@ -447,6 +478,7 @@ function ZONE_BASE:GetZoneMaybe()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- The ZONE_RADIUS class, defined by a zone name, a location and a radius.
|
--- The ZONE_RADIUS class, defined by a zone name, a location and a radius.
|
||||||
-- @type ZONE_RADIUS
|
-- @type ZONE_RADIUS
|
||||||
-- @field DCS#Vec2 Vec2 The current location of the zone.
|
-- @field DCS#Vec2 Vec2 The current location of the zone.
|
||||||
@@ -642,6 +674,7 @@ function ZONE_RADIUS:BoundZone( Points, CountryID, UnBound )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Smokes the zone boundaries in a color.
|
--- Smokes the zone boundaries in a color.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param Utilities.Utils#SMOKECOLOR SmokeColor The smoke color.
|
-- @param Utilities.Utils#SMOKECOLOR SmokeColor The smoke color.
|
||||||
@@ -673,6 +706,7 @@ function ZONE_RADIUS:SmokeZone( SmokeColor, Points, AddHeight, AngleOffset )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Flares the zone boundaries in a color.
|
--- Flares the zone boundaries in a color.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param Utilities.Utils#FLARECOLOR FlareColor The flare color.
|
-- @param Utilities.Utils#FLARECOLOR FlareColor The flare color.
|
||||||
@@ -769,6 +803,10 @@ function ZONE_RADIUS:GetVec3( Height )
|
|||||||
return Vec3
|
return Vec3
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Scan the zone for the presence of units of the given ObjectCategories.
|
--- Scan the zone for the presence of units of the given ObjectCategories.
|
||||||
-- Note that after a zone has been scanned, the zone can be evaluated by:
|
-- Note that after a zone has been scanned, the zone can be evaluated by:
|
||||||
--
|
--
|
||||||
@@ -801,7 +839,7 @@ function ZONE_RADIUS:Scan( ObjectCategories, UnitCategories )
|
|||||||
params = {
|
params = {
|
||||||
point = ZoneCoord:GetVec3(),
|
point = ZoneCoord:GetVec3(),
|
||||||
radius = ZoneRadius,
|
radius = ZoneRadius,
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local function EvaluateZone( ZoneObject )
|
local function EvaluateZone( ZoneObject )
|
||||||
@@ -874,6 +912,7 @@ function ZONE_RADIUS:GetScannedUnits()
|
|||||||
return self.ScanData.Units
|
return self.ScanData.Units
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get a set of scanned units.
|
--- Get a set of scanned units.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @return Core.Set#SET_UNIT Set of units and statics inside the zone.
|
-- @return Core.Set#SET_UNIT Set of units and statics inside the zone.
|
||||||
@@ -927,6 +966,7 @@ function ZONE_RADIUS:GetScannedSetGroup()
|
|||||||
return self.ScanSetGroup
|
return self.ScanSetGroup
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Count the number of different coalitions inside the zone.
|
--- Count the number of different coalitions inside the zone.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @return #number Counted coalitions.
|
-- @return #number Counted coalitions.
|
||||||
@@ -979,6 +1019,7 @@ function ZONE_RADIUS:GetScannedCoalition( Coalition )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get scanned scenery type
|
--- Get scanned scenery type
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @return #table Table of DCS scenery type objects.
|
-- @return #table Table of DCS scenery type objects.
|
||||||
@@ -986,6 +1027,7 @@ function ZONE_RADIUS:GetScannedSceneryType( SceneryType )
|
|||||||
return self.ScanData.Scenery[SceneryType]
|
return self.ScanData.Scenery[SceneryType]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get scanned scenery table
|
--- Get scanned scenery table
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @return #table Table of DCS scenery objects.
|
-- @return #table Table of DCS scenery objects.
|
||||||
@@ -993,8 +1035,9 @@ function ZONE_RADIUS:GetScannedScenery()
|
|||||||
return self.ScanData.Scenery
|
return self.ScanData.Scenery
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Is All in Zone of Coalition?
|
--- Is All in Zone of Coalition?
|
||||||
-- Check if only the specified coalition is inside the zone and noone else.
|
-- Check if only the specifed coalition is inside the zone and noone else.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param #number Coalition Coalition ID of the coalition which is checked to be the only one in the zone.
|
-- @param #number Coalition Coalition ID of the coalition which is checked to be the only one in the zone.
|
||||||
-- @return #boolean True, if **only** that coalition is inside the zone and no one else.
|
-- @return #boolean True, if **only** that coalition is inside the zone and no one else.
|
||||||
@@ -1007,6 +1050,7 @@ function ZONE_RADIUS:IsAllInZoneOfCoalition( Coalition )
|
|||||||
return self:CountScannedCoalitions() == 1 and self:GetScannedCoalition( Coalition ) == true
|
return self:CountScannedCoalitions() == 1 and self:GetScannedCoalition( Coalition ) == true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Is All in Zone of Other Coalition?
|
--- Is All in Zone of Other Coalition?
|
||||||
-- Check if only one coalition is inside the zone and the specified coalition is not the one.
|
-- Check if only one coalition is inside the zone and the specified coalition is not the one.
|
||||||
-- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated!
|
-- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated!
|
||||||
@@ -1023,23 +1067,23 @@ function ZONE_RADIUS:IsAllInZoneOfOtherCoalition( Coalition )
|
|||||||
return self:CountScannedCoalitions() == 1 and self:GetScannedCoalition( Coalition ) == nil
|
return self:CountScannedCoalitions() == 1 and self:GetScannedCoalition( Coalition ) == nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Is Some in Zone of Coalition?
|
--- Is Some in Zone of Coalition?
|
||||||
-- Check if more than one coalition is inside the zone and the specified coalition is one of them.
|
-- Check if more than one coaltion is inside the zone and the specifed coalition is one of them.
|
||||||
-- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated!
|
-- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated!
|
||||||
-- Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.
|
-- Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param #number Coalition ID of the coalition which is checked to be inside the zone.
|
-- @param #number Coalition ID of the coaliton which is checked to be inside the zone.
|
||||||
-- @return #boolean True if more than one coalition is inside the zone and the specified coalition is one of them.
|
-- @return #boolean True if more than one coalition is inside the zone and the specified coalition is one of them.
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
|
||||||
-- self.Zone:Scan()
|
-- self.Zone:Scan()
|
||||||
-- local IsAttacked = self.Zone:IsSomeInZoneOfCoalition( self.Coalition )
|
-- local IsAttacked = self.Zone:IsSomeInZoneOfCoalition( self.Coalition )
|
||||||
--
|
|
||||||
function ZONE_RADIUS:IsSomeInZoneOfCoalition( Coalition )
|
function ZONE_RADIUS:IsSomeInZoneOfCoalition( Coalition )
|
||||||
|
|
||||||
return self:CountScannedCoalitions() > 1 and self:GetScannedCoalition( Coalition ) == true
|
return self:CountScannedCoalitions() > 1 and self:GetScannedCoalition( Coalition ) == true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Is None in Zone of Coalition?
|
--- Is None in Zone of Coalition?
|
||||||
-- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated!
|
-- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated!
|
||||||
-- Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.
|
-- Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.
|
||||||
@@ -1047,30 +1091,30 @@ end
|
|||||||
-- @param Coalition
|
-- @param Coalition
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
|
||||||
-- self.Zone:Scan()
|
-- self.Zone:Scan()
|
||||||
-- local IsOccupied = self.Zone:IsNoneInZoneOfCoalition( self.Coalition )
|
-- local IsOccupied = self.Zone:IsNoneInZoneOfCoalition( self.Coalition )
|
||||||
--
|
|
||||||
function ZONE_RADIUS:IsNoneInZoneOfCoalition( Coalition )
|
function ZONE_RADIUS:IsNoneInZoneOfCoalition( Coalition )
|
||||||
|
|
||||||
return self:GetScannedCoalition( Coalition ) == nil
|
return self:GetScannedCoalition( Coalition ) == nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Is None in Zone?
|
--- Is None in Zone?
|
||||||
-- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated!
|
-- You first need to use the @{#ZONE_RADIUS.Scan} method to scan the zone before it can be evaluated!
|
||||||
-- Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.
|
-- Note that once a zone has been scanned, multiple evaluations can be done on the scan result set.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
-- @usage
|
-- @usage
|
||||||
--
|
|
||||||
-- self.Zone:Scan()
|
-- self.Zone:Scan()
|
||||||
-- local IsEmpty = self.Zone:IsNoneInZone()
|
-- local IsEmpty = self.Zone:IsNoneInZone()
|
||||||
--
|
|
||||||
function ZONE_RADIUS:IsNoneInZone()
|
function ZONE_RADIUS:IsNoneInZone()
|
||||||
|
|
||||||
return self:CountScannedCoalitions() == 0
|
return self:CountScannedCoalitions() == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Searches the zone
|
--- Searches the zone
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param ObjectCategories A list of categories, which are members of Object.Category
|
-- @param ObjectCategories A list of categories, which are members of Object.Category
|
||||||
@@ -1089,11 +1133,12 @@ function ZONE_RADIUS:SearchZone( EvaluateFunction, ObjectCategories )
|
|||||||
params = {
|
params = {
|
||||||
point = ZoneCoord:GetVec3(),
|
point = ZoneCoord:GetVec3(),
|
||||||
radius = ZoneRadius / 2,
|
radius = ZoneRadius / 2,
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local function EvaluateZone( ZoneDCSUnit )
|
local function EvaluateZone( ZoneDCSUnit )
|
||||||
|
|
||||||
|
|
||||||
local ZoneUnit = UNIT:Find( ZoneDCSUnit )
|
local ZoneUnit = UNIT:Find( ZoneDCSUnit )
|
||||||
|
|
||||||
return EvaluateFunction( ZoneUnit )
|
return EvaluateFunction( ZoneUnit )
|
||||||
@@ -1135,24 +1180,54 @@ end
|
|||||||
|
|
||||||
--- Returns a random Vec2 location within the zone.
|
--- Returns a random Vec2 location within the zone.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
-- @param #number inner (Optional) Minimal distance from the center of the zone. Default is 0.
|
||||||
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
-- @param #number outer (Optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
||||||
|
-- @param #table surfacetypes (Optional) Table of surface types. Can also be a single surface type. We will try max 100 times to find the right type!
|
||||||
-- @return DCS#Vec2 The random location within the zone.
|
-- @return DCS#Vec2 The random location within the zone.
|
||||||
function ZONE_RADIUS:GetRandomVec2( inner, outer )
|
function ZONE_RADIUS:GetRandomVec2(inner, outer, surfacetypes)
|
||||||
self:F( self.ZoneName, inner, outer )
|
|
||||||
|
|
||||||
local Point = {}
|
|
||||||
local Vec2 = self:GetVec2()
|
local Vec2 = self:GetVec2()
|
||||||
local _inner = inner or 0
|
local _inner = inner or 0
|
||||||
local _outer = outer or self:GetRadius()
|
local _outer = outer or self:GetRadius()
|
||||||
|
|
||||||
local angle = math.random() * math.pi * 2;
|
if surfacetypes and type(surfacetypes)~="table" then
|
||||||
Point.x = Vec2.x + math.cos( angle ) * math.random( _inner, _outer );
|
surfacetypes={surfacetypes}
|
||||||
Point.y = Vec2.y + math.sin( angle ) * math.random( _inner, _outer );
|
end
|
||||||
|
|
||||||
self:T( { Point } )
|
local function _getpoint()
|
||||||
|
local point = {}
|
||||||
|
local angle = math.random() * math.pi * 2
|
||||||
|
point.x = Vec2.x + math.cos(angle) * math.random(_inner, _outer)
|
||||||
|
point.y = Vec2.y + math.sin(angle) * math.random(_inner, _outer)
|
||||||
|
return point
|
||||||
|
end
|
||||||
|
|
||||||
return Point
|
local function _checkSurface(point)
|
||||||
|
local stype=land.getSurfaceType(point)
|
||||||
|
for _,sf in pairs(surfacetypes) do
|
||||||
|
if sf==stype then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local point=_getpoint()
|
||||||
|
|
||||||
|
if surfacetypes then
|
||||||
|
local N=1 ; local Nmax=100 ; local gotit=false
|
||||||
|
while gotit==false and N<=Nmax do
|
||||||
|
gotit=_checkSurface(point)
|
||||||
|
if gotit then
|
||||||
|
--env.info(string.format("Got random coordinate with surface type %d after N=%d/%d iterations", land.getSurfaceType(point), N, Nmax))
|
||||||
|
else
|
||||||
|
point=_getpoint()
|
||||||
|
N=N+1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return point
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns a @{Core.Point#POINT_VEC2} object reflecting a random 2D location within the zone.
|
--- Returns a @{Core.Point#POINT_VEC2} object reflecting a random 2D location within the zone.
|
||||||
@@ -1185,6 +1260,7 @@ function ZONE_RADIUS:GetRandomVec3( inner, outer )
|
|||||||
return { x = Vec2.x, y = self.y, z = Vec2.y }
|
return { x = Vec2.x, y = self.y, z = Vec2.y }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns a @{Core.Point#POINT_VEC3} object reflecting a random 3D location within the zone.
|
--- Returns a @{Core.Point#POINT_VEC3} object reflecting a random 3D location within the zone.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
||||||
@@ -1200,24 +1276,28 @@ function ZONE_RADIUS:GetRandomPointVec3( inner, outer )
|
|||||||
return PointVec3
|
return PointVec3
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns a @{Core.Point#COORDINATE} object reflecting a random 3D location within the zone.
|
--- Returns a @{Core.Point#COORDINATE} object reflecting a random 3D location within the zone.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
-- @param #number inner (Optional) Minimal distance from the center of the zone. Default is 0.
|
||||||
-- @param #number outer (optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
-- @param #number outer (Optional) Maximal distance from the outer edge of the zone. Default is the radius of the zone.
|
||||||
-- @return Core.Point#COORDINATE
|
-- @param #table surfacetypes (Optional) Table of surface types. Can also be a single surface type. We will try max 1000 times to find the right type!
|
||||||
function ZONE_RADIUS:GetRandomCoordinate( inner, outer )
|
-- @return Core.Point#COORDINATE The random coordinate.
|
||||||
self:F( self.ZoneName, inner, outer )
|
function ZONE_RADIUS:GetRandomCoordinate(inner, outer, surfacetypes)
|
||||||
|
|
||||||
local Coordinate = COORDINATE:NewFromVec2( self:GetRandomVec2( inner, outer ) )
|
local vec2=self:GetRandomVec2(inner, outer, surfacetypes)
|
||||||
|
|
||||||
self:T3( { Coordinate = Coordinate } )
|
local Coordinate = COORDINATE:NewFromVec2(vec2)
|
||||||
|
|
||||||
return Coordinate
|
return Coordinate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- @type ZONE
|
--- @type ZONE
|
||||||
-- @extends #ZONE_RADIUS
|
-- @extends #ZONE_RADIUS
|
||||||
|
|
||||||
|
|
||||||
--- The ZONE class, defined by the zone name as defined within the Mission Editor.
|
--- The ZONE class, defined by the zone name as defined within the Mission Editor.
|
||||||
-- This class implements the inherited functions from @{#ZONE_RADIUS} taking into account the own zone format and properties.
|
-- This class implements the inherited functions from @{#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||||
--
|
--
|
||||||
@@ -1250,6 +1330,7 @@ ZONE = {
|
|||||||
ClassName="ZONE",
|
ClassName="ZONE",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
--- Constructor of ZONE taking the zone name.
|
--- Constructor of ZONE taking the zone name.
|
||||||
-- @param #ZONE self
|
-- @param #ZONE self
|
||||||
-- @param #string ZoneName The name of the zone as defined within the mission editor.
|
-- @param #string ZoneName The name of the zone as defined within the mission editor.
|
||||||
@@ -1269,7 +1350,7 @@ function ZONE:New( ZoneName )
|
|||||||
|
|
||||||
-- Error!
|
-- Error!
|
||||||
if not Zone then
|
if not Zone then
|
||||||
error( "Zone " .. ZoneName .. " does not exist." )
|
env.error( "ERROR: Zone " .. ZoneName .. " does not exist!" )
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1296,10 +1377,13 @@ function ZONE:FindByName( ZoneName )
|
|||||||
return ZoneFound
|
return ZoneFound
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- @type ZONE_UNIT
|
--- @type ZONE_UNIT
|
||||||
-- @field Wrapper.Unit#UNIT ZoneUNIT
|
-- @field Wrapper.Unit#UNIT ZoneUNIT
|
||||||
-- @extends Core.Zone#ZONE_RADIUS
|
-- @extends Core.Zone#ZONE_RADIUS
|
||||||
|
|
||||||
|
|
||||||
--- # ZONE_UNIT class, extends @{Zone#ZONE_RADIUS}
|
--- # ZONE_UNIT class, extends @{Zone#ZONE_RADIUS}
|
||||||
--
|
--
|
||||||
-- The ZONE_UNIT class defined by a zone attached to a @{Wrapper.Unit#UNIT} with a radius and optional offsets.
|
-- The ZONE_UNIT class defined by a zone attached to a @{Wrapper.Unit#UNIT} with a radius and optional offsets.
|
||||||
@@ -1351,6 +1435,7 @@ function ZONE_UNIT:New( ZoneName, ZoneUNIT, Radius, Offset )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns the current location of the @{Wrapper.Unit#UNIT}.
|
--- Returns the current location of the @{Wrapper.Unit#UNIT}.
|
||||||
-- @param #ZONE_UNIT self
|
-- @param #ZONE_UNIT self
|
||||||
-- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Unit#UNIT}location and the offset, if any.
|
-- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Unit#UNIT}location and the offset, if any.
|
||||||
@@ -1437,6 +1522,7 @@ end
|
|||||||
--- @type ZONE_GROUP
|
--- @type ZONE_GROUP
|
||||||
-- @extends #ZONE_RADIUS
|
-- @extends #ZONE_RADIUS
|
||||||
|
|
||||||
|
|
||||||
--- The ZONE_GROUP class defines by a zone around a @{Wrapper.Group#GROUP} with a radius. The current leader of the group defines the center of the zone.
|
--- The ZONE_GROUP class defines by a zone around a @{Wrapper.Group#GROUP} with a radius. The current leader of the group defines the center of the zone.
|
||||||
-- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
-- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||||
--
|
--
|
||||||
@@ -1464,6 +1550,7 @@ function ZONE_GROUP:New( ZoneName, ZoneGROUP, Radius )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns the current location of the @{Wrapper.Group}.
|
--- Returns the current location of the @{Wrapper.Group}.
|
||||||
-- @param #ZONE_GROUP self
|
-- @param #ZONE_GROUP self
|
||||||
-- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Group} location.
|
-- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Group} location.
|
||||||
@@ -1517,10 +1604,12 @@ function ZONE_GROUP:GetRandomPointVec2( inner, outer )
|
|||||||
return PointVec2
|
return PointVec2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- @type ZONE_POLYGON_BASE
|
--- @type ZONE_POLYGON_BASE
|
||||||
-- --@field #ZONE_POLYGON_BASE.ListVec2 Polygon The polygon defined by an array of @{DCS#Vec2}.
|
-- --@field #ZONE_POLYGON_BASE.ListVec2 Polygon The polygon defined by an array of @{DCS#Vec2}.
|
||||||
-- @extends #ZONE_BASE
|
-- @extends #ZONE_BASE
|
||||||
|
|
||||||
|
|
||||||
--- The ZONE_POLYGON_BASE class defined by a sequence of @{Wrapper.Group#GROUP} waypoints within the Mission Editor, forming a polygon.
|
--- The ZONE_POLYGON_BASE class defined by a sequence of @{Wrapper.Group#GROUP} waypoints within the Mission Editor, forming a polygon.
|
||||||
-- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
-- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||||
-- This class is an abstract BASE class for derived classes, and is not meant to be instantiated.
|
-- This class is an abstract BASE class for derived classes, and is not meant to be instantiated.
|
||||||
@@ -1658,6 +1747,7 @@ function ZONE_POLYGON_BASE:GetVertexCoordinate( Index )
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get a list of verticies of the polygon.
|
--- Get a list of verticies of the polygon.
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @return <DCS#Vec2> List of DCS#Vec2 verticies defining the edges of the polygon.
|
-- @return <DCS#Vec2> List of DCS#Vec2 verticies defining the edges of the polygon.
|
||||||
@@ -1753,6 +1843,7 @@ function ZONE_POLYGON_BASE:BoundZone( UnBound )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Draw the zone on the F10 map. **NOTE** Currently, only polygons with **exactly four points** are supported!
|
--- Draw the zone on the F10 map. **NOTE** Currently, only polygons with **exactly four points** are supported!
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
|
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
|
||||||
@@ -1772,6 +1863,7 @@ function ZONE_POLYGON_BASE:DrawZone( Coalition, Color, Alpha, FillColor, FillAlp
|
|||||||
FillColor=FillColor or Color
|
FillColor=FillColor or Color
|
||||||
FillAlpha=FillAlpha or self:GetColorAlpha()
|
FillAlpha=FillAlpha or self:GetColorAlpha()
|
||||||
|
|
||||||
|
|
||||||
if #self._.Polygon==4 then
|
if #self._.Polygon==4 then
|
||||||
|
|
||||||
local Coord2=COORDINATE:NewFromVec2(self._.Polygon[2])
|
local Coord2=COORDINATE:NewFromVec2(self._.Polygon[2])
|
||||||
@@ -1789,6 +1881,7 @@ function ZONE_POLYGON_BASE:DrawZone( Coalition, Color, Alpha, FillColor, FillAlp
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1823,6 +1916,7 @@ function ZONE_POLYGON_BASE:SmokeZone( SmokeColor, Segments )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Flare the zone boundaries in a color.
|
--- Flare the zone boundaries in a color.
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @param Utilities.Utils#FLARECOLOR FlareColor The flare color.
|
-- @param Utilities.Utils#FLARECOLOR FlareColor The flare color.
|
||||||
@@ -1858,6 +1952,9 @@ function ZONE_POLYGON_BASE:FlareZone( FlareColor, Segments, Azimuth, AddHeight )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Returns if a location is within the zone.
|
--- Returns if a location is within the zone.
|
||||||
-- Source learned and taken from: https://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
|
-- Source learned and taken from: https://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
@@ -1876,7 +1973,8 @@ function ZONE_POLYGON_BASE:IsVec2InZone( Vec2 )
|
|||||||
while Next <= #self._.Polygon do
|
while Next <= #self._.Polygon do
|
||||||
self:T( { Next, Prev, self._.Polygon[Next], self._.Polygon[Prev] } )
|
self:T( { Next, Prev, self._.Polygon[Next], self._.Polygon[Prev] } )
|
||||||
if ( ( ( self._.Polygon[Next].y > Vec2.y ) ~= ( self._.Polygon[Prev].y > Vec2.y ) ) and
|
if ( ( ( self._.Polygon[Next].y > Vec2.y ) ~= ( self._.Polygon[Prev].y > Vec2.y ) ) and
|
||||||
(Vec2.x < (self._.Polygon[Prev].x - self._.Polygon[Next].x) * (Vec2.y - self._.Polygon[Next].y) / (self._.Polygon[Prev].y - self._.Polygon[Next].y) + self._.Polygon[Next].x)) then
|
( Vec2.x < ( self._.Polygon[Prev].x - self._.Polygon[Next].x ) * ( Vec2.y - self._.Polygon[Next].y ) / ( self._.Polygon[Prev].y - self._.Polygon[Next].y ) + self._.Polygon[Next].x )
|
||||||
|
) then
|
||||||
InPolygon = not InPolygon
|
InPolygon = not InPolygon
|
||||||
end
|
end
|
||||||
self:T2( { InPolygon = InPolygon } )
|
self:T2( { InPolygon = InPolygon } )
|
||||||
@@ -1892,28 +1990,30 @@ end
|
|||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @return DCS#Vec2 The Vec2 coordinate.
|
-- @return DCS#Vec2 The Vec2 coordinate.
|
||||||
function ZONE_POLYGON_BASE:GetRandomVec2()
|
function ZONE_POLYGON_BASE:GetRandomVec2()
|
||||||
self:F2()
|
|
||||||
|
|
||||||
--- It is a bit tricky to find a random point within a polygon. Right now i am doing it the dirty and inefficient way...
|
-- It is a bit tricky to find a random point within a polygon. Right now i am doing it the dirty and inefficient way...
|
||||||
local Vec2Found = false
|
|
||||||
local Vec2
|
-- Get the bounding square.
|
||||||
local BS = self:GetBoundingSquare()
|
local BS = self:GetBoundingSquare()
|
||||||
|
|
||||||
self:T2( BS )
|
local Nmax=1000 ; local n=0
|
||||||
|
while n<Nmax do
|
||||||
|
|
||||||
while Vec2Found == false do
|
-- Random point in the bounding square.
|
||||||
Vec2 = { x = math.random( BS.x1, BS.x2 ), y = math.random( BS.y1, BS.y2 ) }
|
local Vec2={x=math.random(BS.x1, BS.x2), y=math.random(BS.y1, BS.y2)}
|
||||||
self:T2( Vec2 )
|
|
||||||
|
-- Check if this is in the polygon.
|
||||||
if self:IsVec2InZone(Vec2) then
|
if self:IsVec2InZone(Vec2) then
|
||||||
Vec2Found = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self:T2( Vec2 )
|
|
||||||
|
|
||||||
return Vec2
|
return Vec2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
n=n+1
|
||||||
|
end
|
||||||
|
|
||||||
|
self:E("Could not find a random point in the polygon zone!")
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
--- Return a @{Core.Point#POINT_VEC2} object representing a random 2D point at landheight within the zone.
|
--- Return a @{Core.Point#POINT_VEC2} object representing a random 2D point at landheight within the zone.
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @return @{Core.Point#POINT_VEC2}
|
-- @return @{Core.Point#POINT_VEC2}
|
||||||
@@ -1940,6 +2040,7 @@ function ZONE_POLYGON_BASE:GetRandomPointVec3()
|
|||||||
return PointVec3
|
return PointVec3
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Return a @{Core.Point#COORDINATE} object representing a random 3D point at landheight within the zone.
|
--- Return a @{Core.Point#COORDINATE} object representing a random 3D point at landheight within the zone.
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @return Core.Point#COORDINATE
|
-- @return Core.Point#COORDINATE
|
||||||
@@ -1953,6 +2054,7 @@ function ZONE_POLYGON_BASE:GetRandomCoordinate()
|
|||||||
return Coordinate
|
return Coordinate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get the bounding square the zone.
|
--- Get the bounding square the zone.
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @return #ZONE_POLYGON_BASE.BoundingSquare The bounding square.
|
-- @return #ZONE_POLYGON_BASE.BoundingSquare The bounding square.
|
||||||
@@ -2018,17 +2120,18 @@ end
|
|||||||
--- @type ZONE_POLYGON
|
--- @type ZONE_POLYGON
|
||||||
-- @extends #ZONE_POLYGON_BASE
|
-- @extends #ZONE_POLYGON_BASE
|
||||||
|
|
||||||
|
|
||||||
--- The ZONE_POLYGON class defined by a sequence of @{Wrapper.Group#GROUP} waypoints within the Mission Editor, forming a polygon.
|
--- The ZONE_POLYGON class defined by a sequence of @{Wrapper.Group#GROUP} waypoints within the Mission Editor, forming a polygon.
|
||||||
-- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
-- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||||
--
|
--
|
||||||
-- ## Declare a ZONE_POLYGON directly in the DCS mission editor!
|
-- ## Declare a ZONE_POLYGON directly in the DCS mission editor!
|
||||||
--
|
--
|
||||||
-- You can declare a ZONE_POLYGON using the DCS mission editor by adding the ~ZONE_POLYGON tag in the group name.
|
-- You can declare a ZONE_POLYGON using the DCS mission editor by adding the #ZONE_POLYGON tag in the group name.
|
||||||
--
|
--
|
||||||
-- So, imagine you have a group declared in the mission editor, with group name `DefenseZone~ZONE_POLYGON`.
|
-- So, imagine you have a group declared in the mission editor, with group name `DefenseZone#ZONE_POLYGON`.
|
||||||
-- Then during mission startup, when loading Moose.lua, this group will be detected as a ZONE_POLYGON declaration.
|
-- Then during mission startup, when loading Moose.lua, this group will be detected as a ZONE_POLYGON declaration.
|
||||||
-- Within the background, a ZONE_POLYGON object will be created within the @{Core.Database} using the properties of the group.
|
-- Within the background, a ZONE_POLYGON object will be created within the @{Core.Database} using the properties of the group.
|
||||||
-- The ZONE_POLYGON name will be the group name without the ~ZONE_POLYGON tag.
|
-- The ZONE_POLYGON name will be the group name without the #ZONE_POLYGON tag.
|
||||||
--
|
--
|
||||||
-- So, you can search yourself for the ZONE_POLYGON by using the @{#ZONE_POLYGON.FindByName}() method.
|
-- So, you can search yourself for the ZONE_POLYGON by using the @{#ZONE_POLYGON.FindByName}() method.
|
||||||
-- In this example, `local PolygonZone = ZONE_POLYGON:FindByName( "DefenseZone" )` would return the ZONE_POLYGON object
|
-- In this example, `local PolygonZone = ZONE_POLYGON:FindByName( "DefenseZone" )` would return the ZONE_POLYGON object
|
||||||
@@ -2065,6 +2168,7 @@ function ZONE_POLYGON:New( ZoneName, ZoneGroup )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Constructor to create a ZONE_POLYGON instance, taking the zone name and the **name** of the @{Wrapper.Group#GROUP} defined within the Mission Editor.
|
--- Constructor to create a ZONE_POLYGON instance, taking the zone name and the **name** of the @{Wrapper.Group#GROUP} defined within the Mission Editor.
|
||||||
-- The @{Wrapper.Group#GROUP} waypoints define the polygon corners. The first and the last point are automatically connected by ZONE_POLYGON.
|
-- The @{Wrapper.Group#GROUP} waypoints define the polygon corners. The first and the last point are automatically connected by ZONE_POLYGON.
|
||||||
-- @param #ZONE_POLYGON self
|
-- @param #ZONE_POLYGON self
|
||||||
@@ -2085,6 +2189,7 @@ function ZONE_POLYGON:NewFromGroupName( GroupName )
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Find a polygon zone in the _DATABASE using the name of the polygon zone.
|
--- Find a polygon zone in the _DATABASE using the name of the polygon zone.
|
||||||
-- @param #ZONE_POLYGON self
|
-- @param #ZONE_POLYGON self
|
||||||
-- @param #string ZoneName The name of the polygon zone.
|
-- @param #string ZoneName The name of the polygon zone.
|
||||||
@@ -2098,8 +2203,12 @@ end
|
|||||||
do -- ZONE_AIRBASE
|
do -- ZONE_AIRBASE
|
||||||
|
|
||||||
--- @type ZONE_AIRBASE
|
--- @type ZONE_AIRBASE
|
||||||
|
-- @field #boolean isShip If `true`, airbase is a ship.
|
||||||
|
-- @field #boolean isHelipad If `true`, airbase is a helipad.
|
||||||
|
-- @field #boolean isAirdrome If `true`, airbase is an airdrome.
|
||||||
-- @extends #ZONE_RADIUS
|
-- @extends #ZONE_RADIUS
|
||||||
|
|
||||||
|
|
||||||
--- The ZONE_AIRBASE class defines by a zone around a @{Wrapper.Airbase#AIRBASE} with a radius.
|
--- The ZONE_AIRBASE class defines by a zone around a @{Wrapper.Airbase#AIRBASE} with a radius.
|
||||||
-- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
-- This class implements the inherited functions from @{Core.Zone#ZONE_RADIUS} taking into account the own zone format and properties.
|
||||||
--
|
--
|
||||||
@@ -2108,6 +2217,8 @@ do -- ZONE_AIRBASE
|
|||||||
ClassName="ZONE_AIRBASE",
|
ClassName="ZONE_AIRBASE",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Constructor to create a ZONE_AIRBASE instance, taking the zone name, a zone @{Wrapper.Airbase#AIRBASE} and a radius.
|
--- Constructor to create a ZONE_AIRBASE instance, taking the zone name, a zone @{Wrapper.Airbase#AIRBASE} and a radius.
|
||||||
-- @param #ZONE_AIRBASE self
|
-- @param #ZONE_AIRBASE self
|
||||||
-- @param #string AirbaseName Name of the airbase.
|
-- @param #string AirbaseName Name of the airbase.
|
||||||
@@ -2124,6 +2235,20 @@ do -- ZONE_AIRBASE
|
|||||||
self._.ZoneAirbase = Airbase
|
self._.ZoneAirbase = Airbase
|
||||||
self._.ZoneVec2Cache = self._.ZoneAirbase:GetVec2()
|
self._.ZoneVec2Cache = self._.ZoneAirbase:GetVec2()
|
||||||
|
|
||||||
|
if Airbase:IsShip() then
|
||||||
|
self.isShip=true
|
||||||
|
self.isHelipad=false
|
||||||
|
self.isAirdrome=false
|
||||||
|
elseif Airbase:IsHelipad() then
|
||||||
|
self.isShip=false
|
||||||
|
self.isHelipad=true
|
||||||
|
self.isAirdrome=false
|
||||||
|
elseif Airbase:IsAirdrome() then
|
||||||
|
self.isShip=false
|
||||||
|
self.isHelipad=false
|
||||||
|
self.isAirdrome=true
|
||||||
|
end
|
||||||
|
|
||||||
-- Zone objects are added to the _DATABASE and SET_ZONE objects.
|
-- Zone objects are added to the _DATABASE and SET_ZONE objects.
|
||||||
_EVENTDISPATCHER:CreateEventNewZone( self )
|
_EVENTDISPATCHER:CreateEventNewZone( self )
|
||||||
|
|
||||||
@@ -2137,9 +2262,9 @@ do -- ZONE_AIRBASE
|
|||||||
return self._.ZoneAirbase
|
return self._.ZoneAirbase
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the current location of the @{Wrapper.Group}.
|
--- Returns the current location of the AIRBASE.
|
||||||
-- @param #ZONE_AIRBASE self
|
-- @param #ZONE_AIRBASE self
|
||||||
-- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Group} location.
|
-- @return DCS#Vec2 The location of the zone based on the AIRBASE location.
|
||||||
function ZONE_AIRBASE:GetVec2()
|
function ZONE_AIRBASE:GetVec2()
|
||||||
self:F( self.ZoneName )
|
self:F( self.ZoneName )
|
||||||
|
|
||||||
@@ -2157,24 +2282,6 @@ do -- ZONE_AIRBASE
|
|||||||
return ZoneVec2
|
return ZoneVec2
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns a random location within the zone of the @{Wrapper.Group}.
|
|
||||||
-- @param #ZONE_AIRBASE self
|
|
||||||
-- @return DCS#Vec2 The random location of the zone based on the @{Wrapper.Group} location.
|
|
||||||
function ZONE_AIRBASE:GetRandomVec2()
|
|
||||||
self:F( self.ZoneName )
|
|
||||||
|
|
||||||
local Point = {}
|
|
||||||
local Vec2 = self._.ZoneAirbase:GetVec2()
|
|
||||||
|
|
||||||
local angle = math.random() * math.pi * 2;
|
|
||||||
Point.x = Vec2.x + math.cos( angle ) * math.random() * self:GetRadius();
|
|
||||||
Point.y = Vec2.y + math.sin( angle ) * math.random() * self:GetRadius();
|
|
||||||
|
|
||||||
self:T( { Point } )
|
|
||||||
|
|
||||||
return Point
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns a @{Core.Point#POINT_VEC2} object reflecting a random 2D location within the zone.
|
--- Returns a @{Core.Point#POINT_VEC2} object reflecting a random 2D location within the zone.
|
||||||
-- @param #ZONE_AIRBASE self
|
-- @param #ZONE_AIRBASE self
|
||||||
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
-- @param #number inner (optional) Minimal distance from the center of the zone. Default is 0.
|
||||||
@@ -2190,4 +2297,5 @@ do -- ZONE_AIRBASE
|
|||||||
return PointVec2
|
return PointVec2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2755,7 +2755,7 @@ function RANGE:_DisplayRangeWeather( _unitname )
|
|||||||
local tW = string.format( "%.1f m/s", Ws )
|
local tW = string.format( "%.1f m/s", Ws )
|
||||||
local tP = string.format( "%.1f mmHg", P * hPa2mmHg )
|
local tP = string.format( "%.1f mmHg", P * hPa2mmHg )
|
||||||
if settings:IsImperial() then
|
if settings:IsImperial() then
|
||||||
-- tT=string.format("%d°F", UTILS.CelciusToFarenheit(T))
|
-- tT=string.format("%d°F", UTILS.CelsiusToFahrenheit(T))
|
||||||
tW = string.format( "%.1f knots", UTILS.MpsToKnots( Ws ) )
|
tW = string.format( "%.1f knots", UTILS.MpsToKnots( Ws ) )
|
||||||
tP = string.format( "%.2f inHg", P * hPa2inHg )
|
tP = string.format( "%.2f inHg", P * hPa2inHg )
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -255,10 +255,11 @@ CSAR.AircraftType["Mi-24P"] = 8
|
|||||||
CSAR.AircraftType["Mi-24V"] = 8
|
CSAR.AircraftType["Mi-24V"] = 8
|
||||||
CSAR.AircraftType["Bell-47"] = 2
|
CSAR.AircraftType["Bell-47"] = 2
|
||||||
CSAR.AircraftType["UH-60L"] = 10
|
CSAR.AircraftType["UH-60L"] = 10
|
||||||
|
CSAR.AircraftType["AH-64D_BLK_II"] = 2
|
||||||
|
|
||||||
--- CSAR class version.
|
--- CSAR class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
CSAR.version="1.0.4c"
|
CSAR.version="1.0.4d"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- ToDo list
|
-- ToDo list
|
||||||
|
|||||||
@@ -1017,6 +1017,7 @@ CTLD.UnitTypes = {
|
|||||||
["Hercules"] = {type="Hercules", crates=true, troops=true, cratelimit = 7, trooplimit = 64, length = 25, cargoweightlimit = 19000}, -- 19t cargo, 64 paratroopers.
|
["Hercules"] = {type="Hercules", crates=true, troops=true, cratelimit = 7, trooplimit = 64, length = 25, cargoweightlimit = 19000}, -- 19t cargo, 64 paratroopers.
|
||||||
--Actually it's longer, but the center coord is off-center of the model.
|
--Actually it's longer, but the center coord is off-center of the model.
|
||||||
["UH-60L"] = {type="UH-60L", crates=true, troops=true, cratelimit = 2, trooplimit = 20, length = 16, cargoweightlimit = 3500}, -- 4t cargo, 20 (unsec) seats
|
["UH-60L"] = {type="UH-60L", crates=true, troops=true, cratelimit = 2, trooplimit = 20, length = 16, cargoweightlimit = 3500}, -- 4t cargo, 20 (unsec) seats
|
||||||
|
["AH-64D_BLK_II"] = {type="AH-64D_BLK_II", crates=false, troops=true, cratelimit = 0, trooplimit = 2, length = 17, cargoweightlimit = 200}, -- 2 ppl **outside** the helo
|
||||||
}
|
}
|
||||||
|
|
||||||
--- CTLD class version.
|
--- CTLD class version.
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
-- @module Utils
|
-- @module Utils
|
||||||
-- @image MOOSE.JPG
|
-- @image MOOSE.JPG
|
||||||
|
|
||||||
|
|
||||||
--- @type SMOKECOLOR
|
--- @type SMOKECOLOR
|
||||||
-- @field Green
|
-- @field Green
|
||||||
-- @field Red
|
-- @field Red
|
||||||
@@ -58,9 +59,10 @@ DCSMAP = {
|
|||||||
PersianGulf="PersianGulf",
|
PersianGulf="PersianGulf",
|
||||||
TheChannel="TheChannel",
|
TheChannel="TheChannel",
|
||||||
Syria="Syria",
|
Syria="Syria",
|
||||||
MarianaIslands = "MarianaIslands",
|
MarianaIslands="MarianaIslands"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
--- See [DCS_enum_callsigns](https://wiki.hoggitworld.com/view/DCS_enum_callsigns)
|
--- See [DCS_enum_callsigns](https://wiki.hoggitworld.com/view/DCS_enum_callsigns)
|
||||||
-- @type CALLSIGN
|
-- @type CALLSIGN
|
||||||
CALLSIGN={
|
CALLSIGN={
|
||||||
@@ -256,6 +258,7 @@ UTILS.IsInstanceOf = function( object, className )
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Deep copy a table. See http://lua-users.org/wiki/CopyTable
|
--- Deep copy a table. See http://lua-users.org/wiki/CopyTable
|
||||||
-- @param #table object The input table.
|
-- @param #table object The input table.
|
||||||
-- @return #table Copy of the input table.
|
-- @return #table Copy of the input table.
|
||||||
@@ -287,6 +290,7 @@ UTILS.DeepCopy = function( object )
|
|||||||
return objectreturn
|
return objectreturn
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Porting in Slmod's serialize_slmod2.
|
--- Porting in Slmod's serialize_slmod2.
|
||||||
-- @param #table tbl Input table.
|
-- @param #table tbl Input table.
|
||||||
UTILS.OneLineSerialize = function( tbl ) -- serialization of a table all on a single line, no comments, made to replace old get_table_string function
|
UTILS.OneLineSerialize = function( tbl ) -- serialization of a table all on a single line, no comments, made to replace old get_table_string function
|
||||||
@@ -379,6 +383,7 @@ UTILS.BasicSerialize = function( s )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
UTILS.ToDegree = function(angle)
|
UTILS.ToDegree = function(angle)
|
||||||
return angle*180/math.pi
|
return angle*180/math.pi
|
||||||
end
|
end
|
||||||
@@ -469,20 +474,20 @@ UTILS.KnotsToMps = function( knots )
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- Convert temperature from Celsius to Fahrenheit.
|
--- Convert temperature from Celsius to Fahrenheit.
|
||||||
-- @param #number Celsius Temperature in degrees Celsius.
|
-- @param #number Celcius Temperature in degrees Celsius.
|
||||||
-- @return #number Temperature in degrees Fahrenheit.
|
-- @return #number Temperature in degrees Fahrenheit.
|
||||||
UTILS.CelsiusToFahrenheit = function( Celsius )
|
UTILS.CelsiusToFahrenheit = function( Celcius )
|
||||||
return Celsius * 9 / 5 + 32
|
return Celcius * 9/5 + 32
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Convert pressure from hectopascal (hPa) to inches of mercury (inHg).
|
--- Convert pressure from hecto Pascal (hPa) to inches of mercury (inHg).
|
||||||
-- @param #number hPa Pressure in hPa.
|
-- @param #number hPa Pressure in hPa.
|
||||||
-- @return #number Pressure in inHg.
|
-- @return #number Pressure in inHg.
|
||||||
UTILS.hPa2inHg = function( hPa )
|
UTILS.hPa2inHg = function( hPa )
|
||||||
return hPa * 0.0295299830714
|
return hPa * 0.0295299830714
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Convert knots to altitude corrected KIAS, e.g. for tankers.
|
--- Convert knots to alitude corrected KIAS, e.g. for tankers.
|
||||||
-- @param #number knots Speed in knots.
|
-- @param #number knots Speed in knots.
|
||||||
-- @param #number altitude Altitude in feet
|
-- @param #number altitude Altitude in feet
|
||||||
-- @return #number Corrected KIAS
|
-- @return #number Corrected KIAS
|
||||||
@@ -490,14 +495,14 @@ UTILS.KnotsToAltKIAS = function( knots, altitude )
|
|||||||
return (knots * 0.018 * (altitude / 1000)) + knots
|
return (knots * 0.018 * (altitude / 1000)) + knots
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Convert pressure from hectopascal (hPa) to millimeters of mercury (mmHg).
|
--- Convert pressure from hecto Pascal (hPa) to millimeters of mercury (mmHg).
|
||||||
-- @param #number hPa Pressure in hPa.
|
-- @param #number hPa Pressure in hPa.
|
||||||
-- @return #number Pressure in mmHg.
|
-- @return #number Pressure in mmHg.
|
||||||
UTILS.hPa2mmHg = function( hPa )
|
UTILS.hPa2mmHg = function( hPa )
|
||||||
return hPa * 0.7500615613030
|
return hPa * 0.7500615613030
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Convert kilograms (kg) to pounds (lbs).
|
--- Convert kilo gramms (kg) to pounds (lbs).
|
||||||
-- @param #number kg Mass in kg.
|
-- @param #number kg Mass in kg.
|
||||||
-- @return #number Mass in lbs.
|
-- @return #number Mass in lbs.
|
||||||
UTILS.kg2lbs = function( kg )
|
UTILS.kg2lbs = function( kg )
|
||||||
@@ -564,7 +569,8 @@ UTILS.tostringLL = function( lat, lon, acc, DMS )
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- 024° 23' 12"N or 024° 23' 12.03"N
|
-- 024° 23' 12"N or 024° 23' 12.03"N
|
||||||
return string.format( '%03d°', latDeg ) .. string.format( '%02d', latMin ) .. '\'' .. string.format( secFrmtStr, latSec ) .. '"' .. latHemi .. ' ' .. string.format( '%03d°', lonDeg ) .. string.format( '%02d', lonMin ) .. '\'' .. string.format( secFrmtStr, lonSec ) .. '"' .. lonHemi
|
return string.format('%03d°', latDeg)..string.format('%02d', latMin)..'\''..string.format(secFrmtStr, latSec)..'"'..latHemi..' '
|
||||||
|
.. string.format('%03d°', lonDeg)..string.format('%02d', lonMin)..'\''..string.format(secFrmtStr, lonSec)..'"'..lonHemi
|
||||||
|
|
||||||
else -- degrees, decimal minutes.
|
else -- degrees, decimal minutes.
|
||||||
latMin = UTILS.Round(latMin, acc)
|
latMin = UTILS.Round(latMin, acc)
|
||||||
@@ -589,7 +595,8 @@ UTILS.tostringLL = function( lat, lon, acc, DMS )
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- 024 23'N or 024 23.123'N
|
-- 024 23'N or 024 23.123'N
|
||||||
return string.format( '%03d°', latDeg ) .. ' ' .. string.format( minFrmtStr, latMin ) .. '\'' .. latHemi .. ' ' .. string.format( '%03d°', lonDeg ) .. ' ' .. string.format( minFrmtStr, lonMin ) .. '\'' .. lonHemi
|
return string.format('%03d°', latDeg) .. ' ' .. string.format(minFrmtStr, latMin) .. '\'' .. latHemi .. ' '
|
||||||
|
.. string.format('%03d°', lonDeg) .. ' ' .. string.format(minFrmtStr, lonMin) .. '\'' .. lonHemi
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -614,12 +621,8 @@ UTILS.tostringMGRS = function( MGRS, acc ) -- R2.1
|
|||||||
local nN=5-string.len(Northing)
|
local nN=5-string.len(Northing)
|
||||||
|
|
||||||
-- Get leading zeros (if any).
|
-- Get leading zeros (if any).
|
||||||
for i = 1, nE do
|
for i=1,nE do Easting="0"..Easting end
|
||||||
Easting = "0" .. Easting
|
for i=1,nN do Northing="0"..Northing end
|
||||||
end
|
|
||||||
for i = 1, nN do
|
|
||||||
Northing = "0" .. Northing
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Return MGRS string.
|
-- Return MGRS string.
|
||||||
return string.format("%s %s %s %s", MGRS.UTMZone, MGRS.MGRSDigraph, string.sub(Easting, 1, acc), string.sub(Northing, 1, acc))
|
return string.format("%s %s %s %s", MGRS.UTMZone, MGRS.MGRSDigraph, string.sub(Easting, 1, acc), string.sub(Northing, 1, acc))
|
||||||
@@ -627,6 +630,7 @@ UTILS.tostringMGRS = function( MGRS, acc ) -- R2.1
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- From http://lua-users.org/wiki/SimpleRound
|
--- From http://lua-users.org/wiki/SimpleRound
|
||||||
-- use negative idp for rounding ahead of decimal place, positive for rounding after decimal place
|
-- use negative idp for rounding ahead of decimal place, positive for rounding after decimal place
|
||||||
function UTILS.Round( num, idp )
|
function UTILS.Round( num, idp )
|
||||||
@@ -648,16 +652,12 @@ end
|
|||||||
function UTILS.spairs( t, order )
|
function UTILS.spairs( t, order )
|
||||||
-- collect the keys
|
-- collect the keys
|
||||||
local keys = {}
|
local keys = {}
|
||||||
for k in pairs( t ) do
|
for k in pairs(t) do keys[#keys+1] = k end
|
||||||
keys[#keys + 1] = k
|
|
||||||
end
|
|
||||||
|
|
||||||
-- if order function given, sort by it by passing the table and keys a, b,
|
-- if order function given, sort by it by passing the table and keys a, b,
|
||||||
-- otherwise just sort the keys
|
-- otherwise just sort the keys
|
||||||
if order then
|
if order then
|
||||||
table.sort( keys, function( a, b )
|
table.sort(keys, function(a,b) return order(t, a, b) end)
|
||||||
return order( t, a, b )
|
|
||||||
end )
|
|
||||||
else
|
else
|
||||||
table.sort(keys)
|
table.sort(keys)
|
||||||
end
|
end
|
||||||
@@ -672,22 +672,18 @@ function UTILS.spairs( t, order )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Here is a customized version of pairs, which I called kpairs because it iterates over the table in a sorted order, based on a function that will determine the keys as reference first.
|
-- Here is a customized version of pairs, which I called kpairs because it iterates over the table in a sorted order, based on a function that will determine the keys as reference first.
|
||||||
function UTILS.kpairs( t, getkey, order )
|
function UTILS.kpairs( t, getkey, order )
|
||||||
-- collect the keys
|
-- collect the keys
|
||||||
local keys = {}
|
local keys = {}
|
||||||
local keyso = {}
|
local keyso = {}
|
||||||
for k, o in pairs( t ) do
|
for k, o in pairs(t) do keys[#keys+1] = k keyso[#keyso+1] = getkey( o ) end
|
||||||
keys[#keys + 1] = k
|
|
||||||
keyso[#keyso + 1] = getkey( o )
|
|
||||||
end
|
|
||||||
|
|
||||||
-- if order function given, sort by it by passing the table and keys a, b,
|
-- if order function given, sort by it by passing the table and keys a, b,
|
||||||
-- otherwise just sort the keys
|
-- otherwise just sort the keys
|
||||||
if order then
|
if order then
|
||||||
table.sort( keys, function( a, b )
|
table.sort(keys, function(a,b) return order(t, a, b) end)
|
||||||
return order( t, a, b )
|
|
||||||
end )
|
|
||||||
else
|
else
|
||||||
table.sort(keys)
|
table.sort(keys)
|
||||||
end
|
end
|
||||||
@@ -707,9 +703,7 @@ function UTILS.rpairs( t )
|
|||||||
-- collect the keys
|
-- collect the keys
|
||||||
|
|
||||||
local keys = {}
|
local keys = {}
|
||||||
for k in pairs( t ) do
|
for k in pairs(t) do keys[#keys+1] = k end
|
||||||
keys[#keys + 1] = k
|
|
||||||
end
|
|
||||||
|
|
||||||
local random = {}
|
local random = {}
|
||||||
local j = #keys
|
local j = #keys
|
||||||
@@ -748,6 +742,7 @@ function UTILS.RemoveMark( MarkID, Delay )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Test if a Vec2 is in a radius of another Vec2
|
-- Test if a Vec2 is in a radius of another Vec2
|
||||||
function UTILS.IsInRadius( InVec2, Vec2, Radius )
|
function UTILS.IsInRadius( InVec2, Vec2, Radius )
|
||||||
|
|
||||||
@@ -814,9 +809,9 @@ function UTILS.BeaufortScale( speed )
|
|||||||
return bn,bd
|
return bn,bd
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Split string at separators. C.f. http://stackoverflow.com/questions/1426954/split-string-in-lua
|
--- Split string at seperators. C.f. http://stackoverflow.com/questions/1426954/split-string-in-lua
|
||||||
-- @param #string str Sting to split.
|
-- @param #string str Sting to split.
|
||||||
-- @param #string sep Separator for split.
|
-- @param #string sep Speparator for split.
|
||||||
-- @return #table Split text.
|
-- @return #table Split text.
|
||||||
function UTILS.Split(str, sep)
|
function UTILS.Split(str, sep)
|
||||||
local result = {}
|
local result = {}
|
||||||
@@ -893,7 +888,7 @@ function UTILS.SecondsOfToday()
|
|||||||
return UTILS.ClockToSeconds(clock)
|
return UTILS.ClockToSeconds(clock)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Count seconds until next midnight.
|
--- Cound seconds until next midnight.
|
||||||
-- @return #number Seconds to midnight.
|
-- @return #number Seconds to midnight.
|
||||||
function UTILS.SecondsToMidnight()
|
function UTILS.SecondsToMidnight()
|
||||||
return 24*60*60-UTILS.SecondsOfToday()
|
return 24*60*60-UTILS.SecondsOfToday()
|
||||||
@@ -1044,6 +1039,7 @@ function UTILS.Vec2Dot( a, b )
|
|||||||
return a.x*b.x + a.y*b.y
|
return a.x*b.x + a.y*b.y
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Calculate the [euclidean norm](https://en.wikipedia.org/wiki/Euclidean_distance) (length) of a 3D vector.
|
--- Calculate the [euclidean norm](https://en.wikipedia.org/wiki/Euclidean_distance) (length) of a 3D vector.
|
||||||
-- @param DCS#Vec3 a Vector in 3D with x, y, z components.
|
-- @param DCS#Vec3 a Vector in 3D with x, y, z components.
|
||||||
-- @return #number Norm of the vector.
|
-- @return #number Norm of the vector.
|
||||||
@@ -1071,6 +1067,7 @@ function UTILS.VecDist2D( a, b )
|
|||||||
return d
|
return d
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Calculate the distance between two 3D vectors.
|
--- Calculate the distance between two 3D vectors.
|
||||||
-- @param DCS#Vec3 a Vector in 3D with x, y, z components.
|
-- @param DCS#Vec3 a Vector in 3D with x, y, z components.
|
||||||
-- @param DCS#Vec3 b Vector in 3D with x, y, z components.
|
-- @param DCS#Vec3 b Vector in 3D with x, y, z components.
|
||||||
@@ -1100,6 +1097,14 @@ function UTILS.VecSubstract( a, b )
|
|||||||
return {x=a.x-b.x, y=a.y-b.y, z=a.z-b.z}
|
return {x=a.x-b.x, y=a.y-b.y, z=a.z-b.z}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Calculate the difference between two 2D vectors by substracting the x,y components from each other.
|
||||||
|
-- @param DCS#Vec2 a Vector in 2D with x, y components.
|
||||||
|
-- @param DCS#Vec2 b Vector in 2D with x, y components.
|
||||||
|
-- @return DCS#Vec2 Vector c=a-b with c(i)=a(i)-b(i), i=x,y.
|
||||||
|
function UTILS.Vec2Substract(a, b)
|
||||||
|
return {x=a.x-b.x, y=a.y-b.y}
|
||||||
|
end
|
||||||
|
|
||||||
--- Calculate the total vector of two 3D vectors by adding the x,y,z components of each other.
|
--- Calculate the total vector of two 3D vectors by adding the x,y,z components of each other.
|
||||||
-- @param DCS#Vec3 a Vector in 3D with x, y, z components.
|
-- @param DCS#Vec3 a Vector in 3D with x, y, z components.
|
||||||
-- @param DCS#Vec3 b Vector in 3D with x, y, z components.
|
-- @param DCS#Vec3 b Vector in 3D with x, y, z components.
|
||||||
@@ -1108,6 +1113,14 @@ function UTILS.VecAdd( a, b )
|
|||||||
return {x=a.x+b.x, y=a.y+b.y, z=a.z+b.z}
|
return {x=a.x+b.x, y=a.y+b.y, z=a.z+b.z}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Calculate the total vector of two 2D vectors by adding the x,y components of each other.
|
||||||
|
-- @param DCS#Vec2 a Vector in 2D with x, y components.
|
||||||
|
-- @param DCS#Vec2 b Vector in 2D with x, y components.
|
||||||
|
-- @return DCS#Vec2 Vector c=a+b with c(i)=a(i)+b(i), i=x,y.
|
||||||
|
function UTILS.Vec2Add(a, b)
|
||||||
|
return {x=a.x+b.x, y=a.y+b.y}
|
||||||
|
end
|
||||||
|
|
||||||
--- Calculate the angle between two 3D vectors.
|
--- Calculate the angle between two 3D vectors.
|
||||||
-- @param DCS#Vec3 a Vector in 3D with x, y, z components.
|
-- @param DCS#Vec3 a Vector in 3D with x, y, z components.
|
||||||
-- @param DCS#Vec3 b Vector in 3D with x, y, z components.
|
-- @param DCS#Vec3 b Vector in 3D with x, y, z components.
|
||||||
@@ -1169,6 +1182,7 @@ function UTILS.HdgDiff( h1, h2 )
|
|||||||
return math.abs(delta)
|
return math.abs(delta)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Translate 3D vector in the 2D (x,z) plane. y-component (usually altitude) unchanged.
|
--- Translate 3D vector in the 2D (x,z) plane. y-component (usually altitude) unchanged.
|
||||||
-- @param DCS#Vec3 a Vector in 3D with x, y, z components.
|
-- @param DCS#Vec3 a Vector in 3D with x, y, z components.
|
||||||
-- @param #number distance The distance to translate.
|
-- @param #number distance The distance to translate.
|
||||||
@@ -1240,6 +1254,7 @@ function UTILS.Vec2Rotate2D( a, angle )
|
|||||||
return A
|
return A
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Converts a TACAN Channel/Mode couple into a frequency in Hz.
|
--- Converts a TACAN Channel/Mode couple into a frequency in Hz.
|
||||||
-- @param #number TACANChannel The TACAN channel, i.e. the 10 in "10X".
|
-- @param #number TACANChannel The TACAN channel, i.e. the 10 in "10X".
|
||||||
-- @param #string TACANMode The TACAN mode, i.e. the "X" in "10X".
|
-- @param #string TACANMode The TACAN mode, i.e. the "X" in "10X".
|
||||||
@@ -1276,6 +1291,7 @@ function UTILS.TACANToFrequency( TACANChannel, TACANMode )
|
|||||||
return (A + TACANChannel - B) * 1000000
|
return (A + TACANChannel - B) * 1000000
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns the DCS map/theatre as optained by env.mission.theatre
|
--- Returns the DCS map/theatre as optained by env.mission.theatre
|
||||||
-- @return #string DCS map name.
|
-- @return #string DCS map name.
|
||||||
function UTILS.GetDCSMap()
|
function UTILS.GetDCSMap()
|
||||||
@@ -1321,26 +1337,6 @@ function UTILS.GetMissionDayOfYear( Time )
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the current date.
|
|
||||||
-- @return #string Mission date in yyyy/mm/dd format.
|
|
||||||
-- @return #number The year anno domini.
|
|
||||||
-- @return #number The month.
|
|
||||||
-- @return #number The day.
|
|
||||||
function UTILS.GetDate()
|
|
||||||
|
|
||||||
-- Mission start date
|
|
||||||
local date, year, month, day = UTILS.GetDCSMissionDate()
|
|
||||||
|
|
||||||
local time = timer.getAbsTime()
|
|
||||||
|
|
||||||
local clock = UTILS.SecondsToClock( time, false )
|
|
||||||
|
|
||||||
local x = tonumber( UTILS.Split( clock, "+" )[2] )
|
|
||||||
|
|
||||||
local day = day + x
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns the magnetic declination of the map.
|
--- Returns the magnetic declination of the map.
|
||||||
-- Returned values for the current maps are:
|
-- Returned values for the current maps are:
|
||||||
--
|
--
|
||||||
@@ -1410,7 +1406,8 @@ function UTILS.CheckMemory( output )
|
|||||||
return mem
|
return mem
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get the coalition name from its numerical ID, e.g. coalition.side.RED.
|
|
||||||
|
--- Get the coalition name from its numerical ID, e.g. coaliton.side.RED.
|
||||||
-- @param #number Coalition The coalition ID.
|
-- @param #number Coalition The coalition ID.
|
||||||
-- @return #string The coalition name, i.e. "Neutral", "Red" or "Blue" (or "Unknown").
|
-- @return #string The coalition name, i.e. "Neutral", "Red" or "Blue" (or "Unknown").
|
||||||
function UTILS.GetCoalitionName(Coalition)
|
function UTILS.GetCoalitionName(Coalition)
|
||||||
@@ -1509,6 +1506,7 @@ function UTILS.GMTToLocalTimeDifference()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get the day of the year. Counting starts on 1st of January.
|
--- Get the day of the year. Counting starts on 1st of January.
|
||||||
-- @param #number Year The year.
|
-- @param #number Year The year.
|
||||||
-- @param #number Month The month.
|
-- @param #number Month The month.
|
||||||
@@ -1542,31 +1540,18 @@ function UTILS.GetSunRiseAndSet( DayOfYear, Latitude, Longitude, Rising, Tlocal
|
|||||||
local n=DayOfYear
|
local n=DayOfYear
|
||||||
Tlocal=Tlocal or 0
|
Tlocal=Tlocal or 0
|
||||||
|
|
||||||
|
|
||||||
-- Short cuts.
|
-- Short cuts.
|
||||||
local rad = math.rad
|
local rad = math.rad
|
||||||
local deg = math.deg
|
local deg = math.deg
|
||||||
local floor = math.floor
|
local floor = math.floor
|
||||||
local frac = function( n )
|
local frac = function(n) return n - floor(n) end
|
||||||
return n - floor( n )
|
local cos = function(d) return math.cos(rad(d)) end
|
||||||
end
|
local acos = function(d) return deg(math.acos(d)) end
|
||||||
local cos = function( d )
|
local sin = function(d) return math.sin(rad(d)) end
|
||||||
return math.cos( rad( d ) )
|
local asin = function(d) return deg(math.asin(d)) end
|
||||||
end
|
local tan = function(d) return math.tan(rad(d)) end
|
||||||
local acos = function( d )
|
local atan = function(d) return deg(math.atan(d)) end
|
||||||
return deg( math.acos( d ) )
|
|
||||||
end
|
|
||||||
local sin = function( d )
|
|
||||||
return math.sin( rad( d ) )
|
|
||||||
end
|
|
||||||
local asin = function( d )
|
|
||||||
return deg( math.asin( d ) )
|
|
||||||
end
|
|
||||||
local tan = function( d )
|
|
||||||
return math.tan( rad( d ) )
|
|
||||||
end
|
|
||||||
local atan = function( d )
|
|
||||||
return deg( math.atan( d ) )
|
|
||||||
end
|
|
||||||
|
|
||||||
local function fit_into_range(val, min, max)
|
local function fit_into_range(val, min, max)
|
||||||
local range = max - min
|
local range = max - min
|
||||||
@@ -1762,9 +1747,15 @@ function UTILS.IsLoadingDoorOpen( unit_name )
|
|||||||
ret_val = true
|
ret_val = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if string.find(type_name, "AH-64D") then
|
||||||
|
BASE:T(unit_name .. " front door(s) are open")
|
||||||
|
ret_val = true -- no doors on this one ;)
|
||||||
|
end
|
||||||
|
|
||||||
if ret_val == false then
|
if ret_val == false then
|
||||||
BASE:T(unit_name .. " all doors are closed")
|
BASE:T(unit_name .. " all doors are closed")
|
||||||
end
|
end
|
||||||
|
|
||||||
return ret_val
|
return ret_val
|
||||||
|
|
||||||
end -- nil
|
end -- nil
|
||||||
@@ -1905,7 +1896,9 @@ function UTILS.GenerateLaserCodes()
|
|||||||
while _code < 1777 and _count < 30 do
|
while _code < 1777 and _count < 30 do
|
||||||
while true do
|
while true do
|
||||||
_code = _code + 1
|
_code = _code + 1
|
||||||
if not ContainsDigit( _code, 8 ) and not ContainsDigit( _code, 9 ) and not ContainsDigit( _code, 0 ) then
|
if not ContainsDigit(_code, 8)
|
||||||
|
and not ContainsDigit(_code, 9)
|
||||||
|
and not ContainsDigit(_code, 0) then
|
||||||
table.insert(jtacGeneratedLaserCodes, _code)
|
table.insert(jtacGeneratedLaserCodes, _code)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@@ -2172,9 +2165,7 @@ end
|
|||||||
-- @return #table Table of data objects (tables) containing groupname, coordinate and group object. Returns nil when file cannot be read.
|
-- @return #table Table of data objects (tables) containing groupname, coordinate and group object. Returns nil when file cannot be read.
|
||||||
function UTILS.LoadStationaryListOfGroups(Path,Filename,Reduce)
|
function UTILS.LoadStationaryListOfGroups(Path,Filename,Reduce)
|
||||||
local reduce = true
|
local reduce = true
|
||||||
if Reduce == false then
|
if Reduce == false then reduce = false end
|
||||||
reduce = false
|
|
||||||
end
|
|
||||||
local filename = Filename or "StateListofGroups"
|
local filename = Filename or "StateListofGroups"
|
||||||
local datatable = {}
|
local datatable = {}
|
||||||
if UTILS.CheckFileExists(Path,filename) then
|
if UTILS.CheckFileExists(Path,filename) then
|
||||||
@@ -2193,9 +2184,8 @@ function UTILS.LoadStationaryListOfGroups( Path, Filename, Reduce )
|
|||||||
local data = { groupname=groupname, size=size, coordinate=coordinate, group=GROUP:FindByName(groupname) }
|
local data = { groupname=groupname, size=size, coordinate=coordinate, group=GROUP:FindByName(groupname) }
|
||||||
if reduce then
|
if reduce then
|
||||||
local actualgroup = GROUP:FindByName(groupname)
|
local actualgroup = GROUP:FindByName(groupname)
|
||||||
local actualsize = actualgroup:CountAliveUnits()
|
if actualgroup and actualgroup:IsAlive() and actualgroup:CountAliveUnits() > size then
|
||||||
if actualsize > size then
|
local reduction = actualgroup:CountAliveUnits() - size
|
||||||
local reduction = actualsize - size
|
|
||||||
BASE:I("Reducing groupsize by ".. reduction .. " units!")
|
BASE:I("Reducing groupsize by ".. reduction .. " units!")
|
||||||
-- reduce existing group
|
-- reduce existing group
|
||||||
local units = actualgroup:GetUnits()
|
local units = actualgroup:GetUnits()
|
||||||
@@ -2221,9 +2211,7 @@ end
|
|||||||
-- Returns nil when file cannot be read. Returns a table of data entries if Spawn is false: `{ groupname=groupname, size=size, coordinate=coordinate }`
|
-- Returns nil when file cannot be read. Returns a table of data entries if Spawn is false: `{ groupname=groupname, size=size, coordinate=coordinate }`
|
||||||
function UTILS.LoadSetOfGroups(Path,Filename,Spawn)
|
function UTILS.LoadSetOfGroups(Path,Filename,Spawn)
|
||||||
local spawn = true
|
local spawn = true
|
||||||
if Spawn == false then
|
if Spawn == false then spawn = false end
|
||||||
spawn = false
|
|
||||||
end
|
|
||||||
BASE:I("Spawn = "..tostring(spawn))
|
BASE:I("Spawn = "..tostring(spawn))
|
||||||
local filename = Filename or "SetOfGroups"
|
local filename = Filename or "SetOfGroups"
|
||||||
local setdata = SET_GROUP:New()
|
local setdata = SET_GROUP:New()
|
||||||
@@ -2246,7 +2234,10 @@ function UTILS.LoadSetOfGroups( Path, Filename, Spawn )
|
|||||||
local data = { groupname=groupname, size=size, coordinate=coordinate }
|
local data = { groupname=groupname, size=size, coordinate=coordinate }
|
||||||
table.insert(datatable,data)
|
table.insert(datatable,data)
|
||||||
if spawn then
|
if spawn then
|
||||||
local group = SPAWN:New( groupname ):InitDelayOff():OnSpawnGroup( function( spwndgrp )
|
local group = SPAWN:New(groupname)
|
||||||
|
:InitDelayOff()
|
||||||
|
:OnSpawnGroup(
|
||||||
|
function(spwndgrp)
|
||||||
setdata:AddObject(spwndgrp)
|
setdata:AddObject(spwndgrp)
|
||||||
local actualsize = spwndgrp:CountAliveUnits()
|
local actualsize = spwndgrp:CountAliveUnits()
|
||||||
if actualsize > size then
|
if actualsize > size then
|
||||||
@@ -2258,7 +2249,9 @@ function UTILS.LoadSetOfGroups( Path, Filename, Spawn )
|
|||||||
units2[i]:Destroy(false)
|
units2[i]:Destroy(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end ):SpawnFromCoordinate( coordinate )
|
end
|
||||||
|
)
|
||||||
|
:SpawnFromCoordinate(coordinate)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -2306,9 +2299,7 @@ end
|
|||||||
-- Returns nil when file cannot be read.
|
-- Returns nil when file cannot be read.
|
||||||
function UTILS.LoadStationaryListOfStatics(Path,Filename,Reduce)
|
function UTILS.LoadStationaryListOfStatics(Path,Filename,Reduce)
|
||||||
local reduce = true
|
local reduce = true
|
||||||
if Reduce == false then
|
if Reduce == false then reduce = false end
|
||||||
reduce = false
|
|
||||||
end
|
|
||||||
local filename = Filename or "StateListofStatics"
|
local filename = Filename or "StateListofStatics"
|
||||||
local datatable = {}
|
local datatable = {}
|
||||||
if UTILS.CheckFileExists(Path,filename) then
|
if UTILS.CheckFileExists(Path,filename) then
|
||||||
|
|||||||
@@ -384,6 +384,16 @@ AIRBASE.TheChannel = {
|
|||||||
-- * AIRBASE.Syria.Beirut_Rafic_Hariri
|
-- * AIRBASE.Syria.Beirut_Rafic_Hariri
|
||||||
-- * AIRBASE.Syria.An_Nasiriyah
|
-- * AIRBASE.Syria.An_Nasiriyah
|
||||||
-- * AIRBASE.Syria.Abu_al_Duhur
|
-- * AIRBASE.Syria.Abu_al_Duhur
|
||||||
|
-- * AIRBASE.Syria.At_Tanf
|
||||||
|
-- * AIRBASE.Syria.H3
|
||||||
|
-- * AIRBASE.Syria.H3_Northwest
|
||||||
|
-- * AIRBASE.Syria.H3_Southwest
|
||||||
|
-- * AIRBASE.Syria.Kharab_Ishk
|
||||||
|
-- * AIRBASE.Syria.Raj_al_Issa_East
|
||||||
|
-- * AIRBASE.Syria.Raj_al_Issa_West
|
||||||
|
-- * AIRBASE.Syria.Ruwayshid
|
||||||
|
-- * AIRBASE.Syria.Sanliurfa
|
||||||
|
-- * AIRBASE.Syria.Tal_Siman
|
||||||
--
|
--
|
||||||
--@field Syria
|
--@field Syria
|
||||||
AIRBASE.Syria={
|
AIRBASE.Syria={
|
||||||
@@ -439,6 +449,16 @@ AIRBASE.Syria = {
|
|||||||
["Beirut_Rafic_Hariri"]="Beirut-Rafic Hariri",
|
["Beirut_Rafic_Hariri"]="Beirut-Rafic Hariri",
|
||||||
["An_Nasiriyah"]="An Nasiriyah",
|
["An_Nasiriyah"]="An Nasiriyah",
|
||||||
["Abu_al_Duhur"]="Abu al-Duhur",
|
["Abu_al_Duhur"]="Abu al-Duhur",
|
||||||
|
["At_Tanf"]="At Tanf",
|
||||||
|
["H3"]="H3",
|
||||||
|
["H3_Northwest"]="H3 Northwest",
|
||||||
|
["H3_Southwest"]="H3 Southwest",
|
||||||
|
["Kharab_Ishk"]="Kharab Ishk",
|
||||||
|
["Raj_al_Issa_East"]="Raj al Issa East",
|
||||||
|
["Raj_al_Issa_West"]="Raj al Issa West",
|
||||||
|
["Ruwayshid"]="Ruwayshid",
|
||||||
|
["Sanliurfa"]="Sanliurfa",
|
||||||
|
["Tal_Siman"]="Tal Siman",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Airbases of the Mariana Islands map:
|
--- Airbases of the Mariana Islands map:
|
||||||
|
|||||||
@@ -3770,3 +3770,44 @@ function POSITIONABLE:IsSubmarine()
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Sets the controlled group to go at the specified speed in meters per second.
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @param #number Speed Speed in meters per second.
|
||||||
|
-- @param #boolean Keep (Optional) When set to true, will maintain the speed on passing waypoints. If not present or false, the controlled group will return to the speed as defined by their route.
|
||||||
|
-- @return #CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:SetSpeed(Speed, Keep)
|
||||||
|
self:F2( { self.ControllableName } )
|
||||||
|
-- Set default if not specified.
|
||||||
|
local speed = Speed or 5
|
||||||
|
local DCSControllable = self:GetDCSObject()
|
||||||
|
if DCSControllable then
|
||||||
|
local Controller = self:_GetController()
|
||||||
|
if Controller then
|
||||||
|
Controller:setSpeed(speed, Keep)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- [AIR] Sets the controlled aircraft group to fly at the specified altitude in meters.
|
||||||
|
-- @param #CONTROLLABLE self
|
||||||
|
-- @param #number Altitude Altitude in meters.
|
||||||
|
-- @param #boolean Keep (Optional) When set to true, will maintain the altitude on passing waypoints. If not present or false, the controlled group will return to the altitude as defined by their route.
|
||||||
|
-- @param #string AltType (Optional) Specifies the altitude type used. If nil, the altitude type of the current waypoint will be used. Accepted values are "BARO" and "RADIO".
|
||||||
|
-- @return #CONTROLLABLE self
|
||||||
|
function CONTROLLABLE:SetAltitude(Altitude, Keep, AltType)
|
||||||
|
self:F2( { self.ControllableName } )
|
||||||
|
-- Set default if not specified.
|
||||||
|
local altitude = Altitude or 1000
|
||||||
|
local DCSControllable = self:GetDCSObject()
|
||||||
|
if DCSControllable then
|
||||||
|
local Controller = self:_GetController()
|
||||||
|
if Controller then
|
||||||
|
if self:IsAir() then
|
||||||
|
Controller:setAltitude(altitude, Keep, AltType)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
@@ -10,8 +10,11 @@
|
|||||||
--
|
--
|
||||||
-- @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.
|
||||||
@@ -37,10 +40,13 @@
|
|||||||
--
|
--
|
||||||
-- * @{#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 SANITIZE these STATIC OBJECT REFERENCES! (make the STATIC object references nil).
|
-- IMPORTANT: ONE SHOULD NEVER SANATIZE these STATIC OBJECT REFERENCES! (make the STATIC object references nil).
|
||||||
--
|
--
|
||||||
-- @field #STATIC
|
-- @field #STATIC
|
||||||
STATIC = { ClassName = "STATIC" }
|
STATIC = {
|
||||||
|
ClassName = "STATIC",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
--- Register a static object.
|
--- Register a static object.
|
||||||
-- @param #STATIC self
|
-- @param #STATIC self
|
||||||
@@ -52,6 +58,7 @@ 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.
|
||||||
@@ -90,9 +97,8 @@ end
|
|||||||
|
|
||||||
--- Destroys the STATIC.
|
--- Destroys the STATIC.
|
||||||
-- @param #STATIC self
|
-- @param #STATIC self
|
||||||
-- @param #boolean GenerateEvent (Optional) true to generate a crash or dead event, false to not generate any event. `nil` (default) creates a remove event.
|
-- @param #boolean GenerateEvent (Optional) true if you want to generate a crash or dead event for the static.
|
||||||
-- @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" )
|
||||||
@@ -111,7 +117,7 @@ end
|
|||||||
-- @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 any event upon destruction.
|
-- Ship:Destroy( false ) -- Don't generate an event upon destruction.
|
||||||
--
|
--
|
||||||
function STATIC:Destroy( GenerateEvent )
|
function STATIC:Destroy( GenerateEvent )
|
||||||
self:F2( self.ObjectName )
|
self:F2( self.ObjectName )
|
||||||
@@ -142,6 +148,7 @@ 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
|
||||||
@@ -173,6 +180,7 @@ 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.
|
||||||
@@ -203,6 +211,7 @@ function STATIC:SpawnAt( Coordinate, Heading, Delay )
|
|||||||
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
|
||||||
@@ -225,11 +234,12 @@ function STATIC:ReSpawn( CountryID, Delay )
|
|||||||
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 is the current heading.
|
-- @param #number Heading (Optional) The heading of the static respawn in degrees. Default the current heading.
|
||||||
-- @param #number Delay (Optional) Delay in seconds before static is respawned. Default is now.
|
-- @param #number Delay (Optional) Delay in seconds before static is respawned. Default now.
|
||||||
function STATIC:ReSpawnAt(Coordinate, Heading, Delay)
|
function STATIC:ReSpawnAt(Coordinate, Heading, Delay)
|
||||||
|
|
||||||
--Heading=Heading or 0
|
--Heading=Heading or 0
|
||||||
@@ -237,11 +247,12 @@ function STATIC:ReSpawnAt( Coordinate, Heading, Delay )
|
|||||||
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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user