mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge pull request #1309 from FlightControl-Master/FF/Develop
Misc Fixes and Improvements
This commit is contained in:
commit
364ce927e7
@ -121,7 +121,7 @@ AI_A2A_PATROL = {
|
|||||||
|
|
||||||
--- Creates a new AI_A2A_PATROL object
|
--- Creates a new AI_A2A_PATROL object
|
||||||
-- @param #AI_A2A_PATROL self
|
-- @param #AI_A2A_PATROL self
|
||||||
-- @param Wrapper.Group#GROUP AIPatrol
|
-- @param Wrapper.Group#GROUP AIPatrol The patrol group object.
|
||||||
-- @param Core.Zone#ZONE_BASE PatrolZone The @{Zone} where the patrol needs to be executed.
|
-- @param Core.Zone#ZONE_BASE PatrolZone The @{Zone} where the patrol needs to be executed.
|
||||||
-- @param DCS#Altitude PatrolFloorAltitude The lowest altitude in meters where to execute the patrol.
|
-- @param DCS#Altitude PatrolFloorAltitude The lowest altitude in meters where to execute the patrol.
|
||||||
-- @param DCS#Altitude PatrolCeilingAltitude The highest altitude in meters where to execute the patrol.
|
-- @param DCS#Altitude PatrolCeilingAltitude The highest altitude in meters where to execute the patrol.
|
||||||
@ -137,7 +137,7 @@ AI_A2A_PATROL = {
|
|||||||
function AI_A2A_PATROL:New( AIPatrol, PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, PatrolAltType )
|
function AI_A2A_PATROL:New( AIPatrol, PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, PatrolAltType )
|
||||||
|
|
||||||
local AI_Air = AI_AIR:New( AIPatrol )
|
local AI_Air = AI_AIR:New( AIPatrol )
|
||||||
local AI_Air_Patrol = AI_A2A_PATROL:New( AI_Air, AIPatrol, PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, PatrolAltType )
|
local AI_Air_Patrol = AI_AIR_PATROL:New( AI_Air, AIPatrol, PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, PatrolAltType )
|
||||||
local self = BASE:Inherit( self, AI_Air_Patrol ) -- #AI_A2A_PATROL
|
local self = BASE:Inherit( self, AI_Air_Patrol ) -- #AI_A2A_PATROL
|
||||||
|
|
||||||
self:SetFuelThreshold( .2, 60 )
|
self:SetFuelThreshold( .2, 60 )
|
||||||
|
|||||||
@ -492,6 +492,7 @@ function AI_AIR:onafterStatus()
|
|||||||
OldAIControllable:SetTask( TimedOrbitTask, 10 )
|
OldAIControllable:SetTask( TimedOrbitTask, 10 )
|
||||||
|
|
||||||
self:Fuel()
|
self:Fuel()
|
||||||
|
RTB = true
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
end
|
end
|
||||||
|
|||||||
@ -374,7 +374,7 @@ end
|
|||||||
-- @param #string To The To State string.
|
-- @param #string To The To State string.
|
||||||
function AI_AIR_ENGAGE:onafterAccomplish( AIGroup, From, Event, To )
|
function AI_AIR_ENGAGE:onafterAccomplish( AIGroup, From, Event, To )
|
||||||
self.Accomplished = true
|
self.Accomplished = true
|
||||||
self:SetDetectionOff()
|
--self:SetDetectionOff()
|
||||||
end
|
end
|
||||||
|
|
||||||
--- @param #AI_AIR_ENGAGE self
|
--- @param #AI_AIR_ENGAGE self
|
||||||
|
|||||||
@ -655,6 +655,28 @@ do -- COORDINATE
|
|||||||
return Angle
|
return Angle
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Return an intermediate COORDINATE between this an another coordinate.
|
||||||
|
-- @param #COORDINATE self
|
||||||
|
-- @param #COORDINATE ToCoordinate The other coordinate.
|
||||||
|
-- @param #number Fraction The fraction (0,1) where the new coordinate is created. Default 0.5, i.e. in the middle.
|
||||||
|
-- @return #COORDINATE Coordinate between this and the other coordinate.
|
||||||
|
function COORDINATE:GetIntermediateCoordinate( ToCoordinate, Fraction )
|
||||||
|
|
||||||
|
local f=Fraction or 0.5
|
||||||
|
|
||||||
|
-- Get the vector from A to B
|
||||||
|
local vec=UTILS.VecSubstract(ToCoordinate, self)
|
||||||
|
|
||||||
|
-- Scale the vector.
|
||||||
|
vec.x=f*vec.x
|
||||||
|
vec.y=f*vec.y
|
||||||
|
vec.z=f*vec.z
|
||||||
|
|
||||||
|
-- Move the vector to start at the end of A.
|
||||||
|
vec=UTILS.VecAdd(self, vec)
|
||||||
|
|
||||||
|
return self:New(vec.x,vec.y,vec.z)
|
||||||
|
end
|
||||||
|
|
||||||
--- Return the 2D distance in meters between the target COORDINATE and the COORDINATE.
|
--- Return the 2D distance in meters between the target COORDINATE and the COORDINATE.
|
||||||
-- @param #COORDINATE self
|
-- @param #COORDINATE self
|
||||||
|
|||||||
@ -113,18 +113,20 @@ end
|
|||||||
-- @param #number dt (Optional) Time step in seconds for checking the queue. Default 0.01 sec.
|
-- @param #number dt (Optional) Time step in seconds for checking the queue. Default 0.01 sec.
|
||||||
-- @return #RADIOQUEUE self The RADIOQUEUE object.
|
-- @return #RADIOQUEUE self The RADIOQUEUE object.
|
||||||
function RADIOQUEUE:Start(delay, dt)
|
function RADIOQUEUE:Start(delay, dt)
|
||||||
|
|
||||||
|
-- Delay before start.
|
||||||
self.delay=delay or 1
|
self.delay=delay or 1
|
||||||
|
|
||||||
|
-- Time interval for queue check.
|
||||||
self.dt=dt or 0.01
|
self.dt=dt or 0.01
|
||||||
|
|
||||||
|
-- Debug message.
|
||||||
self:I(self.lid..string.format("Starting RADIOQUEUE %s on Frequency %.2f MHz [modulation=%d] in %.1f seconds (dt=%.3f sec)", self.alias, self.frequency/1000000, self.modulation, delay, dt))
|
self:I(self.lid..string.format("Starting RADIOQUEUE %s on Frequency %.2f MHz [modulation=%d] in %.1f seconds (dt=%.3f sec)", self.alias, self.frequency/1000000, self.modulation, delay, dt))
|
||||||
|
|
||||||
|
-- Start Scheduler.
|
||||||
if self.schedonce then
|
if self.schedonce then
|
||||||
self:_CheckRadioQueueDelayed(self.delta)
|
self:_CheckRadioQueueDelayed(delay)
|
||||||
else
|
else
|
||||||
--self.RQid=self.scheduler:Schedule(self, self._CheckRadioQueue, {}, delay, dt)
|
|
||||||
self.RQid=self.scheduler:Schedule(nil, RADIOQUEUE._CheckRadioQueue, {self}, delay, dt)
|
self.RQid=self.scheduler:Schedule(nil, RADIOQUEUE._CheckRadioQueue, {self}, delay, dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -47,9 +47,13 @@ do -- world
|
|||||||
-- @field S_EVENT_PLAYER_COMMENT
|
-- @field S_EVENT_PLAYER_COMMENT
|
||||||
-- @field S_EVENT_SHOOTING_START [https://wiki.hoggitworld.com/view/DCS_event_shooting_start](https://wiki.hoggitworld.com/view/DCS_event_shooting_start)
|
-- @field S_EVENT_SHOOTING_START [https://wiki.hoggitworld.com/view/DCS_event_shooting_start](https://wiki.hoggitworld.com/view/DCS_event_shooting_start)
|
||||||
-- @field S_EVENT_SHOOTING_END [https://wiki.hoggitworld.com/view/DCS_event_shooting_end](https://wiki.hoggitworld.com/view/DCS_event_shooting_end)
|
-- @field S_EVENT_SHOOTING_END [https://wiki.hoggitworld.com/view/DCS_event_shooting_end](https://wiki.hoggitworld.com/view/DCS_event_shooting_end)
|
||||||
-- @field S_EVENT_MARK ADDED [https://wiki.hoggitworld.com/view/DCS_event_mark_added](https://wiki.hoggitworld.com/view/DCS_event_mark_added)
|
-- @field S_EVENT_MARK ADDED [https://wiki.hoggitworld.com/view/DCS_event_mark_added](https://wiki.hoggitworld.com/view/DCS_event_mark_added) DCS>=2.5.1
|
||||||
-- @field S_EVENT_MARK CHANGE [https://wiki.hoggitworld.com/view/DCS_event_mark_change](https://wiki.hoggitworld.com/view/DCS_event_mark_change)
|
-- @field S_EVENT_MARK CHANGE [https://wiki.hoggitworld.com/view/DCS_event_mark_change](https://wiki.hoggitworld.com/view/DCS_event_mark_change) DCS>=2.5.1
|
||||||
-- @field S_EVENT_MARK REMOVE [https://wiki.hoggitworld.com/view/DCS_event_mark_remove](https://wiki.hoggitworld.com/view/DCS_event_mark_remove)
|
-- @field S_EVENT_MARK REMOVE [https://wiki.hoggitworld.com/view/DCS_event_mark_remove](https://wiki.hoggitworld.com/view/DCS_event_mark_remove) DCS>=2.5.1
|
||||||
|
-- @field S_EVENT_KILL [https://wiki.hoggitworld.com/view/DCS_event_kill](https://wiki.hoggitworld.com/view/DCS_event_kill) DCS>=2.5.6
|
||||||
|
-- @field S_EVENT_SCORE [https://wiki.hoggitworld.com/view/DCS_event_score](https://wiki.hoggitworld.com/view/DCS_event_score) DCS>=2.5.6
|
||||||
|
-- @field S_EVENT_UNIT_LOST [https://wiki.hoggitworld.com/view/DCS_event_unit_lost](https://wiki.hoggitworld.com/view/DCS_event_unit_lost) DCS>=2.5.6
|
||||||
|
-- @field S_EVENT_LANDING_AFTER_EJECTION [https://wiki.hoggitworld.com/view/DCS_event_landing_after_ejection](https://wiki.hoggitworld.com/view/DCS_event_landing_after_ejection) DCS>=2.5.6
|
||||||
-- @field S_EVENT_MAX
|
-- @field S_EVENT_MAX
|
||||||
|
|
||||||
--- The birthplace enumerator is used to define where an aircraft or helicopter has spawned in association with birth events.
|
--- The birthplace enumerator is used to define where an aircraft or helicopter has spawned in association with birth events.
|
||||||
@ -326,9 +330,27 @@ end -- coalition
|
|||||||
do -- Types
|
do -- Types
|
||||||
|
|
||||||
--- @type Desc
|
--- @type Desc
|
||||||
-- @field #TypeName typeName type name
|
-- @field #number speedMax0 Max speed in meters/second at zero altitude.
|
||||||
-- @field #string displayName localized display name
|
-- @field #number massEmpty Empty mass in kg.
|
||||||
-- @field #table attributes object type attributes
|
-- @field #number tankerType Type of refueling system: 0=boom, 1=probe.
|
||||||
|
-- @field #number range Range in km(?).
|
||||||
|
-- @field #table box Bounding box.
|
||||||
|
-- @field #number Hmax Max height in meters.
|
||||||
|
-- @field #number Kmax ?
|
||||||
|
-- @field #number speedMax10K Max speed in meters/second at 10k altitude.
|
||||||
|
-- @field #number NyMin ?
|
||||||
|
-- @field #number NyMax ?
|
||||||
|
-- @field #number fuelMassMax Max fuel mass in kg.
|
||||||
|
-- @field #number speedMax10K Max speed in meters/second.
|
||||||
|
-- @field #number massMax Max mass of unit.
|
||||||
|
-- @field #number RCS ?
|
||||||
|
-- @field #number life Life points.
|
||||||
|
-- @field #number VyMax Max vertical velocity in m/s.
|
||||||
|
-- @field #number Kab ?
|
||||||
|
-- @field #table attributes Table of attributes.
|
||||||
|
-- @field #TypeName typeName Type Name.
|
||||||
|
-- @field #string displayName Localized display name.
|
||||||
|
-- @field #number category Unit category.
|
||||||
|
|
||||||
--- A distance type
|
--- A distance type
|
||||||
-- @type Distance
|
-- @type Distance
|
||||||
|
|||||||
@ -531,7 +531,7 @@ _ATIS={}
|
|||||||
|
|
||||||
--- ATIS class version.
|
--- ATIS class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
ATIS.version="0.7.0"
|
ATIS.version="0.7.1"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@ -1230,13 +1230,22 @@ function ATIS:onafterBroadcast(From, Event, To)
|
|||||||
if self.windtrue then
|
if self.windtrue then
|
||||||
magvar=0
|
magvar=0
|
||||||
end
|
end
|
||||||
|
windFrom=windFrom-magvar
|
||||||
|
|
||||||
|
-- Correct negative values.
|
||||||
|
if windFrom<0 then
|
||||||
|
windFrom=windFrom+360
|
||||||
|
end
|
||||||
|
|
||||||
local WINDFROM=string.format("%03d", windFrom-magvar)
|
local WINDFROM=string.format("%03d", windFrom)
|
||||||
local WINDSPEED=string.format("%d", UTILS.MpsToKnots(windSpeed))
|
local WINDSPEED=string.format("%d", UTILS.MpsToKnots(windSpeed))
|
||||||
|
|
||||||
|
-- Report North as 0.
|
||||||
if WINDFROM=="000" then
|
if WINDFROM=="000" then
|
||||||
WINDFROM="360"
|
WINDFROM="360"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
env.info(string.format("FF WINDFROM = %s", tostring(WINDFROM)))
|
||||||
|
|
||||||
if self.metric then
|
if self.metric then
|
||||||
WINDSPEED=string.format("%d", windSpeed)
|
WINDSPEED=string.format("%d", windSpeed)
|
||||||
|
|||||||
@ -1691,7 +1691,7 @@ AIRBOSS.MenuF10Root=nil
|
|||||||
|
|
||||||
--- Airboss class version.
|
--- Airboss class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
AIRBOSS.version="1.1.1"
|
AIRBOSS.version="1.1.3"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@ -1880,6 +1880,9 @@ function AIRBOSS:New(carriername, alias)
|
|||||||
-- Default recovery case. This sets self.defaultcase and self.case. Default Case I.
|
-- Default recovery case. This sets self.defaultcase and self.case. Default Case I.
|
||||||
self:SetRecoveryCase()
|
self:SetRecoveryCase()
|
||||||
|
|
||||||
|
-- Set time the turn starts before the window opens.
|
||||||
|
self:SetRecoveryTurnTime()
|
||||||
|
|
||||||
-- Set holding offset to 0 degrees. This set self.defaultoffset and self.holdingoffset.
|
-- Set holding offset to 0 degrees. This set self.defaultoffset and self.holdingoffset.
|
||||||
self:SetHoldingOffsetAngle()
|
self:SetHoldingOffsetAngle()
|
||||||
|
|
||||||
@ -2433,6 +2436,15 @@ function AIRBOSS:AddRecoveryWindow(starttime, stoptime, case, holdingoffset, tur
|
|||||||
-- Absolute mission time in seconds.
|
-- Absolute mission time in seconds.
|
||||||
local Tnow=timer.getAbsTime()
|
local Tnow=timer.getAbsTime()
|
||||||
|
|
||||||
|
if starttime and type(starttime)=="number" then
|
||||||
|
starttime=UTILS.SecondsToClock(Tnow+starttime)
|
||||||
|
end
|
||||||
|
|
||||||
|
if stoptime and type(stoptime)=="number" then
|
||||||
|
stoptime=UTILS.SecondsToClock(Tnow+stoptime)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Input or now.
|
-- Input or now.
|
||||||
starttime=starttime or UTILS.SecondsToClock(Tnow)
|
starttime=starttime or UTILS.SecondsToClock(Tnow)
|
||||||
|
|
||||||
@ -2598,6 +2610,15 @@ function AIRBOSS:DeleteRecoveryWindow(window, delay)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set time before carrier turns and recovery window opens.
|
||||||
|
-- @param #AIRBOSS self
|
||||||
|
-- @param #number interval Time interval in seconds. Default 600 sec.
|
||||||
|
-- @return #AIRBOSS self
|
||||||
|
function AIRBOSS:SetRecoveryTurnTime(interval)
|
||||||
|
self.dTturn=interval or 600
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Set time interval for updating queues and other stuff.
|
--- Set time interval for updating queues and other stuff.
|
||||||
-- @param #AIRBOSS self
|
-- @param #AIRBOSS self
|
||||||
-- @param #number interval Time interval in seconds. Default 30 sec.
|
-- @param #number interval Time interval in seconds. Default 30 sec.
|
||||||
@ -3226,6 +3247,27 @@ function AIRBOSS:SetDebugModeOFF()
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get next time the carrier will start recovering aircraft.
|
||||||
|
-- @param #AIRBOSS self
|
||||||
|
-- @param #boolean InSeconds If true, abs. mission time seconds is returned. Default is a clock #string.
|
||||||
|
-- @return #string Clock start (or start time in abs. seconds).
|
||||||
|
-- @return #string Clock stop (or stop time in abs. seconds).
|
||||||
|
function AIRBOSS:GetNextRecoveryTime(InSeconds)
|
||||||
|
if self.recoverywindow then
|
||||||
|
if InSeconds then
|
||||||
|
return self.recoverywindow.START, self.recoverywindow.STOP
|
||||||
|
else
|
||||||
|
return UTILS.SecondsToClock(self.recoverywindow.START), UTILS.SecondsToClock(self.recoverywindow.STOP)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if InSeconds then
|
||||||
|
return -1, -1
|
||||||
|
else
|
||||||
|
return "?", "?"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Check if carrier is recovering aircraft.
|
--- Check if carrier is recovering aircraft.
|
||||||
-- @param #AIRBOSS self
|
-- @param #AIRBOSS self
|
||||||
-- @return #boolean If true, time slot for recovery is open.
|
-- @return #boolean If true, time slot for recovery is open.
|
||||||
@ -3782,7 +3824,7 @@ function AIRBOSS:_CheckRecoveryTimes()
|
|||||||
self:RecoveryCase(nextwindow.CASE, nextwindow.OFFSET)
|
self:RecoveryCase(nextwindow.CASE, nextwindow.OFFSET)
|
||||||
|
|
||||||
-- Check if time is less than 5 minutes.
|
-- Check if time is less than 5 minutes.
|
||||||
if nextwindow.WIND and nextwindow.START-time<5*60 and not self.turnintowind then
|
if nextwindow.WIND and nextwindow.START-time<self.dTturn and not self.turnintowind then
|
||||||
|
|
||||||
-- Check that wind is blowing from a direction > 5° different from the current heading.
|
-- Check that wind is blowing from a direction > 5° different from the current heading.
|
||||||
local hdg=self:GetHeading()
|
local hdg=self:GetHeading()
|
||||||
@ -3805,7 +3847,7 @@ function AIRBOSS:_CheckRecoveryTimes()
|
|||||||
self:T(self.lid..string.format("Heading=%03d°, Wind=%03d° %.1f kts, Delta=%03d° ==> U-turn=%s", hdg, wind,UTILS.MpsToKnots(vwind), delta, tostring(uturn)))
|
self:T(self.lid..string.format("Heading=%03d°, Wind=%03d° %.1f kts, Delta=%03d° ==> U-turn=%s", hdg, wind,UTILS.MpsToKnots(vwind), delta, tostring(uturn)))
|
||||||
|
|
||||||
-- Time into the wind 1 day or if longer recovery time + the 5 min early.
|
-- Time into the wind 1 day or if longer recovery time + the 5 min early.
|
||||||
local t=math.max(nextwindow.STOP-nextwindow.START+300, 60*60*24)
|
local t=math.max(nextwindow.STOP-nextwindow.START+self.dTturn, 60*60*24)
|
||||||
|
|
||||||
-- Recovery wind on deck in knots.
|
-- Recovery wind on deck in knots.
|
||||||
local v=UTILS.KnotsToMps(nextwindow.SPEED)
|
local v=UTILS.KnotsToMps(nextwindow.SPEED)
|
||||||
@ -5964,7 +6006,6 @@ function AIRBOSS:_ScanCarrierZone()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Find new flights that are inside CCA.
|
-- Find new flights that are inside CCA.
|
||||||
for groupname,_group in pairs(insideCCA) do
|
for groupname,_group in pairs(insideCCA) do
|
||||||
local group=_group --Wrapper.Group#GROUP
|
local group=_group --Wrapper.Group#GROUP
|
||||||
@ -6070,7 +6111,6 @@ function AIRBOSS:_ScanCarrierZone()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Find flights that are not in CCA.
|
-- Find flights that are not in CCA.
|
||||||
local remove={}
|
local remove={}
|
||||||
for _,_flight in pairs(self.flights) do
|
for _,_flight in pairs(self.flights) do
|
||||||
@ -10769,53 +10809,6 @@ function AIRBOSS:_GetZoneCorridor(case, l)
|
|||||||
local zone=ZONE_POLYGON_BASE:New("CASE II/III Approach Corridor", p)
|
local zone=ZONE_POLYGON_BASE:New("CASE II/III Approach Corridor", p)
|
||||||
|
|
||||||
return zone
|
return zone
|
||||||
|
|
||||||
--[[
|
|
||||||
-- OLD
|
|
||||||
|
|
||||||
-- Angle between radial and offset in rad.
|
|
||||||
local alpha=math.rad(self.holdingoffset)
|
|
||||||
|
|
||||||
-- Some math...
|
|
||||||
local y1=d-w2
|
|
||||||
local x1=y1*math.tan(alpha)
|
|
||||||
local y2=d+w2
|
|
||||||
local x2=y2*math.tan(alpha)
|
|
||||||
local b=w2*(1/math.cos(alpha)-1)
|
|
||||||
|
|
||||||
-- This is what we need.
|
|
||||||
local P=x1+b
|
|
||||||
local Q=x2-b
|
|
||||||
|
|
||||||
-- Debug output.
|
|
||||||
self:T3(string.format("FF case %d radial = %d", case, radial))
|
|
||||||
self:T3(string.format("FF case %d offset = %d", case, offset))
|
|
||||||
self:T3(string.format("FF w = %.1f NM", w))
|
|
||||||
self:T3(string.format("FF l = %.1f NM", l))
|
|
||||||
self:T3(string.format("FF d = %.1f NM", d))
|
|
||||||
self:T3(string.format("FF y1 = %.1f NM", y1))
|
|
||||||
self:T3(string.format("FF x1 = %.1f NM", x1))
|
|
||||||
self:T3(string.format("FF y2 = %.1f NM", y2))
|
|
||||||
self:T3(string.format("FF x2 = %.1f NM", x2))
|
|
||||||
self:T3(string.format("FF b = %.1f NM", b))
|
|
||||||
self:T3(string.format("FF P = %.1f NM", P))
|
|
||||||
self:T3(string.format("FF Q = %.1f NM", Q))
|
|
||||||
|
|
||||||
-- Complicated case with an angle.
|
|
||||||
c[2]=c[1]:Translate( UTILS.NMToMeters(w2), radial-90) -- 1 Right of carrier.
|
|
||||||
c[3]=c[2]:Translate( UTILS.NMToMeters(d+dx+w2), radial) -- 13 "south" @ 1 right
|
|
||||||
c[4]=c[3]:Translate( UTILS.NMToMeters(Q), radial+90) --
|
|
||||||
c[5]=c[4]:Translate( UTILS.NMToMeters(l), offset)
|
|
||||||
c[6]=c[5]:Translate( UTILS.NMToMeters(w), offset+90) -- Back wall (angled)
|
|
||||||
c[9]=c[1]:Translate( UTILS.NMToMeters(w2), radial+90) -- 1 left of carrier.
|
|
||||||
c[8]=c[9]:Translate( UTILS.NMToMeters(d+dx-w2), radial) -- 1 left and 11 behind of carrier.
|
|
||||||
c[7]=c[8]:Translate( UTILS.NMToMeters(P), radial+90)
|
|
||||||
|
|
||||||
-- Translate these points a bit for a smoother turn.
|
|
||||||
--c[4]=c[4]:Translate(UTILS.NMToMeters(2), offset)
|
|
||||||
--c[7]=c[7]:Translate(UTILS.NMToMeters(2), offset)
|
|
||||||
]]
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -11314,20 +11307,6 @@ function AIRBOSS:_Lineup(unit, runway)
|
|||||||
---
|
---
|
||||||
local lineup=math.deg(math.atan2(z, x))
|
local lineup=math.deg(math.atan2(z, x))
|
||||||
|
|
||||||
--[[
|
|
||||||
-- Position of the aircraft in the new coordinate system.
|
|
||||||
local a={x=x, y=0, z=z}
|
|
||||||
|
|
||||||
-- Stern position in the new coordinate system, which is simply the origin.
|
|
||||||
local b={x=0, y=0, z=0}
|
|
||||||
|
|
||||||
-- Vector from plane to ref point on the boat.
|
|
||||||
local c=UTILS.VecSubstract(a, b)
|
|
||||||
|
|
||||||
-- Current line up and error wrt to final heading of the runway.
|
|
||||||
local lineup=math.deg(math.atan2(c.z, c.x))
|
|
||||||
]]
|
|
||||||
|
|
||||||
return lineup
|
return lineup
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -11946,9 +11925,13 @@ function AIRBOSS:_LSOgrade(playerData)
|
|||||||
local nS=count(G, '%(')
|
local nS=count(G, '%(')
|
||||||
local nN=N-nS-nL
|
local nN=N-nS-nL
|
||||||
|
|
||||||
|
-- Groove time 16-18 sec for a unicorn.
|
||||||
|
local Tgroove=playerData.Tgroove
|
||||||
|
local TgrooveUnicorn=Tgroove and (Tgroove>=16.0 and Tgroove<=18.0) or false
|
||||||
|
|
||||||
local grade
|
local grade
|
||||||
local points
|
local points
|
||||||
if N==0 then
|
if N==0 and TgrooveUnicorn then
|
||||||
-- No deviations, should be REALLY RARE!
|
-- No deviations, should be REALLY RARE!
|
||||||
grade="_OK_"
|
grade="_OK_"
|
||||||
points=5.0
|
points=5.0
|
||||||
@ -12019,7 +12002,7 @@ function AIRBOSS:_LSOgrade(playerData)
|
|||||||
-----------------
|
-----------------
|
||||||
grade="OWO"
|
grade="OWO"
|
||||||
points=2.0
|
points=2.0
|
||||||
if G=="Unicorn" then
|
if N==0 then
|
||||||
G="n/a"
|
G="n/a"
|
||||||
end
|
end
|
||||||
elseif playerData.waveoff then
|
elseif playerData.waveoff then
|
||||||
@ -13511,63 +13494,6 @@ function AIRBOSS:_InitWaypoints()
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--[[
|
|
||||||
|
|
||||||
--- Patrol carrier.
|
|
||||||
-- @param #AIRBOSS self
|
|
||||||
-- @param #number n Current waypoint.
|
|
||||||
-- @return #AIRBOSS self
|
|
||||||
function AIRBOSS:_PatrolRoute(n)
|
|
||||||
|
|
||||||
-- Get carrier group.
|
|
||||||
local CarrierGroup=self.carrier:GetGroup()
|
|
||||||
|
|
||||||
-- Waypoints of group.
|
|
||||||
local Waypoints = CarrierGroup:GetTemplateRoutePoints()
|
|
||||||
|
|
||||||
-- Loop over waypoints.
|
|
||||||
for n=1,#Waypoints do
|
|
||||||
|
|
||||||
-- Passing waypoint taskfunction
|
|
||||||
local TaskPassingWP=CarrierGroup:TaskFunction("AIRBOSS._PassingWaypoint", self, n, #Waypoints)
|
|
||||||
|
|
||||||
-- Call task function when carrier arrives at waypoint.
|
|
||||||
CarrierGroup:SetTaskWaypoint(Waypoints[n], TaskPassingWP)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Init array.
|
|
||||||
self.waypoints={}
|
|
||||||
|
|
||||||
-- Set waypoint table.
|
|
||||||
for i,point in ipairs(Waypoints) do
|
|
||||||
|
|
||||||
-- Coordinate of the waypoint
|
|
||||||
local coord=COORDINATE:New(point.x, point.alt, point.y)
|
|
||||||
|
|
||||||
-- Set velocity of the coordinate.
|
|
||||||
coord:SetVelocity(point.speed)
|
|
||||||
|
|
||||||
-- Add to table.
|
|
||||||
table.insert(self.waypoints, coord)
|
|
||||||
|
|
||||||
-- Debug info.
|
|
||||||
if self.Debug then
|
|
||||||
coord:MarkToAll(string.format("Carrier Waypoint %d, Speed=%.1f knots", i, UTILS.MpsToKnots(point.speed)))
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Current waypoint is 1.
|
|
||||||
self.currentwp=n or 1
|
|
||||||
|
|
||||||
-- Route carrier group.
|
|
||||||
CarrierGroup:Route(Waypoints)
|
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
--- Patrol carrier.
|
--- Patrol carrier.
|
||||||
-- @param #AIRBOSS self
|
-- @param #AIRBOSS self
|
||||||
-- @param #number n Next waypoint number.
|
-- @param #number n Next waypoint number.
|
||||||
|
|||||||
@ -1,49 +1,163 @@
|
|||||||
--- **Utilities** Enumerators.
|
--- **Utilities** Enumerators.
|
||||||
--
|
--
|
||||||
-- See the [Simulator Scripting Engine Documentation](https://wiki.hoggitworld.com/view/Simulator_Scripting_Engine_Documentation) on Hoggit for further explanation and examples.
|
-- An enumerator is a variable that holds a constant value. Enumerators are very useful because they make the code easier to read and to change in general.
|
||||||
--
|
--
|
||||||
-- @module DCS
|
-- For example, instead of using the same value at multiple different places in your code, you should use a variable set to that value.
|
||||||
|
-- If, for whatever reason, the value needs to be changed, you only have to change the variable once and do not have to search through you code and reset
|
||||||
|
-- every value by hand.
|
||||||
|
--
|
||||||
|
-- Another big advantage is that the LDT intellisense "knows" the enumerators. So you can use the autocompletion feature and do not have to keep all the
|
||||||
|
-- values in your head or look them up in the docs.
|
||||||
|
--
|
||||||
|
-- DCS itself provides a lot of enumerators for various things. See [Enumerators](https://wiki.hoggitworld.com/view/Category:Enumerators) on Hoggit.
|
||||||
|
--
|
||||||
|
-- Other Moose classe also have enumerators. For example, the AIRBASE class has enumerators for airbase names.
|
||||||
|
--
|
||||||
|
-- @module ENUMS
|
||||||
-- @image MOOSE.JPG
|
-- @image MOOSE.JPG
|
||||||
|
|
||||||
|
--- [DCS Enum world](https://wiki.hoggitworld.com/view/DCS_enum_world)
|
||||||
|
-- @type ENUMS
|
||||||
|
|
||||||
|
--- Because ENUMS are just better practice.
|
||||||
|
--
|
||||||
|
-- The ENUMS class adds some handy variables, which help you to make your code better and more general.
|
||||||
|
--
|
||||||
|
-- @field #ENUMS
|
||||||
ENUMS = {}
|
ENUMS = {}
|
||||||
|
|
||||||
|
--- Rules of Engagement.
|
||||||
|
-- @type ENUMS.ROE
|
||||||
|
-- @field #number WeaponFree AI will engage any enemy group it detects. Target prioritization is based based on the threat of the target.
|
||||||
|
-- @field #number OpenFireWeaponFree AI will engage any enemy group it detects, but will prioritize targets specified in the groups tasking.
|
||||||
|
-- @field #number OpenFire AI will engage only targets specified in its taskings.
|
||||||
|
-- @field #number ReturnFire AI will only engage threats that shoot first.
|
||||||
|
-- @field #number WeaponHold AI will hold fire under all circumstances.
|
||||||
ENUMS.ROE = {
|
ENUMS.ROE = {
|
||||||
HoldFire = 1,
|
WeaponFree=0,
|
||||||
ReturnFire = 2,
|
OpenFireWeaponFree=1,
|
||||||
OpenFire = 3,
|
OpenFire=2,
|
||||||
WeaponFree = 4
|
ReturnFire=3,
|
||||||
|
WeaponHold=4,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--- Reaction On Threat.
|
||||||
|
-- @type ENUMS.ROT
|
||||||
|
-- @field #number NoReaction No defensive actions will take place to counter threats.
|
||||||
|
-- @field #number PassiveDefense AI will use jammers and other countermeasures in an attempt to defeat the threat. AI will not attempt a maneuver to defeat a threat.
|
||||||
|
-- @field #number EvadeFire AI will react by performing defensive maneuvers against incoming threats. AI will also use passive defense.
|
||||||
|
-- @field #number BypassAndEscape AI will attempt to avoid enemy threat zones all together. This includes attempting to fly above or around threats.
|
||||||
|
-- @field #number AllowAbortMission If a threat is deemed severe enough the AI will abort its mission and return to base.
|
||||||
ENUMS.ROT = {
|
ENUMS.ROT = {
|
||||||
NoReaction = 1,
|
NoReaction=0,
|
||||||
PassiveDefense = 2,
|
PassiveDefense=1,
|
||||||
EvadeFire = 3,
|
EvadeFire=2,
|
||||||
Vertical = 4
|
BypassAndEscape=3,
|
||||||
|
AllowAbortMission=4,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--- Weapon types. See the [Weapon Flag](https://wiki.hoggitworld.com/view/DCS_enum_weapon_flag) enumerotor on hoggit wiki.
|
||||||
|
-- @type ENUMS.WeaponFlag
|
||||||
ENUMS.WeaponFlag={
|
ENUMS.WeaponFlag={
|
||||||
-- Auto
|
|
||||||
Auto=1073741822,
|
|
||||||
-- Bombs
|
-- Bombs
|
||||||
LGB=2,
|
LGB = 2,
|
||||||
TvGB=4,
|
TvGB = 4,
|
||||||
SNSGB=8,
|
SNSGB = 8,
|
||||||
HEBomb=16,
|
HEBomb = 16,
|
||||||
Penetrator=32,
|
Penetrator = 32,
|
||||||
NapalmBomb=64,
|
NapalmBomb = 64,
|
||||||
FAEBomb=128,
|
FAEBomb = 128,
|
||||||
ClusterBomb=256,
|
ClusterBomb = 256,
|
||||||
Dispencer=512,
|
Dispencer = 512,
|
||||||
CandleBomb=1024,
|
CandleBomb = 1024,
|
||||||
ParachuteBomb=2147483648,
|
ParachuteBomb = 2147483648,
|
||||||
GuidedBomb=14, -- (LGB + TvGB + SNSGB)
|
|
||||||
AnyUnguidedBomb=2147485680, -- (HeBomb + Penetrator + NapalmBomb + FAEBomb + ClusterBomb + Dispencer + CandleBomb + ParachuteBomb)
|
|
||||||
AnyBomb=2147485694, -- (GuidedBomb + AnyUnguidedBomb)
|
|
||||||
-- Rockets
|
-- Rockets
|
||||||
LightRocket=2048,
|
LightRocket = 2048,
|
||||||
MarkerRocket=4096,
|
MarkerRocket = 4096,
|
||||||
CandleRocket=8192,
|
CandleRocket = 8192,
|
||||||
HeavyRocket=16384,
|
HeavyRocket = 16384,
|
||||||
AnyRocket=30720 -- (LightRocket + MarkerRocket + CandleRocket + HeavyRocket)
|
-- Air-To-Surface Missiles
|
||||||
|
AntiRadarMissile = 32768,
|
||||||
|
AntiShipMissile = 65536,
|
||||||
|
AntiTankMissile = 131072,
|
||||||
|
FireAndForgetASM = 262144,
|
||||||
|
LaserASM = 524288,
|
||||||
|
TeleASM = 1048576,
|
||||||
|
CruiseMissile = 2097152,
|
||||||
|
AntiRadarMissile2 = 1073741824,
|
||||||
|
-- Air-To-Air Missiles
|
||||||
|
SRAM = 4194304,
|
||||||
|
MRAAM = 8388608,
|
||||||
|
LRAAM = 16777216,
|
||||||
|
IR_AAM = 33554432,
|
||||||
|
SAR_AAM = 67108864,
|
||||||
|
AR_AAM = 134217728,
|
||||||
|
--- Guns
|
||||||
|
GunPod = 268435456,
|
||||||
|
BuiltInCannon = 536870912,
|
||||||
|
---
|
||||||
|
-- Combinations
|
||||||
|
--
|
||||||
|
-- Bombs
|
||||||
|
GuidedBomb = 14, -- (LGB + TvGB + SNSGB)
|
||||||
|
AnyUnguidedBomb = 2147485680, -- (HeBomb + Penetrator + NapalmBomb + FAEBomb + ClusterBomb + Dispencer + CandleBomb + ParachuteBomb)
|
||||||
|
AnyBomb = 2147485694, -- (GuidedBomb + AnyUnguidedBomb)
|
||||||
|
--- Rockets
|
||||||
|
AnyRocket = 30720, -- LightRocket + MarkerRocket + CandleRocket + HeavyRocket
|
||||||
|
--- Air-To-Surface Missiles
|
||||||
|
GuidedASM = 1572864, -- (LaserASM + TeleASM)
|
||||||
|
TacticalASM = 1835008, -- (GuidedASM + FireAndForgetASM)
|
||||||
|
AnyASM = 4161536, -- (AntiRadarMissile + AntiShipMissile + AntiTankMissile + FireAndForgetASM + GuidedASM + CruiseMissile)
|
||||||
|
AnyASM2 = 1077903360, -- 4161536+1073741824,
|
||||||
|
--- Air-To-Air Missiles
|
||||||
|
AnyAAM = 264241152, -- IR_AAM + SAR_AAM + AR_AAM + SRAAM + MRAAM + LRAAM
|
||||||
|
AnyAutonomousMissile = 36012032, -- IR_AAM + AntiRadarMissile + AntiShipMissile + FireAndForgetASM + CruiseMissile
|
||||||
|
AnyMissile = 268402688, -- AnyASM + AnyAAM
|
||||||
|
--- Guns
|
||||||
|
Cannons = 805306368, -- GUN_POD + BuiltInCannon
|
||||||
|
---
|
||||||
|
-- Even More Genral
|
||||||
|
Auto = 3221225470, -- Any Weapon (AnyBomb + AnyRocket + AnyMissile + Cannons)
|
||||||
|
AutoDCS = 1073741822, -- Something if often see
|
||||||
|
AnyAG = 2956984318, -- Any Air-To-Ground Weapon
|
||||||
|
AnyAA = 264241152, -- Any Air-To-Air Weapon
|
||||||
|
AnyUnguided = 2952822768, -- Any Unguided Weapon
|
||||||
|
AnyGuided = 268402702, -- Any Guided Weapon
|
||||||
|
}
|
||||||
|
|
||||||
|
--- Mission tasks.
|
||||||
|
-- @type ENUMS.MissionTask
|
||||||
|
-- @field #string NOTHING No special task. Group can perform the minimal tasks: Orbit, Refuelling, Follow and Aerobatics.
|
||||||
|
-- @field #string AFAC Forward Air Controller Air. Can perform the tasks: Attack Group, Attack Unit, FAC assign group, Bombing, Attack Map Object.
|
||||||
|
-- @field #string ANTISHIPSTRIKE Naval ops. Can perform the tasks: Attack Group, Attack Unit.
|
||||||
|
-- @field #string AWACS AWACS.
|
||||||
|
-- @field #string CAP Combat Air Patrol.
|
||||||
|
-- @field #string CAS Close Air Support.
|
||||||
|
-- @field #string ESCORT Escort another group.
|
||||||
|
-- @field #string FIGHTERSWEEP Fighter sweep.
|
||||||
|
-- @field #string GROUNDATTACK Ground attack.
|
||||||
|
-- @field #string INTERCEPT Intercept.
|
||||||
|
-- @field #string PINPOINTSTRIKE Pinpoint strike.
|
||||||
|
-- @field #string RECONNAISSANCE Reconnaissance mission.
|
||||||
|
-- @field #string REFUELING Refueling mission.
|
||||||
|
-- @field #string RUNWAYATTACK Attack the runway of an airdrome.
|
||||||
|
-- @field #string SEAD Suppression of Enemy Air Defenses.
|
||||||
|
-- @field #string TRANSPORT Troop transport.
|
||||||
|
ENUMS.MissionTask={
|
||||||
|
NOTHING="Nothing",
|
||||||
|
AFAC="AFAC",
|
||||||
|
ANTISHIPSTRIKE="Antiship Strike",
|
||||||
|
AWACS="AWACS",
|
||||||
|
CAP="CAP",
|
||||||
|
CAS="CAS",
|
||||||
|
ESCORT="Escort",
|
||||||
|
FIGHTERSWEEP="Fighter Sweep",
|
||||||
|
GROUNDATTACK="Ground Attack",
|
||||||
|
INTERCEPT="Intercept",
|
||||||
|
PINPOINTSTRIKE="Pinpoint Strike",
|
||||||
|
RECONNAISSANCE="Reconnaissance",
|
||||||
|
REFUELING="Refueling",
|
||||||
|
RUNWAYATTACK="Runway Attack",
|
||||||
|
SEAD="SEAD",
|
||||||
|
TRANSPORT="Transport",
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ CALLSIGN={
|
|||||||
Enfield=1,
|
Enfield=1,
|
||||||
Springfield=2,
|
Springfield=2,
|
||||||
Uzi=3,
|
Uzi=3,
|
||||||
Cold=4,
|
Colt=4,
|
||||||
Dodge=5,
|
Dodge=5,
|
||||||
Ford=6,
|
Ford=6,
|
||||||
Chevy=7,
|
Chevy=7,
|
||||||
@ -437,8 +437,8 @@ UTILS.tostringLL = function( lat, lon, acc, DMS)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- 024<32> 23' 12"N or 024<32> 23' 12.03"N
|
-- 024<32> 23' 12"N or 024<32> 23' 12.03"N
|
||||||
return string.format('%03d°', latDeg) .. ' ' .. string.format('%02d', latMin) .. '\' ' .. string.format(secFrmtStr, latSec) .. '"' .. latHemi .. ' '
|
return string.format('%03d°', latDeg)..string.format('%02d', latMin)..'\''..string.format(secFrmtStr, latSec)..'"'..latHemi..' '
|
||||||
.. string.format('%03d°', lonDeg) .. ' ' .. string.format('%02d', lonMin) .. '\' ' .. string.format(secFrmtStr, lonSec) .. '"' .. lonHemi
|
.. string.format('%03d°', lonDeg)..string.format('%02d', lonMin)..'\''..string.format(secFrmtStr, lonSec)..'"'..lonHemi
|
||||||
|
|
||||||
else -- degrees, decimal minutes.
|
else -- degrees, decimal minutes.
|
||||||
latMin = UTILS.Round(latMin, acc)
|
latMin = UTILS.Round(latMin, acc)
|
||||||
@ -1098,5 +1098,36 @@ function UTILS.GetModulationName(Modulation)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get the callsign name from its enumerator value
|
||||||
|
-- @param #number Callsign The enumerator callsign.
|
||||||
|
-- @return #string The callsign name.
|
||||||
|
function UTILS.GetCallsignName(Callsign)
|
||||||
|
|
||||||
|
for name, value in pairs(CALLSIGN.Aircraft) do
|
||||||
|
if value==Callsign then
|
||||||
|
return name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for name, value in pairs(CALLSIGN.AWACS) do
|
||||||
|
if value==Callsign then
|
||||||
|
return name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for name, value in pairs(CALLSIGN.JTAC) do
|
||||||
|
if value==Callsign then
|
||||||
|
return name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for name, value in pairs(CALLSIGN.Tanker) do
|
||||||
|
if value==Callsign then
|
||||||
|
return name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return "Unknown Calsing"
|
||||||
|
end
|
||||||
|
|
||||||
-- Just a test to see commits in new environment for Wingthor
|
-- Just a test to see commits in new environment for Wingthor
|
||||||
File diff suppressed because it is too large
Load Diff
@ -440,9 +440,16 @@ function GROUP:Destroy( GenerateEvent, delay )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns category of the DCS Group.
|
--- Returns category of the DCS Group. Returns one of
|
||||||
|
--
|
||||||
|
-- * Group.Category.AIRPLANE
|
||||||
|
-- * Group.Category.HELICOPTER
|
||||||
|
-- * Group.Category.GROUND
|
||||||
|
-- * Group.Category.SHIP
|
||||||
|
-- * Group.Category.TRAIN
|
||||||
|
--
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @return DCS#Group.Category The category ID
|
-- @return DCS#Group.Category The category ID.
|
||||||
function GROUP:GetCategory()
|
function GROUP:GetCategory()
|
||||||
self:F2( self.GroupName )
|
self:F2( self.GroupName )
|
||||||
|
|
||||||
@ -458,7 +465,7 @@ end
|
|||||||
|
|
||||||
--- Returns the category name of the #GROUP.
|
--- Returns the category name of the #GROUP.
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
-- @return #string Category name = Helicopter, Airplane, Ground Unit, Ship
|
-- @return #string Category name = Helicopter, Airplane, Ground Unit, Ship, Train.
|
||||||
function GROUP:GetCategoryName()
|
function GROUP:GetCategoryName()
|
||||||
self:F2( self.GroupName )
|
self:F2( self.GroupName )
|
||||||
|
|
||||||
@ -469,6 +476,7 @@ function GROUP:GetCategoryName()
|
|||||||
[Group.Category.HELICOPTER] = "Helicopter",
|
[Group.Category.HELICOPTER] = "Helicopter",
|
||||||
[Group.Category.GROUND] = "Ground Unit",
|
[Group.Category.GROUND] = "Ground Unit",
|
||||||
[Group.Category.SHIP] = "Ship",
|
[Group.Category.SHIP] = "Ship",
|
||||||
|
[Group.Category.TRAIN] = "Train",
|
||||||
}
|
}
|
||||||
local GroupCategory = DCSGroup:getCategory()
|
local GroupCategory = DCSGroup:getCategory()
|
||||||
self:T3( GroupCategory )
|
self:T3( GroupCategory )
|
||||||
@ -867,10 +875,15 @@ end
|
|||||||
|
|
||||||
--- Activates a late activated GROUP.
|
--- Activates a late activated GROUP.
|
||||||
-- @param #GROUP self
|
-- @param #GROUP self
|
||||||
|
-- @param #number delay Delay in seconds, before the group is activated.
|
||||||
-- @return #GROUP self
|
-- @return #GROUP self
|
||||||
function GROUP:Activate()
|
function GROUP:Activate(delay)
|
||||||
self:F2( { self.GroupName } )
|
self:F2( { self.GroupName } )
|
||||||
trigger.action.activateGroup( self:GetDCSObject() )
|
if delay and delay>0 then
|
||||||
|
self:ScheduleOnce(delay, GROUP.Activate, self)
|
||||||
|
else
|
||||||
|
trigger.action.activateGroup( self:GetDCSObject() )
|
||||||
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -90,7 +90,6 @@ end
|
|||||||
--- Returns the type name of the DCS Identifiable.
|
--- Returns the type name of the DCS Identifiable.
|
||||||
-- @param #IDENTIFIABLE self
|
-- @param #IDENTIFIABLE self
|
||||||
-- @return #string The type name of the DCS Identifiable.
|
-- @return #string The type name of the DCS Identifiable.
|
||||||
-- @return #nil The DCS Identifiable is not existing or alive.
|
|
||||||
function IDENTIFIABLE:GetTypeName()
|
function IDENTIFIABLE:GetTypeName()
|
||||||
self:F2( self.IdentifiableName )
|
self:F2( self.IdentifiableName )
|
||||||
|
|
||||||
@ -107,9 +106,17 @@ function IDENTIFIABLE:GetTypeName()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns category of the DCS Identifiable.
|
--- Returns object category of the DCS Identifiable. One of
|
||||||
|
--
|
||||||
|
-- * Object.Category.UNIT = 1
|
||||||
|
-- * Object.Category.WEAPON = 2
|
||||||
|
-- * Object.Category.STATIC = 3
|
||||||
|
-- * Object.Category.BASE = 4
|
||||||
|
-- * Object.Category.SCENERY = 5
|
||||||
|
-- * Object.Category.Cargo = 6
|
||||||
|
--
|
||||||
-- @param #IDENTIFIABLE self
|
-- @param #IDENTIFIABLE self
|
||||||
-- @return DCS#Object.Category The category ID
|
-- @return DCS#Object.Category The category ID, i.e. a number.
|
||||||
function IDENTIFIABLE:GetCategory()
|
function IDENTIFIABLE:GetCategory()
|
||||||
self:F2( self.ObjectName )
|
self:F2( self.ObjectName )
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
--
|
--
|
||||||
-- ### Author: **FlightControl**
|
-- ### Author: **FlightControl**
|
||||||
--
|
--
|
||||||
-- ### Contributions:
|
-- ### Contributions: **funkyfranky**
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@ -48,6 +48,10 @@ STATIC = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
--- Register a static object.
|
||||||
|
-- @param #STATIC self
|
||||||
|
-- @param #string StaticName Name of the static object.
|
||||||
|
-- @return #STATIC self
|
||||||
function STATIC:Register( StaticName )
|
function STATIC:Register( StaticName )
|
||||||
local self = BASE:Inherit( self, POSITIONABLE:New( StaticName ) )
|
local self = BASE:Inherit( self, POSITIONABLE:New( StaticName ) )
|
||||||
self.StaticName = StaticName
|
self.StaticName = StaticName
|
||||||
@ -71,19 +75,21 @@ end
|
|||||||
-- @param #STATIC self
|
-- @param #STATIC self
|
||||||
-- @param #string StaticName Name of the DCS **Static** as defined within the Mission Editor.
|
-- @param #string StaticName Name of the DCS **Static** as defined within the Mission Editor.
|
||||||
-- @param #boolean RaiseError Raise an error if not found.
|
-- @param #boolean RaiseError Raise an error if not found.
|
||||||
-- @return #STATIC
|
-- @return #STATIC self or *nil*
|
||||||
function STATIC:FindByName( StaticName, RaiseError )
|
function STATIC:FindByName( StaticName, RaiseError )
|
||||||
|
|
||||||
|
-- Find static in DB.
|
||||||
local StaticFound = _DATABASE:FindStatic( StaticName )
|
local StaticFound = _DATABASE:FindStatic( StaticName )
|
||||||
|
|
||||||
|
-- Set static name.
|
||||||
self.StaticName = StaticName
|
self.StaticName = StaticName
|
||||||
|
|
||||||
if StaticFound then
|
if StaticFound then
|
||||||
StaticFound:F3( { StaticName } )
|
|
||||||
return StaticFound
|
return StaticFound
|
||||||
end
|
end
|
||||||
|
|
||||||
if RaiseError == nil or RaiseError == true then
|
if RaiseError == nil or RaiseError == true then
|
||||||
error( "STATIC not found for: " .. StaticName )
|
error( "STATIC not found for: " .. StaticName )
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -424,9 +424,9 @@ function UNIT:GetRange()
|
|||||||
local Desc = self:GetDesc()
|
local Desc = self:GetDesc()
|
||||||
|
|
||||||
if Desc then
|
if Desc then
|
||||||
local Range = Desc.range --This is in nautical miles for some reason. But should check again!
|
local Range = Desc.range --This is in kilometers (not meters) for some reason. But should check again!
|
||||||
if Range then
|
if Range then
|
||||||
Range=UTILS.NMToMeters(Range)
|
Range=Range*1000 -- convert to meters.
|
||||||
else
|
else
|
||||||
Range=10000000 --10.000 km if no range
|
Range=10000000 --10.000 km if no range
|
||||||
end
|
end
|
||||||
@ -436,6 +436,64 @@ function UNIT:GetRange()
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Check if the unit is refuelable. Also retrieves the refuelling system (boom or probe) if applicable.
|
||||||
|
-- @param #UNIT self
|
||||||
|
-- @return #boolean If true, unit is refuelable (checks for the attribute "Refuelable").
|
||||||
|
-- @return #number Refueling system (if any): 0=boom, 1=probe.
|
||||||
|
function UNIT:IsRefuelable()
|
||||||
|
self:F2( self.UnitName )
|
||||||
|
|
||||||
|
local refuelable=self:HasAttribute("Refuelable")
|
||||||
|
|
||||||
|
local system=nil
|
||||||
|
|
||||||
|
local Desc=self:GetDesc()
|
||||||
|
if Desc and Desc.tankerType then
|
||||||
|
system=Desc.tankerType
|
||||||
|
end
|
||||||
|
|
||||||
|
return refuelable, system
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Check if the unit is a tanker. Also retrieves the refuelling system (boom or probe) if applicable.
|
||||||
|
-- @param #UNIT self
|
||||||
|
-- @return #boolean If true, unit is refuelable (checks for the attribute "Refuelable").
|
||||||
|
-- @return #number Refueling system (if any): 0=boom, 1=probe.
|
||||||
|
function UNIT:IsTanker()
|
||||||
|
self:F2( self.UnitName )
|
||||||
|
|
||||||
|
local tanker=self:HasAttribute("Tankers")
|
||||||
|
|
||||||
|
local system=nil
|
||||||
|
|
||||||
|
if tanker then
|
||||||
|
|
||||||
|
local Desc=self:GetDesc()
|
||||||
|
if Desc and Desc.tankerType then
|
||||||
|
system=Desc.tankerType
|
||||||
|
end
|
||||||
|
|
||||||
|
local typename=self:GetTypeName()
|
||||||
|
|
||||||
|
-- Some hard coded data as this is not in the descriptors...
|
||||||
|
if typename=="IL-78M" then
|
||||||
|
system=1 --probe
|
||||||
|
elseif typename=="KC130" then
|
||||||
|
system=1 --probe
|
||||||
|
elseif typename=="KC135BDA" then
|
||||||
|
system=1 --probe
|
||||||
|
elseif typename=="KC135MPRS" then
|
||||||
|
system=1 --probe
|
||||||
|
elseif typename=="S-3B Tanker" then
|
||||||
|
system=1 --probe
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
return tanker, system
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Returns the unit's group if it exist and nil otherwise.
|
--- Returns the unit's group if it exist and nil otherwise.
|
||||||
-- @param Wrapper.Unit#UNIT self
|
-- @param Wrapper.Unit#UNIT self
|
||||||
-- @return Wrapper.Group#GROUP The Group of the Unit.
|
-- @return Wrapper.Group#GROUP The Group of the Unit.
|
||||||
@ -756,6 +814,27 @@ function UNIT:GetDamageRelative()
|
|||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Returns the category of the #UNIT from descriptor. Returns one of
|
||||||
|
--
|
||||||
|
-- * Unit.Category.AIRPLANE
|
||||||
|
-- * Unit.Category.HELICOPTER
|
||||||
|
-- * Unit.Category.GROUND_UNIT
|
||||||
|
-- * Unit.Category.SHIP
|
||||||
|
-- * Unit.Category.STRUCTURE
|
||||||
|
--
|
||||||
|
-- @param #UNIT self
|
||||||
|
-- @return #number Unit category from `getDesc().category`.
|
||||||
|
function UNIT:GetUnitCategory()
|
||||||
|
self:F3( self.UnitName )
|
||||||
|
|
||||||
|
local DCSUnit = self:GetDCSObject()
|
||||||
|
if DCSUnit then
|
||||||
|
return DCSUnit:getDesc().category
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
--- Returns the category name of the #UNIT.
|
--- Returns the category name of the #UNIT.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @return #string Category name = Helicopter, Airplane, Ground Unit, Ship
|
-- @return #string Category name = Helicopter, Airplane, Ground Unit, Ship
|
||||||
@ -833,7 +912,9 @@ end
|
|||||||
-- * Threat level 10: Unit is AAA.
|
-- * Threat level 10: Unit is AAA.
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
|
-- @return #number Number between 0 (low threat level) and 10 (high threat level).
|
||||||
|
-- @return #string Some text.
|
||||||
function UNIT:GetThreatLevel()
|
function UNIT:GetThreatLevel()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user