mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Ops
- Airboss optimizations WIP
This commit is contained in:
parent
f9ec21a2b5
commit
caef309547
@ -300,6 +300,45 @@ do -- COORDINATE
|
|||||||
return { x = self.x, y = self.z }
|
return { x = self.x, y = self.z }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Update x,y,z coordinates from a given 3D vector.
|
||||||
|
-- @param #COORDINATE self
|
||||||
|
-- @param DCS#Vec3 Vec3 The 3D vector with x,y,z components.
|
||||||
|
-- @return #COORDINATE The modified COORDINATE itself.
|
||||||
|
function COORDINATE:UpdateFromVec3(Vec3)
|
||||||
|
|
||||||
|
self.x=Vec3.x
|
||||||
|
self.y=Vec3.y
|
||||||
|
self.z=Vec3.z
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Update x,y,z coordinates from another given COORDINATE.
|
||||||
|
-- @param #COORDINATE self
|
||||||
|
-- @param #COORDINATE Coordinate The coordinate with the new x,y,z positions.
|
||||||
|
-- @return #COORDINATE The modified COORDINATE itself.
|
||||||
|
function COORDINATE:UpdateFromCoordinate(Coordinate)
|
||||||
|
|
||||||
|
self.x=Coordinate.x
|
||||||
|
self.y=Coordinate.y
|
||||||
|
self.z=Coordinate.z
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Update x and z coordinates from a given 2D vector.
|
||||||
|
-- @param #COORDINATE self
|
||||||
|
-- @param DCS#Vec2 Vec2 The 2D vector with x,y components. x is overwriting COORDINATE.x while y is overwriting COORDINATE.z.
|
||||||
|
-- @return #COORDINATE The modified COORDINATE itself.
|
||||||
|
function COORDINATE:UpdateFromVec2(Vec2)
|
||||||
|
|
||||||
|
self.x=Vec2.x
|
||||||
|
self.z=Vec2.y
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns the coordinate from the latitude and longitude given in decimal degrees.
|
--- Returns the coordinate from the latitude and longitude given in decimal degrees.
|
||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
-- @param #number latitude Latitude in decimal degrees.
|
-- @param #number latitude Latitude in decimal degrees.
|
||||||
@ -503,19 +542,27 @@ do -- COORDINATE
|
|||||||
-- @param DCS#Distance Distance The Distance to be added in meters.
|
-- @param DCS#Distance Distance The Distance to be added in meters.
|
||||||
-- @param DCS#Angle Angle The Angle in degrees. Defaults to 0 if not specified (nil).
|
-- @param DCS#Angle Angle The Angle in degrees. Defaults to 0 if not specified (nil).
|
||||||
-- @param #boolean Keepalt If true, keep altitude of original coordinate. Default is that the new coordinate is created at the translated land height.
|
-- @param #boolean Keepalt If true, keep altitude of original coordinate. Default is that the new coordinate is created at the translated land height.
|
||||||
-- @return Core.Point#COORDINATE The new calculated COORDINATE.
|
-- @param #boolean Overwrite If true, overwrite the original COORDINATE with the translated one. Otherwise, create a new COODINATE.
|
||||||
function COORDINATE:Translate( Distance, Angle, Keepalt )
|
-- @return #COORDINATE The new calculated COORDINATE.
|
||||||
local SX = self.x
|
function COORDINATE:Translate( Distance, Angle, Keepalt, Overwrite )
|
||||||
local SY = self.z
|
|
||||||
local Radians = (Angle or 0) / 180 * math.pi
|
-- Angle in rad.
|
||||||
local TX = Distance * math.cos( Radians ) + SX
|
local alpha = math.rad((Angle or 0))
|
||||||
local TY = Distance * math.sin( Radians ) + SY
|
|
||||||
|
local x = Distance * math.cos(alpha) + self.x -- New x
|
||||||
if Keepalt then
|
local z = Distance * math.sin(alpha) + self.z -- New z
|
||||||
return COORDINATE:NewFromVec3( { x = TX, y=self.y, z = TY } )
|
|
||||||
|
local y=Keepalt and self.y or land.getHeight({x=x, y=z})
|
||||||
|
|
||||||
|
if Overwrite then
|
||||||
|
self.x=x
|
||||||
|
self.y=y
|
||||||
|
self.z=z
|
||||||
|
return self
|
||||||
else
|
else
|
||||||
return COORDINATE:NewFromVec2( { x = TX, y = TY } )
|
return COORDINATE:New(x, y, z)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Rotate coordinate in 2D (x,z) space.
|
--- Rotate coordinate in 2D (x,z) space.
|
||||||
@ -1356,7 +1403,7 @@ do -- COORDINATE
|
|||||||
-- @param #number Coalition (Optional) Coalition of the airbase.
|
-- @param #number Coalition (Optional) Coalition of the airbase.
|
||||||
-- @return Wrapper.Airbase#AIRBASE Closest Airbase to the given coordinate.
|
-- @return Wrapper.Airbase#AIRBASE Closest Airbase to the given coordinate.
|
||||||
-- @return #number Distance to the closest airbase in meters.
|
-- @return #number Distance to the closest airbase in meters.
|
||||||
function COORDINATE:GetClosestAirbase(Category, Coalition)
|
function COORDINATE:GetClosestAirbase2(Category, Coalition)
|
||||||
|
|
||||||
-- Get all airbases of the map.
|
-- Get all airbases of the map.
|
||||||
local airbases=AIRBASE.GetAllAirbases(Coalition)
|
local airbases=AIRBASE.GetAllAirbases(Coalition)
|
||||||
@ -1389,6 +1436,36 @@ do -- COORDINATE
|
|||||||
|
|
||||||
return closest,distmin
|
return closest,distmin
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Gets the nearest airbase with respect to the current coordinates.
|
||||||
|
-- @param #COORDINATE self
|
||||||
|
-- @param #number Category (Optional) Category of the airbase. Enumerator of @{Wrapper.Airbase#AIRBASE.Category}.
|
||||||
|
-- @param #number Coalition (Optional) Coalition of the airbase.
|
||||||
|
-- @return Wrapper.Airbase#AIRBASE Closest Airbase to the given coordinate.
|
||||||
|
-- @return #number Distance to the closest airbase in meters.
|
||||||
|
function COORDINATE:GetClosestAirbase(Category, Coalition)
|
||||||
|
|
||||||
|
local a=self:GetVec3()
|
||||||
|
|
||||||
|
local distmin=math.huge
|
||||||
|
local airbase=nil
|
||||||
|
for DCSairbaseID, DCSairbase in pairs(world.getAirbases(Coalition)) do
|
||||||
|
local b=DCSairbase:getPoint()
|
||||||
|
|
||||||
|
local c=UTILS.VecSubstract(a,b)
|
||||||
|
local dist=UTILS.VecNorm(c)
|
||||||
|
|
||||||
|
--env.info(string.format("Airbase %s dist=%d category=%d", DCSairbase:getName(), dist, DCSairbase:getCategory()))
|
||||||
|
|
||||||
|
if dist<distmin and (Category==nil or Category==DCSairbase:getDesc().category) then
|
||||||
|
distmin=dist
|
||||||
|
airbase=DCSairbase
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return AIRBASE:Find(airbase)
|
||||||
|
end
|
||||||
|
|
||||||
--- Gets the nearest parking spot.
|
--- Gets the nearest parking spot.
|
||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
|
|||||||
@ -1398,9 +1398,13 @@ 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.
|
||||||
@ -1425,6 +1429,40 @@ function ZONE_POLYGON_BASE:New( ZoneName, PointsArray )
|
|||||||
return self
|
return self
|
||||||
end
|
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
|
||||||
|
end
|
||||||
|
|
||||||
--- Returns the center location of the polygon.
|
--- Returns the center location of the polygon.
|
||||||
-- @param #ZONE_GROUP self
|
-- @param #ZONE_GROUP self
|
||||||
-- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Group} location.
|
-- @return DCS#Vec2 The location of the zone based on the @{Wrapper.Group} location.
|
||||||
|
|||||||
@ -95,6 +95,11 @@ do -- world
|
|||||||
--- Returns a table of mark panels indexed numerically that are present within the mission. See [hoggit](https://wiki.hoggitworld.com/view/DCS_func_getMarkPanels)
|
--- Returns a table of mark panels indexed numerically that are present within the mission. See [hoggit](https://wiki.hoggitworld.com/view/DCS_func_getMarkPanels)
|
||||||
-- @function [parent=#world] getMarkPanels
|
-- @function [parent=#world] getMarkPanels
|
||||||
-- @return #table Table of marks.
|
-- @return #table Table of marks.
|
||||||
|
|
||||||
|
--- Returns a table of DCS airbase objects.
|
||||||
|
-- @function [parent=#world] getAirbases
|
||||||
|
-- @param #number coalitionId The coalition side number ID. Default is all airbases are returned.
|
||||||
|
-- @return #table Table of DCS airbase objects.
|
||||||
|
|
||||||
end -- world
|
end -- world
|
||||||
|
|
||||||
@ -360,7 +365,7 @@ do -- Types
|
|||||||
|
|
||||||
--- Time is given in seconds.
|
--- Time is given in seconds.
|
||||||
-- @type Time
|
-- @type Time
|
||||||
-- @extends #number
|
-- @extends #number Time in seconds.
|
||||||
|
|
||||||
--- Model time is the time that drives the simulation. Model time may be stopped, accelerated and decelerated relative real time.
|
--- Model time is the time that drives the simulation. Model time may be stopped, accelerated and decelerated relative real time.
|
||||||
-- @type ModelTime
|
-- @type ModelTime
|
||||||
@ -368,20 +373,20 @@ do -- Types
|
|||||||
|
|
||||||
--- Mission time is a model time plus time of the mission start.
|
--- Mission time is a model time plus time of the mission start.
|
||||||
-- @type MissionTime
|
-- @type MissionTime
|
||||||
-- @extends #number
|
-- @extends #number Time in seconds.
|
||||||
|
|
||||||
|
|
||||||
--- Distance is given in meters.
|
--- Distance is given in meters.
|
||||||
-- @type Distance
|
-- @type Distance
|
||||||
-- @extends #number
|
-- @extends #number Distance in meters.
|
||||||
|
|
||||||
--- Angle is given in radians.
|
--- Angle is given in radians.
|
||||||
-- @type Angle
|
-- @type Angle
|
||||||
-- @extends #number
|
-- @extends #number Angle in radians.
|
||||||
|
|
||||||
--- Azimuth is an angle of rotation around world axis y counter-clockwise.
|
--- Azimuth is an angle of rotation around world axis y counter-clockwise.
|
||||||
-- @type Azimuth
|
-- @type Azimuth
|
||||||
-- @extends #number
|
-- @extends #number Angle in radians.
|
||||||
|
|
||||||
--- Mass is given in kilograms.
|
--- Mass is given in kilograms.
|
||||||
-- @type Mass
|
-- @type Mass
|
||||||
@ -401,15 +406,15 @@ do -- Types
|
|||||||
|
|
||||||
--- Position is a composite structure. It consists of both coordinate vector and orientation matrix. Position3 (also known as "Pos3" for short) is a table that has following format:
|
--- Position is a composite structure. It consists of both coordinate vector and orientation matrix. Position3 (also known as "Pos3" for short) is a table that has following format:
|
||||||
-- @type Position3
|
-- @type Position3
|
||||||
-- @field #Vec3 p
|
-- @field #Vec3 p 3D position vector.
|
||||||
-- @field #Vec3 x
|
-- @field #Vec3 x Orientation component of vector pointing East.
|
||||||
-- @field #Vec3 y
|
-- @field #Vec3 y Orientation component of vector pointing up.
|
||||||
-- @field #Vec3 z
|
-- @field #Vec3 z Orientation component of vector pointing North.
|
||||||
|
|
||||||
--- 3-dimensional box.
|
--- 3-dimensional box.
|
||||||
-- @type Box3
|
-- @type Box3
|
||||||
-- @field #Vec3 min
|
-- @field #Vec3 min Min.
|
||||||
-- @field #Vec3 max
|
-- @field #Vec3 max Max
|
||||||
|
|
||||||
--- Each object belongs to a type. Object type is a named couple of properties those independent of mission and common for all units of the same type. Name of unit type is a string. Samples of unit type: "Su-27", "KAMAZ" and "M2 Bradley".
|
--- Each object belongs to a type. Object type is a named couple of properties those independent of mission and common for all units of the same type. Name of unit type is a string. Samples of unit type: "Su-27", "KAMAZ" and "M2 Bradley".
|
||||||
-- @type TypeName
|
-- @type TypeName
|
||||||
@ -514,7 +519,7 @@ do -- Object
|
|||||||
--- Returns object coordinates for current time.
|
--- Returns object coordinates for current time.
|
||||||
-- @function [parent=#Object] getPoint
|
-- @function [parent=#Object] getPoint
|
||||||
-- @param #Object self
|
-- @param #Object self
|
||||||
-- @return #Vec3
|
-- @return #Vec3 3D position vector with x,y,z components.
|
||||||
|
|
||||||
--- Returns object position for current time.
|
--- Returns object position for current time.
|
||||||
-- @function [parent=#Object] getPosition
|
-- @function [parent=#Object] getPosition
|
||||||
@ -524,7 +529,7 @@ do -- Object
|
|||||||
--- Returns the unit's velocity vector.
|
--- Returns the unit's velocity vector.
|
||||||
-- @function [parent=#Object] getVelocity
|
-- @function [parent=#Object] getVelocity
|
||||||
-- @param #Object self
|
-- @param #Object self
|
||||||
-- @return #Vec3
|
-- @return #Vec3 3D velocity vector.
|
||||||
|
|
||||||
--- Returns true if the unit is in air.
|
--- Returns true if the unit is in air.
|
||||||
-- @function [parent=#Object] inAir
|
-- @function [parent=#Object] inAir
|
||||||
|
|||||||
@ -821,7 +821,7 @@ function AIRWING:onafterStatus(From, Event, To)
|
|||||||
-- Assets tot
|
-- Assets tot
|
||||||
local Npq, Np, Nq=self:CountAssetsOnMission()
|
local Npq, Np, Nq=self:CountAssetsOnMission()
|
||||||
|
|
||||||
local assets=string.format("%d [Mission=%d (Active=%d, Queued=%d)]", self:CountAssets(), Npq, Np, Nq)
|
local assets=string.format("%d (OnMission: Total=%d, Active=%d, Queued=%d)", self:CountAssets(), Npq, Np, Nq)
|
||||||
|
|
||||||
-- Output.
|
-- Output.
|
||||||
local text=string.format("%s: Missions=%d, Payloads=%d (%d), Squads=%d, Assets=%s", fsmstate, Nmissions, Npayloads, #self.payloads, #self.squadrons, assets)
|
local text=string.format("%s: Missions=%d, Payloads=%d (%d), Squads=%d, Assets=%s", fsmstate, Nmissions, Npayloads, #self.payloads, #self.squadrons, assets)
|
||||||
@ -836,7 +836,7 @@ function AIRWING:onafterStatus(From, Event, To)
|
|||||||
for i,_mission in pairs(self.missionqueue) do
|
for i,_mission in pairs(self.missionqueue) do
|
||||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||||
|
|
||||||
local prio=string.format("%d/%d", mission.prio, mission.importance) ; if mission.urgent then prio=prio.." (!)" end
|
local prio=string.format("%d/%s", mission.prio, tostring(mission.importance)) ; if mission.urgent then prio=prio.." (!)" end
|
||||||
local assets=string.format("%d/%d", mission:CountOpsGroups(), mission.nassets)
|
local assets=string.format("%d/%d", mission:CountOpsGroups(), mission.nassets)
|
||||||
local target=string.format("%d/%d Damage=%.1f", mission:CountMissionTargets(), mission:GetTargetInitialNumber(), mission:GetTargetDamage())
|
local target=string.format("%d/%d Damage=%.1f", mission:CountMissionTargets(), mission:GetTargetInitialNumber(), mission:GetTargetDamage())
|
||||||
|
|
||||||
@ -1030,7 +1030,9 @@ function AIRWING:CheckRescuhelo()
|
|||||||
|
|
||||||
local N=self:CountMissionsInQueue({AUFTRAG.Type.RESCUEHELO})
|
local N=self:CountMissionsInQueue({AUFTRAG.Type.RESCUEHELO})
|
||||||
|
|
||||||
local carrier=UNIT:FindByName(self.airbase:GetName())
|
local name=self.airbase:GetName()
|
||||||
|
|
||||||
|
local carrier=UNIT:FindByName(name)
|
||||||
|
|
||||||
for i=1,self.nflightsRescueHelo-N do
|
for i=1,self.nflightsRescueHelo-N do
|
||||||
|
|
||||||
@ -1127,7 +1129,7 @@ function AIRWING:_GetNextMission()
|
|||||||
local vip=math.huge
|
local vip=math.huge
|
||||||
for _,_mission in pairs(self.missionqueue) do
|
for _,_mission in pairs(self.missionqueue) do
|
||||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||||
if mission.importance<vip then
|
if mission.importance and mission.importance<vip then
|
||||||
vip=mission.importance
|
vip=mission.importance
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1140,7 +1142,7 @@ function AIRWING:_GetNextMission()
|
|||||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||||
|
|
||||||
-- Firstly, check if mission is due?
|
-- Firstly, check if mission is due?
|
||||||
if mission:IsQueued() and mission:IsReadyToGo() and mission.importance<=vip then
|
if mission:IsQueued() and mission:IsReadyToGo() and (mission.importance==nil or mission.importance<=vip) then
|
||||||
|
|
||||||
-- Check if airwing can do the mission and gather required assets.
|
-- Check if airwing can do the mission and gather required assets.
|
||||||
local can, assets=self:CanMission(mission)
|
local can, assets=self:CanMission(mission)
|
||||||
@ -1571,8 +1573,6 @@ function AIRWING:onafterAssetSpawned(From, Event, To, group, asset, request)
|
|||||||
-- Create a flight group.
|
-- Create a flight group.
|
||||||
local flightgroup=self:_CreateFlightGroup(asset)
|
local flightgroup=self:_CreateFlightGroup(asset)
|
||||||
|
|
||||||
-- Set home base.
|
|
||||||
flightgroup.homebase=self.airbase
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Asset
|
-- Asset
|
||||||
@ -1765,7 +1765,11 @@ function AIRWING:_CreateFlightGroup(asset)
|
|||||||
-- Set airwing.
|
-- Set airwing.
|
||||||
flightgroup:SetAirwing(self)
|
flightgroup:SetAirwing(self)
|
||||||
|
|
||||||
|
-- Set squadron.
|
||||||
flightgroup.squadron=self:GetSquadronOfAsset(asset)
|
flightgroup.squadron=self:GetSquadronOfAsset(asset)
|
||||||
|
|
||||||
|
-- Set home base.
|
||||||
|
flightgroup.homebase=self.airbase
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
|
|
||||||
|
|||||||
@ -260,7 +260,7 @@
|
|||||||
--
|
--
|
||||||
-- That being said, this script allows you to use any of the three cases to be used at any time. Or, in other words, *you* need to specify when which case is safe and appropriate.
|
-- That being said, this script allows you to use any of the three cases to be used at any time. Or, in other words, *you* need to specify when which case is safe and appropriate.
|
||||||
--
|
--
|
||||||
-- This is a lot of responsability. *You* are the boss, but *you* need to make the right decisions or things will go terribly wrong!
|
-- This is a lot of responsibility. *You* are the boss, but *you* need to make the right decisions or things will go terribly wrong!
|
||||||
--
|
--
|
||||||
-- Recovery windows can be set up via the @{#AIRBOSS.AddRecoveryWindow} function as explained below. With this it is possible to seamlessly (within reason!) switch recovery cases in the same mission.
|
-- Recovery windows can be set up via the @{#AIRBOSS.AddRecoveryWindow} function as explained below. With this it is possible to seamlessly (within reason!) switch recovery cases in the same mission.
|
||||||
--
|
--
|
||||||
@ -287,7 +287,7 @@
|
|||||||
--
|
--
|
||||||
-- 
|
-- 
|
||||||
--
|
--
|
||||||
-- Once the aircraft reaches the Inital, the landing pattern begins. The important steps of the pattern are shown in the image above.
|
-- Once the aircraft reaches the Initial, the landing pattern begins. The important steps of the pattern are shown in the image above.
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- ## CASE III
|
-- ## CASE III
|
||||||
@ -1931,6 +1931,11 @@ function AIRBOSS:New(carriername, alias)
|
|||||||
|
|
||||||
-- Welcome players.
|
-- Welcome players.
|
||||||
self:SetWelcomePlayers(true)
|
self:SetWelcomePlayers(true)
|
||||||
|
|
||||||
|
-- Coordinates
|
||||||
|
self.landingcoord=COORDINATE:New(0,0,0) --Core.Point#COORDINATE
|
||||||
|
self.sterncoord=COORDINATE:New(0, 0, 0) --Core.Point#COORDINATE
|
||||||
|
self.landingspotcoord=COORDINATE:New(0,0,0) --Core.Point#COORDINATE
|
||||||
|
|
||||||
-- Init carrier parameters.
|
-- Init carrier parameters.
|
||||||
if self.carriertype==AIRBOSS.CarrierType.STENNIS then
|
if self.carriertype==AIRBOSS.CarrierType.STENNIS then
|
||||||
@ -3391,19 +3396,12 @@ end
|
|||||||
-- @param #string To To state.
|
-- @param #string To To state.
|
||||||
function AIRBOSS:onafterStatus(From, Event, To)
|
function AIRBOSS:onafterStatus(From, Event, To)
|
||||||
|
|
||||||
if true then
|
|
||||||
--env.info("FF Status ==> return")
|
|
||||||
--return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Get current time.
|
-- Get current time.
|
||||||
local time=timer.getTime()
|
local time=timer.getTime()
|
||||||
|
|
||||||
-- Update marshal and pattern queue every 30 seconds.
|
-- Update marshal and pattern queue every 30 seconds.
|
||||||
if time-self.Tqueue>self.dTqueue then
|
if time-self.Tqueue>self.dTqueue then
|
||||||
|
|
||||||
--collectgarbage()
|
|
||||||
|
|
||||||
-- Get time.
|
-- Get time.
|
||||||
local clock=UTILS.SecondsToClock(timer.getAbsTime())
|
local clock=UTILS.SecondsToClock(timer.getAbsTime())
|
||||||
local eta=UTILS.SecondsToClock(self:_GetETAatNextWP())
|
local eta=UTILS.SecondsToClock(self:_GetETAatNextWP())
|
||||||
@ -3414,7 +3412,7 @@ function AIRBOSS:onafterStatus(From, Event, To)
|
|||||||
local speed=self.carrier:GetVelocityKNOTS()
|
local speed=self.carrier:GetVelocityKNOTS()
|
||||||
|
|
||||||
-- Check water is ahead.
|
-- Check water is ahead.
|
||||||
local collision=self:_CheckCollisionCoord(pos:Translate(self.collisiondist, hdg))
|
local collision=false --self:_CheckCollisionCoord(pos:Translate(self.collisiondist, hdg))
|
||||||
|
|
||||||
local holdtime=0
|
local holdtime=0
|
||||||
if self.holdtimestamp then
|
if self.holdtimestamp then
|
||||||
@ -3470,15 +3468,9 @@ function AIRBOSS:onafterStatus(From, Event, To)
|
|||||||
-- Disable turn into the wind for this window so that we do not do this all over again.
|
-- Disable turn into the wind for this window so that we do not do this all over again.
|
||||||
self.recoverywindow.WIND=false
|
self.recoverywindow.WIND=false
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
-- Find path around the obstacle.
|
|
||||||
if not self.detour then
|
|
||||||
--self:_Pathfinder()
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -10287,24 +10279,25 @@ function AIRBOSS:_GetSternCoord()
|
|||||||
local FB=self:GetFinalBearing()
|
local FB=self:GetFinalBearing()
|
||||||
|
|
||||||
-- Stern coordinate (sterndist<0). Also translate 10 meters starboard wrt Final bearing.
|
-- Stern coordinate (sterndist<0). Also translate 10 meters starboard wrt Final bearing.
|
||||||
local stern=self:GetCoordinate()
|
self.sterncoord:UpdateFromCoordinate(self:GetCoordinate())
|
||||||
|
--local stern=self:GetCoordinate()
|
||||||
|
|
||||||
-- Stern coordinate (sterndist<0).
|
-- Stern coordinate (sterndist<0).
|
||||||
if self.carriertype==AIRBOSS.CarrierType.TARAWA then
|
if self.carriertype==AIRBOSS.CarrierType.TARAWA then
|
||||||
-- Tarawa: Translate 8 meters port.
|
-- Tarawa: Translate 8 meters port.
|
||||||
stern=stern:Translate(self.carrierparam.sterndist, hdg):Translate(8, FB-90)
|
self.sterncoord:Translate(self.carrierparam.sterndist, hdg, true, true):Translate(8, FB-90, true, true)
|
||||||
elseif self.carriertype==AIRBOSS.CarrierType.STENNIS then
|
elseif self.carriertype==AIRBOSS.CarrierType.STENNIS then
|
||||||
-- Stennis: translate 7 meters starboard wrt Final bearing.
|
-- Stennis: translate 7 meters starboard wrt Final bearing.
|
||||||
stern=stern:Translate(self.carrierparam.sterndist, hdg):Translate(7, FB+90)
|
self.sterncoord:Translate(self.carrierparam.sterndist, hdg, true, true):Translate(7, FB+90, true, true)
|
||||||
else
|
else
|
||||||
-- Nimitz SC: translate 8 meters starboard wrt Final bearing.
|
-- Nimitz SC: translate 8 meters starboard wrt Final bearing.
|
||||||
stern=stern:Translate(self.carrierparam.sterndist, hdg):Translate(8.5, FB+90)
|
self.sterncoord:Translate(self.carrierparam.sterndist, hdg, true, true):Translate(8.5, FB+90, true, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set altitude.
|
-- Set altitude.
|
||||||
stern:SetAltitude(self.carrierparam.deckheight)
|
self.sterncoord:SetAltitude(self.carrierparam.deckheight)
|
||||||
|
|
||||||
return stern
|
return self.sterncoord
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get wire from landing position.
|
--- Get wire from landing position.
|
||||||
@ -11339,9 +11332,12 @@ end
|
|||||||
-- @param #AIRBOSS self
|
-- @param #AIRBOSS self
|
||||||
-- @return Core.Point#COORDINATE Optimal landing coordinate.
|
-- @return Core.Point#COORDINATE Optimal landing coordinate.
|
||||||
function AIRBOSS:_GetOptLandingCoordinate()
|
function AIRBOSS:_GetOptLandingCoordinate()
|
||||||
|
|
||||||
|
-- Start with stern coordiante.
|
||||||
|
self.landingcoord:UpdateFromCoordinate(self:_GetSternCoord())
|
||||||
|
|
||||||
-- Stern coordinate.
|
-- Stern coordinate.
|
||||||
local stern=self:_GetSternCoord()
|
--local stern=self:_GetSternCoord()
|
||||||
|
|
||||||
-- Final bearing.
|
-- Final bearing.
|
||||||
local FB=self:GetFinalBearing(false)
|
local FB=self:GetFinalBearing(false)
|
||||||
@ -11349,10 +11345,11 @@ function AIRBOSS:_GetOptLandingCoordinate()
|
|||||||
if self.carriertype==AIRBOSS.CarrierType.TARAWA then
|
if self.carriertype==AIRBOSS.CarrierType.TARAWA then
|
||||||
|
|
||||||
-- Landing 100 ft abeam, 120 ft alt.
|
-- Landing 100 ft abeam, 120 ft alt.
|
||||||
stern=self:_GetLandingSpotCoordinate():Translate(35, FB-90)
|
self.landingcoord:UpdateFromCoordinate(self:_GetLandingSpotCoordinate()):Translate(35, FB-90, true, true)
|
||||||
|
--stern=self:_GetLandingSpotCoordinate():Translate(35, FB-90)
|
||||||
|
|
||||||
-- Alitude 120 ft.
|
-- Alitude 120 ft.
|
||||||
stern:SetAltitude(UTILS.FeetToMeters(120))
|
self.landingcoord:SetAltitude(UTILS.FeetToMeters(120))
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
@ -11360,15 +11357,15 @@ function AIRBOSS:_GetOptLandingCoordinate()
|
|||||||
if self.carrierparam.wire3 then
|
if self.carrierparam.wire3 then
|
||||||
-- We take the position of the 3rd wire to approximately account for the length of the aircraft.
|
-- We take the position of the 3rd wire to approximately account for the length of the aircraft.
|
||||||
local w3=self.carrierparam.wire3
|
local w3=self.carrierparam.wire3
|
||||||
stern=stern:Translate(w3, FB, true)
|
self.landingcoord:Translate(w3, FB, true, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add 2 meters to account for aircraft height.
|
-- Add 2 meters to account for aircraft height.
|
||||||
stern.y=stern.y+2
|
self.landingcoord.y=self.landingcoord.y+2
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return stern
|
return self.landingcoord
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get landing spot on Tarawa.
|
--- Get landing spot on Tarawa.
|
||||||
@ -11376,8 +11373,10 @@ end
|
|||||||
-- @return Core.Point#COORDINATE Primary landing spot coordinate.
|
-- @return Core.Point#COORDINATE Primary landing spot coordinate.
|
||||||
function AIRBOSS:_GetLandingSpotCoordinate()
|
function AIRBOSS:_GetLandingSpotCoordinate()
|
||||||
|
|
||||||
|
self.landingspotcoord:UpdateFromCoordinate(self:_GetSternCoord())
|
||||||
|
|
||||||
-- Stern coordinate.
|
-- Stern coordinate.
|
||||||
local stern=self:_GetSternCoord()
|
--local stern=self:_GetSternCoord()
|
||||||
|
|
||||||
if self.carriertype==AIRBOSS.CarrierType.TARAWA then
|
if self.carriertype==AIRBOSS.CarrierType.TARAWA then
|
||||||
|
|
||||||
@ -11385,11 +11384,11 @@ function AIRBOSS:_GetLandingSpotCoordinate()
|
|||||||
local hdg=self:GetHeading()
|
local hdg=self:GetHeading()
|
||||||
|
|
||||||
-- Primary landing spot 7.5
|
-- Primary landing spot 7.5
|
||||||
stern=stern:Translate(57, hdg):SetAltitude(self.carrierparam.deckheight)
|
self.landingspotcoord:Translate(57, hdg, true, true):SetAltitude(self.carrierparam.deckheight)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return stern
|
return self.landingspotcoord
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get true (or magnetic) heading of carrier.
|
--- Get true (or magnetic) heading of carrier.
|
||||||
@ -14333,7 +14332,7 @@ end
|
|||||||
-- @param #AIRBOSS self
|
-- @param #AIRBOSS self
|
||||||
-- @return Core.Point#COORDINATE Carrier coordinate.
|
-- @return Core.Point#COORDINATE Carrier coordinate.
|
||||||
function AIRBOSS:GetCoordinate()
|
function AIRBOSS:GetCoordinate()
|
||||||
return self.carrier:GetCoordinate()
|
return self.carrier:GetCoord()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1096,7 +1096,9 @@ function AUFTRAG:NewRESCUEHELO(Carrier)
|
|||||||
|
|
||||||
local mission=AUFTRAG:New(AUFTRAG.Type.RESCUEHELO)
|
local mission=AUFTRAG:New(AUFTRAG.Type.RESCUEHELO)
|
||||||
|
|
||||||
self.carrier=Carrier
|
--mission.carrier=Carrier
|
||||||
|
|
||||||
|
mission:_TargetFromObject(Carrier)
|
||||||
|
|
||||||
-- Mission options:
|
-- Mission options:
|
||||||
mission.missionTask=ENUMS.MissionTask.NOTHING
|
mission.missionTask=ENUMS.MissionTask.NOTHING
|
||||||
@ -1412,12 +1414,12 @@ end
|
|||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
-- @param #number Prio Priority 1=high, 100=low. Default 50.
|
-- @param #number Prio Priority 1=high, 100=low. Default 50.
|
||||||
-- @param #boolean Urgent If *true*, another running mission might be cancelled if it has a lower priority.
|
-- @param #boolean Urgent If *true*, another running mission might be cancelled if it has a lower priority.
|
||||||
-- @param #number Importance Number 1-10. If missions with lower value are in the queue, these have to be finished first. Default is 5.
|
-- @param #number Importance Number 1-10. If missions with lower value are in the queue, these have to be finished first. Default is `nil`.
|
||||||
-- @return #AUFTRAG self
|
-- @return #AUFTRAG self
|
||||||
function AUFTRAG:SetPriority(Prio, Urgent, Importance)
|
function AUFTRAG:SetPriority(Prio, Urgent, Importance)
|
||||||
self.prio=Prio or 50
|
self.prio=Prio or 50
|
||||||
self.urgent=Urgent
|
self.urgent=Urgent
|
||||||
self.importance=Importance or 5
|
self.importance=Importance
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1665,6 +1667,47 @@ function AUFTRAG:SetICLS(Channel, Morse, UnitName)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get mission type.
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @return #string Mission type, e.g. "BAI".
|
||||||
|
function AUFTRAG:GetType()
|
||||||
|
return self.type
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get mission name.
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @return #string Mission name, e.g. "Auftrag Nr.1".
|
||||||
|
function AUFTRAG:GetName()
|
||||||
|
return self.name
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get number of required assets.
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @return #number Numer of required assets.
|
||||||
|
function AUFTRAG:GetNumberOfRequiredAssets()
|
||||||
|
return self.nassets
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get mission priority.
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @return #number Priority. Smaller is higher.
|
||||||
|
function AUFTRAG:GetPriority()
|
||||||
|
return self.prio
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if mission is "urgent".
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @return #boolean If `true`, mission is "urgent".
|
||||||
|
function AUFTRAG:IsUrgent()
|
||||||
|
return self.urgent
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Get mission importance.
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @return #number Importance. Smaller is higher.
|
||||||
|
function AUFTRAG:GetImportance()
|
||||||
|
return self.importance
|
||||||
|
end
|
||||||
|
|
||||||
--- Add start condition.
|
--- Add start condition.
|
||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
@ -2599,7 +2642,7 @@ function AUFTRAG:onafterSuccess(From, Event, To)
|
|||||||
self.status=AUFTRAG.Status.SUCCESS
|
self.status=AUFTRAG.Status.SUCCESS
|
||||||
self:T(self.lid..string.format("New mission status=%s", self.status))
|
self:T(self.lid..string.format("New mission status=%s", self.status))
|
||||||
|
|
||||||
local repeatme=self.repeatedFailure<self.NrepeatFailure or self.repeated<self.Nrepeat
|
local repeatme=self.repeatedSuccess<self.NrepeatSuccess or self.repeated<self.Nrepeat
|
||||||
|
|
||||||
if repeatme then
|
if repeatme then
|
||||||
|
|
||||||
@ -3291,7 +3334,7 @@ function AUFTRAG:GetDCSMissionTask(TaskControllable)
|
|||||||
|
|
||||||
-- We create a "fake" DCS task and pass the parameters to the FLIGHTGROUP.
|
-- We create a "fake" DCS task and pass the parameters to the FLIGHTGROUP.
|
||||||
local param={}
|
local param={}
|
||||||
param.unitname=self.carrier:GetName()
|
param.unitname=self:GetTargetName() --self.carrier:GetName()
|
||||||
param.offsetX=200
|
param.offsetX=200
|
||||||
param.offsetZ=240
|
param.offsetZ=240
|
||||||
param.altitude=70
|
param.altitude=70
|
||||||
|
|||||||
@ -890,7 +890,7 @@ end
|
|||||||
-- @param Core.Event#EVENTDATA EventData Event data.
|
-- @param Core.Event#EVENTDATA EventData Event data.
|
||||||
function FLIGHTGROUP:OnEventBirth(EventData)
|
function FLIGHTGROUP:OnEventBirth(EventData)
|
||||||
|
|
||||||
env.info(string.format("EVENT: Birth for unit %s", tostring(EventData.IniUnitName)))
|
--env.info(string.format("EVENT: Birth for unit %s", tostring(EventData.IniUnitName)))
|
||||||
|
|
||||||
-- Check that this is the right group.
|
-- Check that this is the right group.
|
||||||
if EventData and EventData.IniGroup and EventData.IniUnit and EventData.IniGroupName and EventData.IniGroupName==self.groupname then
|
if EventData and EventData.IniGroup and EventData.IniUnit and EventData.IniGroupName and EventData.IniGroupName==self.groupname then
|
||||||
|
|||||||
@ -1791,7 +1791,7 @@ function OPSGROUP:_GetNextMission()
|
|||||||
local vip=math.huge
|
local vip=math.huge
|
||||||
for _,_mission in pairs(self.missionqueue) do
|
for _,_mission in pairs(self.missionqueue) do
|
||||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||||
if mission.importance<vip then
|
if mission.importance and mission.importance<vip then
|
||||||
vip=mission.importance
|
vip=mission.importance
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1800,7 +1800,7 @@ function OPSGROUP:_GetNextMission()
|
|||||||
for _,_mission in pairs(self.missionqueue) do
|
for _,_mission in pairs(self.missionqueue) do
|
||||||
local mission=_mission --Ops.Auftrag#AUFTRAG
|
local mission=_mission --Ops.Auftrag#AUFTRAG
|
||||||
|
|
||||||
if mission:GetGroupStatus(self)==AUFTRAG.Status.SCHEDULED and (mission:IsReadyToGo() or self.airwing) and mission.importance<=vip then
|
if mission:GetGroupStatus(self)==AUFTRAG.Status.SCHEDULED and (mission:IsReadyToGo() or self.airwing) and (mission.importance==nil or mission.importance<=vip) then
|
||||||
return mission
|
return mission
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -437,6 +437,13 @@ function SQUADRON:DelAsset(Asset)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get name of the squadron
|
||||||
|
-- @param #SQUADRON self
|
||||||
|
-- @return #sting Name of the squadron.
|
||||||
|
function SQUADRON:GetName()
|
||||||
|
return self.name
|
||||||
|
end
|
||||||
|
|
||||||
--- Get radio frequency and modulation.
|
--- Get radio frequency and modulation.
|
||||||
-- @param #SQUADRON self
|
-- @param #SQUADRON self
|
||||||
-- @return #number Radio frequency in MHz.
|
-- @return #number Radio frequency in MHz.
|
||||||
@ -850,7 +857,7 @@ function SQUADRON:RecruitAssets(Mission, Npayloads)
|
|||||||
if Mission.type==AUFTRAG.Type.INTERCEPT then
|
if Mission.type==AUFTRAG.Type.INTERCEPT then
|
||||||
combatready=flightgroup:CanAirToAir()
|
combatready=flightgroup:CanAirToAir()
|
||||||
else
|
else
|
||||||
local excludeguns=Mission.type==AUFTRAG.Type.BOMBING or Mission.type==AUFTRAG.Type.BOMBRUNWAY or Mission.type==AUFTRAG.Type.BOMBCARPET
|
local excludeguns=Mission.type==AUFTRAG.Type.BOMBING or Mission.type==AUFTRAG.Type.BOMBRUNWAY or Mission.type==AUFTRAG.Type.BOMBCARPET or Mission.type==AUFTRAG.Type.SEAD or Mission.type==AUFTRAG.Type.ANTISHIP
|
||||||
combatready=flightgroup:CanAirToGround(excludeguns)
|
combatready=flightgroup:CanAirToGround(excludeguns)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -99,7 +99,7 @@ TARGET.ObjectStatus={
|
|||||||
-- @field #number ID Target unique ID.
|
-- @field #number ID Target unique ID.
|
||||||
-- @field #string Name Target name.
|
-- @field #string Name Target name.
|
||||||
-- @field #string Type Target type.
|
-- @field #string Type Target type.
|
||||||
-- @field Wrapper.Positionable#POSITIONABLE Object.
|
-- @field Wrapper.Positionable#POSITIONABLE Object The object, which can be many things, e.g. a UNIT, GROUP, STATIC, AIRBASE or COORDINATE object.
|
||||||
-- @field #number Life Life points on last status update.
|
-- @field #number Life Life points on last status update.
|
||||||
-- @field #number Life0 Life points of completely healthy target.
|
-- @field #number Life0 Life points of completely healthy target.
|
||||||
-- @field #string Status Status "Alive" or "Dead".
|
-- @field #string Status Status "Alive" or "Dead".
|
||||||
@ -137,10 +137,18 @@ function TARGET:New(TargetObject)
|
|||||||
-- Add object.
|
-- Add object.
|
||||||
self:AddObject(TargetObject)
|
self:AddObject(TargetObject)
|
||||||
|
|
||||||
|
-- Get first target.
|
||||||
local Target=self.targets[1] --#TARGET.Object
|
local Target=self.targets[1] --#TARGET.Object
|
||||||
|
|
||||||
|
if not Target then
|
||||||
|
self:E(self.lid.."ERROR: No valid TARGET!")
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Target Name.
|
||||||
self.name=self:GetTargetName(Target)
|
self.name=self:GetTargetName(Target)
|
||||||
|
|
||||||
|
-- Target category.
|
||||||
self.category=self:GetTargetCategory(Target)
|
self.category=self:GetTargetCategory(Target)
|
||||||
|
|
||||||
-- Log ID.
|
-- Log ID.
|
||||||
@ -681,6 +689,7 @@ function TARGET:GetTargetVec3(Target)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self:E(self.lid.."ERROR: Unknown TARGET type! Cannot get Vec3")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -780,6 +789,7 @@ function TARGET:GetCoordinate()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self:E(self.lid..string.format("ERROR: Cannot get coordinate of target %s", self.name))
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -588,6 +588,25 @@ function AIRBASE.GetAllAirbases(coalition, category)
|
|||||||
return airbases
|
return airbases
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- 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 #number category (Optional) Return only airbases of a certain category, e.g. Airbase.Category.FARP
|
||||||
|
-- @return #table Table containing all airbase names of the current map.
|
||||||
|
function AIRBASE.GetAllAirbaseNames(coalition, category)
|
||||||
|
|
||||||
|
local airbases={}
|
||||||
|
for airbasename,_airbase in pairs(_DATABASE.AIRBASES) do
|
||||||
|
local airbase=_airbase --#AIRBASE
|
||||||
|
if coalition==nil or airbase:GetCoalition()==coalition then
|
||||||
|
if category==nil or category==airbase:GetAirbaseCategory() then
|
||||||
|
table.insert(airbases, airbasename)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return airbases
|
||||||
|
end
|
||||||
|
|
||||||
--- Get ID of the airbase.
|
--- Get ID of the airbase.
|
||||||
-- @param #AIRBASE self
|
-- @param #AIRBASE self
|
||||||
-- @param #boolean unique (Optional) If true, ships will get a negative sign as the unit ID might be the same as an airbase ID. Default off!
|
-- @param #boolean unique (Optional) If true, ships will get a negative sign as the unit ID might be the same as an airbase ID. Default off!
|
||||||
|
|||||||
@ -947,24 +947,29 @@ end
|
|||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @return DCS#Vec2 Current Vec2 point of the first DCS Unit of the DCS Group.
|
-- @return DCS#Vec2 Current Vec2 point of the first DCS Unit of the DCS Group.
|
||||||
function GROUP:GetVec2()
|
function GROUP:GetVec2()
|
||||||
self:F2( self.GroupName )
|
|
||||||
|
|
||||||
local UnitPoint = self:GetUnit(1)
|
local Unit=self:GetUnit(1)
|
||||||
UnitPoint:GetVec2()
|
|
||||||
local GroupPointVec2 = UnitPoint:GetVec2()
|
if Unit then
|
||||||
self:T3( GroupPointVec2 )
|
return Unit:GetVec2()
|
||||||
return GroupPointVec2
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the current Vec3 vector of the first DCS Unit in the GROUP.
|
--- Returns the current Vec3 vector of the first DCS Unit in the GROUP.
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @return DCS#Vec3 Current Vec3 of the first DCS Unit of the GROUP.
|
-- @return DCS#Vec3 Current Vec3 of the first DCS Unit of the GROUP.
|
||||||
function GROUP:GetVec3()
|
function GROUP:GetVec3()
|
||||||
self:F2( self.GroupName )
|
|
||||||
|
|
||||||
local GroupVec3 = self:GetUnit(1):GetVec3()
|
-- Get first unit.
|
||||||
self:T3( GroupVec3 )
|
local unit=self:GetUnit(1)
|
||||||
return GroupVec3
|
|
||||||
|
if unit then
|
||||||
|
return unit:GetVec3()
|
||||||
|
end
|
||||||
|
|
||||||
|
self:E("ERROR: Cannot get Vec3 of group "..tostring(self.GroupName))
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns a POINT_VEC2 object indicating the point in 2D of the first UNIT of the GROUP within the mission.
|
--- Returns a POINT_VEC2 object indicating the point in 2D of the first UNIT of the GROUP within the mission.
|
||||||
|
|||||||
@ -125,10 +125,17 @@ function POSITIONABLE:Destroy( GenerateEvent )
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Returns the DCS object. Polymorphic for other classes like UNIT, STATIC, GROUP, AIRBASE.
|
||||||
|
-- @param #POSITIONABLE self
|
||||||
|
-- @return DCS#Object The DCS object.
|
||||||
|
function POSITIONABLE:GetDCSObject()
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
--- Returns a pos3 table of the objects current position and orientation in 3D space. X, Y, Z values are unit vectors defining the objects orientation.
|
--- Returns a pos3 table of the objects current position and orientation in 3D space. X, Y, Z values are unit vectors defining the objects orientation.
|
||||||
-- Coordinates are dependent on the position of the maps origin.
|
-- Coordinates are dependent on the position of the maps origin.
|
||||||
-- @param Wrapper.Positionable#POSITIONABLE self
|
-- @param Wrapper.Positionable#POSITIONABLE self
|
||||||
-- @return DCS#Position Table consisting of the point and orientation tables.
|
-- @return DCS#Position3 Table consisting of the point and orientation tables.
|
||||||
function POSITIONABLE:GetPosition()
|
function POSITIONABLE:GetPosition()
|
||||||
self:F2( self.PositionableName )
|
self:F2( self.PositionableName )
|
||||||
|
|
||||||
@ -221,45 +228,42 @@ end
|
|||||||
|
|
||||||
--- Returns the @{DCS#Vec3} vector indicating the 3D vector of the POSITIONABLE within the mission.
|
--- Returns the @{DCS#Vec3} vector indicating the 3D vector of the POSITIONABLE within the mission.
|
||||||
-- @param Wrapper.Positionable#POSITIONABLE self
|
-- @param Wrapper.Positionable#POSITIONABLE self
|
||||||
-- @return DCS#Vec3 The 3D point vector of the POSITIONABLE.
|
-- @return DCS#Vec3 The 3D point vector of the POSITIONABLE or `nil` if it is not existing or alive.
|
||||||
-- @return #nil The POSITIONABLE is not existing or alive.
|
|
||||||
function POSITIONABLE:GetVec3()
|
function POSITIONABLE:GetVec3()
|
||||||
self:F2( self.PositionableName )
|
|
||||||
|
|
||||||
local DCSPositionable = self:GetDCSObject()
|
local DCSPositionable = self:GetDCSObject()
|
||||||
|
|
||||||
if DCSPositionable then
|
if DCSPositionable then
|
||||||
local PositionableVec3 = DCSPositionable:getPosition().p
|
|
||||||
self:T3( PositionableVec3 )
|
local vec3=DCSPositionable:getPoint()
|
||||||
return PositionableVec3
|
|
||||||
|
if vec3 then
|
||||||
|
return vec3
|
||||||
|
else
|
||||||
|
self:E("ERROR: Cannot get vec3!")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
BASE:E( { "Cannot GetVec3", Positionable = self, Alive = self:IsAlive() } )
|
-- ERROR!
|
||||||
|
self:E( { "Cannot GetVec3", Positionable = self, Alive = self:IsAlive() } )
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns the @{DCS#Vec2} vector indicating the point in 2D of the POSITIONABLE within the mission.
|
--- Returns the @{DCS#Vec2} vector indicating the point in 2D of the POSITIONABLE within the mission.
|
||||||
-- @param Wrapper.Positionable#POSITIONABLE self
|
-- @param Wrapper.Positionable#POSITIONABLE self
|
||||||
-- @return DCS#Vec2 The 2D point vector of the POSITIONABLE.
|
-- @return DCS#Vec2 The 2D point vector of the POSITIONABLE or #nil if it is not existing or alive.
|
||||||
-- @return #nil The POSITIONABLE is not existing or alive.
|
|
||||||
function POSITIONABLE:GetVec2()
|
function POSITIONABLE:GetVec2()
|
||||||
self:F2( self.PositionableName )
|
|
||||||
|
|
||||||
local DCSPositionable = self:GetDCSObject()
|
local DCSPositionable = self:GetDCSObject()
|
||||||
|
|
||||||
if DCSPositionable then
|
if DCSPositionable then
|
||||||
local PositionableVec3 = DCSPositionable:getPosition().p
|
|
||||||
|
|
||||||
local PositionableVec2 = {}
|
|
||||||
PositionableVec2.x = PositionableVec3.x
|
|
||||||
PositionableVec2.y = PositionableVec3.z
|
|
||||||
|
|
||||||
self:T2( PositionableVec2 )
|
local Vec3=DCSPositionable:getPoint() --DCS#Vec3
|
||||||
return PositionableVec2
|
|
||||||
|
return {x=Vec3.x, y=Vec3.z}
|
||||||
end
|
end
|
||||||
|
|
||||||
BASE:E( { "Cannot GetVec2", Positionable = self, Alive = self:IsAlive() } )
|
self:E( { "Cannot GetVec2", Positionable = self, Alive = self:IsAlive() } )
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@ -282,7 +286,7 @@ function POSITIONABLE:GetPointVec2()
|
|||||||
return PositionablePointVec2
|
return PositionablePointVec2
|
||||||
end
|
end
|
||||||
|
|
||||||
BASE:E( { "Cannot GetPointVec2", Positionable = self, Alive = self:IsAlive() } )
|
self:E( { "Cannot GetPointVec2", Positionable = self, Alive = self:IsAlive() } )
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@ -333,20 +337,20 @@ function POSITIONABLE:GetCoord()
|
|||||||
if DCSPositionable then
|
if DCSPositionable then
|
||||||
|
|
||||||
-- Get the current position.
|
-- Get the current position.
|
||||||
local PositionableVec3 = self:GetPositionVec3()
|
local Vec3 = self:GetVec3()
|
||||||
|
|
||||||
if self.coordinate then
|
if self.coordinate then
|
||||||
--env.info("FF GetCoordinate GOT for "..tostring(self.PositionableName))
|
|
||||||
|
|
||||||
-- Update vector.
|
-- Update vector.
|
||||||
self.coordinate.x=PositionableVec3.x
|
self.coordinate.x=Vec3.x
|
||||||
self.coordinate.y=PositionableVec3.y
|
self.coordinate.y=Vec3.y
|
||||||
self.coordinate.z=PositionableVec3.z
|
self.coordinate.z=Vec3.z
|
||||||
|
|
||||||
else
|
else
|
||||||
--env.info("FF GetCoordinate NEW for "..tostring(self.PositionableName))
|
|
||||||
|
|
||||||
self.coordinate=COORDINATE:NewFromVec3(PositionableVec3)
|
-- New COORDINATE.
|
||||||
|
self.coordinate=COORDINATE:NewFromVec3(Vec3)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return self.coordinate
|
return self.coordinate
|
||||||
@ -369,33 +373,15 @@ function POSITIONABLE:GetCoordinate()
|
|||||||
if DCSPositionable then
|
if DCSPositionable then
|
||||||
|
|
||||||
-- Get the current position.
|
-- Get the current position.
|
||||||
local PositionableVec3 = self:GetPositionVec3()
|
local PositionableVec3 = self:GetVec3()
|
||||||
|
|
||||||
if self.coordinate then
|
-- Return a new coordiante object.
|
||||||
--env.info("FF GetCoordinate GOT for "..tostring(self.PositionableName))
|
return COORDINATE:NewFromVec3(PositionableVec3)
|
||||||
|
|
||||||
-- Update vector.
|
|
||||||
self.coordinate.x=PositionableVec3.x
|
|
||||||
self.coordinate.y=PositionableVec3.y
|
|
||||||
self.coordinate.z=PositionableVec3.z
|
|
||||||
|
|
||||||
else
|
|
||||||
--env.info("FF GetCoordinate NEW for "..tostring(self.PositionableName))
|
|
||||||
|
|
||||||
self.coordinate=COORDINATE:NewFromVec3(PositionableVec3)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-- Set heading and velocity.
|
|
||||||
self.coordinate:SetHeading( self:GetHeading() )
|
|
||||||
self.coordinate:SetVelocity( self:GetVelocityMPS() )
|
|
||||||
|
|
||||||
return self.coordinate
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Error message.
|
-- Error message.
|
||||||
BASE:E( { "Cannot GetCoordinate", Positionable = self, Alive = self:IsAlive() } )
|
self:E( { "Cannot GetCoordinate", Positionable = self, Alive = self:IsAlive() } )
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user