This commit is contained in:
Frank
2020-04-06 00:19:50 +02:00
parent 7465fd065f
commit f22837103b
4 changed files with 213 additions and 155 deletions
+64 -29
View File
@@ -9,9 +9,6 @@
-- * Specific mission options for ROE, ROT, formation, etc. -- * Specific mission options for ROE, ROT, formation, etc.
-- * Interface to FLIGHTGROUP, AIRWING and WINGCOMMANDER classes. -- * Interface to FLIGHTGROUP, AIRWING and WINGCOMMANDER classes.
-- --
--
--
--
-- === -- ===
-- --
-- ### Author: **funkyfranky** -- ### Author: **funkyfranky**
@@ -61,6 +58,14 @@
-- @field Wrapper.Group#GROUP escortGroup The group to be escorted. -- @field Wrapper.Group#GROUP escortGroup The group to be escorted.
-- @field DCS#Vec3 escortVec3 The 3D offset vector from the escorted group to the escort group. -- @field DCS#Vec3 escortVec3 The 3D offset vector from the escorted group to the escort group.
-- --
-- @field #number facDesignation FAC designation type.
-- @field #boolean facDatalink FAC datalink enabled.
-- @field #number facFreq FAC radio frequency in MHz.
-- @field #number facModu FAC radio modulation 0=AM 1=FM.
--
-- @field Core.Set#SET_GROUP transportGroupSet Groups to be transported.
-- @field Core.Point#COORDINATE transportPickup Coordinate where to pickup the cargo.
--
-- @field Ops.WingCommander#WINGCOMMANDER wingcommander The WINGCOMMANDER managing this mission. -- @field Ops.WingCommander#WINGCOMMANDER wingcommander The WINGCOMMANDER managing this mission.
-- @field Ops.AirWing#AIRWING airwing The assigned airwing. -- @field Ops.AirWing#AIRWING airwing The assigned airwing.
-- @field #string squadname Name of the assigned Airwing squadron. -- @field #string squadname Name of the assigned Airwing squadron.
@@ -585,34 +590,26 @@ function AUFTRAG:NewCAS(OrbitCoordinate, OrbitSpeed, Heading, Leg, ZoneCAS, Targ
return mission return mission
end end
--- Create a CAS mission. --- Create a FACA mission.
-- @param #AUFTRAG self -- @param #AUFTRAG self
-- @param Core.Point#COORDINATE OrbitCoordinate Where to orbit. Altitude is also taken from the coordinate. -- @param Wrapper.Group#GROUP Target Target group. Must be a GROUP object.
-- @param #number OrbitSpeed Orbit speed in knots. Default 350 kts. -- @param #string Designation Designation of target. See `AI.Task.Designation`. Default `AI.Task.Designation.AUTO`.
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West). -- @param #boolean DataLink Enable data link. Default `true`.
-- @param #number Leg Length of race-track in NM. Default 10 NM. -- @param #number Frequency Radio frequency in MHz the FAC uses for communication. Default is 133 MHz.
-- @param Core.Zone#ZONE_RADIUS ZoneCAS Circular CAS zone. Detected targets in this zone will be engaged. -- @param #number Modulation Radio modulation band. Default 0=AM. Use 1 for FM. See radio.modulation.AM or radio.modulaton.FM.
-- @param #table TargetTypes Table of target types. Default {"Helicopters", "Ground Units", "Light armed ships"}.
-- @return #AUFTRAG self -- @return #AUFTRAG self
function AUFTRAG:NewFACA(TargetGroup) function AUFTRAG:NewFACA(Target, Designation, DataLink, Frequency, Modulation)
-- Ensure given TargetTypes parameter is a table. local mission=AUFTRAG:New(AUFTRAG.Type.FACA)
if TargetTypes then
if type(TargetTypes)~="table" then
TargetTypes={TargetTypes}
end
end
-- Create ORBIT first. mission.engageTarget=mission:_TargetFromObject(Target)
local mission=self:NewORBIT(OrbitCoordinate, OrbitSpeed, Heading, Leg)
-- CAS paramters.
mission.type=AUFTRAG.Type.FACA
mission.engageZone=ZoneCAS or ZONE_RADIUS:New("CAS Zone", OrbitCoordinate:GetVec2(), Leg) -- TODO: check that target is really a group object!
mission.engageTargetTypes=TargetTypes or {"Helicopters", "Ground Units", "Light armed ships"}
mission:_SetLogID() mission.facDesignation=Designation
mission.facDatalink=true
mission.facFreq=Frequency or 133
mission.facModu=Modulation or radio.modulation.AM
mission.missionTask=ENUMS.MissionTask.AFAC mission.missionTask=ENUMS.MissionTask.AFAC
mission.optionROE=ENUMS.ROE.ReturnFire mission.optionROE=ENUMS.ROE.ReturnFire
@@ -792,6 +789,37 @@ function AUFTRAG:NewESCORT(EscortGroup, OffsetVector, EngageMaxDistance, TargetT
return mission return mission
end end
--- Create an TRANSPORT mission.
-- @param #AUFTRAG self
-- @param Core.Set#SET_GROUP TransportGroupSet The set group(s) to be transported.
-- @param Core.Point#COORDINATE PickupCoordinate Coordinate where the helo will land to pick up the the cargo. Default is the fist transport group.
-- @return #AUFTRAG self
function AUFTRAG:NewTRANSPORT(TransportGroupSet, PickupCoordinate)
local mission=AUFTRAG:New(AUFTRAG.Type.TRANSPORT)
if TransportGroupSet:IsInstanceOf("GROUP") then
mission.transportGroupSet=SET_GROUP:New()
mission.transportGroupSet:AddGroup(TransportGroupSet)
elseif TransportGroupSet:IsInstanceOf("SET_GROUP") then
mission.transportGroupSet=TransportGroupSet
else
env.info("FF error in TRANSPORT auftrag")
end
mission.transportPickup=PickupCoordinate or mission.transportGroupSet:GetFirst():GetCoordinate()
mission.transportPickup:MarkToAll("Pickup")
-- TODO: what's the best ROE here? Make dependent on ESCORT or FOLLOW!
mission.optionROE=ENUMS.ROE.ReturnFire
mission.optionROT=ENUMS.ROT.PassiveDefense
mission.DCStask=mission:GetDCSMissionTask()
return mission
end
--- Create a mission to attack a group. Mission type is automatically chosen from the group category. --- Create a mission to attack a group. Mission type is automatically chosen from the group category.
-- @param #AUFTRAG self -- @param #AUFTRAG self
@@ -1198,7 +1226,7 @@ function AUFTRAG:onafterStatus(From, Event, To)
self:I(self.lid..text) self:I(self.lid..text)
end end
local ready2evaluate=self.Tover and Tnow-self.Tover>self.dTevaluate or false local ready2evaluate=self.Tover and Tnow-self.Tover>=self.dTevaluate or false
-- Check if mission is OVER (done or cancelled) and enough time passed to evaluate the result. -- Check if mission is OVER (done or cancelled) and enough time passed to evaluate the result.
if self:IsOver() and ready2evaluate then if self:IsOver() and ready2evaluate then
@@ -1871,6 +1899,8 @@ function AUFTRAG:GetTargetCoordinate()
return self.orbitCoord return self.orbitCoord
elseif self.escortGroup then elseif self.escortGroup then
return self.escortGroup:GetCoordinate() return self.escortGroup:GetCoordinate()
elseif self.transportPi1ckup then
return self.transportPickup
end end
return nil return nil
@@ -1892,6 +1922,8 @@ function AUFTRAG:GetTargetName()
return self.orbitCoord:ToStringLLDMS() return self.orbitCoord:ToStringLLDMS()
elseif self.escortGroup then elseif self.escortGroup then
return self.escortGroup:GetName() return self.escortGroup:GetName()
elseif self.transportPickup then
return self.transportPickup:ToStringLLDMS()
end end
return nil return nil
@@ -2067,7 +2099,8 @@ function AUFTRAG:GetDCSMissionTask()
-- FAC Mission -- -- FAC Mission --
----------------- -----------------
local DCStask=CONTROLLABLE.TaskFAC_AttackGroup(nil, self.engageAsGroup, self.engageWeaponType, self.facDesignation, self.facDatalink) -- TODO
local DCStask=CONTROLLABLE.TaskFAC_AttackGroup(nil, self.engageTarget.Target, self.engageWeaponType, self.facDesignation, self.facDatalink, self.facFrequency, self.facModulation, CallsignName, CallsignNumber)
table.insert(DCStasks, DCStask) table.insert(DCStasks, DCStask)
@@ -2149,9 +2182,11 @@ function AUFTRAG:GetDCSMissionTask()
-- TRANSPORT Mission -- -- TRANSPORT Mission --
----------------------- -----------------------
-- TODO: What? -- TODO: What about the groups to embark?
local DCStask=CONTROLLABLE.TaskEmbarking(self,Vec2,GroupSetForEmbarking,Duration,DistributionGroupSet) local Vec2=self.transportPickup:GetVec2()
local DCStask=CONTROLLABLE.TaskEmbarking(self, Vec2, self.transportGroupSet, Duration, DistributionGroupSet)
else else
self:E(self.lid..string.format("ERROR: Unknown mission task!")) self:E(self.lid..string.format("ERROR: Unknown mission task!"))
+128 -121
View File
@@ -64,6 +64,7 @@
-- @field Core.Set#SET_ZONE inzones Set of zones in which the group is currently in. -- @field Core.Set#SET_ZONE inzones Set of zones in which the group is currently in.
-- @field #boolean groupinitialized If true, group parameters were initialized. -- @field #boolean groupinitialized If true, group parameters were initialized.
-- @field #boolean ishelo If true, the is a helicopter group. -- @field #boolean ishelo If true, the is a helicopter group.
--
-- @field Core.Radio#BEACON beacon The beacon object. -- @field Core.Radio#BEACON beacon The beacon object.
-- @field #number TACANchannel TACAN channel. -- @field #number TACANchannel TACAN channel.
-- @field #string TACANmode TACAN mode, i.e. "Y" (or "X"). -- @field #string TACANmode TACAN mode, i.e. "Y" (or "X").
@@ -371,15 +372,8 @@ FLIGHTGROUP.version="0.3.8"
-- TODO list -- TODO list
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- DONE: Add tasks.
-- DONE: Waypoints, read, add, insert, detour.
-- DONE: Get ammo.
-- DONE: Get pylons.
-- DONE: Fuel threshhold ==> RTB.
-- DONE: ROE
-- TODO: Options EPLRS, Afterburner restrict etc. -- TODO: Options EPLRS, Afterburner restrict etc.
-- TODO: Add TACAN beacon. -- TODO: Add TACAN beacon.
-- NOGO: Respawn? With correct loadout, fuelstate. Solved in DCS 2.5.6!
-- TODO: Damage? -- TODO: Damage?
-- TODO: shot events? -- TODO: shot events?
-- TODO: Marks to add waypoints/tasks on-the-fly. -- TODO: Marks to add waypoints/tasks on-the-fly.
@@ -387,6 +381,13 @@ FLIGHTGROUP.version="0.3.8"
-- TODO: Let user request a parking spot via F10 marker :) -- TODO: Let user request a parking spot via F10 marker :)
-- TODO: Monitor traveled distance in air ==> calculate fuel consumption ==> calcuate range remaining. Will this give half way accurate results? -- TODO: Monitor traveled distance in air ==> calculate fuel consumption ==> calcuate range remaining. Will this give half way accurate results?
-- TODO: Out of AG/AA missiles. Safe state of out-of-ammo. -- TODO: Out of AG/AA missiles. Safe state of out-of-ammo.
-- DONE: Add tasks.
-- DONE: Waypoints, read, add, insert, detour.
-- DONE: Get ammo.
-- DONE: Get pylons.
-- DONE: Fuel threshhold ==> RTB.
-- DONE: ROE
-- NOGO: Respawn? With correct loadout, fuelstate. Solved in DCS 2.5.6!
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Constructor -- Constructor
@@ -820,110 +821,7 @@ function FLIGHTGROUP:SetParkingSpots(airbase, spots)
return self return self
end end
--- Set TACAN parameters. AA TACANs are aleays on "Y" band.
-- @param #FLIGHTGROUP self
-- @param #number Channel TACAN channel.
-- @param #string Morse Morse code. Default "XX".
-- @return #FLIGHTGROUP self
function FLIGHTGROUP:SetTACAN(Channel, Morse)
self.TACANchannel=Channel
self.TACANmorse=Morse or "XXX"
self.TACANactive=false
self.TACANon=true
return self
end
--- Set Radio parameters.
-- @param #FLIGHTGROUP self
-- @param #number Frequency Radio frequency in MHz. Default 305 MHz.
-- @param #number Modulation Radio modulation. Default `radio.Modulation.AM`.
-- @return #FLIGHTGROUP self
function FLIGHTGROUP:SetRadio(Frequency, Modulation)
self.radioFreq=Frequency or 305
self.radioModu=Modulation or radio.modulation.AM
self.radioOn=false
self.radioUse=true
return self
end
--- Activate TACAN beacon.
-- @param #FLIGHTGROUP self
-- @return #FLIGHTGROUP self
function FLIGHTGROUP:SwitchTACANOn()
if self:IsAlive() then
local unit=self.group:GetUnit(1)
if unit and unit:IsAlive() then
-- Create a new beacon and activate TACAN.
if not self.beacon then
self.beacon=BEACON:New(unit)
end
self.beacon:ActivateTACAN(self.TACANchannel, "Y", self.TACANmorse, true)
self.TACANactive=true
end
end
return self
end
--- Deactivate TACAN beacon.
-- @param #FLIGHTGROUP self
-- @return #FLIGHTGROUP self
function FLIGHTGROUP:SwitchTACANOff()
if self.beacon then
self.beacon:StopAATACAN()
end
self.TACANactive=false
end
--- Turn radio on.
-- @param #FLIGHTGROUP self
-- @param #number Frequency Radio frequency in MHz. Default 305 MHz.
-- @param #number Modulation Radio modulation. Default `radio.Modulation.AM`.
-- @return #FLIGHTGROUP self
function FLIGHTGROUP:SwitchRadioOn()
self.group:SetOption(AI.Option.Air.id.SILENCE, false)
self.group:CommandSetFrequency(self.radioFreq, self.radioModu)
self.radioOn=true
return self
end
--- Turn radio off.
-- @param #FLIGHTGROUP self
-- @return #FLIGHTGROUP self
function FLIGHTGROUP:SwitchRadioOff()
self.group:SetOption(AI.Option.Air.id.SILENCE, true)
self.radioOn=false
return self
end
--- Set the FLIGHTCONTROL controlling this flight group. --- Set the FLIGHTCONTROL controlling this flight group.
@@ -1636,18 +1534,31 @@ function FLIGHTGROUP:onafterFlightStatus(From, Event, To)
-- Distance travelled -- Distance travelled
--- ---
local position=self:GetCoordinate()
local dist=self.position:Get3DDistance(position)
local time=timer.getAbsTime() local time=timer.getAbsTime()
local vel=dist/(time-self.traveltime) local position=self:GetCoordinate()
local ds=self.position:Get3DDistance(position)
local dt=time-self.traveltime
local v=ds/dt
self.traveldist=self.traveldist+dist self.traveldist=self.traveldist+ds
self.traveltime=time self.traveltime=time
self.position=position self.position=position
local fuelmass=math.huge
for _,_element in pairs(self.elements) do
local element=_element --#FLIGHTGROUP.Element
local fuel=element.unit:GetFuel() or 0
local fmass=element.fuelmass*fuel
if fmass<fuelmass then
fuelmass=fmass
end
end
env.info(string.format("FF Distance travelled = %.1f km v=%.1f knots", self.traveldist/1000, UTILS.MpsToKnots(vel))) env.info(string.format("FF Distance travelled = %.1f km v=%.1f knots fuel=%d kg", self.traveldist/1000, UTILS.MpsToKnots(v), fuelmass))
--- ---
-- Tasks -- Tasks
@@ -4053,11 +3964,6 @@ function FLIGHTGROUP:_InitGroup()
self.refueltype=select(2, unit:IsRefuelable()) self.refueltype=select(2, unit:IsRefuelable())
self.ai=not self:_IsHuman(self.group) self.ai=not self:_IsHuman(self.group)
for _,_element in pairs(self.elements) do
local element=_element --#FLIGHTGROUP.Element
element.ai=not self:_IsHumanUnit(element.unit)
end
-- Init waypoints. -- Init waypoints.
if not self.waypoints then if not self.waypoints then
@@ -5850,6 +5756,107 @@ function FLIGHTGROUP:SetOptionROT(rot)
return self return self
end end
--- Set TACAN parameters. AA TACANs are aleays on "Y" band.
-- @param #FLIGHTGROUP self
-- @param #number Channel TACAN channel.
-- @param #string Morse Morse code. Default "XX".
-- @return #FLIGHTGROUP self
function FLIGHTGROUP:SetTACAN(Channel, Morse)
self.TACANchannel=Channel
self.TACANmorse=Morse or "XXX"
self.TACANactive=false
self.TACANon=true
return self
end
--- Activate TACAN beacon.
-- @param #FLIGHTGROUP self
-- @return #FLIGHTGROUP self
function FLIGHTGROUP:SwitchTACANOn()
if self:IsAlive() then
local unit=self.group:GetUnit(1)
if unit and unit:IsAlive() then
-- Create a new beacon and activate TACAN.
if not self.beacon then
self.beacon=BEACON:New(unit)
end
self.beacon:ActivateTACAN(self.TACANchannel, "Y", self.TACANmorse, true)
self.TACANactive=true
end
end
return self
end
--- Deactivate TACAN beacon.
-- @param #FLIGHTGROUP self
-- @return #FLIGHTGROUP self
function FLIGHTGROUP:SwitchTACANOff()
if self.beacon then
self.beacon:StopAATACAN()
end
self.TACANactive=false
end
--- Set Radio parameters.
-- @param #FLIGHTGROUP self
-- @param #number Frequency Radio frequency in MHz. Default 305 MHz.
-- @param #number Modulation Radio modulation. Default `radio.Modulation.AM`.
-- @return #FLIGHTGROUP self
function FLIGHTGROUP:SetRadio(Frequency, Modulation)
self.radioFreq=Frequency or 305
self.radioModu=Modulation or radio.modulation.AM
self.radioOn=false
self.radioUse=true
return self
end
--- Turn radio on.
-- @param #FLIGHTGROUP self
-- @param #number Frequency Radio frequency in MHz. Default 305 MHz.
-- @param #number Modulation Radio modulation. Default `radio.Modulation.AM`.
-- @return #FLIGHTGROUP self
function FLIGHTGROUP:SwitchRadioOn()
self.group:SetOption(AI.Option.Air.id.SILENCE, false)
self.group:CommandSetFrequency(self.radioFreq, self.radioModu)
self.radioOn=true
return self
end
--- Turn radio off.
-- @param #FLIGHTGROUP self
-- @return #FLIGHTGROUP self
function FLIGHTGROUP:SwitchRadioOff()
self.group:SetOption(AI.Option.Air.id.SILENCE, true)
self.radioOn=false
return self
end
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- MENU FUNCTIONS -- MENU FUNCTIONS
+17 -1
View File
@@ -49,11 +49,13 @@ ENUMS.ROT = {
--- Weapon types. --- Weapon types.
-- @type ENUMS.WeaponFlag -- @type ENUMS.WeaponFlag
ENUMS.WeaponFlag={ ENUMS.WeaponFlag={
-- Combinations
Auto=3221225470, --AnyWeapon (AnyBomb + AnyRocket + AnyMissile + Cannons) Auto=3221225470, --AnyWeapon (AnyBomb + AnyRocket + AnyMissile + Cannons)
AnyAG=2956984318, AnyAG=2956984318,
AnyAA=264241152, AnyAA=264241152,
AnyUnguided=2952822768, AnyUnguided=2952822768,
AnyGuided=268402702, AnyGuided=268402702,
-- Bombs
LGB=2, LGB=2,
TvGB=4, TvGB=4,
SNSGB=8, SNSGB=8,
@@ -73,7 +75,21 @@ ENUMS.WeaponFlag={
MarkerRocket=4096, MarkerRocket=4096,
CandleRocket=8192, CandleRocket=8192,
HeavyRocket=16384, HeavyRocket=16384,
AnyRocket=30720 -- (LightRocket + MarkerRocket + CandleRocket + HeavyRocket) AnyRocket=30720, -- LightRocket + MarkerRocket + CandleRocket + HeavyRocket
--- Air-To-Air Missiles
SRAM=4194304,
MRAAM=8388608,
LRAaM=16777216,
IR_AAM=33554432,
SAR_AAM=67108864,
AR_AAM=134217728,
AnyAAM=264241152, -- IR_AAM + SAR_AAM + AR_AAM + SRAAM + MRAAM + LRAAM
AnyMissile=268402688, -- ASM + AnyAAM
AnyAutonomousMissile=36012032, --IR_AAM + AntiRadarMissile + AntiShipMissile + FireAndForgetASM + CruiseMissile
--- Guns
GUN_POD=268435456,
BuiltInCannon=536870912,
Cannos=805306368, --GUN_POD + BuiltInCannon)
} }
--- Mission tasks. --- Mission tasks.
@@ -1424,10 +1424,10 @@ end
-- The killer is player-controlled allied CAS-aircraft that is in contact with the FAC. -- The killer is player-controlled allied CAS-aircraft that is in contact with the FAC.
-- If the task is assigned to the controllable lead unit will be a FAC. -- If the task is assigned to the controllable lead unit will be a FAC.
-- @param #CONTROLLABLE self -- @param #CONTROLLABLE self
-- @param Wrapper.Controllable#CONTROLLABLE AttackGroup Target CONTROLLABLE. -- @param Wrapper.Group#GROUP AttackGroup Target GROUP object.
-- @param #number WeaponType Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. -- @param #number WeaponType Bitmask of weapon types, which are allowed to use.
-- @param DCS#AI.Task.Designation Designation (optional) Designation type. -- @param DCS#AI.Task.Designation Designation (Optional) Designation type.
-- @param #boolean Datalink (optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default. -- @param #boolean Datalink (Optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default.
-- @param #number Frequency Frequency used to communicate with the FAC. -- @param #number Frequency Frequency used to communicate with the FAC.
-- @param #number Modulation Modulation of radio for communication. -- @param #number Modulation Modulation of radio for communication.
-- @param #number CallsignName Callsign enumerator name of the FAC. -- @param #number CallsignName Callsign enumerator name of the FAC.