mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d7e7d55a9 | ||
|
|
6e37300d9b | ||
|
|
85fef96d00 | ||
|
|
47d814e409 | ||
|
|
41b01a508d | ||
|
|
1ae41319fa | ||
|
|
0265152c12 | ||
|
|
a893d46cb9 | ||
|
|
b68f271fb7 | ||
|
|
057e231a9d | ||
|
|
b6fedbd97d | ||
|
|
7cd29501a9 | ||
|
|
59e4f48726 | ||
|
|
20fe2ee505 | ||
|
|
8b4ba430fb | ||
|
|
3b0949de72 | ||
|
|
ebb4623bb5 | ||
|
|
2309487429 | ||
|
|
a3decc33c9 | ||
|
|
b2d87a8780 | ||
|
|
5034005f6b | ||
|
|
c045ba0c6d | ||
|
|
d0fb4d44ef | ||
|
|
d1f3e3f4bb | ||
|
|
45f578b5a3 | ||
|
|
620f4b96b9 | ||
|
|
39d3f85b71 | ||
|
|
9a7df65faa | ||
|
|
596eb4c7e4 | ||
|
|
2bce305451 | ||
|
|
2bcc531e73 | ||
|
|
2e66a854b1 | ||
|
|
57f6096aa1 |
@@ -277,7 +277,7 @@ function AI_CARGO_HELICOPTER:onafterLanded( Helicopter, From, Event, To )
|
|||||||
self:F( { Helicopter:GetName(), Height = Helicopter:GetHeight( true ), Velocity = Helicopter:GetVelocityKMH() } )
|
self:F( { Helicopter:GetName(), Height = Helicopter:GetHeight( true ), Velocity = Helicopter:GetVelocityKMH() } )
|
||||||
|
|
||||||
if self.RoutePickup == true then
|
if self.RoutePickup == true then
|
||||||
if Helicopter:GetHeight( true ) <= 5.5 and Helicopter:GetVelocityKMH() < 10 then
|
if Helicopter:GetHeight( true ) <= 5.5 and Helicopter:GetVelocityKMH() < 15 then
|
||||||
--self:Load( Helicopter:GetPointVec2() )
|
--self:Load( Helicopter:GetPointVec2() )
|
||||||
self:Load( self.PickupZone )
|
self:Load( self.PickupZone )
|
||||||
self.RoutePickup = false
|
self.RoutePickup = false
|
||||||
@@ -285,7 +285,7 @@ function AI_CARGO_HELICOPTER:onafterLanded( Helicopter, From, Event, To )
|
|||||||
end
|
end
|
||||||
|
|
||||||
if self.RouteDeploy == true then
|
if self.RouteDeploy == true then
|
||||||
if Helicopter:GetHeight( true ) <= 5.5 and Helicopter:GetVelocityKMH() < 10 then
|
if Helicopter:GetHeight( true ) <= 5.5 and Helicopter:GetVelocityKMH() < 15 then
|
||||||
self:Unload( self.DeployZone )
|
self:Unload( self.DeployZone )
|
||||||
self.RouteDeploy = false
|
self.RouteDeploy = false
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -298,24 +298,78 @@ do -- Zones
|
|||||||
-- @return #DATABASE self
|
-- @return #DATABASE self
|
||||||
function DATABASE:_RegisterZones()
|
function DATABASE:_RegisterZones()
|
||||||
|
|
||||||
for ZoneID, ZoneData in pairs( env.mission.triggers.zones ) do
|
for ZoneID, ZoneData in pairs(env.mission.triggers.zones) do
|
||||||
local ZoneName = ZoneData.name
|
local ZoneName = ZoneData.name
|
||||||
|
|
||||||
self:I( { "Register ZONE:", Name = ZoneName } )
|
-- Color
|
||||||
local Zone = ZONE:New( ZoneName )
|
local color=ZoneData.color or {1, 0, 0, 0.15}
|
||||||
self.ZONENAMES[ZoneName] = ZoneName
|
|
||||||
self:AddZone( ZoneName, Zone )
|
-- Create new Zone
|
||||||
|
local Zone=nil --Core.Zone#ZONE_BASE
|
||||||
|
|
||||||
|
if ZoneData.type==0 then
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Circular zone
|
||||||
|
---
|
||||||
|
|
||||||
|
self:I(string.format("Register ZONE: %s (Circular)", ZoneName))
|
||||||
|
|
||||||
|
Zone=ZONE:New(ZoneName)
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
---
|
||||||
|
-- Quad-point zone
|
||||||
|
---
|
||||||
|
|
||||||
|
self:I(string.format("Register ZONE: %s (Polygon, Quad)", ZoneName))
|
||||||
|
|
||||||
|
Zone=ZONE_POLYGON_BASE:New(ZoneName, ZoneData.verticies)
|
||||||
|
|
||||||
|
--for i,vec2 in pairs(ZoneData.verticies) do
|
||||||
|
-- local coord=COORDINATE:NewFromVec2(vec2)
|
||||||
|
-- coord:MarkToAll(string.format("%s Point %d", ZoneName, i))
|
||||||
|
--end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if Zone then
|
||||||
|
|
||||||
|
-- Store color of zone.
|
||||||
|
Zone.Color=color
|
||||||
|
|
||||||
|
-- Store in DB.
|
||||||
|
self.ZONENAMES[ZoneName] = ZoneName
|
||||||
|
|
||||||
|
-- Add zone.
|
||||||
|
self:AddZone(ZoneName, Zone)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Polygon zones defined by late activated groups.
|
||||||
for ZoneGroupName, ZoneGroup in pairs( self.GROUPS ) do
|
for ZoneGroupName, ZoneGroup in pairs( self.GROUPS ) do
|
||||||
if ZoneGroupName:match("#ZONE_POLYGON") then
|
if ZoneGroupName:match("#ZONE_POLYGON") then
|
||||||
|
|
||||||
local ZoneName1 = ZoneGroupName:match("(.*)#ZONE_POLYGON")
|
local ZoneName1 = ZoneGroupName:match("(.*)#ZONE_POLYGON")
|
||||||
local ZoneName2 = ZoneGroupName:match(".*#ZONE_POLYGON(.*)")
|
local ZoneName2 = ZoneGroupName:match(".*#ZONE_POLYGON(.*)")
|
||||||
local ZoneName = ZoneName1 .. ( ZoneName2 or "" )
|
local ZoneName = ZoneName1 .. ( ZoneName2 or "" )
|
||||||
|
|
||||||
self:I( { "Register ZONE_POLYGON:", Name = ZoneName } )
|
-- Debug output
|
||||||
|
self:I(string.format("Register ZONE: %s (Polygon)", ZoneName))
|
||||||
|
|
||||||
|
-- Create a new polygon zone.
|
||||||
local Zone_Polygon = ZONE_POLYGON:New( ZoneName, ZoneGroup )
|
local Zone_Polygon = ZONE_POLYGON:New( ZoneName, ZoneGroup )
|
||||||
|
|
||||||
|
-- Set color.
|
||||||
|
Zone_Polygon:SetColor({1, 0, 0}, 0.15)
|
||||||
|
|
||||||
|
-- Store name in DB.
|
||||||
self.ZONENAMES[ZoneName] = ZoneName
|
self.ZONENAMES[ZoneName] = ZoneName
|
||||||
|
|
||||||
|
-- Add zone to DB.
|
||||||
self:AddZone( ZoneName, Zone_Polygon )
|
self:AddZone( ZoneName, Zone_Polygon )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1000,11 +1000,7 @@ function EVENT:onEvent( Event )
|
|||||||
-- Check if this is a known event?
|
-- Check if this is a known event?
|
||||||
if EventMeta then
|
if EventMeta then
|
||||||
|
|
||||||
if self and
|
if self and self.Events and self.Events[Event.id] and self.MissionEnd==false and (Event.initiator~=nil or (Event.initiator==nil and Event.id~=EVENTS.PlayerLeaveUnit)) then
|
||||||
self.Events and
|
|
||||||
self.Events[Event.id] and
|
|
||||||
self.MissionEnd == false and
|
|
||||||
( Event.initiator ~= nil or ( Event.initiator == nil and Event.id ~= EVENTS.PlayerLeaveUnit ) ) then
|
|
||||||
|
|
||||||
if Event.id and Event.id == EVENTS.MissionEnd then
|
if Event.id and Event.id == EVENTS.MissionEnd then
|
||||||
self.MissionEnd = true
|
self.MissionEnd = true
|
||||||
@@ -1039,9 +1035,10 @@ function EVENT:onEvent( Event )
|
|||||||
end
|
end
|
||||||
|
|
||||||
if Event.IniObjectCategory == Object.Category.STATIC then
|
if Event.IniObjectCategory == Object.Category.STATIC then
|
||||||
|
|
||||||
if Event.id==31 then
|
if Event.id==31 then
|
||||||
--env.info("FF event 31")
|
|
||||||
-- Event.initiator is a Static object representing the pilot. But getName() error due to DCS bug.
|
-- Event.initiator is a Static object representing the pilot. But getName() errors due to DCS bug.
|
||||||
Event.IniDCSUnit = Event.initiator
|
Event.IniDCSUnit = Event.initiator
|
||||||
local ID=Event.initiator.id_
|
local ID=Event.initiator.id_
|
||||||
Event.IniDCSUnitName = string.format("Ejected Pilot ID %s", tostring(ID))
|
Event.IniDCSUnitName = string.format("Ejected Pilot ID %s", tostring(ID))
|
||||||
@@ -1049,6 +1046,14 @@ function EVENT:onEvent( Event )
|
|||||||
Event.IniCoalition = 0
|
Event.IniCoalition = 0
|
||||||
Event.IniCategory = 0
|
Event.IniCategory = 0
|
||||||
Event.IniTypeName = "Ejected Pilot"
|
Event.IniTypeName = "Ejected Pilot"
|
||||||
|
elseif Event.id == 33 then -- ejection seat discarded
|
||||||
|
Event.IniDCSUnit = Event.initiator
|
||||||
|
local ID=Event.initiator.id_
|
||||||
|
Event.IniDCSUnitName = string.format("Ejection Seat ID %s", tostring(ID))
|
||||||
|
Event.IniUnitName = Event.IniDCSUnitName
|
||||||
|
Event.IniCoalition = 0
|
||||||
|
Event.IniCategory = 0
|
||||||
|
Event.IniTypeName = "Ejection Seat"
|
||||||
else
|
else
|
||||||
Event.IniDCSUnit = Event.initiator
|
Event.IniDCSUnit = Event.initiator
|
||||||
Event.IniDCSUnitName = Event.IniDCSUnit:getName()
|
Event.IniDCSUnitName = Event.IniDCSUnit:getName()
|
||||||
@@ -1115,25 +1120,33 @@ function EVENT:onEvent( Event )
|
|||||||
end
|
end
|
||||||
|
|
||||||
if Event.TgtObjectCategory == Object.Category.STATIC then
|
if Event.TgtObjectCategory == Object.Category.STATIC then
|
||||||
BASE:T({Event = Event})
|
-- get base data
|
||||||
--[[
|
|
||||||
Event.TgtDCSUnit = Event.target
|
Event.TgtDCSUnit = Event.target
|
||||||
|
if Event.target:isExist() and Event.id ~= 33 then -- leave out ejected seat object
|
||||||
Event.TgtDCSUnitName = Event.TgtDCSUnit:getName()
|
Event.TgtDCSUnitName = Event.TgtDCSUnit:getName()
|
||||||
Event.TgtUnitName = Event.TgtDCSUnitName
|
Event.TgtUnitName = Event.TgtDCSUnitName
|
||||||
Event.TgtUnit = STATIC:FindByName( Event.TgtDCSUnitName, false )
|
Event.TgtUnit = STATIC:FindByName( Event.TgtDCSUnitName, false )
|
||||||
Event.TgtCoalition = Event.TgtDCSUnit:getCoalition()
|
Event.TgtCoalition = Event.TgtDCSUnit:getCoalition()
|
||||||
Event.TgtCategory = Event.TgtDCSUnit:getDesc().category
|
Event.TgtCategory = Event.TgtDCSUnit:getDesc().category
|
||||||
Event.TgtTypeName = Event.TgtDCSUnit:getTypeName()
|
Event.TgtTypeName = Event.TgtDCSUnit:getTypeName()
|
||||||
--]]
|
else
|
||||||
-- Same as for Event Initiator above 2.7 issue
|
Event.TgtDCSUnitName = string.format("No target object for Event ID %s", tostring(Event.id))
|
||||||
Event.TgtDCSUnit = Event.target
|
|
||||||
local ID=Event.initiator.id_
|
|
||||||
Event.TgtDCSUnitName = string.format("Ejected Pilot ID %s", tostring(ID))
|
|
||||||
Event.TgtUnitName = Event.TgtDCSUnitName
|
Event.TgtUnitName = Event.TgtDCSUnitName
|
||||||
--Event.TgtUnit = STATIC:FindByName( Event.TgtDCSUnitName, false )
|
Event.TgtUnit = nil
|
||||||
Event.TgtCoalition = Event.IniCoalition
|
Event.TgtCoalition = 0
|
||||||
Event.TgtCategory = Event.IniCategory
|
Event.TgtCategory = 0
|
||||||
|
if Event.id == 6 then
|
||||||
Event.TgtTypeName = "Ejected Pilot"
|
Event.TgtTypeName = "Ejected Pilot"
|
||||||
|
Event.TgtDCSUnitName = string.format("Ejected Pilot ID %s", tostring(Event.IniDCSUnitName))
|
||||||
|
Event.TgtUnitName = Event.TgtDCSUnitName
|
||||||
|
elseif Event.id == 33 then
|
||||||
|
Event.TgtTypeName = "Ejection Seat"
|
||||||
|
Event.TgtDCSUnitName = string.format("Ejection Seat ID %s", tostring(Event.IniDCSUnitName))
|
||||||
|
Event.TgtUnitName = Event.TgtDCSUnitName
|
||||||
|
else
|
||||||
|
Event.TgtTypeName = "Static"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if Event.TgtObjectCategory == Object.Category.SCENERY then
|
if Event.TgtObjectCategory == Object.Category.SCENERY then
|
||||||
|
|||||||
@@ -540,7 +540,7 @@ do -- FSM
|
|||||||
|
|
||||||
--- Returns a table with the scores defined.
|
--- Returns a table with the scores defined.
|
||||||
-- @param #FSM self
|
-- @param #FSM self
|
||||||
-- @param #table Scores.
|
-- @return #table Scores.
|
||||||
function FSM:GetScores()
|
function FSM:GetScores()
|
||||||
return self._Scores or {}
|
return self._Scores or {}
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ do -- COORDINATE
|
|||||||
--
|
--
|
||||||
-- * @{#COORDINATE.WaypointAir}(): Build an air route point.
|
-- * @{#COORDINATE.WaypointAir}(): Build an air route point.
|
||||||
-- * @{#COORDINATE.WaypointGround}(): Build a ground route point.
|
-- * @{#COORDINATE.WaypointGround}(): Build a ground route point.
|
||||||
|
-- * @{#COORDINATE.WaypointNaval}(): Build a naval route point.
|
||||||
--
|
--
|
||||||
-- Route points can be used in the Route methods of the @{Wrapper.Group#GROUP} class.
|
-- Route points can be used in the Route methods of the @{Wrapper.Group#GROUP} class.
|
||||||
--
|
--
|
||||||
@@ -183,10 +184,18 @@ do -- COORDINATE
|
|||||||
--
|
--
|
||||||
-- ## 9) Coordinate text generation
|
-- ## 9) Coordinate text generation
|
||||||
--
|
--
|
||||||
--
|
|
||||||
-- * @{#COORDINATE.ToStringBR}(): Generates a Bearing & Range text in the format of DDD for DI where DDD is degrees and DI is distance.
|
-- * @{#COORDINATE.ToStringBR}(): Generates a Bearing & Range text in the format of DDD for DI where DDD is degrees and DI is distance.
|
||||||
-- * @{#COORDINATE.ToStringLL}(): Generates a Latutude & Longutude text.
|
-- * @{#COORDINATE.ToStringLL}(): Generates a Latutude & Longutude text.
|
||||||
--
|
--
|
||||||
|
-- ## 10) Drawings on F10 map
|
||||||
|
--
|
||||||
|
-- * @{#COORDINATE.CircleToAll}(): Draw a circle on the F10 map.
|
||||||
|
-- * @{#COORDINATE.LineToAll}(): Draw a line on the F10 map.
|
||||||
|
-- * @{#COORDINATE.RectToAll}(): Draw a rectangle on the F10 map.
|
||||||
|
-- * @{#COORDINATE.QuadToAll}(): Draw a shape with four points on the F10 map.
|
||||||
|
-- * @{#COORDINATE.TextToAll}(): Write some text on the F10 map.
|
||||||
|
-- * @{#COORDINATE.ArrowToAll}(): Draw an arrow on the F10 map.
|
||||||
|
--
|
||||||
-- @field #COORDINATE
|
-- @field #COORDINATE
|
||||||
COORDINATE = {
|
COORDINATE = {
|
||||||
ClassName = "COORDINATE",
|
ClassName = "COORDINATE",
|
||||||
@@ -625,9 +634,9 @@ do -- COORDINATE
|
|||||||
|
|
||||||
--- Return a random Coordinate within an Outer Radius and optionally NOT within an Inner Radius of the COORDINATE.
|
--- Return a random Coordinate within an Outer Radius and optionally NOT within an Inner Radius of the COORDINATE.
|
||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
-- @param DCS#Distance OuterRadius
|
-- @param DCS#Distance OuterRadius Outer radius in meters.
|
||||||
-- @param DCS#Distance InnerRadius
|
-- @param DCS#Distance InnerRadius Inner radius in meters.
|
||||||
-- @return #COORDINATE
|
-- @return #COORDINATE self
|
||||||
function COORDINATE:GetRandomCoordinateInRadius( OuterRadius, InnerRadius )
|
function COORDINATE:GetRandomCoordinateInRadius( OuterRadius, InnerRadius )
|
||||||
self:F2( { OuterRadius, InnerRadius } )
|
self:F2( { OuterRadius, InnerRadius } )
|
||||||
|
|
||||||
@@ -1184,7 +1193,7 @@ do -- COORDINATE
|
|||||||
|
|
||||||
-- ETA.
|
-- ETA.
|
||||||
RoutePoint.ETA=0
|
RoutePoint.ETA=0
|
||||||
RoutePoint.ETA_locked=true
|
RoutePoint.ETA_locked=false
|
||||||
|
|
||||||
-- Waypoint description.
|
-- Waypoint description.
|
||||||
RoutePoint.name=description
|
RoutePoint.name=description
|
||||||
@@ -1333,7 +1342,7 @@ do -- COORDINATE
|
|||||||
RoutePoint.formation_template=""
|
RoutePoint.formation_template=""
|
||||||
|
|
||||||
RoutePoint.ETA=0
|
RoutePoint.ETA=0
|
||||||
RoutePoint.ETA_locked=true
|
RoutePoint.ETA_locked=false
|
||||||
|
|
||||||
RoutePoint.speed = ( Speed or 20 ) / 3.6
|
RoutePoint.speed = ( Speed or 20 ) / 3.6
|
||||||
RoutePoint.speed_locked = true
|
RoutePoint.speed_locked = true
|
||||||
@@ -1368,7 +1377,7 @@ do -- COORDINATE
|
|||||||
RoutePoint.formation_template = ""
|
RoutePoint.formation_template = ""
|
||||||
|
|
||||||
RoutePoint.ETA=0
|
RoutePoint.ETA=0
|
||||||
RoutePoint.ETA_locked=true
|
RoutePoint.ETA_locked=false
|
||||||
|
|
||||||
RoutePoint.speed = ( Speed or 20 ) / 3.6
|
RoutePoint.speed = ( Speed or 20 ) / 3.6
|
||||||
RoutePoint.speed_locked = true
|
RoutePoint.speed_locked = true
|
||||||
@@ -1984,13 +1993,13 @@ do -- COORDINATE
|
|||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
-- @param #COORDINATE Endpoint COORDIANTE to where the line is drawn.
|
-- @param #COORDINATE Endpoint COORDIANTE to where the line is drawn.
|
||||||
-- @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.
|
||||||
-- @param #number LineType Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 1=Solid.
|
|
||||||
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red (default).
|
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red (default).
|
||||||
-- @param #number Alpha Transparency [0,1]. Default 1.
|
-- @param #number Alpha Transparency [0,1]. Default 1.
|
||||||
|
-- @param #number LineType Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 1=Solid.
|
||||||
-- @param #boolean ReadOnly (Optional) Mark is readonly and cannot be removed by users. Default false.
|
-- @param #boolean ReadOnly (Optional) Mark is readonly and cannot be removed by users. Default false.
|
||||||
-- @param #string Text (Optional) Text displayed when mark is added. Default none.
|
-- @param #string Text (Optional) Text displayed when mark is added. Default none.
|
||||||
-- @return #number The resulting Mark ID which is a number.
|
-- @return #number The resulting Mark ID, which is a number. Can be used to remove the object again.
|
||||||
function COORDINATE:LineToAll(Endpoint, Coalition, LineType, Color, Alpha, ReadOnly, Text)
|
function COORDINATE:LineToAll(Endpoint, Coalition, Color, Alpha, LineType, ReadOnly, Text)
|
||||||
local MarkID = UTILS.GetMarkID()
|
local MarkID = UTILS.GetMarkID()
|
||||||
if ReadOnly==nil then
|
if ReadOnly==nil then
|
||||||
ReadOnly=false
|
ReadOnly=false
|
||||||
@@ -2007,18 +2016,17 @@ do -- COORDINATE
|
|||||||
--- Circle to all.
|
--- Circle to all.
|
||||||
-- Creates a circle on the map with a given radius, color, fill color, and outline.
|
-- Creates a circle on the map with a given radius, color, fill color, and outline.
|
||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
-- @param #COORDINATE Center COORDIANTE of the center of the circle.
|
|
||||||
-- @param #numberr Radius Radius in meters. Default 1000 m.
|
-- @param #numberr Radius Radius in meters. Default 1000 m.
|
||||||
-- @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.
|
||||||
-- @param #number LineType Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 1=Solid.
|
|
||||||
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red (default).
|
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red (default).
|
||||||
-- @param #number Alpha Transparency [0,1]. Default 1.
|
-- @param #number Alpha Transparency [0,1]. Default 1.
|
||||||
-- @param #table FillColor RGB color table {r, g, b}, e.g. {1,0,0} for red (default).
|
-- @param #table FillColor RGB color table {r, g, b}, e.g. {1,0,0} for red. Default is same as `Color` value.
|
||||||
-- @param #number FillAlpha Transparency [0,1]. Default 0.5.
|
-- @param #number FillAlpha Transparency [0,1]. Default 0.15.
|
||||||
|
-- @param #number LineType Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 1=Solid.
|
||||||
-- @param #boolean ReadOnly (Optional) Mark is readonly and cannot be removed by users. Default false.
|
-- @param #boolean ReadOnly (Optional) Mark is readonly and cannot be removed by users. Default false.
|
||||||
-- @param #string Text (Optional) Text displayed when mark is added. Default none.
|
-- @param #string Text (Optional) Text displayed when mark is added. Default none.
|
||||||
-- @return #number The resulting Mark ID which is a number.
|
-- @return #number The resulting Mark ID, which is a number. Can be used to remove the object again.
|
||||||
function COORDINATE:CircleToAll(Radius, Coalition, LineType, Color, Alpha, FillColor, FillAlpha, ReadOnly, Text)
|
function COORDINATE:CircleToAll(Radius, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly, Text)
|
||||||
local MarkID = UTILS.GetMarkID()
|
local MarkID = UTILS.GetMarkID()
|
||||||
if ReadOnly==nil then
|
if ReadOnly==nil then
|
||||||
ReadOnly=false
|
ReadOnly=false
|
||||||
@@ -2029,14 +2037,193 @@ do -- COORDINATE
|
|||||||
Color=Color or {1,0,0}
|
Color=Color or {1,0,0}
|
||||||
Color[4]=Alpha or 1.0
|
Color[4]=Alpha or 1.0
|
||||||
LineType=LineType or 1
|
LineType=LineType or 1
|
||||||
FillColor=FillColor or {1,0,0}
|
FillColor=FillColor or Color
|
||||||
FillColor[4]=FillAlpha or 0.5
|
FillColor[4]=FillAlpha or 0.15
|
||||||
trigger.action.circleToAll(Coalition, MarkID, vec3, Radius, Color, FillColor, LineType, ReadOnly, Text or "")
|
trigger.action.circleToAll(Coalition, MarkID, vec3, Radius, Color, FillColor, LineType, ReadOnly, Text or "")
|
||||||
return MarkID
|
return MarkID
|
||||||
end
|
end
|
||||||
|
|
||||||
end -- Markings
|
end -- Markings
|
||||||
|
|
||||||
|
--- Rectangle to all. Creates a rectangle on the map from the COORDINATE in one corner to the end COORDINATE in the opposite corner.
|
||||||
|
-- Creates a line on the F10 map from one point to another.
|
||||||
|
-- @param #COORDINATE self
|
||||||
|
-- @param #COORDINATE Endpoint COORDIANTE in the opposite corner.
|
||||||
|
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
|
||||||
|
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red (default).
|
||||||
|
-- @param #number Alpha Transparency [0,1]. Default 1.
|
||||||
|
-- @param #table FillColor RGB color table {r, g, b}, e.g. {1,0,0} for red. Default is same as `Color` value.
|
||||||
|
-- @param #number FillAlpha Transparency [0,1]. Default 0.15.
|
||||||
|
-- @param #number LineType Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 1=Solid.
|
||||||
|
-- @param #boolean ReadOnly (Optional) Mark is readonly and cannot be removed by users. Default false.
|
||||||
|
-- @param #string Text (Optional) Text displayed when mark is added. Default none.
|
||||||
|
-- @return #number The resulting Mark ID, which is a number. Can be used to remove the object again.
|
||||||
|
function COORDINATE:RectToAll(Endpoint, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly, Text)
|
||||||
|
local MarkID = UTILS.GetMarkID()
|
||||||
|
if ReadOnly==nil then
|
||||||
|
ReadOnly=false
|
||||||
|
end
|
||||||
|
local vec3=Endpoint:GetVec3()
|
||||||
|
Coalition=Coalition or -1
|
||||||
|
Color=Color or {1,0,0}
|
||||||
|
Color[4]=Alpha or 1.0
|
||||||
|
LineType=LineType or 1
|
||||||
|
FillColor=FillColor or Color
|
||||||
|
FillColor[4]=FillAlpha or 0.15
|
||||||
|
trigger.action.rectToAll(Coalition, MarkID, self:GetVec3(), vec3, Color, FillColor, LineType, ReadOnly, Text or "")
|
||||||
|
return MarkID
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Creates a shape defined by 4 points on the F10 map. The first point is the current COORDINATE. The remaining three points need to be specified.
|
||||||
|
-- @param #COORDINATE self
|
||||||
|
-- @param #COORDINATE Coord2 Second COORDIANTE of the quad shape.
|
||||||
|
-- @param #COORDINATE Coord3 Third COORDIANTE of the quad shape.
|
||||||
|
-- @param #COORDINATE Coord4 Fourth COORDIANTE of the quad shape.
|
||||||
|
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
|
||||||
|
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red (default).
|
||||||
|
-- @param #number Alpha Transparency [0,1]. Default 1.
|
||||||
|
-- @param #table FillColor RGB color table {r, g, b}, e.g. {1,0,0} for red. Default is same as `Color` value.
|
||||||
|
-- @param #number FillAlpha Transparency [0,1]. Default 0.15.
|
||||||
|
-- @param #number LineType Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 1=Solid.
|
||||||
|
-- @param #boolean ReadOnly (Optional) Mark is readonly and cannot be removed by users. Default false.
|
||||||
|
-- @param #string Text (Optional) Text displayed when mark is added. Default none.
|
||||||
|
-- @return #number The resulting Mark ID, which is a number. Can be used to remove the object again.
|
||||||
|
function COORDINATE:QuadToAll(Coord2, Coord3, Coord4, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly, Text)
|
||||||
|
local MarkID = UTILS.GetMarkID()
|
||||||
|
if ReadOnly==nil then
|
||||||
|
ReadOnly=false
|
||||||
|
end
|
||||||
|
local point1=self:GetVec3()
|
||||||
|
local point2=Coord2:GetVec3()
|
||||||
|
local point3=Coord3:GetVec3()
|
||||||
|
local point4=Coord4:GetVec3()
|
||||||
|
Coalition=Coalition or -1
|
||||||
|
Color=Color or {1,0,0}
|
||||||
|
Color[4]=Alpha or 1.0
|
||||||
|
LineType=LineType or 1
|
||||||
|
FillColor=FillColor or Color
|
||||||
|
FillColor[4]=FillAlpha or 0.15
|
||||||
|
trigger.action.quadToAll(Coalition, MarkID, self:GetVec3(), point2, point3, point4, Color, FillColor, LineType, ReadOnly, Text or "")
|
||||||
|
return MarkID
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Creates a free form shape on the F10 map. The first point is the current COORDINATE. The remaining points need to be specified.
|
||||||
|
-- **NOTE**: A free form polygon must have **at least three points** in total and currently only **up to 10 points** in total are supported.
|
||||||
|
-- @param #COORDINATE self
|
||||||
|
-- @param #table Coordinates Table of coordinates of the remaining points of the shape.
|
||||||
|
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
|
||||||
|
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red (default).
|
||||||
|
-- @param #number Alpha Transparency [0,1]. Default 1.
|
||||||
|
-- @param #table FillColor RGB color table {r, g, b}, e.g. {1,0,0} for red. Default is same as `Color` value.
|
||||||
|
-- @param #number FillAlpha Transparency [0,1]. Default 0.15.
|
||||||
|
-- @param #number LineType Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 1=Solid.
|
||||||
|
-- @param #boolean ReadOnly (Optional) Mark is readonly and cannot be removed by users. Default false.
|
||||||
|
-- @param #string Text (Optional) Text displayed when mark is added. Default none.
|
||||||
|
-- @return #number The resulting Mark ID, which is a number. Can be used to remove the object again.
|
||||||
|
function COORDINATE:MarkupToAllFreeForm(Coordinates, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly, Text)
|
||||||
|
|
||||||
|
local MarkID = UTILS.GetMarkID()
|
||||||
|
if ReadOnly==nil then
|
||||||
|
ReadOnly=false
|
||||||
|
end
|
||||||
|
|
||||||
|
Coalition=Coalition or -1
|
||||||
|
|
||||||
|
Color=Color or {1,0,0}
|
||||||
|
Color[4]=Alpha or 1.0
|
||||||
|
|
||||||
|
LineType=LineType or 1
|
||||||
|
|
||||||
|
FillColor=FillColor or UTILS.DeepCopy(Color)
|
||||||
|
FillColor[4]=FillAlpha or 0.15
|
||||||
|
|
||||||
|
local vecs={}
|
||||||
|
vecs[1]=self:GetVec3()
|
||||||
|
for i,coord in ipairs(Coordinates) do
|
||||||
|
vecs[i+1]=coord:GetVec3()
|
||||||
|
end
|
||||||
|
|
||||||
|
if #vecs<3 then
|
||||||
|
self:E("ERROR: A free form polygon needs at least three points!")
|
||||||
|
elseif #vecs==3 then
|
||||||
|
trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], Color, FillColor, LineType, ReadOnly, Text or "")
|
||||||
|
elseif #vecs==4 then
|
||||||
|
trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], vecs[4], Color, FillColor, LineType, ReadOnly, Text or "")
|
||||||
|
elseif #vecs==5 then
|
||||||
|
trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], vecs[4], vecs[5], Color, FillColor, LineType, ReadOnly, Text or "")
|
||||||
|
elseif #vecs==6 then
|
||||||
|
trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], vecs[4], vecs[5], vecs[6], Color, FillColor, LineType, Text or "")
|
||||||
|
elseif #vecs==7 then
|
||||||
|
trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], vecs[4], vecs[5], vecs[6], vecs[7], Color, FillColor, LineType, ReadOnly, Text or "")
|
||||||
|
elseif #vecs==8 then
|
||||||
|
trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], vecs[4], vecs[5], vecs[6], vecs[7], vecs[8], Color, FillColor, LineType, ReadOnly, Text or "")
|
||||||
|
elseif #vecs==9 then
|
||||||
|
trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], vecs[4], vecs[5], vecs[6], vecs[7], vecs[8], vecs[9], Color, FillColor, LineType, ReadOnly, Text or "")
|
||||||
|
elseif #vecs==10 then
|
||||||
|
trigger.action.markupToAll(7, Coalition, MarkID, vecs[1], vecs[2], vecs[3], vecs[4], vecs[5], vecs[6], vecs[7], vecs[8], vecs[9], vecs[10], Color, FillColor, LineType, ReadOnly, Text or "")
|
||||||
|
else
|
||||||
|
self:E("ERROR: Currently a free form polygon can only have 10 points in total!")
|
||||||
|
-- Unfortunately, unpack(vecs) does not work! So no idea how to generalize this :(
|
||||||
|
trigger.action.markupToAll(7, Coalition, MarkID, unpack(vecs), Color, FillColor, LineType, ReadOnly, Text or "")
|
||||||
|
end
|
||||||
|
|
||||||
|
return MarkID
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Text to all. Creates a text imposed on the map at the COORDINATE. Text scales with the map.
|
||||||
|
-- @param #COORDINATE self
|
||||||
|
-- @param #string Text Text displayed on the F10 map.
|
||||||
|
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
|
||||||
|
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red (default).
|
||||||
|
-- @param #number Alpha Transparency [0,1]. Default 1.
|
||||||
|
-- @param #table FillColor RGB color table {r, g, b}, e.g. {1,0,0} for red. Default is same as `Color` value.
|
||||||
|
-- @param #number FillAlpha Transparency [0,1]. Default 0.3.
|
||||||
|
-- @param #number FontSize Font size. Default 14.
|
||||||
|
-- @param #boolean ReadOnly (Optional) Mark is readonly and cannot be removed by users. Default false.
|
||||||
|
-- @return #number The resulting Mark ID, which is a number. Can be used to remove the object again.
|
||||||
|
function COORDINATE:TextToAll(Text, Coalition, Color, Alpha, FillColor, FillAlpha, FontSize, ReadOnly)
|
||||||
|
local MarkID = UTILS.GetMarkID()
|
||||||
|
if ReadOnly==nil then
|
||||||
|
ReadOnly=false
|
||||||
|
end
|
||||||
|
Coalition=Coalition or -1
|
||||||
|
Color=Color or {1,0,0}
|
||||||
|
Color[4]=Alpha or 1.0
|
||||||
|
FillColor=FillColor or Color
|
||||||
|
FillColor[4]=FillAlpha or 0.3
|
||||||
|
FontSize=FontSize or 14
|
||||||
|
trigger.action.textToAll(Coalition, MarkID, self:GetVec3(), Color, FillColor, FontSize, ReadOnly, Text or "Hello World")
|
||||||
|
return MarkID
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Arrow to all. Creates an arrow from the COORDINATE to the endpoint COORDINATE on the F10 map. There is no control over other dimensions of the arrow.
|
||||||
|
-- @param #COORDINATE self
|
||||||
|
-- @param #COORDINATE Endpoint COORDINATE where the tip of the arrow is pointing at.
|
||||||
|
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
|
||||||
|
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red (default).
|
||||||
|
-- @param #number Alpha Transparency [0,1]. Default 1.
|
||||||
|
-- @param #table FillColor RGB color table {r, g, b}, e.g. {1,0,0} for red. Default is same as `Color` value.
|
||||||
|
-- @param #number FillAlpha Transparency [0,1]. Default 0.15.
|
||||||
|
-- @param #number LineType Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 1=Solid.
|
||||||
|
-- @param #boolean ReadOnly (Optional) Mark is readonly and cannot be removed by users. Default false.
|
||||||
|
-- @param #string Text (Optional) Text displayed when mark is added. Default none.
|
||||||
|
-- @return #number The resulting Mark ID, which is a number. Can be used to remove the object again.
|
||||||
|
function COORDINATE:ArrowToAll(Endpoint, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly, Text)
|
||||||
|
local MarkID = UTILS.GetMarkID()
|
||||||
|
if ReadOnly==nil then
|
||||||
|
ReadOnly=false
|
||||||
|
end
|
||||||
|
local vec3=Endpoint:GetVec3()
|
||||||
|
Coalition=Coalition or -1
|
||||||
|
Color=Color or {1,0,0}
|
||||||
|
Color[4]=Alpha or 1.0
|
||||||
|
LineType=LineType or 1
|
||||||
|
FillColor=FillColor or Color
|
||||||
|
FillColor[4]=FillAlpha or 0.15
|
||||||
|
--trigger.action.textToAll(Coalition, MarkID, self:GetVec3(), Color, FillColor, FontSize, ReadOnly, Text or "Hello World")
|
||||||
|
trigger.action.arrowToAll(Coalition, MarkID, vec3, self:GetVec3(), Color, FillColor, LineType, ReadOnly, Text or "")
|
||||||
|
return MarkID
|
||||||
|
end
|
||||||
|
|
||||||
--- Returns if a Coordinate has Line of Sight (LOS) with the ToCoordinate.
|
--- Returns if a Coordinate has Line of Sight (LOS) with the ToCoordinate.
|
||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
|
|||||||
@@ -3267,7 +3267,7 @@ do -- SET_STATIC
|
|||||||
-- @param #SET_STATIC self
|
-- @param #SET_STATIC self
|
||||||
-- @param Core.Zone#ZONE Zone The Zone to be tested for.
|
-- @param Core.Zone#ZONE Zone The Zone to be tested for.
|
||||||
-- @return #boolean
|
-- @return #boolean
|
||||||
function SET_STATIC:IsPatriallyInZone( Zone )
|
function SET_STATIC:IsPartiallyInZone( Zone )
|
||||||
|
|
||||||
local IsPartiallyInZone = false
|
local IsPartiallyInZone = false
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
-- * Get zone properties.
|
-- * Get zone properties.
|
||||||
-- * Get zone bounding box.
|
-- * Get zone bounding box.
|
||||||
-- * Set/get zone name.
|
-- * Set/get zone name.
|
||||||
|
-- * Draw zones (circular and polygon) on the F10 map.
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- There are essentially two core functions that zones accomodate:
|
-- There are essentially two core functions that zones accomodate:
|
||||||
@@ -56,6 +57,8 @@
|
|||||||
--- @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.
|
||||||
|
-- @field #number DrawID Unique ID of the drawn zone on the F10 map.
|
||||||
|
-- @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
|
||||||
|
|
||||||
|
|
||||||
@@ -104,7 +107,9 @@ ZONE_BASE = {
|
|||||||
ClassName = "ZONE_BASE",
|
ClassName = "ZONE_BASE",
|
||||||
ZoneName = "",
|
ZoneName = "",
|
||||||
ZoneProbability = 1,
|
ZoneProbability = 1,
|
||||||
}
|
DrawID=nil,
|
||||||
|
Color={}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
--- The ZONE_BASE.BoundingSquare
|
--- The ZONE_BASE.BoundingSquare
|
||||||
@@ -221,22 +226,6 @@ function ZONE_BASE:GetPointVec2()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns a @{Core.Point#COORDINATE} of the zone.
|
|
||||||
-- @param #ZONE_BASE self
|
|
||||||
-- @return Core.Point#COORDINATE The Coordinate of the zone.
|
|
||||||
function ZONE_BASE:GetCoordinate()
|
|
||||||
self:F2( self.ZoneName )
|
|
||||||
|
|
||||||
local Vec2 = self:GetVec2()
|
|
||||||
|
|
||||||
local Coordinate = COORDINATE:NewFromVec2( Vec2 )
|
|
||||||
|
|
||||||
self:T2( { Coordinate } )
|
|
||||||
|
|
||||||
return Coordinate
|
|
||||||
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.
|
||||||
@@ -276,15 +265,27 @@ end
|
|||||||
-- @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.
|
||||||
-- @return Core.Point#COORDINATE The Coordinate of the zone.
|
-- @return Core.Point#COORDINATE The Coordinate of the zone.
|
||||||
function ZONE_BASE:GetCoordinate( Height ) --R2.1
|
function ZONE_BASE:GetCoordinate( Height ) --R2.1
|
||||||
self:F2( self.ZoneName )
|
self:F2(self.ZoneName)
|
||||||
|
|
||||||
local Vec3 = self:GetVec3( Height )
|
local Vec3 = self:GetVec3( Height )
|
||||||
|
|
||||||
local PointVec3 = COORDINATE:NewFromVec3( Vec3 )
|
if self.Coordinate then
|
||||||
|
|
||||||
self:T2( { PointVec3 } )
|
-- Update coordinates.
|
||||||
|
self.Coordinate.x=Vec3.x
|
||||||
|
self.Coordinate.y=Vec3.y
|
||||||
|
self.Coordinate.z=Vec3.z
|
||||||
|
|
||||||
return PointVec3
|
--env.info("FF GetCoordinate NEW for ZONE_BASE "..tostring(self.ZoneName))
|
||||||
|
else
|
||||||
|
|
||||||
|
-- Create a new coordinate object.
|
||||||
|
self.Coordinate=COORDINATE:NewFromVec3(Vec3)
|
||||||
|
|
||||||
|
--env.info("FF GetCoordinate NEW for ZONE_BASE "..tostring(self.ZoneName))
|
||||||
|
end
|
||||||
|
|
||||||
|
return self.Coordinate
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -324,6 +325,76 @@ function ZONE_BASE:BoundZone()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set color of zone.
|
||||||
|
-- @param #ZONE_BASE self
|
||||||
|
-- @param #table RGBcolor RGB color table. Default `{1, 0, 0}`.
|
||||||
|
-- @param #number Alpha Transparacy between 0 and 1. Default 0.15.
|
||||||
|
-- @return #ZONE_BASE self
|
||||||
|
function ZONE_BASE:SetColor(RGBcolor, Alpha)
|
||||||
|
|
||||||
|
RGBcolor=RGBcolor or {1, 0, 0}
|
||||||
|
Alpha=Alpha or 0.15
|
||||||
|
|
||||||
|
self.Color={}
|
||||||
|
self.Color[1]=RGBcolor[1]
|
||||||
|
self.Color[2]=RGBcolor[2]
|
||||||
|
self.Color[3]=RGBcolor[3]
|
||||||
|
self.Color[4]=Alpha
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get color table of the zone.
|
||||||
|
-- @param #ZONE_BASE self
|
||||||
|
-- @return #table Table with four entries, e.g. {1, 0, 0, 0.15}. First three are RGB color code. Fourth is the transparency Alpha value.
|
||||||
|
function ZONE_BASE:GetColor()
|
||||||
|
return self.Color
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get RGB color of zone.
|
||||||
|
-- @param #ZONE_BASE self
|
||||||
|
-- @return #table Table with three entries, e.g. {1, 0, 0}, which is the RGB color code.
|
||||||
|
function ZONE_BASE:GetColorRGB()
|
||||||
|
local rgb={}
|
||||||
|
rgb[1]=self.Color[1]
|
||||||
|
rgb[2]=self.Color[2]
|
||||||
|
rgb[3]=self.Color[3]
|
||||||
|
return rgb
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get transperency Alpha value of zone.
|
||||||
|
-- @param #ZONE_BASE self
|
||||||
|
-- @return #number Alpha value.
|
||||||
|
function ZONE_BASE:GetColorAlpha()
|
||||||
|
local alpha=self.Color[4]
|
||||||
|
return alpha
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Remove the drawing of the zone from the F10 map.
|
||||||
|
-- @param #ZONE_BASE self
|
||||||
|
-- @param #number Delay (Optional) Delay before the drawing is removed.
|
||||||
|
-- @return #ZONE_BASE self
|
||||||
|
function ZONE_BASE:UndrawZone(Delay)
|
||||||
|
if Delay and Delay>0 then
|
||||||
|
self:ScheduleOnce(Delay, ZONE_BASE.UndrawZone, self)
|
||||||
|
else
|
||||||
|
if self.DrawID then
|
||||||
|
UTILS.RemoveMark(self.DrawID)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get ID of the zone object drawn on the F10 map.
|
||||||
|
-- The ID can be used to remove the drawn object from the F10 map view via `UTILS.RemoveMark(MarkID)`.
|
||||||
|
-- @param #ZONE_BASE self
|
||||||
|
-- @return #number Unique ID of the
|
||||||
|
function ZONE_BASE:GetDrawID()
|
||||||
|
return self.DrawID
|
||||||
|
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.
|
||||||
@@ -421,6 +492,10 @@ end
|
|||||||
-- * @{#ZONE_RADIUS.GetRandomPointVec2}(): Gets a @{Core.Point#POINT_VEC2} object representing a random 2D point in the zone.
|
-- * @{#ZONE_RADIUS.GetRandomPointVec2}(): Gets a @{Core.Point#POINT_VEC2} object representing a random 2D point in the zone.
|
||||||
-- * @{#ZONE_RADIUS.GetRandomPointVec3}(): Gets a @{Core.Point#POINT_VEC3} object representing a random 3D point in the zone. Note that the height of the point is at landheight.
|
-- * @{#ZONE_RADIUS.GetRandomPointVec3}(): Gets a @{Core.Point#POINT_VEC3} object representing a random 3D point in the zone. Note that the height of the point is at landheight.
|
||||||
--
|
--
|
||||||
|
-- ## Draw zone
|
||||||
|
--
|
||||||
|
-- * @{#ZONE_RADIUS.DrawZone}(): Draws the zone on the F10 map.
|
||||||
|
--
|
||||||
-- @field #ZONE_RADIUS
|
-- @field #ZONE_RADIUS
|
||||||
ZONE_RADIUS = {
|
ZONE_RADIUS = {
|
||||||
ClassName="ZONE_RADIUS",
|
ClassName="ZONE_RADIUS",
|
||||||
@@ -433,12 +508,51 @@ ZONE_RADIUS = {
|
|||||||
-- @param DCS#Distance Radius The radius of the zone.
|
-- @param DCS#Distance Radius The radius of the zone.
|
||||||
-- @return #ZONE_RADIUS self
|
-- @return #ZONE_RADIUS self
|
||||||
function ZONE_RADIUS:New( ZoneName, Vec2, Radius )
|
function ZONE_RADIUS:New( ZoneName, Vec2, Radius )
|
||||||
|
|
||||||
|
-- Inherit ZONE_BASE.
|
||||||
local self = BASE:Inherit( self, ZONE_BASE:New( ZoneName ) ) -- #ZONE_RADIUS
|
local self = BASE:Inherit( self, ZONE_BASE:New( ZoneName ) ) -- #ZONE_RADIUS
|
||||||
self:F( { ZoneName, Vec2, Radius } )
|
self:F( { ZoneName, Vec2, Radius } )
|
||||||
|
|
||||||
self.Radius = Radius
|
self.Radius = Radius
|
||||||
self.Vec2 = Vec2
|
self.Vec2 = Vec2
|
||||||
|
|
||||||
|
--self.Coordinate=COORDINATE:NewFromVec2(Vec2)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Update zone from a 2D vector.
|
||||||
|
-- @param #ZONE_RADIUS self
|
||||||
|
-- @param DCS#Vec2 Vec2 The location of the zone.
|
||||||
|
-- @param DCS#Distance Radius The radius of the zone.
|
||||||
|
-- @return #ZONE_RADIUS self
|
||||||
|
function ZONE_RADIUS:UpdateFromVec2(Vec2, Radius)
|
||||||
|
|
||||||
|
-- New center of the zone.
|
||||||
|
self.Vec2=Vec2
|
||||||
|
|
||||||
|
if Radius then
|
||||||
|
self.Radius=Radius
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Update zone from a 2D vector.
|
||||||
|
-- @param #ZONE_RADIUS self
|
||||||
|
-- @param DCS#Vec3 Vec3 The location of the zone.
|
||||||
|
-- @param DCS#Distance Radius The radius of the zone.
|
||||||
|
-- @return #ZONE_RADIUS self
|
||||||
|
function ZONE_RADIUS:UpdateFromVec3(Vec3, Radius)
|
||||||
|
|
||||||
|
-- New center of the zone.
|
||||||
|
self.Vec2.x=Vec3.x
|
||||||
|
self.Vec2.y=Vec3.z
|
||||||
|
|
||||||
|
if Radius then
|
||||||
|
self.Radius=Radius
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -469,6 +583,32 @@ function ZONE_RADIUS:MarkZone(Points)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Draw the zone circle on the F10 map.
|
||||||
|
-- @param #ZONE_RADIUS self
|
||||||
|
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
|
||||||
|
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red.
|
||||||
|
-- @param #number Alpha Transparency [0,1]. Default 1.
|
||||||
|
-- @param #table FillColor RGB color table {r, g, b}, e.g. {1,0,0} for red. Default is same as `Color` value.
|
||||||
|
-- @param #number FillAlpha Transparency [0,1]. Default 0.15.
|
||||||
|
-- @param #number LineType Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 1=Solid.
|
||||||
|
-- @param #boolean ReadOnly (Optional) Mark is readonly and cannot be removed by users. Default false.
|
||||||
|
-- @return #ZONE_RADIUS self
|
||||||
|
function ZONE_RADIUS:DrawZone(Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly)
|
||||||
|
|
||||||
|
local coordinate=self:GetCoordinate()
|
||||||
|
|
||||||
|
local Radius=self:GetRadius()
|
||||||
|
|
||||||
|
Color=Color or self:GetColorRGB()
|
||||||
|
Alpha=Alpha or 1
|
||||||
|
FillColor=FillColor or Color
|
||||||
|
FillAlpha=FillAlpha or self:GetColorAlpha()
|
||||||
|
|
||||||
|
self.DrawID=coordinate:CircleToAll(Radius, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Bounds the zone with tires.
|
--- Bounds the zone with tires.
|
||||||
-- @param #ZONE_RADIUS self
|
-- @param #ZONE_RADIUS self
|
||||||
-- @param #number Points (optional) The amount of points in the circle. Default 360.
|
-- @param #number Points (optional) The amount of points in the circle. Default 360.
|
||||||
@@ -781,6 +921,32 @@ function ZONE_RADIUS:GetScannedSetUnit()
|
|||||||
return SetUnit
|
return SetUnit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get a set of scanned units.
|
||||||
|
-- @param #ZONE_RADIUS self
|
||||||
|
-- @return Core.Set#SET_GROUP Set of groups.
|
||||||
|
function ZONE_RADIUS:GetScannedSetGroup()
|
||||||
|
|
||||||
|
self.ScanSetGroup=self.ScanSetGroup or SET_GROUP:New() --Core.Set#SET_GROUP
|
||||||
|
|
||||||
|
self.ScanSetGroup.Set={}
|
||||||
|
|
||||||
|
if self.ScanData then
|
||||||
|
for ObjectID, UnitObject in pairs( self.ScanData.Units ) do
|
||||||
|
local UnitObject = UnitObject -- DCS#Unit
|
||||||
|
if UnitObject:isExist() then
|
||||||
|
|
||||||
|
local FoundUnit=UNIT:FindByName(UnitObject:getName())
|
||||||
|
if FoundUnit then
|
||||||
|
local group=FoundUnit:GetGroup()
|
||||||
|
self.ScanSetGroup:AddGroup(group)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return self.ScanSetGroup
|
||||||
|
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
|
||||||
@@ -1116,22 +1282,37 @@ 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.
|
||||||
-- @return #ZONE
|
-- @return #ZONE self
|
||||||
function ZONE:New( ZoneName )
|
function ZONE:New( ZoneName )
|
||||||
|
|
||||||
|
-- First try to find the zone in the DB.
|
||||||
|
local zone=_DATABASE:FindZone(ZoneName)
|
||||||
|
|
||||||
|
if zone then
|
||||||
|
--env.info("FF found zone in DB")
|
||||||
|
return zone
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get zone from DCS trigger function.
|
||||||
local Zone = trigger.misc.getZone( ZoneName )
|
local Zone = trigger.misc.getZone( ZoneName )
|
||||||
|
|
||||||
|
-- Error!
|
||||||
if not Zone then
|
if not Zone then
|
||||||
error( "Zone " .. ZoneName .. " does not exist." )
|
error( "Zone " .. ZoneName .. " does not exist." )
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local self = BASE:Inherit( self, ZONE_RADIUS:New( ZoneName, { x = Zone.point.x, y = Zone.point.z }, Zone.radius ) )
|
-- Create a new ZONE_RADIUS.
|
||||||
self:F( ZoneName )
|
local self=BASE:Inherit( self, ZONE_RADIUS:New(ZoneName, {x=Zone.point.x, y=Zone.point.z}, Zone.radius))
|
||||||
|
self:F(ZoneName)
|
||||||
|
|
||||||
|
-- Color of zone.
|
||||||
|
self.Color={1, 0, 0, 0.15}
|
||||||
|
|
||||||
|
-- DCS zone.
|
||||||
self.Zone = Zone
|
self.Zone = Zone
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@@ -1392,26 +1573,38 @@ end
|
|||||||
-- * @{#ZONE_POLYGON_BASE.GetRandomPointVec2}(): Return a @{Core.Point#POINT_VEC2} object representing a random 2D point within the zone.
|
-- * @{#ZONE_POLYGON_BASE.GetRandomPointVec2}(): Return a @{Core.Point#POINT_VEC2} object representing a random 2D point within the zone.
|
||||||
-- * @{#ZONE_POLYGON_BASE.GetRandomPointVec3}(): Return a @{Core.Point#POINT_VEC3} object representing a random 3D point at landheight within the zone.
|
-- * @{#ZONE_POLYGON_BASE.GetRandomPointVec3}(): Return a @{Core.Point#POINT_VEC3} object representing a random 3D point at landheight within the zone.
|
||||||
--
|
--
|
||||||
|
-- ## Draw zone
|
||||||
|
--
|
||||||
|
-- * @{#ZONE_POLYGON_BASE.DrawZone}(): Draws the zone on the F10 map.
|
||||||
|
-- * @{#ZONE_POLYGON_BASE.Boundary}(): Draw a frontier on the F10 map with small filled circles.
|
||||||
|
--
|
||||||
|
--
|
||||||
-- @field #ZONE_POLYGON_BASE
|
-- @field #ZONE_POLYGON_BASE
|
||||||
ZONE_POLYGON_BASE = {
|
ZONE_POLYGON_BASE = {
|
||||||
ClassName="ZONE_POLYGON_BASE",
|
ClassName="ZONE_POLYGON_BASE",
|
||||||
}
|
}
|
||||||
|
|
||||||
--- A points array.
|
--- A 2D points array.
|
||||||
-- @type ZONE_POLYGON_BASE.ListVec2
|
-- @type ZONE_POLYGON_BASE.ListVec2
|
||||||
-- @list <DCS#Vec2>
|
-- @list <DCS#Vec2> Table of 2D vectors.
|
||||||
|
|
||||||
|
--- A 3D points array.
|
||||||
|
-- @type ZONE_POLYGON_BASE.ListVec3
|
||||||
|
-- @list <DCS#Vec3> Table of 3D vectors.
|
||||||
|
|
||||||
--- Constructor to create a ZONE_POLYGON_BASE instance, taking the zone name and an array of @{DCS#Vec2}, forming a polygon.
|
--- Constructor to create a ZONE_POLYGON_BASE instance, taking the zone name and an array of @{DCS#Vec2}, forming a polygon.
|
||||||
-- The @{Wrapper.Group#GROUP} waypoints define the polygon corners. The first and the last point are automatically connected.
|
-- The @{Wrapper.Group#GROUP} waypoints define the polygon corners. The first and the last point are automatically connected.
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @param #string ZoneName Name of the zone.
|
-- @param #string ZoneName Name of the zone.
|
||||||
-- @param #ZONE_POLYGON_BASE.ListVec2 PointsArray An array of @{DCS#Vec2}, forming a polygon..
|
-- @param #ZONE_POLYGON_BASE.ListVec2 PointsArray An array of @{DCS#Vec2}, forming a polygon.
|
||||||
-- @return #ZONE_POLYGON_BASE self
|
-- @return #ZONE_POLYGON_BASE self
|
||||||
function ZONE_POLYGON_BASE:New( ZoneName, PointsArray )
|
function ZONE_POLYGON_BASE:New( ZoneName, PointsArray )
|
||||||
|
|
||||||
|
-- Inherit ZONE_BASE.
|
||||||
local self = BASE:Inherit( self, ZONE_BASE:New( ZoneName ) )
|
local self = BASE:Inherit( self, ZONE_BASE:New( ZoneName ) )
|
||||||
self:F( { ZoneName, PointsArray } )
|
self:F( { ZoneName, PointsArray } )
|
||||||
|
|
||||||
local i = 0
|
if PointsArray then
|
||||||
|
|
||||||
self._.Polygon = {}
|
self._.Polygon = {}
|
||||||
|
|
||||||
@@ -1421,11 +1614,47 @@ function ZONE_POLYGON_BASE:New( ZoneName, PointsArray )
|
|||||||
self._.Polygon[i].y = PointsArray[i].y
|
self._.Polygon[i].y = PointsArray[i].y
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Update polygon points with an array of @{DCS#Vec2}.
|
||||||
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
|
-- @param #ZONE_POLYGON_BASE.ListVec2 Vec2Array An array of @{DCS#Vec2}, forming a polygon.
|
||||||
|
-- @return #ZONE_POLYGON_BASE self
|
||||||
|
function ZONE_POLYGON_BASE:UpdateFromVec2(Vec2Array)
|
||||||
|
|
||||||
|
self._.Polygon = {}
|
||||||
|
|
||||||
|
for i=1,#Vec2Array do
|
||||||
|
self._.Polygon[i] = {}
|
||||||
|
self._.Polygon[i].x=Vec2Array[i].x
|
||||||
|
self._.Polygon[i].y=Vec2Array[i].y
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Update polygon points with an array of @{DCS#Vec3}.
|
||||||
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
|
-- @param #ZONE_POLYGON_BASE.ListVec3 Vec2Array An array of @{DCS#Vec3}, forming a polygon.
|
||||||
|
-- @return #ZONE_POLYGON_BASE self
|
||||||
|
function ZONE_POLYGON_BASE:UpdateFromVec3(Vec3Array)
|
||||||
|
|
||||||
|
self._.Polygon = {}
|
||||||
|
|
||||||
|
for i=1,#Vec3Array do
|
||||||
|
self._.Polygon[i] = {}
|
||||||
|
self._.Polygon[i].x=Vec3Array[i].x
|
||||||
|
self._.Polygon[i].y=Vec3Array[i].z
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the center location of the polygon.
|
--- Returns the center location of the polygon.
|
||||||
-- @param #ZONE_GROUP self
|
-- @param #ZONE_POLYGON_BASE 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.
|
||||||
function ZONE_POLYGON_BASE:GetVec2()
|
function ZONE_POLYGON_BASE:GetVec2()
|
||||||
self:F( self.ZoneName )
|
self:F( self.ZoneName )
|
||||||
@@ -1435,6 +1664,78 @@ function ZONE_POLYGON_BASE:GetVec2()
|
|||||||
return { x = ( Bounds.x2 + Bounds.x1 ) / 2, y = ( Bounds.y2 + Bounds.y1 ) / 2 }
|
return { x = ( Bounds.x2 + Bounds.x1 ) / 2, y = ( Bounds.y2 + Bounds.y1 ) / 2 }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get a vertex of the polygon.
|
||||||
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
|
-- @param #number Index Index of the vertex. Default 1.
|
||||||
|
-- @return DCS#Vec2 Vertex of the polygon.
|
||||||
|
function ZONE_POLYGON_BASE:GetVertexVec2(Index)
|
||||||
|
return self._.Polygon[Index or 1]
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get a vertex of the polygon.
|
||||||
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
|
-- @param #number Index Index of the vertex. Default 1.
|
||||||
|
-- @return DCS#Vec3 Vertex of the polygon.
|
||||||
|
function ZONE_POLYGON_BASE:GetVertexVec3(Index)
|
||||||
|
local vec2=self:GetVertexVec2(Index)
|
||||||
|
if vec2 then
|
||||||
|
local vec3={x=vec2.x, y=land.getHeight(vec2), z=vec2.y}
|
||||||
|
return vec3
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get a vertex of the polygon.
|
||||||
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
|
-- @param #number Index Index of the vertex. Default 1.
|
||||||
|
-- @return Core.Point#COORDINATE Vertex of the polygon.
|
||||||
|
function ZONE_POLYGON_BASE:GetVertexCoordinate(Index)
|
||||||
|
local vec2=self:GetVertexVec2(Index)
|
||||||
|
if vec2 then
|
||||||
|
local coord=COORDINATE:NewFromVec2(vec2)
|
||||||
|
return coord
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Get a list of verticies of the polygon.
|
||||||
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
|
-- @return <DCS#Vec2> List of DCS#Vec2 verticies defining the edges of the polygon.
|
||||||
|
function ZONE_POLYGON_BASE:GetVerticiesVec2()
|
||||||
|
return self._.Polygon
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get a list of verticies of the polygon.
|
||||||
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
|
-- @return #table List of DCS#Vec3 verticies defining the edges of the polygon.
|
||||||
|
function ZONE_POLYGON_BASE:GetVerticiesVec3()
|
||||||
|
|
||||||
|
local coords={}
|
||||||
|
|
||||||
|
for i,vec2 in ipairs(self._.Polygon) do
|
||||||
|
local vec3={x=vec2.x, y=land.getHeight(vec2), z=vec2.y}
|
||||||
|
table.insert(coords, vec3)
|
||||||
|
end
|
||||||
|
|
||||||
|
return coords
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get a list of verticies of the polygon.
|
||||||
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
|
-- @return #table List of COORDINATES verticies defining the edges of the polygon.
|
||||||
|
function ZONE_POLYGON_BASE:GetVerticiesCoordinates()
|
||||||
|
|
||||||
|
local coords={}
|
||||||
|
|
||||||
|
for i,vec2 in ipairs(self._.Polygon) do
|
||||||
|
local coord=COORDINATE:NewFromVec2(vec2)
|
||||||
|
table.insert(coords, coord)
|
||||||
|
end
|
||||||
|
|
||||||
|
return coords
|
||||||
|
end
|
||||||
|
|
||||||
--- Flush polygon coordinates as a table in DCS.log.
|
--- Flush polygon coordinates as a table in DCS.log.
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
-- @return #ZONE_POLYGON_BASE self
|
-- @return #ZONE_POLYGON_BASE self
|
||||||
@@ -1494,6 +1795,46 @@ function ZONE_POLYGON_BASE:BoundZone( UnBound )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Draw the zone on the F10 map. **NOTE** Currently, only polygons with **exactly four points** are supported!
|
||||||
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
|
-- @param #number Coalition Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1=All.
|
||||||
|
-- @param #table Color RGB color table {r, g, b}, e.g. {1,0,0} for red.
|
||||||
|
-- @param #number Alpha Transparency [0,1]. Default 1.
|
||||||
|
-- @param #table FillColor RGB color table {r, g, b}, e.g. {1,0,0} for red. Default is same as `Color` value.
|
||||||
|
-- @param #number FillAlpha Transparency [0,1]. Default 0.15.
|
||||||
|
-- @param #number LineType Line type: 0=No line, 1=Solid, 2=Dashed, 3=Dotted, 4=Dot dash, 5=Long dash, 6=Two dash. Default 1=Solid.
|
||||||
|
-- @param #boolean ReadOnly (Optional) Mark is readonly and cannot be removed by users. Default false.
|
||||||
|
-- @return #ZONE_POLYGON_BASE self
|
||||||
|
function ZONE_POLYGON_BASE:DrawZone(Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly)
|
||||||
|
|
||||||
|
local coordinate=COORDINATE:NewFromVec2(self._.Polygon[1])
|
||||||
|
|
||||||
|
Color=Color or self:GetColorRGB()
|
||||||
|
Alpha=Alpha or 1
|
||||||
|
FillColor=FillColor or Color
|
||||||
|
FillAlpha=FillAlpha or self:GetColorAlpha()
|
||||||
|
|
||||||
|
|
||||||
|
if #self._.Polygon==4 then
|
||||||
|
|
||||||
|
local Coord2=COORDINATE:NewFromVec2(self._.Polygon[2])
|
||||||
|
local Coord3=COORDINATE:NewFromVec2(self._.Polygon[3])
|
||||||
|
local Coord4=COORDINATE:NewFromVec2(self._.Polygon[4])
|
||||||
|
|
||||||
|
self.DrawID=coordinate:QuadToAll(Coord2, Coord3, Coord4, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly)
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
local Coordinates=self:GetVerticiesCoordinates()
|
||||||
|
table.remove(Coordinates, 1)
|
||||||
|
|
||||||
|
self.DrawID=coordinate:MarkupToAllFreeForm(Coordinates, Coalition, Color, Alpha, FillColor, FillAlpha, LineType, ReadOnly)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Smokes the zone boundaries in a color.
|
--- Smokes the zone boundaries in a color.
|
||||||
-- @param #ZONE_POLYGON_BASE self
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
@@ -1685,6 +2026,45 @@ function ZONE_POLYGON_BASE:GetBoundingSquare()
|
|||||||
return { x1 = x1, y1 = y1, x2 = x2, y2 = y2 }
|
return { x1 = x1, y1 = y1, x2 = x2, y2 = y2 }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Draw a frontier on the F10 map with small filled circles.
|
||||||
|
-- @param #ZONE_POLYGON_BASE self
|
||||||
|
-- @param #number Coalition (Optional) Coalition: All=-1, Neutral=0, Red=1, Blue=2. Default -1= All.
|
||||||
|
-- @param #table Color (Optional) RGB color table {r, g, b}, e.g. {1, 0, 0} for red. Default {1, 1, 1}= White.
|
||||||
|
-- @param #number Radius (Optional) Radius of the circles in meters. Default 1000.
|
||||||
|
-- @param #number Alpha (Optional) Alpha transparency [0,1]. Default 1.
|
||||||
|
-- @param #number Segments (Optional) Number of segments within boundary line. Default 10.
|
||||||
|
-- @param #boolean Closed (Optional) Link the last point with the first one to obtain a closed boundary. Default false
|
||||||
|
-- @return #ZONE_POLYGON_BASE self
|
||||||
|
function ZONE_POLYGON_BASE:Boundary(Coalition, Color, Radius, Alpha, Segments, Closed)
|
||||||
|
Coalition = Coalition or -1
|
||||||
|
Color = Color or {1, 1, 1}
|
||||||
|
Radius = Radius or 1000
|
||||||
|
Alpha = Alpha or 1
|
||||||
|
Segments = Segments or 10
|
||||||
|
Closed = Closed or false
|
||||||
|
local i = 1
|
||||||
|
local j = #self._.Polygon
|
||||||
|
if (Closed) then
|
||||||
|
Limit = #self._.Polygon + 1
|
||||||
|
else
|
||||||
|
Limit = #self._.Polygon
|
||||||
|
end
|
||||||
|
while i <= #self._.Polygon do
|
||||||
|
self:T( { i, j, self._.Polygon[i], self._.Polygon[j] } )
|
||||||
|
if j ~= Limit then
|
||||||
|
local DeltaX = self._.Polygon[j].x - self._.Polygon[i].x
|
||||||
|
local DeltaY = self._.Polygon[j].y - self._.Polygon[i].y
|
||||||
|
for Segment = 0, Segments do
|
||||||
|
local PointX = self._.Polygon[i].x + ( Segment * DeltaX / Segments )
|
||||||
|
local PointY = self._.Polygon[i].y + ( Segment * DeltaY / Segments )
|
||||||
|
ZONE_RADIUS:New( "Zone", {x = PointX, y = PointY}, Radius ):DrawZone(Coalition, Color, 1, Color, Alpha, nil, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
j = i
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- @type ZONE_POLYGON
|
--- @type ZONE_POLYGON
|
||||||
-- @extends #ZONE_POLYGON_BASE
|
-- @extends #ZONE_POLYGON_BASE
|
||||||
@@ -1711,7 +2091,7 @@ end
|
|||||||
-- This is especially handy if you want to quickly setup a SET_ZONE...
|
-- This is especially handy if you want to quickly setup a SET_ZONE...
|
||||||
-- So when you would declare `local SetZone = SET_ZONE:New():FilterPrefixes( "Defense" ):FilterStart()`,
|
-- So when you would declare `local SetZone = SET_ZONE:New():FilterPrefixes( "Defense" ):FilterStart()`,
|
||||||
-- then SetZone would contain the ZONE_POLYGON object `DefenseZone` as part of the zone collection,
|
-- then SetZone would contain the ZONE_POLYGON object `DefenseZone` as part of the zone collection,
|
||||||
-- without much scripting overhead!!!
|
-- without much scripting overhead!
|
||||||
--
|
--
|
||||||
-- @field #ZONE_POLYGON
|
-- @field #ZONE_POLYGON
|
||||||
ZONE_POLYGON = {
|
ZONE_POLYGON = {
|
||||||
|
|||||||
@@ -295,6 +295,17 @@ do -- country
|
|||||||
-- @field QATAR
|
-- @field QATAR
|
||||||
-- @field OMAN
|
-- @field OMAN
|
||||||
-- @field UNITED_ARAB_EMIRATES
|
-- @field UNITED_ARAB_EMIRATES
|
||||||
|
-- @field SOUTH_AFRICA
|
||||||
|
-- @field CUBA
|
||||||
|
-- @field PORTUGAL
|
||||||
|
-- @field GDR
|
||||||
|
-- @field LEBANON
|
||||||
|
-- @field CJTF_BLUE
|
||||||
|
-- @field CJTF_RED
|
||||||
|
-- @field UN_PEACEKEEPERS
|
||||||
|
-- @field Argentinia
|
||||||
|
-- @field Cyprus
|
||||||
|
-- @field Slovenia
|
||||||
|
|
||||||
country = {} --#country
|
country = {} --#country
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
-- @field #number adv_state Advanced mode state tracker
|
-- @field #number adv_state Advanced mode state tracker
|
||||||
-- @field #boolean advAwacs Boolean switch to use Awacs as a separate detection stream
|
-- @field #boolean advAwacs Boolean switch to use Awacs as a separate detection stream
|
||||||
-- @field #number awacsrange Detection range of an optional Awacs unit
|
-- @field #number awacsrange Detection range of an optional Awacs unit
|
||||||
-- @field #boolean UseAIOnOff Decide if we are using AI on/off (true) or AlarmState red/green (default)
|
-- @field #boolean UseEmOnOff Decide if we are using Emissions on/off (true) or AlarmState red/green (default)
|
||||||
-- @field Functional.Shorad#SHORAD Shorad SHORAD Object, if available
|
-- @field Functional.Shorad#SHORAD Shorad SHORAD Object, if available
|
||||||
-- @field #boolean ShoradLink If true, #MANTIS has #SHORAD enabled
|
-- @field #boolean ShoradLink If true, #MANTIS has #SHORAD enabled
|
||||||
-- @field #number ShoradTime Timer in seconds, how long #SHORAD will be active after a detection inside of the defense range
|
-- @field #number ShoradTime Timer in seconds, how long #SHORAD will be active after a detection inside of the defense range
|
||||||
@@ -191,7 +191,7 @@ MANTIS = {
|
|||||||
ShoradLink = false,
|
ShoradLink = false,
|
||||||
ShoradTime = 600,
|
ShoradTime = 600,
|
||||||
ShoradActDistance = 15000,
|
ShoradActDistance = 15000,
|
||||||
UseAIOnOff = false,
|
UseEmOnOff = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
@@ -208,7 +208,7 @@ do
|
|||||||
--@param #string coaltion Coalition side of your setup, e.g. "blue", "red" or "neutral"
|
--@param #string coaltion Coalition side of your setup, e.g. "blue", "red" or "neutral"
|
||||||
--@param #boolean dynamic Use constant (true) filtering or just filter once (false, default) (optional)
|
--@param #boolean dynamic Use constant (true) filtering or just filter once (false, default) (optional)
|
||||||
--@param #string awacs Group name of your Awacs (optional)
|
--@param #string awacs Group name of your Awacs (optional)
|
||||||
--@param #boolean AIOnOff Make MANTIS switch AI on and off instead of changing the alarm state between RED and GREEN (optional)
|
--@param #boolean EmOnOff Make MANTIS switch Emissions on and off instead of changing the alarm state between RED and GREEN (optional, deault true)
|
||||||
--@return #MANTIS self
|
--@return #MANTIS self
|
||||||
--@usage Start up your MANTIS with a basic setting
|
--@usage Start up your MANTIS with a basic setting
|
||||||
--
|
--
|
||||||
@@ -230,7 +230,7 @@ do
|
|||||||
-- `mybluemantis = MANTIS:New("bluemantis","Blue SAM","Blue EWR",nil,"blue",false,"Blue Awacs")`
|
-- `mybluemantis = MANTIS:New("bluemantis","Blue SAM","Blue EWR",nil,"blue",false,"Blue Awacs")`
|
||||||
-- `mybluemantis:Start()`
|
-- `mybluemantis:Start()`
|
||||||
--
|
--
|
||||||
function MANTIS:New(name,samprefix,ewrprefix,hq,coaltion,dynamic,awacs, AIOnOff)
|
function MANTIS:New(name,samprefix,ewrprefix,hq,coaltion,dynamic,awacs, EmOnOff)
|
||||||
|
|
||||||
-- DONE: Create some user functions for these
|
-- DONE: Create some user functions for these
|
||||||
-- DONE: Make HQ useful
|
-- DONE: Make HQ useful
|
||||||
@@ -264,7 +264,11 @@ do
|
|||||||
self.ShoradTime = 600
|
self.ShoradTime = 600
|
||||||
self.ShoradActDistance = 15000
|
self.ShoradActDistance = 15000
|
||||||
-- TODO: add emissions on/off when available .... in 2 weeks
|
-- TODO: add emissions on/off when available .... in 2 weeks
|
||||||
self.UseAIOnOff = AIOnOff or false
|
if EmOnOff then
|
||||||
|
if EmOnOff == false then
|
||||||
|
self.UseEmOnOff = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if type(awacs) == "string" then
|
if type(awacs) == "string" then
|
||||||
self.advAwacs = true
|
self.advAwacs = true
|
||||||
@@ -304,7 +308,7 @@ do
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
self.version="0.4.0"
|
self.version="0.4.1"
|
||||||
self:I(string.format("***** Starting MANTIS Version %s *****", self.version))
|
self:I(string.format("***** Starting MANTIS Version %s *****", self.version))
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@@ -463,11 +467,11 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set using AI on/off instead of changing alarm state
|
--- Set using Emissions on/off instead of changing alarm state
|
||||||
-- @param #MANTIS self
|
-- @param #MANTIS self
|
||||||
-- @param #boolean switch Decide if we are changing alarm state or AI state
|
-- @param #boolean switch Decide if we are changing alarm state or Emission state
|
||||||
function MANTIS:SetUsingAIOnOff(switch)
|
function MANTIS:SetUsingEmOnOff(switch)
|
||||||
self.UseAIOnOff = switch or false
|
self.UseEmOnOff = switch or false
|
||||||
end
|
end
|
||||||
|
|
||||||
--- [Internal] Function to check if HQ is alive
|
--- [Internal] Function to check if HQ is alive
|
||||||
@@ -714,8 +718,9 @@ do
|
|||||||
for _i,_group in pairs (SAM_Grps) do
|
for _i,_group in pairs (SAM_Grps) do
|
||||||
local group = _group
|
local group = _group
|
||||||
-- TODO: add emissions on/off
|
-- TODO: add emissions on/off
|
||||||
if self.UseAIOnOff then
|
if self.UseEmOnOff then
|
||||||
group:SetAIOff()
|
group:EnableEmission(false)
|
||||||
|
--group:SetAIOff()
|
||||||
else
|
else
|
||||||
group:OptionAlarmStateGreen() -- AI off
|
group:OptionAlarmStateGreen() -- AI off
|
||||||
end
|
end
|
||||||
@@ -822,9 +827,10 @@ do
|
|||||||
if IsInZone then --check any target in zone
|
if IsInZone then --check any target in zone
|
||||||
if samgroup:IsAlive() then
|
if samgroup:IsAlive() then
|
||||||
-- switch on SAM
|
-- switch on SAM
|
||||||
if self.UseAIOnOff then
|
if self.UseEmOnOff then
|
||||||
-- TODO: add emissions on/off
|
-- TODO: add emissions on/off
|
||||||
samgroup:SetAIOn()
|
--samgroup:SetAIOn()
|
||||||
|
samgroup:EnableEmission(true)
|
||||||
end
|
end
|
||||||
samgroup:OptionAlarmStateRed()
|
samgroup:OptionAlarmStateRed()
|
||||||
-- link in to SHORAD if available
|
-- link in to SHORAD if available
|
||||||
@@ -843,9 +849,10 @@ do
|
|||||||
else
|
else
|
||||||
if samgroup:IsAlive() then
|
if samgroup:IsAlive() then
|
||||||
-- switch off SAM
|
-- switch off SAM
|
||||||
if self.UseAIOnOff then
|
if self.UseEmOnOff then
|
||||||
-- TODO: add emissions on/off
|
-- TODO: add emissions on/off
|
||||||
samgroup:SetAIOff()
|
samgroup:EnableEmission(false)
|
||||||
|
--samgroup:SetAIOff()
|
||||||
else
|
else
|
||||||
samgroup:OptionAlarmStateGreen()
|
samgroup:OptionAlarmStateGreen()
|
||||||
end
|
end
|
||||||
@@ -883,9 +890,10 @@ do
|
|||||||
local name = _data[1]
|
local name = _data[1]
|
||||||
local samgroup = GROUP:FindByName(name)
|
local samgroup = GROUP:FindByName(name)
|
||||||
if samgroup:IsAlive() then
|
if samgroup:IsAlive() then
|
||||||
if self.UseAIOnOff then
|
if self.UseEmOnOff then
|
||||||
-- TODO: add emissions on/off
|
-- TODO: add emissions on/off
|
||||||
samgroup:SetAIOn()
|
--samgroup:SetAIOn()
|
||||||
|
samgroup:EnableEmission(true)
|
||||||
end
|
end
|
||||||
samgroup:OptionAlarmStateRed()
|
samgroup:OptionAlarmStateRed()
|
||||||
end -- end alive
|
end -- end alive
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
--
|
--
|
||||||
-- ### Authors: **FlightControl**, **applevangelist**
|
-- ### Authors: **FlightControl**, **applevangelist**
|
||||||
--
|
--
|
||||||
-- Last Update: Feb 2021
|
-- Last Update: April 2021
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@@ -109,7 +109,7 @@ function SEAD:New( SEADGroupPrefixes )
|
|||||||
end
|
end
|
||||||
|
|
||||||
self:HandleEvent( EVENTS.Shot )
|
self:HandleEvent( EVENTS.Shot )
|
||||||
self:I("*** SEAD - Started Version 0.2.5")
|
self:I("*** SEAD - Started Version 0.2.7")
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -205,15 +205,18 @@ function SEAD:OnEventShot( EventData )
|
|||||||
SEADWeaponName == "weapons.missiles.AGM_84H" --AGM84 anti-radiation missiles fired
|
SEADWeaponName == "weapons.missiles.AGM_84H" --AGM84 anti-radiation missiles fired
|
||||||
--]]
|
--]]
|
||||||
if self:_CheckHarms(SEADWeaponName) then
|
if self:_CheckHarms(SEADWeaponName) then
|
||||||
|
local _targetskill = "Random"
|
||||||
|
local _targetMimgroupName = "none"
|
||||||
local _evade = math.random (1,100) -- random number for chance of evading action
|
local _evade = math.random (1,100) -- random number for chance of evading action
|
||||||
local _targetMim = EventData.Weapon:getTarget() -- Identify target
|
local _targetMim = EventData.Weapon:getTarget() -- Identify target
|
||||||
local _targetMimname = Unit.getName(_targetMim) -- Unit name
|
local _targetUnit = UNIT:Find(_targetMim) -- Unit name by DCS Object
|
||||||
local _targetMimgroup = Unit.getGroup(Weapon.getTarget(SEADWeapon)) --targeted group
|
if _targetUnit and _targetUnit:IsAlive() then
|
||||||
local _targetMimgroupName = _targetMimgroup:getName() -- group name
|
local _targetMimgroup = _targetUnit:GetGroup()
|
||||||
local _targetskill = _DATABASE.Templates.Units[_targetMimname].Template.skill
|
local _targetMimgroupName = _targetMimgroup:GetName() -- group name
|
||||||
|
--local _targetskill = _DATABASE.Templates.Units[_targetUnit].Template.skill
|
||||||
self:T( self.SEADGroupPrefixes )
|
self:T( self.SEADGroupPrefixes )
|
||||||
self:T( _targetMimgroupName )
|
self:T( _targetMimgroupName )
|
||||||
|
end
|
||||||
-- see if we are shot at
|
-- see if we are shot at
|
||||||
local SEADGroupFound = false
|
local SEADGroupFound = false
|
||||||
for SEADGroupPrefixID, SEADGroupPrefix in pairs( self.SEADGroupPrefixes ) do
|
for SEADGroupPrefixID, SEADGroupPrefix in pairs( self.SEADGroupPrefixes ) do
|
||||||
@@ -249,6 +252,7 @@ function SEAD:OnEventShot( EventData )
|
|||||||
local range = self.EngagementRange -- Feature Request #1355
|
local range = self.EngagementRange -- Feature Request #1355
|
||||||
self:T(string.format("*** SEAD - Engagement Range is %d", range))
|
self:T(string.format("*** SEAD - Engagement Range is %d", range))
|
||||||
id.ctrl:setOption(AI.Option.Ground.id.ALARM_STATE,AI.Option.Ground.val.ALARM_STATE.RED)
|
id.ctrl:setOption(AI.Option.Ground.id.ALARM_STATE,AI.Option.Ground.val.ALARM_STATE.RED)
|
||||||
|
--id.groupName:enableEmission(true)
|
||||||
id.ctrl:setOption(AI.Option.Ground.id.AC_ENGAGEMENT_RANGE_RESTRICTION,range) --Feature Request #1355
|
id.ctrl:setOption(AI.Option.Ground.id.AC_ENGAGEMENT_RANGE_RESTRICTION,range) --Feature Request #1355
|
||||||
self.SuppressedGroups[id.groupName] = nil --delete group id from table when done
|
self.SuppressedGroups[id.groupName] = nil --delete group id from table when done
|
||||||
end
|
end
|
||||||
@@ -261,6 +265,7 @@ function SEAD:OnEventShot( EventData )
|
|||||||
SuppressionEndTime = delay
|
SuppressionEndTime = delay
|
||||||
}
|
}
|
||||||
Controller.setOption(_targetMimcont, AI.Option.Ground.id.ALARM_STATE,AI.Option.Ground.val.ALARM_STATE.GREEN)
|
Controller.setOption(_targetMimcont, AI.Option.Ground.id.ALARM_STATE,AI.Option.Ground.val.ALARM_STATE.GREEN)
|
||||||
|
--_targetMimgroup:enableEmission(false)
|
||||||
timer.scheduleFunction(SuppressionEnd, id, SuppressionEndTime) --Schedule the SuppressionEnd() function
|
timer.scheduleFunction(SuppressionEnd, id, SuppressionEndTime) --Schedule the SuppressionEnd() function
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
-- @module Functional.Shorad
|
-- @module Functional.Shorad
|
||||||
-- @image Functional.Shorad.jpg
|
-- @image Functional.Shorad.jpg
|
||||||
--
|
--
|
||||||
-- Date: Feb 2021
|
-- Date: May 2021
|
||||||
|
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
--- **SHORAD** class, extends Core.Base#BASE
|
--- **SHORAD** class, extends Core.Base#BASE
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
-- @field #boolean DefendMavs Default true, intercept incoming AG-Missiles
|
-- @field #boolean DefendMavs Default true, intercept incoming AG-Missiles
|
||||||
-- @field #number DefenseLowProb Default 70, minimum detection limit
|
-- @field #number DefenseLowProb Default 70, minimum detection limit
|
||||||
-- @field #number DefenseHighProb Default 90, maximim detection limit
|
-- @field #number DefenseHighProb Default 90, maximim detection limit
|
||||||
-- @field #boolean UseAIOnOff Decide if we are using AI on/off (true) or AlarmState red/green (default).
|
-- @field #boolean UseEmOnOff Decide if we are using Emission on/off (default) or AlarmState red/green.
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
--- *Good friends are worth defending.* Mr Tushman, Wonder (the Movie)
|
--- *Good friends are worth defending.* Mr Tushman, Wonder (the Movie)
|
||||||
@@ -96,7 +96,7 @@ SHORAD = {
|
|||||||
DefendMavs = true,
|
DefendMavs = true,
|
||||||
DefenseLowProb = 70,
|
DefenseLowProb = 70,
|
||||||
DefenseHighProb = 90,
|
DefenseHighProb = 90,
|
||||||
UseAIOnOff = false,
|
UseEmOnOff = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
-----------------------------------------------------------------------
|
||||||
@@ -159,7 +159,7 @@ do
|
|||||||
-- @param #string Coalition Coalition, i.e. "blue", "red", or "neutral"
|
-- @param #string Coalition Coalition, i.e. "blue", "red", or "neutral"
|
||||||
function SHORAD:New(Name, ShoradPrefix, Samset, Radius, ActiveTimer, Coalition)
|
function SHORAD:New(Name, ShoradPrefix, Samset, Radius, ActiveTimer, Coalition)
|
||||||
local self = BASE:Inherit( self, BASE:New() )
|
local self = BASE:Inherit( self, BASE:New() )
|
||||||
self:F({Name, ShoradPrefix, Samset, Radius, ActiveTimer, Coalition})
|
self:T({Name, ShoradPrefix, Samset, Radius, ActiveTimer, Coalition})
|
||||||
|
|
||||||
local GroupSet = SET_GROUP:New():FilterPrefixes(ShoradPrefix):FilterCoalitions(Coalition):FilterCategoryGround():FilterStart()
|
local GroupSet = SET_GROUP:New():FilterPrefixes(ShoradPrefix):FilterCoalitions(Coalition):FilterCategoryGround():FilterStart()
|
||||||
|
|
||||||
@@ -176,8 +176,8 @@ do
|
|||||||
self.DefendMavs = true
|
self.DefendMavs = true
|
||||||
self.DefenseLowProb = 70 -- probability to detect a missile shot, low margin
|
self.DefenseLowProb = 70 -- probability to detect a missile shot, low margin
|
||||||
self.DefenseHighProb = 90 -- probability to detect a missile shot, high margin
|
self.DefenseHighProb = 90 -- probability to detect a missile shot, high margin
|
||||||
self.UseAIOnOff = false -- Decide if we are using AI on/off (true) or AlarmState red/green (default)
|
self.UseEmOnOff = true -- Decide if we are using Emission on/off (default) or AlarmState red/green
|
||||||
self:I("*** SHORAD - Started Version 0.1.0")
|
self:I("*** SHORAD - Started Version 0.2.5")
|
||||||
-- Set the string id for output to DCS.log file.
|
-- Set the string id for output to DCS.log file.
|
||||||
self.lid=string.format("SHORAD %s | ", self.name)
|
self.lid=string.format("SHORAD %s | ", self.name)
|
||||||
self:_InitState()
|
self:_InitState()
|
||||||
@@ -192,8 +192,9 @@ do
|
|||||||
self:T({set = set})
|
self:T({set = set})
|
||||||
local aliveset = set:GetAliveSet() --#table
|
local aliveset = set:GetAliveSet() --#table
|
||||||
for _,_group in pairs (aliveset) do
|
for _,_group in pairs (aliveset) do
|
||||||
if self.UseAIOnOff then
|
if self.UseEmOnOff then
|
||||||
_group:SetAIOff()
|
--_group:SetAIOff()
|
||||||
|
_group:EnableEmission(false)
|
||||||
else
|
else
|
||||||
_group:OptionAlarmStateGreen() --Wrapper.Group#GROUP
|
_group:OptionAlarmStateGreen() --Wrapper.Group#GROUP
|
||||||
end
|
end
|
||||||
@@ -208,7 +209,7 @@ do
|
|||||||
-- @param #SHORAD self
|
-- @param #SHORAD self
|
||||||
-- @param #boolean debug Switch debug on (true) or off (false)
|
-- @param #boolean debug Switch debug on (true) or off (false)
|
||||||
function SHORAD:SwitchDebug(debug)
|
function SHORAD:SwitchDebug(debug)
|
||||||
self:F( { debug } )
|
self:T( { debug } )
|
||||||
local onoff = debug or false
|
local onoff = debug or false
|
||||||
if debug then
|
if debug then
|
||||||
self.debug = true
|
self.debug = true
|
||||||
@@ -225,7 +226,7 @@ do
|
|||||||
-- @param #SHORAD self
|
-- @param #SHORAD self
|
||||||
-- @param #boolean onoff
|
-- @param #boolean onoff
|
||||||
function SHORAD:SwitchHARMDefense(onoff)
|
function SHORAD:SwitchHARMDefense(onoff)
|
||||||
self:F( { onoff } )
|
self:T( { onoff } )
|
||||||
local onoff = onoff or true
|
local onoff = onoff or true
|
||||||
self.DefendHarms = onoff
|
self.DefendHarms = onoff
|
||||||
end
|
end
|
||||||
@@ -234,7 +235,7 @@ do
|
|||||||
-- @param #SHORAD self
|
-- @param #SHORAD self
|
||||||
-- @param #boolean onoff
|
-- @param #boolean onoff
|
||||||
function SHORAD:SwitchAGMDefense(onoff)
|
function SHORAD:SwitchAGMDefense(onoff)
|
||||||
self:F( { onoff } )
|
self:T( { onoff } )
|
||||||
local onoff = onoff or true
|
local onoff = onoff or true
|
||||||
self.DefendMavs = onoff
|
self.DefendMavs = onoff
|
||||||
end
|
end
|
||||||
@@ -244,7 +245,7 @@ do
|
|||||||
-- @param #number low Minimum detection limit, integer 1-100
|
-- @param #number low Minimum detection limit, integer 1-100
|
||||||
-- @param #number high Maximum detection limit integer 1-100
|
-- @param #number high Maximum detection limit integer 1-100
|
||||||
function SHORAD:SetDefenseLimits(low,high)
|
function SHORAD:SetDefenseLimits(low,high)
|
||||||
self:F( { low, high } )
|
self:T( { low, high } )
|
||||||
local low = low or 70
|
local low = low or 70
|
||||||
local high = high or 90
|
local high = high or 90
|
||||||
if (low < 0) or (low > 100) or (low > high) then
|
if (low < 0) or (low > 100) or (low > high) then
|
||||||
@@ -279,11 +280,11 @@ do
|
|||||||
self.Radius = radius
|
self.Radius = radius
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set using AI on/off instead of changing alarm state
|
--- Set using Emission on/off instead of changing alarm state
|
||||||
-- @param #SHORAD self
|
-- @param #SHORAD self
|
||||||
-- @param #boolean switch Decide if we are changing alarm state or AI state
|
-- @param #boolean switch Decide if we are changing alarm state or AI state
|
||||||
function SHORAD:SetUsingAIOnOff(switch)
|
function SHORAD:SetUsingEmOnOff(switch)
|
||||||
self.UseAIOnOff = switch or false
|
self.UseEmOnOff = switch or false
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Check if a HARM was fired
|
--- Check if a HARM was fired
|
||||||
@@ -291,7 +292,7 @@ do
|
|||||||
-- @param #string WeaponName
|
-- @param #string WeaponName
|
||||||
-- @return #boolean Returns true for a match
|
-- @return #boolean Returns true for a match
|
||||||
function SHORAD:_CheckHarms(WeaponName)
|
function SHORAD:_CheckHarms(WeaponName)
|
||||||
self:F( { WeaponName } )
|
self:T( { WeaponName } )
|
||||||
local hit = false
|
local hit = false
|
||||||
if self.DefendHarms then
|
if self.DefendHarms then
|
||||||
for _,_name in pairs (SHORAD.Harms) do
|
for _,_name in pairs (SHORAD.Harms) do
|
||||||
@@ -306,7 +307,7 @@ do
|
|||||||
-- @param #string WeaponName
|
-- @param #string WeaponName
|
||||||
-- @return #boolean Returns true for a match
|
-- @return #boolean Returns true for a match
|
||||||
function SHORAD:_CheckMavs(WeaponName)
|
function SHORAD:_CheckMavs(WeaponName)
|
||||||
self:F( { WeaponName } )
|
self:T( { WeaponName } )
|
||||||
local hit = false
|
local hit = false
|
||||||
if self.DefendMavs then
|
if self.DefendMavs then
|
||||||
for _,_name in pairs (SHORAD.Mavs) do
|
for _,_name in pairs (SHORAD.Mavs) do
|
||||||
@@ -351,6 +352,7 @@ do
|
|||||||
local groupname = _groups:GetName()
|
local groupname = _groups:GetName()
|
||||||
if string.find(groupname, tgtgrp, 1) then
|
if string.find(groupname, tgtgrp, 1) then
|
||||||
returnname = true
|
returnname = true
|
||||||
|
_groups:RelocateGroundRandomInRadius(7,100,false,false) -- be a bit evasive
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return returnname
|
return returnname
|
||||||
@@ -363,7 +365,8 @@ do
|
|||||||
function SHORAD:_CheckShotAtSams(TargetGroupName)
|
function SHORAD:_CheckShotAtSams(TargetGroupName)
|
||||||
local tgtgrp = TargetGroupName
|
local tgtgrp = TargetGroupName
|
||||||
local shorad = self.Samset
|
local shorad = self.Samset
|
||||||
local shoradset = shorad:GetAliveSet() --#table
|
--local shoradset = shorad:GetAliveSet() --#table
|
||||||
|
local shoradset = shorad:GetSet() --#table
|
||||||
local returnname = false
|
local returnname = false
|
||||||
for _,_groups in pairs (shoradset) do
|
for _,_groups in pairs (shoradset) do
|
||||||
local groupname = _groups:GetName()
|
local groupname = _groups:GetName()
|
||||||
@@ -392,6 +395,7 @@ do
|
|||||||
-- @param #string TargetGroup Name of the target group used to build the #ZONE
|
-- @param #string TargetGroup Name of the target group used to build the #ZONE
|
||||||
-- @param #number Radius Radius of the #ZONE
|
-- @param #number Radius Radius of the #ZONE
|
||||||
-- @param #number ActiveTimer Number of seconds to stay active
|
-- @param #number ActiveTimer Number of seconds to stay active
|
||||||
|
-- @param #number TargetCat (optional) Category, i.e. Object.Category.UNIT or Object.Category.STATIC
|
||||||
-- @usage Use this function to integrate with other systems, example
|
-- @usage Use this function to integrate with other systems, example
|
||||||
--
|
--
|
||||||
-- local SamSet = SET_GROUP:New():FilterPrefixes("Blue SAM"):FilterCoalitions("blue"):FilterStart()
|
-- local SamSet = SET_GROUP:New():FilterPrefixes("Blue SAM"):FilterCoalitions("blue"):FilterStart()
|
||||||
@@ -400,18 +404,30 @@ do
|
|||||||
-- mymantis = MANTIS:New("BlueMantis","Blue SAM","Blue EWR",nil,"blue",false,"Blue Awacs")
|
-- mymantis = MANTIS:New("BlueMantis","Blue SAM","Blue EWR",nil,"blue",false,"Blue Awacs")
|
||||||
-- mymantis:AddShorad(myshorad,720)
|
-- mymantis:AddShorad(myshorad,720)
|
||||||
-- mymantis:Start()
|
-- mymantis:Start()
|
||||||
function SHORAD:WakeUpShorad(TargetGroup, Radius, ActiveTimer)
|
function SHORAD:WakeUpShorad(TargetGroup, Radius, ActiveTimer, TargetCat)
|
||||||
self:F({TargetGroup, Radius, ActiveTimer})
|
self:T({TargetGroup, Radius, ActiveTimer, TargetCat})
|
||||||
local targetgroup = GROUP:FindByName(TargetGroup)
|
local targetcat = TargetCat or Object.Category.UNIT
|
||||||
local targetzone = ZONE_GROUP:New("Shorad",targetgroup,Radius) -- create a defense zone to check
|
local targetgroup = TargetGroup
|
||||||
|
local targetvec2 = nil
|
||||||
|
if targetcat == Object.Category.UNIT then
|
||||||
|
targetvec2 = GROUP:FindByName(targetgroup):GetVec2()
|
||||||
|
elseif targetcat == Object.Category.STATIC then
|
||||||
|
targetvec2 = STATIC:FindByName(targetgroup,false):GetVec2()
|
||||||
|
else
|
||||||
|
local samset = self.Samset
|
||||||
|
local sam = samset:GetRandom()
|
||||||
|
targetvec2 = sam:GetVec2()
|
||||||
|
end
|
||||||
|
local targetzone = ZONE_RADIUS:New("Shorad",targetvec2,Radius) -- create a defense zone to check
|
||||||
local groupset = self.Groupset --Core.Set#SET_GROUP
|
local groupset = self.Groupset --Core.Set#SET_GROUP
|
||||||
local shoradset = groupset:GetAliveSet() --#table
|
local shoradset = groupset:GetAliveSet() --#table
|
||||||
-- local function to switch off shorad again
|
-- local function to switch off shorad again
|
||||||
local function SleepShorad(group)
|
local function SleepShorad(group)
|
||||||
local groupname = group:GetName()
|
local groupname = group:GetName()
|
||||||
self.ActiveGroups[groupname] = nil
|
self.ActiveGroups[groupname] = nil
|
||||||
if self.UseAIOnOff then
|
if self.UseEmOnOff then
|
||||||
group:SetAIOff()
|
group:EnableEmission(false)
|
||||||
|
--group:SetAIOff()
|
||||||
else
|
else
|
||||||
group:OptionAlarmStateGreen()
|
group:OptionAlarmStateGreen()
|
||||||
end
|
end
|
||||||
@@ -425,8 +441,9 @@ do
|
|||||||
local text = string.format("Waking up SHORAD %s", _group:GetName())
|
local text = string.format("Waking up SHORAD %s", _group:GetName())
|
||||||
self:T(text)
|
self:T(text)
|
||||||
local m = MESSAGE:New(text,10,"SHORAD"):ToAllIf(self.debug)
|
local m = MESSAGE:New(text,10,"SHORAD"):ToAllIf(self.debug)
|
||||||
if self.UseAIOnOff then
|
if self.UseEmOnOff then
|
||||||
_group:SetAIOn()
|
_group:SetAIOn()
|
||||||
|
_group:EnableEmission(true)
|
||||||
end
|
end
|
||||||
_group:OptionAlarmStateRed()
|
_group:OptionAlarmStateRed()
|
||||||
local groupname = _group:GetName()
|
local groupname = _group:GetName()
|
||||||
@@ -443,7 +460,7 @@ do
|
|||||||
-- @param #SHORAD self
|
-- @param #SHORAD self
|
||||||
-- @param Core.Event#EVENTDATA EventData The event details table data set
|
-- @param Core.Event#EVENTDATA EventData The event details table data set
|
||||||
function SHORAD:OnEventShot( EventData )
|
function SHORAD:OnEventShot( EventData )
|
||||||
self:F( { EventData } )
|
self:T( { EventData } )
|
||||||
|
|
||||||
--local ShootingUnit = EventData.IniDCSUnit
|
--local ShootingUnit = EventData.IniDCSUnit
|
||||||
--local ShootingUnitName = EventData.IniDCSUnitName
|
--local ShootingUnitName = EventData.IniDCSUnitName
|
||||||
@@ -461,14 +478,35 @@ do
|
|||||||
end
|
end
|
||||||
local text = string.format("%s Missile Launched = %s | Detected probability state is %s", self.lid, ShootingWeaponName, DetectedText)
|
local text = string.format("%s Missile Launched = %s | Detected probability state is %s", self.lid, ShootingWeaponName, DetectedText)
|
||||||
self:T( text )
|
self:T( text )
|
||||||
local m = MESSAGE:New(text,15,"Info"):ToAllIf(self.debug)
|
local m = MESSAGE:New(text,10,"Info"):ToAllIf(self.debug)
|
||||||
--
|
--
|
||||||
if (self:_CheckHarms(ShootingWeaponName) or self:_CheckMavs(ShootingWeaponName)) and IsDetected then
|
if (self:_CheckHarms(ShootingWeaponName) or self:_CheckMavs(ShootingWeaponName)) and IsDetected then
|
||||||
-- get target data
|
-- get target data
|
||||||
local targetdata = EventData.Weapon:getTarget() -- Identify target
|
local targetdata = EventData.Weapon:getTarget() -- Identify target
|
||||||
local targetunitname = Unit.getName(targetdata) -- Unit name
|
local targetcat = targetdata:getCategory() -- Identify category
|
||||||
local targetgroup = Unit.getGroup(Weapon.getTarget(ShootingWeapon)) --targeted group
|
self:T(string.format("Target Category (3=STATIC, 1=UNIT)= %s",tostring(targetcat)))
|
||||||
local targetgroupname = targetgroup:getName() -- group name
|
local targetunit = nil
|
||||||
|
if targetcat == Object.Category.UNIT then -- UNIT
|
||||||
|
targetunit = UNIT:Find(targetdata)
|
||||||
|
elseif targetcat == Object.Category.STATIC then -- STATIC
|
||||||
|
targetunit = STATIC:Find(targetdata)
|
||||||
|
end
|
||||||
|
--local targetunitname = Unit.getName(targetdata) -- Unit name
|
||||||
|
if targetunit and targetunit:IsAlive() then
|
||||||
|
local targetunitname = targetunit:GetName()
|
||||||
|
--local targetgroup = Unit.getGroup(Weapon.getTarget(ShootingWeapon)) --targeted group
|
||||||
|
local targetgroup = nil
|
||||||
|
local targetgroupname = "none"
|
||||||
|
if targetcat == Object.Category.UNIT then
|
||||||
|
targetgroup = targetunit:GetGroup()
|
||||||
|
targetgroupname = targetgroup:GetName() -- group name
|
||||||
|
elseif targetcat == Object.Category.STATIC then
|
||||||
|
targetgroup = targetunit
|
||||||
|
targetgroupname = targetunitname
|
||||||
|
end
|
||||||
|
local text = string.format("%s Missile Target = %s", self.lid, tostring(targetgroupname))
|
||||||
|
self:T( text )
|
||||||
|
local m = MESSAGE:New(text,10,"Info"):ToAllIf(self.debug)
|
||||||
-- check if we or a SAM site are the target
|
-- check if we or a SAM site are the target
|
||||||
--local TargetGroup = EventData.TgtGroup -- Wrapper.Group#GROUP
|
--local TargetGroup = EventData.TgtGroup -- Wrapper.Group#GROUP
|
||||||
local shotatus = self:_CheckShotAtShorad(targetgroupname) --#boolean
|
local shotatus = self:_CheckShotAtShorad(targetgroupname) --#boolean
|
||||||
@@ -476,7 +514,8 @@ do
|
|||||||
-- if being shot at, find closest SHORADs to activate
|
-- if being shot at, find closest SHORADs to activate
|
||||||
if shotatsams or shotatus then
|
if shotatsams or shotatus then
|
||||||
self:T({shotatsams=shotatsams,shotatus=shotatus})
|
self:T({shotatsams=shotatsams,shotatus=shotatus})
|
||||||
self:WakeUpShorad(targetgroupname, self.Radius, self.ActiveTimer)
|
self:WakeUpShorad(targetgroupname, self.Radius, self.ActiveTimer, targetcat)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ __Moose.Include( 'Scripts/Moose/Utilities/Enums.lua' )
|
|||||||
__Moose.Include( 'Scripts/Moose/Utilities/Routines.lua' )
|
__Moose.Include( 'Scripts/Moose/Utilities/Routines.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Utilities/Utils.lua' )
|
__Moose.Include( 'Scripts/Moose/Utilities/Utils.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Utilities/Profiler.lua' )
|
__Moose.Include( 'Scripts/Moose/Utilities/Profiler.lua' )
|
||||||
|
__Moose.Include( 'Scripts/Moose/Utilities/Templates.lua' )
|
||||||
|
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Base.lua' )
|
__Moose.Include( 'Scripts/Moose/Core/Base.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/UserFlag.lua' )
|
__Moose.Include( 'Scripts/Moose/Core/UserFlag.lua' )
|
||||||
|
|||||||
612
Moose Development/Moose/Utilities/Templates.lua
Normal file
612
Moose Development/Moose/Utilities/Templates.lua
Normal file
@@ -0,0 +1,612 @@
|
|||||||
|
--- **Utils** Templates
|
||||||
|
--
|
||||||
|
-- DCS unit templates
|
||||||
|
--
|
||||||
|
-- @module Utilities.Templates
|
||||||
|
-- @image MOOSE.JPG
|
||||||
|
|
||||||
|
--- TEMPLATE class.
|
||||||
|
-- @type TEMPLATE
|
||||||
|
-- @field #string ClassName Name of the class.
|
||||||
|
|
||||||
|
--- *Templates*
|
||||||
|
--
|
||||||
|
-- ===
|
||||||
|
--
|
||||||
|
-- 
|
||||||
|
--
|
||||||
|
-- Get DCS templates from thin air.
|
||||||
|
--
|
||||||
|
-- # Ground Units
|
||||||
|
--
|
||||||
|
-- Ground units.
|
||||||
|
--
|
||||||
|
-- # Naval Units
|
||||||
|
--
|
||||||
|
-- Ships are not implemented yet.
|
||||||
|
--
|
||||||
|
-- # Aircraft
|
||||||
|
--
|
||||||
|
-- ## Airplanes
|
||||||
|
--
|
||||||
|
-- Airplanes are not implemented yet.
|
||||||
|
--
|
||||||
|
-- ## Helicopters
|
||||||
|
--
|
||||||
|
-- Helicopters are not implemented yet.
|
||||||
|
--
|
||||||
|
-- @field #TEMPLATE
|
||||||
|
TEMPLATE = {
|
||||||
|
ClassName = "TEMPLATE",
|
||||||
|
Ground = {},
|
||||||
|
Naval = {},
|
||||||
|
Airplane = {},
|
||||||
|
Helicopter = {},
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Ground unit type names.
|
||||||
|
-- @type TEMPLATE.TypeGround
|
||||||
|
-- @param #string InfantryAK
|
||||||
|
TEMPLATE.TypeGround={
|
||||||
|
InfantryAK="Infantry AK",
|
||||||
|
ParatrooperAKS74="Paratrooper AKS-74",
|
||||||
|
ParatrooperRPG16="Paratrooper RPG-16",
|
||||||
|
SoldierWWIIUS="soldier_wwii_us",
|
||||||
|
InfantryM248="Infantry M249",
|
||||||
|
SoldierM4="Soldier M4",
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Naval unit type names.
|
||||||
|
-- @type TEMPLATE.TypeNaval
|
||||||
|
-- @param #string Ticonderoga
|
||||||
|
TEMPLATE.TypeNaval={
|
||||||
|
Ticonderoga="TICONDEROG",
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Rotary wing unit type names.
|
||||||
|
-- @type TEMPLATE.TypeAirplane
|
||||||
|
-- @param #string A10C
|
||||||
|
TEMPLATE.TypeAirplane={
|
||||||
|
A10C="A-10C",
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Rotary wing unit type names.
|
||||||
|
-- @type TEMPLATE.TypeHelicopter
|
||||||
|
-- @param #string AH1W
|
||||||
|
TEMPLATE.TypeHelicopter={
|
||||||
|
AH1W="AH-1W",
|
||||||
|
}
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Ground Template
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Get template for ground units.
|
||||||
|
-- @param #string TypeName Type name of the unit(s) in the groups. See `TEMPLATE.Ground`.
|
||||||
|
-- @param #string GroupName Name of the spawned group. **Must be unique!**
|
||||||
|
-- @param #number CountryID Country ID. Default `country.id.USA`. Coalition is automatically determined by the one the country belongs to.
|
||||||
|
-- @param DCS#Vec3 Vec3 Position of the group and the first unit.
|
||||||
|
-- @param #number Nunits Number of units. Default 1.
|
||||||
|
-- @param #number Radius Spawn radius for additonal units in meters. Default 50 m.
|
||||||
|
-- @return #table Template Template table.
|
||||||
|
function TEMPLATE.GetGround(TypeName, GroupName, CountryID, Vec3, Nunits, Radius)
|
||||||
|
|
||||||
|
-- Defaults.
|
||||||
|
TypeName=TypeName or TEMPLATE.TypeGround.SoldierM4
|
||||||
|
GroupName=GroupName or "Ground-1"
|
||||||
|
CountryID=CountryID or country.id.USA
|
||||||
|
Vec3=Vec3 or {x=0, y=0, z=0}
|
||||||
|
Nunits=Nunits or 1
|
||||||
|
Radius=Radius or 50
|
||||||
|
|
||||||
|
|
||||||
|
-- Get generic template.
|
||||||
|
local template=UTILS.DeepCopy(TEMPLATE.GenericGround)
|
||||||
|
|
||||||
|
-- Set group name.
|
||||||
|
template.name=GroupName
|
||||||
|
|
||||||
|
-- These are additional entries required by the MOOSE _DATABASE:Spawn() function.
|
||||||
|
template.CountryID=CountryID
|
||||||
|
template.CoalitionID=coalition.getCountryCoalition(template.CountryID)
|
||||||
|
template.CategoryID=Unit.Category.GROUND_UNIT
|
||||||
|
|
||||||
|
-- Set first unit.
|
||||||
|
template.units[1].type=TypeName
|
||||||
|
template.units[1].name=GroupName.."-1"
|
||||||
|
|
||||||
|
if Vec3 then
|
||||||
|
TEMPLATE.SetPositionFromVec3(template, Vec3)
|
||||||
|
end
|
||||||
|
|
||||||
|
TEMPLATE.SetUnits(template, Nunits, COORDINATE:NewFromVec3(Vec3), Radius)
|
||||||
|
|
||||||
|
return template
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Naval Template
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Get template for ground units.
|
||||||
|
-- @param #string TypeName Type name of the unit(s) in the groups. See `TEMPLATE.Ground`.
|
||||||
|
-- @param #string GroupName Name of the spawned group. **Must be unique!**
|
||||||
|
-- @param #number CountryID Country ID. Default `country.id.USA`. Coalition is automatically determined by the one the country belongs to.
|
||||||
|
-- @param DCS#Vec3 Vec3 Position of the group and the first unit.
|
||||||
|
-- @param #number Nunits Number of units. Default 1.
|
||||||
|
-- @param #number Radius Spawn radius for additonal units in meters. Default 500 m.
|
||||||
|
-- @return #table Template Template table.
|
||||||
|
function TEMPLATE.GetNaval(TypeName, GroupName, CountryID, Vec3, Nunits, Radius)
|
||||||
|
|
||||||
|
-- Defaults.
|
||||||
|
TypeName=TypeName or TEMPLATE.TypeNaval.Ticonderoga
|
||||||
|
GroupName=GroupName or "Naval-1"
|
||||||
|
CountryID=CountryID or country.id.USA
|
||||||
|
Vec3=Vec3 or {x=0, y=0, z=0}
|
||||||
|
Nunits=Nunits or 1
|
||||||
|
Radius=Radius or 500
|
||||||
|
|
||||||
|
|
||||||
|
-- Get generic template.
|
||||||
|
local template=UTILS.DeepCopy(TEMPLATE.GenericNaval)
|
||||||
|
|
||||||
|
-- Set group name.
|
||||||
|
template.name=GroupName
|
||||||
|
|
||||||
|
-- These are additional entries required by the MOOSE _DATABASE:Spawn() function.
|
||||||
|
template.CountryID=CountryID
|
||||||
|
template.CoalitionID=coalition.getCountryCoalition(template.CountryID)
|
||||||
|
template.CategoryID=Unit.Category.SHIP
|
||||||
|
|
||||||
|
-- Set first unit.
|
||||||
|
template.units[1].type=TypeName
|
||||||
|
template.units[1].name=GroupName.."-1"
|
||||||
|
|
||||||
|
if Vec3 then
|
||||||
|
TEMPLATE.SetPositionFromVec3(template, Vec3)
|
||||||
|
end
|
||||||
|
|
||||||
|
TEMPLATE.SetUnits(template, Nunits, COORDINATE:NewFromVec3(Vec3), Radius)
|
||||||
|
|
||||||
|
return template
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Aircraft Template
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Get template for fixed wing units.
|
||||||
|
-- @param #string TypeName Type name of the unit(s) in the groups. See `TEMPLATE.Ground`.
|
||||||
|
-- @param #string GroupName Name of the spawned group. **Must be unique!**
|
||||||
|
-- @param #number CountryID Country ID. Default `country.id.USA`. Coalition is automatically determined by the one the country belongs to.
|
||||||
|
-- @param DCS#Vec3 Vec3 Position of the group and the first unit.
|
||||||
|
-- @param #number Nunits Number of units. Default 1.
|
||||||
|
-- @param #number Radius Spawn radius for additonal units in meters. Default 500 m.
|
||||||
|
-- @return #table Template Template table.
|
||||||
|
function TEMPLATE.GetAirplane(TypeName, GroupName, CountryID, Vec3, Nunits, Radius)
|
||||||
|
|
||||||
|
-- Defaults.
|
||||||
|
TypeName=TypeName or TEMPLATE.TypeAirplane.A10C
|
||||||
|
GroupName=GroupName or "Airplane-1"
|
||||||
|
CountryID=CountryID or country.id.USA
|
||||||
|
Vec3=Vec3 or {x=0, y=1000, z=0}
|
||||||
|
Nunits=Nunits or 1
|
||||||
|
Radius=Radius or 100
|
||||||
|
|
||||||
|
local template=TEMPLATE._GetAircraft(true, TypeName, GroupName, CountryID, Vec3, Nunits, Radius)
|
||||||
|
|
||||||
|
return template
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get template for fixed wing units.
|
||||||
|
-- @param #string TypeName Type name of the unit(s) in the groups. See `TEMPLATE.Ground`.
|
||||||
|
-- @param #string GroupName Name of the spawned group. **Must be unique!**
|
||||||
|
-- @param #number CountryID Country ID. Default `country.id.USA`. Coalition is automatically determined by the one the country belongs to.
|
||||||
|
-- @param DCS#Vec3 Vec3 Position of the group and the first unit.
|
||||||
|
-- @param #number Nunits Number of units. Default 1.
|
||||||
|
-- @param #number Radius Spawn radius for additonal units in meters. Default 500 m.
|
||||||
|
-- @return #table Template Template table.
|
||||||
|
function TEMPLATE.GetHelicopter(TypeName, GroupName, CountryID, Vec3, Nunits, Radius)
|
||||||
|
|
||||||
|
-- Defaults.
|
||||||
|
TypeName=TypeName or TEMPLATE.TypeHelicopter.AH1W
|
||||||
|
GroupName=GroupName or "Helicopter-1"
|
||||||
|
CountryID=CountryID or country.id.USA
|
||||||
|
Vec3=Vec3 or {x=0, y=500, z=0}
|
||||||
|
Nunits=Nunits or 1
|
||||||
|
Radius=Radius or 100
|
||||||
|
|
||||||
|
-- Limit unis to 4.
|
||||||
|
Nunits=math.min(Nunits, 4)
|
||||||
|
|
||||||
|
local template=TEMPLATE._GetAircraft(false, TypeName, GroupName, CountryID, Vec3, Nunits, Radius)
|
||||||
|
|
||||||
|
return template
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Get template for aircraft units.
|
||||||
|
-- @param #boolean Airplane If true, this is a fixed wing. Else, rotary wing.
|
||||||
|
-- @param #string TypeName Type name of the unit(s) in the groups. See `TEMPLATE.Ground`.
|
||||||
|
-- @param #string GroupName Name of the spawned group. **Must be unique!**
|
||||||
|
-- @param #number CountryID Country ID. Default `country.id.USA`. Coalition is automatically determined by the one the country belongs to.
|
||||||
|
-- @param DCS#Vec3 Vec3 Position of the group and the first unit.
|
||||||
|
-- @param #number Nunits Number of units. Default 1.
|
||||||
|
-- @param #number Radius Spawn radius for additonal units in meters. Default 500 m.
|
||||||
|
-- @return #table Template Template table.
|
||||||
|
function TEMPLATE._GetAircraft(Airplane, TypeName, GroupName, CountryID, Vec3, Nunits, Radius)
|
||||||
|
|
||||||
|
-- Defaults.
|
||||||
|
TypeName=TypeName
|
||||||
|
GroupName=GroupName or "Aircraft-1"
|
||||||
|
CountryID=CountryID or country.id.USA
|
||||||
|
Vec3=Vec3 or {x=0, y=0, z=0}
|
||||||
|
Nunits=Nunits or 1
|
||||||
|
Radius=Radius or 100
|
||||||
|
|
||||||
|
-- Get generic template.
|
||||||
|
local template=UTILS.DeepCopy(TEMPLATE.GenericAircraft)
|
||||||
|
|
||||||
|
-- Set group name.
|
||||||
|
template.name=GroupName
|
||||||
|
|
||||||
|
-- These are additional entries required by the MOOSE _DATABASE:Spawn() function.
|
||||||
|
template.CountryID=CountryID
|
||||||
|
template.CoalitionID=coalition.getCountryCoalition(template.CountryID)
|
||||||
|
if Airplane then
|
||||||
|
template.CategoryID=Unit.Category.AIRPLANE
|
||||||
|
else
|
||||||
|
template.CategoryID=Unit.Category.HELICOPTER
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Set first unit.
|
||||||
|
template.units[1].type=TypeName
|
||||||
|
template.units[1].name=GroupName.."-1"
|
||||||
|
|
||||||
|
-- Set position.
|
||||||
|
if Vec3 then
|
||||||
|
TEMPLATE.SetPositionFromVec3(template, Vec3)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Set number of units.
|
||||||
|
TEMPLATE.SetUnits(template, Nunits, COORDINATE:NewFromVec3(Vec3), Radius)
|
||||||
|
|
||||||
|
return template
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Misc Functions
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Set the position of the template.
|
||||||
|
-- @param #table Template The template to be modified.
|
||||||
|
-- @param DCS#Vec2 Vec2 2D Position vector with x and y components of the group.
|
||||||
|
function TEMPLATE.SetPositionFromVec2(Template, Vec2)
|
||||||
|
|
||||||
|
Template.x=Vec2.x
|
||||||
|
Template.y=Vec2.y
|
||||||
|
|
||||||
|
for _,unit in pairs(Template.units) do
|
||||||
|
unit.x=Vec2.x
|
||||||
|
unit.y=Vec2.y
|
||||||
|
end
|
||||||
|
|
||||||
|
Template.route.points[1].x=Vec2.x
|
||||||
|
Template.route.points[1].y=Vec2.y
|
||||||
|
Template.route.points[1].alt=0 --TODO: Use land height.
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set the position of the template.
|
||||||
|
-- @param #table Template The template to be modified.
|
||||||
|
-- @param DCS#Vec3 Vec3 Position vector of the group.
|
||||||
|
function TEMPLATE.SetPositionFromVec3(Template, Vec3)
|
||||||
|
|
||||||
|
local Vec2={x=Vec3.x, y=Vec3.z}
|
||||||
|
|
||||||
|
TEMPLATE.SetPositionFromVec2(Template, Vec2)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set the position of the template.
|
||||||
|
-- @param #table Template The template to be modified.
|
||||||
|
-- @param #number N Total number of units in the group.
|
||||||
|
-- @param Core.Point#COORDINATE Coordinate Position of the first unit.
|
||||||
|
-- @param #number Radius Radius in meters to randomly place the additional units.
|
||||||
|
function TEMPLATE.SetUnits(Template, N, Coordinate, Radius)
|
||||||
|
|
||||||
|
local units=Template.units
|
||||||
|
|
||||||
|
local unit1=units[1]
|
||||||
|
|
||||||
|
local Vec3=Coordinate:GetVec3()
|
||||||
|
|
||||||
|
unit1.x=Vec3.x
|
||||||
|
unit1.y=Vec3.z
|
||||||
|
unit1.alt=Vec3.y
|
||||||
|
|
||||||
|
for i=2,N do
|
||||||
|
units[i]=UTILS.DeepCopy(unit1)
|
||||||
|
end
|
||||||
|
|
||||||
|
for i=1,N do
|
||||||
|
local unit=units[i]
|
||||||
|
unit.name=string.format("%s-%d", Template.name, i)
|
||||||
|
if i>1 then
|
||||||
|
local vec2=Coordinate:GetRandomCoordinateInRadius(Radius, 5):GetVec2()
|
||||||
|
unit.x=vec2.x
|
||||||
|
unit.y=vec2.y
|
||||||
|
unit.alt=unit1.alt
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set the position of the template.
|
||||||
|
-- @param #table Template The template to be modified.
|
||||||
|
-- @param Wrapper.Airbase#AIRBASE AirBase The airbase where the aircraft are spawned.
|
||||||
|
-- @param #table ParkingSpots List of parking spot IDs. Every unit needs one!
|
||||||
|
-- @param #boolean EngineOn If true, aircraft are spawned hot.
|
||||||
|
function TEMPLATE.SetAirbase(Template, AirBase, ParkingSpots, EngineOn)
|
||||||
|
|
||||||
|
-- Airbase ID.
|
||||||
|
local AirbaseID=AirBase:GetID()
|
||||||
|
|
||||||
|
-- Spawn point.
|
||||||
|
local point=Template.route.points[1]
|
||||||
|
|
||||||
|
-- Set ID.
|
||||||
|
if AirBase:IsAirdrome() then
|
||||||
|
point.airdromeId=AirbaseID
|
||||||
|
else
|
||||||
|
point.helipadId=AirbaseID
|
||||||
|
point.linkUnit=AirbaseID
|
||||||
|
end
|
||||||
|
|
||||||
|
if EngineOn then
|
||||||
|
point.action=COORDINATE.WaypointAction.FromParkingAreaHot
|
||||||
|
point.type=COORDINATE.WaypointType.TakeOffParkingHot
|
||||||
|
else
|
||||||
|
point.action=COORDINATE.WaypointAction.FromParkingArea
|
||||||
|
point.type=COORDINATE.WaypointType.TakeOffParking
|
||||||
|
end
|
||||||
|
|
||||||
|
for i,unit in ipairs(Template.units) do
|
||||||
|
unit.parking_id=ParkingSpots[i]
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Add a waypoint.
|
||||||
|
-- @param #table Template The template to be modified.
|
||||||
|
-- @param #table Waypoint Waypoint table.
|
||||||
|
function TEMPLATE.AddWaypoint(Template, Waypoint)
|
||||||
|
|
||||||
|
table.insert(Template.route.points, Waypoint)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Generic Ground Template
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
TEMPLATE.GenericGround=
|
||||||
|
{
|
||||||
|
["visible"] = false,
|
||||||
|
["tasks"] = {}, -- end of ["tasks"]
|
||||||
|
["uncontrollable"] = false,
|
||||||
|
["task"] = "Ground Nothing",
|
||||||
|
["route"] =
|
||||||
|
{
|
||||||
|
["spans"] = {}, -- end of ["spans"]
|
||||||
|
["points"] =
|
||||||
|
{
|
||||||
|
[1] =
|
||||||
|
{
|
||||||
|
["alt"] = 0,
|
||||||
|
["type"] = "Turning Point",
|
||||||
|
["ETA"] = 0,
|
||||||
|
["alt_type"] = "BARO",
|
||||||
|
["formation_template"] = "",
|
||||||
|
["y"] = 0,
|
||||||
|
["x"] = 0,
|
||||||
|
["ETA_locked"] = true,
|
||||||
|
["speed"] = 0,
|
||||||
|
["action"] = "Off Road",
|
||||||
|
["task"] =
|
||||||
|
{
|
||||||
|
["id"] = "ComboTask",
|
||||||
|
["params"] =
|
||||||
|
{
|
||||||
|
["tasks"] =
|
||||||
|
{
|
||||||
|
}, -- end of ["tasks"]
|
||||||
|
}, -- end of ["params"]
|
||||||
|
}, -- end of ["task"]
|
||||||
|
["speed_locked"] = true,
|
||||||
|
}, -- end of [1]
|
||||||
|
}, -- end of ["points"]
|
||||||
|
}, -- end of ["route"]
|
||||||
|
["groupId"] = nil,
|
||||||
|
["hidden"] = false,
|
||||||
|
["units"] =
|
||||||
|
{
|
||||||
|
[1] =
|
||||||
|
{
|
||||||
|
["transportable"] =
|
||||||
|
{
|
||||||
|
["randomTransportable"] = false,
|
||||||
|
}, -- end of ["transportable"]
|
||||||
|
["skill"] = "Average",
|
||||||
|
["type"] = "Infantry AK",
|
||||||
|
["unitId"] = nil,
|
||||||
|
["y"] = 0,
|
||||||
|
["x"] = 0,
|
||||||
|
["name"] = "Infantry AK-47 Rus",
|
||||||
|
["heading"] = 0,
|
||||||
|
["playerCanDrive"] = false,
|
||||||
|
}, -- end of [1]
|
||||||
|
}, -- end of ["units"]
|
||||||
|
["y"] = 0,
|
||||||
|
["x"] = 0,
|
||||||
|
["name"] = "Infantry AK-47 Rus",
|
||||||
|
["start_time"] = 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Generic Ship Template
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
TEMPLATE.GenericNaval=
|
||||||
|
{
|
||||||
|
["visible"] = false,
|
||||||
|
["tasks"] = {}, -- end of ["tasks"]
|
||||||
|
["uncontrollable"] = false,
|
||||||
|
["route"] =
|
||||||
|
{
|
||||||
|
["points"] =
|
||||||
|
{
|
||||||
|
[1] =
|
||||||
|
{
|
||||||
|
["alt"] = 0,
|
||||||
|
["type"] = "Turning Point",
|
||||||
|
["ETA"] = 0,
|
||||||
|
["alt_type"] = "BARO",
|
||||||
|
["formation_template"] = "",
|
||||||
|
["y"] = 0,
|
||||||
|
["x"] = 0,
|
||||||
|
["ETA_locked"] = true,
|
||||||
|
["speed"] = 0,
|
||||||
|
["action"] = "Turning Point",
|
||||||
|
["task"] =
|
||||||
|
{
|
||||||
|
["id"] = "ComboTask",
|
||||||
|
["params"] =
|
||||||
|
{
|
||||||
|
["tasks"] =
|
||||||
|
{
|
||||||
|
}, -- end of ["tasks"]
|
||||||
|
}, -- end of ["params"]
|
||||||
|
}, -- end of ["task"]
|
||||||
|
["speed_locked"] = true,
|
||||||
|
}, -- end of [1]
|
||||||
|
}, -- end of ["points"]
|
||||||
|
}, -- end of ["route"]
|
||||||
|
["groupId"] = nil,
|
||||||
|
["hidden"] = false,
|
||||||
|
["units"] =
|
||||||
|
{
|
||||||
|
[1] =
|
||||||
|
{
|
||||||
|
["transportable"] =
|
||||||
|
{
|
||||||
|
["randomTransportable"] = false,
|
||||||
|
}, -- end of ["transportable"]
|
||||||
|
["skill"] = "Average",
|
||||||
|
["type"] = "TICONDEROG",
|
||||||
|
["unitId"] = nil,
|
||||||
|
["y"] = 0,
|
||||||
|
["x"] = 0,
|
||||||
|
["name"] = "Naval-1-1",
|
||||||
|
["heading"] = 0,
|
||||||
|
["modulation"] = 0,
|
||||||
|
["frequency"] = 127500000,
|
||||||
|
}, -- end of [1]
|
||||||
|
}, -- end of ["units"]
|
||||||
|
["y"] = 0,
|
||||||
|
["x"] = 0,
|
||||||
|
["name"] = "Naval-1",
|
||||||
|
["start_time"] = 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Generic Aircraft Template
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
TEMPLATE.GenericAircraft=
|
||||||
|
{
|
||||||
|
["groupId"] = nil,
|
||||||
|
["name"] = "Rotary-1",
|
||||||
|
["uncontrolled"] = false,
|
||||||
|
["hidden"] = false,
|
||||||
|
["task"] = "Nothing",
|
||||||
|
["y"] = 0,
|
||||||
|
["x"] = 0,
|
||||||
|
["start_time"] = 0,
|
||||||
|
["communication"] = true,
|
||||||
|
["radioSet"] = false,
|
||||||
|
["frequency"] = 127.5,
|
||||||
|
["modulation"] = 0,
|
||||||
|
["taskSelected"] = true,
|
||||||
|
["tasks"] = {}, -- end of ["tasks"]
|
||||||
|
["route"] =
|
||||||
|
{
|
||||||
|
["points"] =
|
||||||
|
{
|
||||||
|
[1] =
|
||||||
|
{
|
||||||
|
["y"] = 0,
|
||||||
|
["x"] = 0,
|
||||||
|
["alt"] = 1000,
|
||||||
|
["alt_type"] = "BARO",
|
||||||
|
["action"] = "Turning Point",
|
||||||
|
["type"] = "Turning Point",
|
||||||
|
["airdromeId"] = nil,
|
||||||
|
["task"] =
|
||||||
|
{
|
||||||
|
["id"] = "ComboTask",
|
||||||
|
["params"] =
|
||||||
|
{
|
||||||
|
["tasks"] = {}, -- end of ["tasks"]
|
||||||
|
}, -- end of ["params"]
|
||||||
|
}, -- end of ["task"]
|
||||||
|
["ETA"] = 0,
|
||||||
|
["ETA_locked"] = true,
|
||||||
|
["speed"] = 100,
|
||||||
|
["speed_locked"] = true,
|
||||||
|
["formation_template"] = "",
|
||||||
|
}, -- end of [1]
|
||||||
|
}, -- end of ["points"]
|
||||||
|
}, -- end of ["route"]
|
||||||
|
["units"] =
|
||||||
|
{
|
||||||
|
[1] =
|
||||||
|
{
|
||||||
|
["name"] = "Rotary-1-1",
|
||||||
|
["unitId"] = nil,
|
||||||
|
["type"] = "AH-1W",
|
||||||
|
["onboard_num"] = "050",
|
||||||
|
["livery_id"] = "USA X Black",
|
||||||
|
["skill"] = "High",
|
||||||
|
["ropeLength"] = 15,
|
||||||
|
["speed"] = 0,
|
||||||
|
["x"] = 0,
|
||||||
|
["y"] = 0,
|
||||||
|
["alt"] = 10,
|
||||||
|
["alt_type"] = "BARO",
|
||||||
|
["heading"] = 0,
|
||||||
|
["psi"] = 0,
|
||||||
|
["parking"] = nil,
|
||||||
|
["parking_id"] = nil,
|
||||||
|
["payload"] =
|
||||||
|
{
|
||||||
|
["pylons"] = {}, -- end of ["pylons"]
|
||||||
|
["fuel"] = "1250.0",
|
||||||
|
["flare"] = 30,
|
||||||
|
["chaff"] = 30,
|
||||||
|
["gun"] = 100,
|
||||||
|
}, -- end of ["payload"]
|
||||||
|
["callsign"] =
|
||||||
|
{
|
||||||
|
[1] = 2,
|
||||||
|
[2] = 1,
|
||||||
|
[3] = 1,
|
||||||
|
["name"] = "Springfield11",
|
||||||
|
}, -- end of ["callsign"]
|
||||||
|
}, -- end of [1]
|
||||||
|
}, -- end of ["units"]
|
||||||
|
}
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -652,6 +652,17 @@ function UTILS.GetMarkID()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Remove an object (marker, circle, arrow, text, quad, ...) on the F10 map.
|
||||||
|
-- @param #number MarkID Unique ID of the object.
|
||||||
|
-- @param #number Delay (Optional) Delay in seconds before the mark is removed.
|
||||||
|
function UTILS.RemoveMark(MarkID, Delay)
|
||||||
|
if Delay and Delay>0 then
|
||||||
|
TIMER:New(UTILS.RemoveMark, MarkID):Start(Delay)
|
||||||
|
else
|
||||||
|
trigger.action.removeMark(MarkID)
|
||||||
|
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 )
|
||||||
|
|||||||
@@ -608,7 +608,7 @@ end
|
|||||||
|
|
||||||
--- Get all airbase names of the current map. This includes ships and FARPS.
|
--- Get all airbase names of the current map. This includes ships and FARPS.
|
||||||
-- @param DCS#Coalition coalition (Optional) Return only airbases belonging to the specified coalition. By default, all airbases of the map are returned.
|
-- @param DCS#Coalition coalition (Optional) Return only airbases belonging to the specified coalition. By default, all airbases of the map are returned.
|
||||||
-- @param #number category (Optional) Return only airbases of a certain category, e.g. Airbase.Category.FARP
|
-- @param #number category (Optional) Return only airbases of a certain category, e.g. `Airbase.Category.HELIPAD`.
|
||||||
-- @return #table Table containing all airbase names of the current map.
|
-- @return #table Table containing all airbase names of the current map.
|
||||||
function AIRBASE.GetAllAirbaseNames(coalition, category)
|
function AIRBASE.GetAllAirbaseNames(coalition, category)
|
||||||
|
|
||||||
|
|||||||
@@ -175,10 +175,7 @@
|
|||||||
-- * @{#CONTROLLABLE.OptionKeepWeaponsOnThreat}
|
-- * @{#CONTROLLABLE.OptionKeepWeaponsOnThreat}
|
||||||
--
|
--
|
||||||
-- ## 5.5) Air-2-Air missile attack range:
|
-- ## 5.5) Air-2-Air missile attack range:
|
||||||
-- * @{#CONTROLLABLE.OptionAAAttackRange}(): Defines the usage of A2A missiles against possible targets.
|
-- * @{#CONTROLLABLE.OptionAAAttackRange}(): Defines the usage of A2A missiles against possible targets .
|
||||||
--
|
|
||||||
-- ## 5.6) GROUND units attack range:
|
|
||||||
-- * @{#CONTROLLABLE.OptionEngageRange}(): Engage range limit in percent (a number between 0 and 100). Default 100. Defines the range at which a GROUND unit/group (e.g. a SAM site) is allowed to use its weapons automatically.
|
|
||||||
--
|
--
|
||||||
-- @field #CONTROLLABLE
|
-- @field #CONTROLLABLE
|
||||||
CONTROLLABLE = {
|
CONTROLLABLE = {
|
||||||
@@ -1463,7 +1460,7 @@ function CONTROLLABLE:TaskFireAtPoint( Vec2, Radius, AmmoCount, WeaponType, Alti
|
|||||||
DCSTask.params.weaponType=WeaponType
|
DCSTask.params.weaponType=WeaponType
|
||||||
end
|
end
|
||||||
|
|
||||||
self:I(DCSTask)
|
--self:I(DCSTask)
|
||||||
|
|
||||||
return DCSTask
|
return DCSTask
|
||||||
end
|
end
|
||||||
@@ -1482,6 +1479,7 @@ end
|
|||||||
--- (AIR + GROUND) The task makes the controllable/unit a FAC and orders the FAC to control the target (enemy ground controllable) destruction.
|
--- (AIR + GROUND) The task makes the controllable/unit a FAC and orders the FAC to control the target (enemy ground controllable) destruction.
|
||||||
-- The killer is player-controlled allied CAS-aircraft that is in contact with the FAC.
|
-- The killer is player-controlled allied CAS-aircraft that is in contact with the FAC.
|
||||||
-- If the task is assigned to the controllable lead unit will be a FAC.
|
-- If the task is assigned to the controllable lead unit will be a FAC.
|
||||||
|
-- It's important to note that depending on the type of unit that is being assigned the task (AIR or GROUND), you must choose the correct type of callsign enumerator. For airborne controllables use CALLSIGN.Aircraft and for ground based use CALLSIGN.JTAC enumerators.
|
||||||
-- @param #CONTROLLABLE self
|
-- @param #CONTROLLABLE self
|
||||||
-- @param Wrapper.Group#GROUP AttackGroup Target GROUP object.
|
-- @param Wrapper.Group#GROUP AttackGroup Target GROUP object.
|
||||||
-- @param #number WeaponType Bitmask of weapon types, which are allowed to use.
|
-- @param #number WeaponType Bitmask of weapon types, which are allowed to use.
|
||||||
@@ -1489,7 +1487,7 @@ end
|
|||||||
-- @param #boolean Datalink (Optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default.
|
-- @param #boolean Datalink (Optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default.
|
||||||
-- @param #number Frequency Frequency in MHz used to communicate with the FAC. Default 133 MHz.
|
-- @param #number Frequency Frequency in MHz used to communicate with the FAC. Default 133 MHz.
|
||||||
-- @param #number Modulation Modulation of radio for communication. Default 0=AM.
|
-- @param #number Modulation Modulation of radio for communication. Default 0=AM.
|
||||||
-- @param #number CallsignName Callsign enumerator name of the FAC.
|
-- @param #number CallsignName Callsign enumerator name of the FAC. (CALLSIGN.Aircraft.{name} for airborne controllables, CALLSIGN.JTACS.{name} for ground units)
|
||||||
-- @param #number CallsignNumber Callsign number, e.g. Axeman-**1**.
|
-- @param #number CallsignNumber Callsign number, e.g. Axeman-**1**.
|
||||||
-- @return DCS#Task The DCS task structure.
|
-- @return DCS#Task The DCS task structure.
|
||||||
function CONTROLLABLE:TaskFAC_AttackGroup( AttackGroup, WeaponType, Designation, Datalink, Frequency, Modulation, CallsignName, CallsignNumber )
|
function CONTROLLABLE:TaskFAC_AttackGroup( AttackGroup, WeaponType, Designation, Datalink, Frequency, Modulation, CallsignName, CallsignNumber )
|
||||||
@@ -1853,7 +1851,26 @@ do -- Patrol methods
|
|||||||
|
|
||||||
-- Calculate the new Route.
|
-- Calculate the new Route.
|
||||||
local FromCoord = PatrolGroup:GetCoordinate()
|
local FromCoord = PatrolGroup:GetCoordinate()
|
||||||
local From = FromCoord:WaypointGround( 120 )
|
|
||||||
|
-- test for submarine
|
||||||
|
local depth = 0
|
||||||
|
local IsSub = false
|
||||||
|
if PatrolGroup:IsShip() then
|
||||||
|
local navalvec3 = FromCoord:GetVec3()
|
||||||
|
if navalvec3.y < 0 then
|
||||||
|
depth = navalvec3.y
|
||||||
|
IsSub = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local Waypoint = Waypoints[1]
|
||||||
|
local Speed = Waypoint.speed or (20 / 3.6)
|
||||||
|
local From = FromCoord:WaypointGround( Speed )
|
||||||
|
|
||||||
|
if IsSub then
|
||||||
|
From = FromCoord:WaypointNaval( Speed, Waypoint.alt )
|
||||||
|
end
|
||||||
|
|
||||||
table.insert( Waypoints, 1, From )
|
table.insert( Waypoints, 1, From )
|
||||||
|
|
||||||
@@ -1894,7 +1911,16 @@ do -- Patrol methods
|
|||||||
if ToWaypoint then
|
if ToWaypoint then
|
||||||
FromWaypoint = ToWaypoint
|
FromWaypoint = ToWaypoint
|
||||||
end
|
end
|
||||||
|
-- test for submarine
|
||||||
|
local depth = 0
|
||||||
|
local IsSub = false
|
||||||
|
if PatrolGroup:IsShip() then
|
||||||
|
local navalvec3 = FromCoord:GetVec3()
|
||||||
|
if navalvec3.y < 0 then
|
||||||
|
depth = navalvec3.y
|
||||||
|
IsSub = true
|
||||||
|
end
|
||||||
|
end
|
||||||
-- Loop until a waypoint has been found that is not the same as the current waypoint.
|
-- Loop until a waypoint has been found that is not the same as the current waypoint.
|
||||||
-- Otherwise the object zon't move or drive in circles and the algorithm would not do exactly
|
-- Otherwise the object zon't move or drive in circles and the algorithm would not do exactly
|
||||||
-- what it is supposed to do, which is making groups drive around.
|
-- what it is supposed to do, which is making groups drive around.
|
||||||
@@ -1909,9 +1935,13 @@ do -- Patrol methods
|
|||||||
local ToCoord = COORDINATE:NewFromVec2( { x = Waypoint.x, y = Waypoint.y } )
|
local ToCoord = COORDINATE:NewFromVec2( { x = Waypoint.x, y = Waypoint.y } )
|
||||||
-- Create a "ground route point", which is a "point" structure that can be given as a parameter to a Task
|
-- Create a "ground route point", which is a "point" structure that can be given as a parameter to a Task
|
||||||
local Route = {}
|
local Route = {}
|
||||||
|
if IsSub then
|
||||||
|
Route[#Route+1] = FromCoord:WaypointNaval( Speed, depth )
|
||||||
|
Route[#Route+1] = ToCoord:WaypointNaval( Speed, Waypoint.alt )
|
||||||
|
else
|
||||||
Route[#Route+1] = FromCoord:WaypointGround( Speed, Formation )
|
Route[#Route+1] = FromCoord:WaypointGround( Speed, Formation )
|
||||||
Route[#Route+1] = ToCoord:WaypointGround( Speed, Formation )
|
Route[#Route+1] = ToCoord:WaypointGround( Speed, Formation )
|
||||||
|
end
|
||||||
|
|
||||||
local TaskRouteToZone = PatrolGroup:TaskFunction( "CONTROLLABLE.PatrolRouteRandom", Speed, Formation, ToWaypoint )
|
local TaskRouteToZone = PatrolGroup:TaskFunction( "CONTROLLABLE.PatrolRouteRandom", Speed, Formation, ToWaypoint )
|
||||||
|
|
||||||
@@ -1956,15 +1986,30 @@ do -- Patrol methods
|
|||||||
-- Calculate the new Route.
|
-- Calculate the new Route.
|
||||||
local FromCoord = PatrolGroup:GetCoordinate()
|
local FromCoord = PatrolGroup:GetCoordinate()
|
||||||
|
|
||||||
|
-- test for submarine
|
||||||
|
local depth = 0
|
||||||
|
local IsSub = false
|
||||||
|
if PatrolGroup:IsShip() then
|
||||||
|
local navalvec3 = FromCoord:GetVec3()
|
||||||
|
if navalvec3.y < 0 then
|
||||||
|
depth = navalvec3.y
|
||||||
|
IsSub = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Select a random Zone and get the Coordinate of the new Zone.
|
-- Select a random Zone and get the Coordinate of the new Zone.
|
||||||
local RandomZone = ZoneList[ math.random( 1, #ZoneList ) ] -- Core.Zone#ZONE
|
local RandomZone = ZoneList[ math.random( 1, #ZoneList ) ] -- Core.Zone#ZONE
|
||||||
local ToCoord = RandomZone:GetRandomCoordinate( 10 )
|
local ToCoord = RandomZone:GetRandomCoordinate( 10 )
|
||||||
|
|
||||||
-- Create a "ground route point", which is a "point" structure that can be given as a parameter to a Task
|
-- Create a "ground route point", which is a "point" structure that can be given as a parameter to a Task
|
||||||
local Route = {}
|
local Route = {}
|
||||||
|
if IsSub then
|
||||||
|
Route[#Route+1] = FromCoord:WaypointNaval( Speed, depth )
|
||||||
|
Route[#Route+1] = ToCoord:WaypointNaval( Speed, depth )
|
||||||
|
else
|
||||||
Route[#Route+1] = FromCoord:WaypointGround( Speed, Formation )
|
Route[#Route+1] = FromCoord:WaypointGround( Speed, Formation )
|
||||||
Route[#Route+1] = ToCoord:WaypointGround( Speed, Formation )
|
Route[#Route+1] = ToCoord:WaypointGround( Speed, Formation )
|
||||||
|
end
|
||||||
|
|
||||||
local TaskRouteToZone = PatrolGroup:TaskFunction( "CONTROLLABLE.PatrolZones", ZoneList, Speed, Formation, DelayMin, DelayMax )
|
local TaskRouteToZone = PatrolGroup:TaskFunction( "CONTROLLABLE.PatrolZones", ZoneList, Speed, Formation, DelayMin, DelayMax )
|
||||||
|
|
||||||
@@ -3772,10 +3817,30 @@ function CONTROLLABLE:OptionDisperseOnAttack(Seconds)
|
|||||||
local Controller = self:_GetController()
|
local Controller = self:_GetController()
|
||||||
if Controller then
|
if Controller then
|
||||||
if self:IsGround() then
|
if self:IsGround() then
|
||||||
self:SetOption(AI.Option.GROUND.id.DISPERSE_ON_ATTACK, seconds)
|
self:SetOption(AI.Option.Ground.id.DISPERSE_ON_ATTACK, seconds)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Returns if the unit is a submarine.
|
||||||
|
-- @param #POSITIONABLE self
|
||||||
|
-- @return #boolean Submarines attributes result.
|
||||||
|
function POSITIONABLE:IsSubmarine()
|
||||||
|
self:F2()
|
||||||
|
|
||||||
|
local DCSUnit = self:GetDCSObject()
|
||||||
|
|
||||||
|
if DCSUnit then
|
||||||
|
local UnitDescriptor = DCSUnit:getDesc()
|
||||||
|
if UnitDescriptor.attributes["Submarines"] == true then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|||||||
@@ -2551,9 +2551,10 @@ do -- Players
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- GROUND - Switch on/off radar emissions
|
--- GROUND - Switch on/off radar emissions for the group.
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @param #boolean switch
|
-- @param #boolean switch If true, emission is enabled. If false, emission is disabled.
|
||||||
|
-- @return #GROUP self
|
||||||
function GROUP:EnableEmission(switch)
|
function GROUP:EnableEmission(switch)
|
||||||
self:F2( self.GroupName )
|
self:F2( self.GroupName )
|
||||||
local switch = switch or false
|
local switch = switch or false
|
||||||
@@ -2566,6 +2567,7 @@ function GROUP:EnableEmission(switch)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--do -- Smoke
|
--do -- Smoke
|
||||||
|
|||||||
@@ -761,40 +761,6 @@ function UNIT:GetFuel()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Sets the passed group or unit objects radar emitters on or off. Can be used on sam sites for example to shut down the radar without setting AI off or changing the alarm state.
|
|
||||||
-- @param #UNIT self
|
|
||||||
-- @param #boolean Switch If `true` or `nil`, emission is enabled. If `false`, emission is turned off.
|
|
||||||
-- @return #UNIT self
|
|
||||||
function UNIT:SetEmission(Switch)
|
|
||||||
|
|
||||||
if Switch==nil then
|
|
||||||
Switch=true
|
|
||||||
end
|
|
||||||
|
|
||||||
local DCSUnit = self:GetDCSObject()
|
|
||||||
|
|
||||||
if DCSUnit then
|
|
||||||
DCSUnit:enableEmission(Switch)
|
|
||||||
end
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Sets the passed group or unit objects radar emitters ON. Can be used on sam sites for example to shut down the radar without setting AI off or changing the alarm state.
|
|
||||||
-- @param #UNIT self
|
|
||||||
-- @return #UNIT self
|
|
||||||
function UNIT:EnableEmission()
|
|
||||||
self:SetEmission(true)
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Sets the passed group or unit objects radar emitters OFF. Can be used on sam sites for example to shut down the radar without setting AI off or changing the alarm state.
|
|
||||||
-- @param #UNIT self
|
|
||||||
-- @return #UNIT self
|
|
||||||
function UNIT:DisableEmission()
|
|
||||||
self:SetEmission(false)
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns a list of one @{Wrapper.Unit}.
|
--- Returns a list of one @{Wrapper.Unit}.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
@@ -1429,9 +1395,10 @@ function UNIT:GetTemplateFuel()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- GROUND - Switch on/off radar emissions.
|
--- GROUND - Switch on/off radar emissions of a unit.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @param #boolean switch
|
-- @param #boolean switch If true, emission is enabled. If false, emission is disabled.
|
||||||
|
-- @return #UNIT self
|
||||||
function UNIT:EnableEmission(switch)
|
function UNIT:EnableEmission(switch)
|
||||||
self:F2( self.UnitName )
|
self:F2( self.UnitName )
|
||||||
|
|
||||||
@@ -1445,4 +1412,5 @@ function UNIT:EnableEmission(switch)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ Utilities/Routines.lua
|
|||||||
Utilities/Utils.lua
|
Utilities/Utils.lua
|
||||||
Utilities/Enums.lua
|
Utilities/Enums.lua
|
||||||
Utilities/Profiler.lua
|
Utilities/Profiler.lua
|
||||||
|
Utilities/Templates.lua
|
||||||
|
|
||||||
Core/Base.lua
|
Core/Base.lua
|
||||||
Core/UserFlag.lua
|
Core/UserFlag.lua
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ This repository contains the source lua code of the MOOSE framework.
|
|||||||
|
|
||||||
### [MOOSE_INCLUDE](https://github.com/FlightControl-Master/MOOSE_INCLUDE) - For use and generated
|
### [MOOSE_INCLUDE](https://github.com/FlightControl-Master/MOOSE_INCLUDE) - For use and generated
|
||||||
|
|
||||||
This repository contains the Moose.lua file to be included within your missions.
|
This repository contains the Moose.lua file to be included within your missions. Note that the Moose\_.lua is technically the same as Moose.lua, but without any commentary or unnecessary whitespace in it. You only need to load **one** of those at the beginning of your mission.
|
||||||
|
|
||||||
|
|
||||||
### [MOOSE_DOCS](https://github.com/FlightControl-Master/MOOSE_DOCS) - Not for use
|
### [MOOSE_DOCS](https://github.com/FlightControl-Master/MOOSE_DOCS) - Not for use
|
||||||
|
|||||||
Reference in New Issue
Block a user