mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-07-17 17:26:53 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e76c26ff59 | |||
| cb11de6f9c | |||
| cdd78e5163 | |||
| a8da02774a | |||
| 04258a69c4 | |||
| 49882f03d9 |
@@ -676,7 +676,7 @@ do -- COORDINATE
|
||||
local _,_,_,_,_,scenerys=self:ScanObjects(radius, false, false, true)
|
||||
|
||||
local set={}
|
||||
|
||||
|
||||
for _,_scenery in pairs(scenerys) do
|
||||
local scenery=_scenery --DCS#Object
|
||||
|
||||
|
||||
@@ -115,6 +115,10 @@ __Moose.Include( 'Scripts/Moose/Ops/RescueHelo.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Squadron.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Ops/Target.lua' )
|
||||
|
||||
__Moose.Include( 'Scripts/Moose/Navigation/Navaid.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Navigation/NavFix.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/Navigation/FlightPlan.lua' )
|
||||
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Balancer.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Air.lua' )
|
||||
__Moose.Include( 'Scripts/Moose/AI/AI_Air_Patrol.lua' )
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
--- **NAVIGATION** - Flight Plan.
|
||||
--
|
||||
-- **Main Features:**
|
||||
--
|
||||
-- * Manage navigation aids
|
||||
-- * VOR, NDB
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ## Example Missions:
|
||||
--
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Ops%20-%20FlightPlan).
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ### Author: **funkyfranky**
|
||||
--
|
||||
-- ===
|
||||
-- @module Navigation.FlightPlan
|
||||
-- @image NAVIGATION_FlightPlan.png
|
||||
|
||||
|
||||
--- FLIGHTPLAN class.
|
||||
-- @type FLIGHTPLAN
|
||||
-- @field #string ClassName Name of the class.
|
||||
-- @field #number verbose Verbosity of output.
|
||||
-- @field #table fixes Navigation fixes.
|
||||
-- @field Wrapper.Airbase#AIRBASE departureAirbase Departure airbase.
|
||||
-- @field Wrapper.Airbase#AIRBASE destinationAirbase Destination airbase.
|
||||
-- @field #number altitudeCruiseMin Minimum cruise altitude in feet MSL.
|
||||
-- @field #number altitudeCruiseMax Maximum cruise altitude in feet MSL.
|
||||
-- @extends Core.Base#BASE
|
||||
|
||||
--- *A fleet of British ships at war are the best negotiators.* -- Horatio Nelson
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- # The FLIGHTPLAN Concept
|
||||
--
|
||||
-- A FLIGHTPLAN consists of one or multiple FLOTILLAs. These flotillas "live" in a WAREHOUSE that has a phyiscal struction (STATIC or UNIT) and can be captured or destroyed.
|
||||
--
|
||||
-- # Basic Setup
|
||||
--
|
||||
-- A new `FLIGHTPLAN` object can be created with the @{#FLIGHTPLAN.New}(`WarehouseName`, `FleetName`) function, where `WarehouseName` is the name of the static or unit object hosting the fleet
|
||||
-- and `FleetName` is the name you want to give the fleet. This must be *unique*!
|
||||
--
|
||||
-- myFlightplan=FLIGHTPLAN:New("Plan A")
|
||||
-- myFleet:SetPortZone(ZonePort1stFleet)
|
||||
-- myFleet:Start()
|
||||
--
|
||||
-- A fleet needs a *port zone*, which is set via the @{#FLIGHTPLAN.SetPortZone}(`PortZone`) function. This is the zone where the naval assets are spawned and return to.
|
||||
--
|
||||
-- Finally, the fleet needs to be started using the @{#FLIGHTPLAN.Start}() function. If the fleet is not started, it will not process any requests.
|
||||
--
|
||||
-- @field #FLIGHTPLAN
|
||||
FLIGHTPLAN = {
|
||||
ClassName = "FLIGHTPLAN",
|
||||
verbose = 0,
|
||||
fixes = {}
|
||||
}
|
||||
|
||||
--- Type of navaid
|
||||
-- @type FLIGHTPLAN.Type
|
||||
-- @field #string VOR VOR
|
||||
-- @field #string NDB NDB
|
||||
FLIGHTPLAN.TYPE={
|
||||
VOR="VOR",
|
||||
NDB="NDB",
|
||||
}
|
||||
|
||||
--- FLIGHTPLAN class version.
|
||||
-- @field #string version
|
||||
FLIGHTPLAN.version="0.0.1"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- ToDo list
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- TODO: A lot...
|
||||
-- TODO: How to handle the FLIGHTGROUP:_LandAtAirBase
|
||||
-- TODO: Do we always need a holding pattern? https://www.faa.gov/air_traffic/publications/atpubs/aip_html/part2_enr_section_1.5.html#:~:text=If%20no%20holding%20pattern%20is,than%20that%20desired%20by%20ATC.
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Constructor
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- Create a new FLIGHTPLAN instance.
|
||||
-- @param #FLIGHTPLAN self
|
||||
-- @param #string Name Name of this flight plan.
|
||||
-- @return #FLIGHTPLAN self
|
||||
function FLIGHTPLAN:New(Name)
|
||||
|
||||
-- Inherit everything from SCENERY class.
|
||||
self=BASE:Inherit(self, BASE:New()) -- #FLIGHTPLAN
|
||||
|
||||
-- Set alias.
|
||||
self.alias=tostring(Name)
|
||||
|
||||
-- Set some string id for output to DCS.log file.
|
||||
self.lid=string.format("FLIGHTPLAN %s | ", self.alias)
|
||||
|
||||
-- Debug info.
|
||||
self:I(self.lid..string.format("Created FLIGHTPLAN!"))
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Create a new FLIGHTPLAN instance from another FLIGHTPLAN acting as blue print.
|
||||
-- The newly created flight plan is deep copied from the given one.
|
||||
-- @param #FLIGHTPLAN self
|
||||
-- @param #FLIGHTPLAN FlightPlan Blue print of the flight plan to copy.
|
||||
-- @return #FLIGHTPLAN self
|
||||
function FLIGHTPLAN:NewFromFlightPlan(FlightPlan)
|
||||
self=UTILS.DeepCopy(FlightPlan)
|
||||
return self
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- User Functions
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- Add navigation fix to the flight plan.
|
||||
-- @param #FLIGHTPLAN self
|
||||
-- @param Navigation.NavFix#NAVFIX NavFix The nav fix.
|
||||
-- @return #FLIGHTPLAN self
|
||||
function FLIGHTPLAN:AddNavFix(NavFix)
|
||||
|
||||
table.insert(self.fixes, NavFix)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set depature airbase.
|
||||
-- @param #FLIGHTPLAN self
|
||||
-- @param #string AirbaseName Name of the airbase or AIRBASE object.
|
||||
-- @return #FLIGHTPLAN self
|
||||
function FLIGHTPLAN:SetDepartureAirbase(AirbaseName)
|
||||
|
||||
self.departureAirbase=AIRBASE:FindByName(AirbaseName)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set destination airbase.
|
||||
-- @param #FLIGHTPLAN self
|
||||
-- @param #string AirbaseName Name of the airbase or AIRBASE object.
|
||||
-- @return #FLIGHTPLAN self
|
||||
function FLIGHTPLAN:SetDestinationAirbase(AirbaseName)
|
||||
|
||||
self.destinationAirbase=AIRBASE:FindByName(AirbaseName)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set cruise altitude.
|
||||
-- @param #FLIGHTPLAN self
|
||||
-- @param #number AltMin Minimum altitude in feet MSL.
|
||||
-- @param #number AltMax Maximum altitude in feet MSL. Default is `AltMin`.
|
||||
-- @return #FLIGHTPLAN self
|
||||
function FLIGHTPLAN:SetCruiseAltitude(AltMin, AltMax)
|
||||
|
||||
self.altitudeCruiseMin=AltMin
|
||||
self.altitudeCruiseMax=AltMax or self.altitudeCruiseMin
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Get the name of this flight plan.
|
||||
-- @param #FLIGHTPLAN self
|
||||
-- @return #string The name.
|
||||
function FLIGHTPLAN:GetName()
|
||||
return self.alias
|
||||
end
|
||||
|
||||
|
||||
--- Get cruise altitude. This returns a random altitude between the set min/max cruise altitudes.
|
||||
-- @param #FLIGHTPLAN self
|
||||
-- @return #number Cruise altitude in feet MSL.
|
||||
function FLIGHTPLAN:GetCruiseAltitude()
|
||||
|
||||
local alt=10000
|
||||
if self.altitudeCruiseMin and self.altitudeCruiseMax then
|
||||
alt=math.random(self.altitudeCruiseMin, self.altitudeCruiseMax)
|
||||
elseif self.altitudeCruiseMin then
|
||||
alt=self.altitudeCruiseMin
|
||||
elseif self.altitudeCruiseMax then
|
||||
alt=self.altitudeCruiseMax
|
||||
end
|
||||
|
||||
return alt
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Private Functions
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -0,0 +1,212 @@
|
||||
--- **NAVIGATION** - Navigation Airspace Fix.
|
||||
--
|
||||
-- **Main Features:**
|
||||
--
|
||||
-- * Stuff
|
||||
-- * More Stuff
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ## Example Missions:
|
||||
--
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Navigation%20-%20NavFix).
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ### Author: **funkyfranky**
|
||||
--
|
||||
-- ===
|
||||
-- @module Navigation.NavFix
|
||||
-- @image NAVIGATION_NavFix.png
|
||||
|
||||
|
||||
--- NAVFIX class.
|
||||
-- @type NAVFIX
|
||||
-- @field #string ClassName Name of the class.
|
||||
-- @field #number verbose Verbosity of output.
|
||||
-- @field #string name Name of the fix.
|
||||
-- @field Core.Point#COORDINATE coordinate Coordinate of the fix.
|
||||
-- @field Wrapper.Marker#MARKER marker Marker of fix on F10 map.
|
||||
-- @field #boolean isCompulsory Is this a compulsory fix.
|
||||
-- @field #boolean isFlyover Is this a fly over fix.
|
||||
-- @field #boolean isIAF Is initial approach fix (IAF).
|
||||
-- @field #boolean isIF Is intermediate fix (IF).
|
||||
--
|
||||
-- @extends Core.Base#BASE
|
||||
|
||||
--- *A fleet of British ships at war are the best negotiators.* -- Horatio Nelson
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- # The NAVFIX Concept
|
||||
--
|
||||
-- The NAVFIX class has a great concept!
|
||||
--
|
||||
-- # Basic Setup
|
||||
--
|
||||
-- A new `NAVFIX` object can be created with the @{#NAVFIX.New}() function.
|
||||
--
|
||||
-- myTemplate=NAVFIX:New()
|
||||
-- myTemplate:SetXYZ(X, Y, Z)
|
||||
--
|
||||
-- This is how it works.
|
||||
--
|
||||
-- @field #NAVFIX
|
||||
NAVFIX = {
|
||||
ClassName = "NAVFIX",
|
||||
verbose = 0,
|
||||
}
|
||||
|
||||
--- Type of navaid
|
||||
-- @type NAVFIX.Type
|
||||
-- @field #string VOR VOR
|
||||
-- @field #string NDB NDB
|
||||
NAVFIX.Type={
|
||||
VOR="VOR",
|
||||
NDB="NDB",
|
||||
}
|
||||
|
||||
--- NAVFIX class version.
|
||||
-- @field #string version
|
||||
NAVFIX.version="0.0.1"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- ToDo list
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- TODO: A lot...
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Constructor
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- Create a new NAVFIX class instance.
|
||||
-- @param #NAVFIX self
|
||||
-- @return #NAVFIX self
|
||||
function NAVFIX:New(Coordinate, Name)
|
||||
|
||||
-- Inherit everything from SCENERY class.
|
||||
self=BASE:Inherit(self, BASE:New()) -- #NAVFIX
|
||||
|
||||
self.coordinate=Coordinate
|
||||
|
||||
self.name=Name
|
||||
|
||||
self.marker=MARKER:New(Coordinate, self:_GetMarkerText())
|
||||
self.marker:ToAll()
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- User Functions
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- Set minimum altitude.
|
||||
-- @param #NAVFIX self
|
||||
-- @param #number Altitude Min altitude in feet.
|
||||
-- @return #NAVFIX self
|
||||
function NAVFIX:SetAltMin(Altitude)
|
||||
|
||||
self.altMin=Altitude
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set maximum altitude.
|
||||
-- @param #NAVFIX self
|
||||
-- @param #number Altitude Max altitude in feet.
|
||||
-- @return #NAVFIX self
|
||||
function NAVFIX:SetAltMax(Altitude)
|
||||
|
||||
self.altMax=Altitude
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set whether this fix is compulsory.
|
||||
-- @param #NAVFIX self
|
||||
-- @param #boolean Compulsory If `true`, this is a compusory fix. If `false` or nil, it is non-compulsory.
|
||||
-- @return #NAVFIX self
|
||||
function NAVFIX:SetCompulsory(Compulsory)
|
||||
self.isCompulsory=Compulsory
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set whether this fix is compulsory.
|
||||
-- @param #NAVFIX self
|
||||
-- @param #boolean FlyOver If `true`, this is a fly over fix. If `false` or nil, it is not.
|
||||
-- @return #NAVFIX self
|
||||
function NAVFIX:SetFlyOver(FlyOver)
|
||||
self.isFlyover=FlyOver
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set whether this is the intermediate fix.
|
||||
-- @param #NAVFIX self
|
||||
-- @param #boolean IntermediateFix If `true`, this is an intermediate fix.
|
||||
-- @return #NAVFIX self
|
||||
function NAVFIX:SetIntermediateFix(IntermediateFix)
|
||||
self.isIF=IntermediateFix
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set whether this is an initial approach fix (IAF).
|
||||
-- @param #NAVFIX self
|
||||
-- @param #boolean IntermediateFix If `true`, this is an intermediate fix.
|
||||
-- @return #NAVFIX self
|
||||
function NAVFIX:SetInitialApproachFix(IntermediateFix)
|
||||
self.isIAF=IntermediateFix
|
||||
return self
|
||||
end
|
||||
|
||||
--- Get the altitude in feet MSL.
|
||||
-- @param #NAVFIX self
|
||||
-- @return #number Altitude in feet MSL. Can be `#nil`
|
||||
function NAVFIX:GetAltitude()
|
||||
|
||||
local alt=nil
|
||||
if self.altMin and self.altMax then
|
||||
alt=math.random(self.altMin, self.altMax)
|
||||
elseif self.altMin then
|
||||
alt=self.altMin
|
||||
elseif self.altMax then
|
||||
alt=self.altMax
|
||||
end
|
||||
|
||||
return alt
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Private Functions
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- Get text displayed in the F10 marker.
|
||||
-- @param #NAVFIX self
|
||||
-- @return #string Marker text.
|
||||
function NAVFIX:_GetMarkerText()
|
||||
|
||||
local altmin=self.altMin and tostring(self.altMin) or ""
|
||||
local altmax=self.altMax and tostring(self.altMax) or ""
|
||||
local speedmin=self.speedMin and tostring(self.speedMin) or ""
|
||||
local speedmax=self.speedMax and tostring(self.speedMax) or ""
|
||||
|
||||
|
||||
local text=string.format("NAVFIX %s", self.name)
|
||||
if self.isIAF then
|
||||
text=text..string.format(" (IAF)")
|
||||
end
|
||||
if self.isIF then
|
||||
text=text..string.format(" (IF)")
|
||||
end
|
||||
text=text..string.format("\nAltitude: %s - %s", altmin, altmax)
|
||||
text=text..string.format("\nSpeed: %s - %s", speedmin, speedmax)
|
||||
text=text..string.format("\nCompulsory: %s", tostring(self.isCompulsory))
|
||||
text=text..string.format("\nFly Over: %s", tostring(self.isFlyover))
|
||||
|
||||
return text
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -0,0 +1,172 @@
|
||||
--- **Navigation** - Navigation aid.
|
||||
--
|
||||
-- **Main Features:**
|
||||
--
|
||||
-- * Manage navigation aids
|
||||
-- * VOR, NDB
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ## Example Missions:
|
||||
--
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Navigation%20-%20Navaid).
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ### Author: **funkyfranky**
|
||||
--
|
||||
-- ===
|
||||
-- @module Navigation.Navaid
|
||||
-- @image Navigation_Navaid.png
|
||||
|
||||
|
||||
--- NAVAID class.
|
||||
-- @type NAVAID
|
||||
-- @field #string ClassName Name of the class.
|
||||
-- @field #number verbose Verbosity of output.
|
||||
-- @extends Core.Base#BASE
|
||||
|
||||
--- *A fleet of British ships at war are the best negotiators.* -- Horatio Nelson
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- # The NAVAID Concept
|
||||
--
|
||||
-- A NAVAID consists of one or multiple FLOTILLAs. These flotillas "live" in a WAREHOUSE that has a phyiscal struction (STATIC or UNIT) and can be captured or destroyed.
|
||||
--
|
||||
-- # Basic Setup
|
||||
--
|
||||
-- A new `NAVAID` object can be created with the @{#NAVAID.New}(`WarehouseName`, `FleetName`) function, where `WarehouseName` is the name of the static or unit object hosting the fleet
|
||||
-- and `FleetName` is the name you want to give the fleet. This must be *unique*!
|
||||
--
|
||||
-- myFleet=NAVAID:New("myWarehouseName", "1st Fleet")
|
||||
-- myFleet:SetPortZone(ZonePort1stFleet)
|
||||
-- myFleet:Start()
|
||||
--
|
||||
-- A fleet needs a *port zone*, which is set via the @{#NAVAID.SetPortZone}(`PortZone`) function. This is the zone where the naval assets are spawned and return to.
|
||||
--
|
||||
-- Finally, the fleet needs to be started using the @{#NAVAID.Start}() function. If the fleet is not started, it will not process any requests.
|
||||
--
|
||||
-- @field #NAVAID
|
||||
NAVAID = {
|
||||
ClassName = "NAVAID",
|
||||
verbose = 0,
|
||||
}
|
||||
|
||||
--- Type of navaid
|
||||
-- @type NAVAID.Type
|
||||
-- @field #string VOR VOR
|
||||
-- @field #string NDB NDB
|
||||
NAVAID.TYPE={
|
||||
VOR="VOR",
|
||||
NDB="NDB",
|
||||
}
|
||||
|
||||
--- NAVAID class version.
|
||||
-- @field #string version
|
||||
NAVAID.version="0.0.1"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- ToDo list
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- TODO: A lot...
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Constructor
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- Create a new NAVAID class instance.
|
||||
-- @param #NAVAID self
|
||||
-- @param #string ZoneName Name of the zone to scan the scenery.
|
||||
-- @param #string SceneryName Name of the scenery object.
|
||||
-- @param #string Type Type of Navaid.
|
||||
-- @return #NAVAID self
|
||||
function NAVAID:New(ZoneName, SceneryName, Type)
|
||||
|
||||
-- Inherit everything from SCENERY class.
|
||||
self=BASE:Inherit(self, BASE:New()) -- #NAVAID
|
||||
|
||||
|
||||
self.zone=ZONE:FindByName(ZoneName)
|
||||
|
||||
self.coordinate=self.zone:GetCoordinate()
|
||||
|
||||
if SceneryName then
|
||||
self.scenery=SCENERY:FindByNameInZone(SceneryName, ZoneName)
|
||||
if not self.scenery then
|
||||
self:E("ERROR: Could not find scenery object %s in zone %s", SceneryName, ZoneName)
|
||||
end
|
||||
end
|
||||
|
||||
self.alias=string.format("%s %s %s", tostring(ZoneName), tostring(SceneryName), tostring(Type))
|
||||
|
||||
|
||||
-- Set some string id for output to DCS.log file.
|
||||
self.lid=string.format("NAVAID %s | ", self.alias)
|
||||
|
||||
self:I(self.lid..string.format("Created NAVAID!"))
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- User Functions
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- Set frequency.
|
||||
-- @param #NAVAID self
|
||||
-- @param #number Frequency Frequency in Hz.
|
||||
-- @return #NAVAID self
|
||||
function NAVAID:SetFrequency(Frequency)
|
||||
|
||||
self.frequency=Frequency
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set channel.
|
||||
-- @param #NAVAID self
|
||||
-- @param #number Channel
|
||||
-- @param #string Band
|
||||
-- @return #NAVAID self
|
||||
function NAVAID:SetChannel(Channel, Band)
|
||||
|
||||
self.channel=Channel
|
||||
self.band=Band
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Add marker the NAVAID on the F10 map.
|
||||
-- @param #NAVAID self
|
||||
-- @return #NAVAID self
|
||||
function NAVAID:AddMarker()
|
||||
|
||||
local text=string.format("I am a NAVAID!")
|
||||
|
||||
self.markID=self.coordinate:MarkToAll(text, true)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Remove marker of the NAVAID from the F10 map.
|
||||
-- @param #NAVAID self
|
||||
-- @return #NAVAID self
|
||||
function NAVAID:DelMarker()
|
||||
|
||||
if self.markID then
|
||||
UTILS.RemoveMark(self.markID)
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Private Functions
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -0,0 +1,108 @@
|
||||
--- **NAVIGATION** - Template.
|
||||
--
|
||||
-- **Main Features:**
|
||||
--
|
||||
-- * Stuff
|
||||
-- * More Stuff
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ## Example Missions:
|
||||
--
|
||||
-- Demo missions can be found on [github](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/develop/Navigation%20-%20Template).
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ### Author: **funkyfranky**
|
||||
--
|
||||
-- ===
|
||||
-- @module Navigation.Template
|
||||
-- @image NAVIGATION_Template.png
|
||||
|
||||
|
||||
--- TEMPLATE class.
|
||||
-- @type TEMPLATE
|
||||
-- @field #string ClassName Name of the class.
|
||||
-- @field #number verbose Verbosity of output.
|
||||
-- @extends Core.Base#BASE
|
||||
|
||||
--- *A fleet of British ships at war are the best negotiators.* -- Horatio Nelson
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- # The TEMPLATE Concept
|
||||
--
|
||||
-- The TEMPLATE class has a great concept!
|
||||
--
|
||||
-- # Basic Setup
|
||||
--
|
||||
-- A new `TEMPLATE` object can be created with the @{#TEMPLATE.New}() function.
|
||||
--
|
||||
-- myTemplate=TEMPLATE:New()
|
||||
-- myTemplate:SetXYZ(X, Y, Z)
|
||||
--
|
||||
-- This is how it works.
|
||||
--
|
||||
-- @field #TEMPLATE
|
||||
TEMPLATE = {
|
||||
ClassName = "TEMPLATE",
|
||||
verbose = 0,
|
||||
}
|
||||
|
||||
--- Type of navaid
|
||||
-- @type TEMPLATE.Type
|
||||
-- @field #string VOR VOR
|
||||
-- @field #string NDB NDB
|
||||
TEMPLATE.TYPE={
|
||||
VOR="VOR",
|
||||
NDB="NDB",
|
||||
}
|
||||
|
||||
--- TEMPLATE class version.
|
||||
-- @field #string version
|
||||
TEMPLATE.version="0.0.1"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- ToDo list
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- TODO: A lot...
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Constructor
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- Create a new TEMPLATE class instance.
|
||||
-- @param #TEMPLATE self
|
||||
-- @return #TEMPLATE self
|
||||
function TEMPLATE:New()
|
||||
|
||||
-- Inherit everything from SCENERY class.
|
||||
self=BASE:Inherit(self, BASE:New()) -- #TEMPLATE
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- User Functions
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- Set frequency.
|
||||
-- @param #TEMPLATE self
|
||||
-- @param #number Frequency Frequency in Hz.
|
||||
-- @return #TEMPLATE self
|
||||
function TEMPLATE:SetFrequency(Frequency)
|
||||
|
||||
self.frequency=Frequency
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Private Functions
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
@@ -332,6 +332,13 @@ FLIGHTCONTROL.version="0.7.3"
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
|
||||
-- TODO: Ground control for takeoff and taxi.
|
||||
-- TODO: Improve approach pattern with new NAVIGATION classes.
|
||||
-- TODO: SID procedure for departures.
|
||||
-- TODO: STAR procedure for arrivals.
|
||||
-- TODO: Holding positions for runways.
|
||||
-- TODO: Taxi ways.
|
||||
-- TODO: Better phrasiology.
|
||||
-- TODO: Switch to enable/disable AI messages.
|
||||
-- TODO: Talk me down option.
|
||||
-- TODO: Check runways and clean up.
|
||||
@@ -777,7 +784,7 @@ end
|
||||
--- Remove a holding pattern.
|
||||
-- @param #FLIGHTCONTROL self
|
||||
-- @param #FLIGHTCONTROL.HoldingPattern HoldingPattern Holding pattern to be removed.
|
||||
-- @param #FLIGHTCONTROL self
|
||||
-- @return #FLIGHTCONTROL self
|
||||
function FLIGHTCONTROL:RemoveHoldingPattern(HoldingPattern)
|
||||
|
||||
for i,_holdingpattern in pairs(self.holdingpatterns) do
|
||||
|
||||
@@ -59,6 +59,8 @@
|
||||
-- @field #boolean prohibitAB Disallow (true) or allow (false) AI to use the afterburner.
|
||||
-- @field #boolean jettisonEmptyTanks Allow (true) or disallow (false) AI to jettison empty fuel tanks.
|
||||
-- @field #boolean jettisonWeapons Allow (true) or disallow (false) AI to jettison weapons if in danger.
|
||||
-- @field #table flightplans Flight plans for this group.
|
||||
-- @field Navigation.FlightPlan#FLIGHTPLAN flightplan Currently active flight plan.
|
||||
--
|
||||
-- @extends Ops.OpsGroup#OPSGROUP
|
||||
|
||||
@@ -150,7 +152,8 @@ FLIGHTGROUP = {
|
||||
playerWarnings = {},
|
||||
prohibitAB = false,
|
||||
jettisonEmptyTanks = true,
|
||||
jettisonWeapons = true, -- that's actually a negative option like prohibitAB
|
||||
jettisonWeapons = true, -- that's actually a negative option like prohibitAB
|
||||
flightplans = {},
|
||||
}
|
||||
|
||||
|
||||
@@ -647,6 +650,18 @@ function FLIGHTGROUP:SetDespawnAfterHolding()
|
||||
return self
|
||||
end
|
||||
|
||||
--- Add flightplan.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param Navigation.FlightPlan#FLIGHTPLAN FlightPlan The flight plan.
|
||||
-- @return #FLIGHTGROUP self
|
||||
function FLIGHTGROUP:AddFlightPlan(FlightPlan)
|
||||
|
||||
self:T(self.lid..string.format("Adding flight plan %s", FlightPlan:GetName() ))
|
||||
table.insert(self.flightplans, FlightPlan)
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Check if flight is parking.
|
||||
-- @param #FLIGHTGROUP self
|
||||
@@ -1305,6 +1320,10 @@ function FLIGHTGROUP:Status()
|
||||
|
||||
-- Current mission.
|
||||
local mission=self:GetMissionCurrent()
|
||||
|
||||
if not (self.cargoTransport or mission) then
|
||||
self:_CheckFlightPlans()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -3353,6 +3372,56 @@ function FLIGHTGROUP:onafterFuelCritical(From, Event, To)
|
||||
end
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Flightplan Functions
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- Check flightplans.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @param Navigation.FlightPlan#FLIGHTPLAN FlightPlan Flight plan.
|
||||
-- @return #FLIGHTGROUP self
|
||||
function FLIGHTGROUP:_SetFlightPlan(FlightPlan)
|
||||
|
||||
self.flightplan=FlightPlan
|
||||
|
||||
for i,_fix in pairs(FlightPlan.fixes) do
|
||||
local fix=_fix --Navigation.NavFix#NAVFIX
|
||||
|
||||
--fix.coordinate
|
||||
|
||||
local speed=fix.altMin
|
||||
|
||||
local altitude=(fix.altMin or fix.altMax)~=nil and fix:GetAltitude() or FlightPlan:GetCruiseAltitude()
|
||||
|
||||
local wp=self:AddWaypoint(fix.coordinate, Speed, AfterWaypointWithID, altitude or 10000, false)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--- Check flightplans.
|
||||
-- @param #FLIGHTGROUP self
|
||||
-- @return #FLIGHTGROUP self
|
||||
function FLIGHTGROUP:_CheckFlightPlans()
|
||||
|
||||
if self.flightplan then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
for i,_flightplan in pairs(self.flightplans) do
|
||||
local flightplan=_flightplan --Navigation.FlightPlan#FLIGHTPLAN
|
||||
|
||||
if flightplan then
|
||||
|
||||
self:_SetFlightPlan(flightplan)
|
||||
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- Task functions
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -555,6 +555,18 @@ UTILS.kg2lbs = function( kg )
|
||||
return kg * 2.20462
|
||||
end
|
||||
|
||||
--- Convert latitude or longitude from degrees, minutes, seconds (DMS) to decimal degrees (DD).
|
||||
-- @param #number Degrees Degrees in grad.
|
||||
-- @param #number Minutes Minutes.
|
||||
-- @param #number Seconds Seconds.
|
||||
-- @return #number Latitude or Longitude in decimal degrees.
|
||||
UTILS.LLDMSToDD = function(Degrees, Minutes, Seconds)
|
||||
|
||||
local dd=(Degrees or 0) + (Minutes or 0)/60 + (Seconds or 0)/3600
|
||||
|
||||
return dd
|
||||
end
|
||||
|
||||
--[[acc:
|
||||
in DM: decimal point of minutes.
|
||||
In DMS: decimal point of seconds.
|
||||
|
||||
@@ -128,7 +128,7 @@ function SCENERY:FindByName(Name, Coordinate, Radius)
|
||||
-- @param #number radius
|
||||
-- @param #string name
|
||||
local function SceneryScan(coordinate, radius, name)
|
||||
if coordinate ~= nil then
|
||||
if coordinate ~= nil then
|
||||
local scenerylist = coordinate:ScanScenery(radius)
|
||||
local rscenery = nil
|
||||
for _,_scenery in pairs(scenerylist) do
|
||||
@@ -157,14 +157,14 @@ end
|
||||
--@param Core.Zone#ZONE Zone Where to find the scenery object. Can be handed as zone name.
|
||||
--@param #number Radius (optional) Search radius around coordinate, defaults to 100
|
||||
--@return #SCENERY Scenery Object or `nil` if it cannot be found
|
||||
function SCENERY:FindByNameInZone(Name, Zone, Radius)
|
||||
function SCENERY:FindByNameInZone(Name, Zone, Radius)
|
||||
local radius = Radius or 100
|
||||
local name = Name or "unknown"
|
||||
if type(Zone) == "string" then
|
||||
Zone = ZONE:FindByName(Zone)
|
||||
end
|
||||
local coordinate = Zone:GetCoordinate()
|
||||
return self:FindByName(Name,coordinate,Radius)
|
||||
return self:FindByName(Name,coordinate,Radius)
|
||||
end
|
||||
|
||||
--- Find a SCENERY object from its zone name. Since SCENERY isn't registered in the Moose database (just too many objects per map), we need to do a scan first
|
||||
|
||||
@@ -107,6 +107,9 @@ Ops/FlightControl.lua
|
||||
Ops/PlayerTask.lua
|
||||
Ops/PlayerRecce.lua
|
||||
|
||||
Navigation/Navaid.lua
|
||||
Navigation/FlightPlan.lua
|
||||
|
||||
AI/AI_Balancer.lua
|
||||
AI/AI_Air.lua
|
||||
AI/AI_Air_Patrol.lua
|
||||
|
||||
Reference in New Issue
Block a user