FG CONTROLLABLE

FG v0.3.2
CONTROLLABLE removed self dependencies for some tasks.
This commit is contained in:
Frank
2020-02-22 11:03:15 +01:00
parent 6e97433ec4
commit 8925bc11ca
2 changed files with 139 additions and 154 deletions
+64 -20
View File
@@ -322,6 +322,7 @@ FLIGHTGROUP.TaskType={
-- @param #string FACA Forward AirController airborne mission. -- @param #string FACA Forward AirController airborne mission.
-- @param #string FERRY Ferry flight mission. -- @param #string FERRY Ferry flight mission.
-- @param #string INTERCEPT Intercept mission. -- @param #string INTERCEPT Intercept mission.
-- @param #string ORBIT Orbit mission.
-- @param #string RECON Recon mission. -- @param #string RECON Recon mission.
-- @param #string SEAD Suppression/destruction of enemy air defences. -- @param #string SEAD Suppression/destruction of enemy air defences.
-- @param #string STRIKE Strike mission. -- @param #string STRIKE Strike mission.
@@ -337,7 +338,8 @@ FLIGHTGROUP.MissionType={
ESCORT="Escort", ESCORT="Escort",
FACA="FAC-A", FACA="FAC-A",
FERRY="Ferry Flight", FERRY="Ferry Flight",
INTERCEPT="Intercept", INTERCEPT="Intercept",
ORBIT="Orbit",
RECON="Recon", RECON="Recon",
SEAD="SEAD", SEAD="SEAD",
STRIKE="Strike", STRIKE="Strike",
@@ -408,7 +410,7 @@ FLIGHTGROUP.MissionStatus={
--- FLIGHTGROUP class version. --- FLIGHTGROUP class version.
-- @field #string version -- @field #string version
FLIGHTGROUP.version="0.3.1" FLIGHTGROUP.version="0.3.2"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list
@@ -1046,11 +1048,14 @@ function FLIGHTGROUP:Activate(delay)
if self:IsAlive()==false then if self:IsAlive()==false then
if delay then if delay then
self:I(self.lid..string.format("Activating late activated group in %d seconds", delay))
self:ScheduleOnce(delay, FLIGHTGROUP.Activate, self) self:ScheduleOnce(delay, FLIGHTGROUP.Activate, self)
else else
self:I(self.lid.."Activating late activated group") self:I(self.lid.."Activating late activated group")
self.group:Activate() self.group:Activate()
end end
else
self:E(self.lid..string.format("ERROR: Cannot activate group as IsAlive()==%s", tostring(self:IsAlive())))
end end
return self return self
@@ -1194,7 +1199,7 @@ end
-- @param Core.Zone#ZONE_RADIUS ZoneCAP Circular CAP zone. Detected targets in this zone will be engaged. -- @param Core.Zone#ZONE_RADIUS ZoneCAP Circular CAP zone. Detected targets in this zone will be engaged.
-- @param #table TargetTypes Table of target types. Default {"Air"}. -- @param #table TargetTypes Table of target types. Default {"Air"}.
-- @return #FLIGHTGROUP.MissionCAP The CAP mission table. -- @return #FLIGHTGROUP.MissionCAP The CAP mission table.
function FLIGHTGROUP:CreateMissionCAP(OrbitCoordinate, OrbitSpeed, Heading, Leg, ZoneCap, TargetTypes) function FLIGHTGROUP:CreateMissionCAP(OrbitCoordinate, OrbitSpeed, Heading, Leg, ZoneCAP, TargetTypes)
local mission=self:CreateMissionORBIT(OrbitCoordinate, OrbitSpeed, Heading, Leg) --#FLIGHTGROUP.MissionCAP local mission=self:CreateMissionORBIT(OrbitCoordinate, OrbitSpeed, Heading, Leg) --#FLIGHTGROUP.MissionCAP
@@ -1205,6 +1210,27 @@ function FLIGHTGROUP:CreateMissionCAP(OrbitCoordinate, OrbitSpeed, Heading, Leg,
return mission return mission
end end
--- Create a CAS mission.
-- @param #FLIGHTGROUP self
-- @param Core.Point#COORDINATE OrbitCoordinate Where to orbit. Altitude is also taken from the coordinate.
-- @param #number OrbitSpeed Orbit speed in knots. Default 350 kts.
-- @param #number Heading Heading of race-track pattern in degrees. Default 270 (East to West).
-- @param #number Leg Length of race-track in NM. Default 10 NM.
-- @param Core.Zone#ZONE_RADIUS ZoneCAS Circular CAS zone. Detected targets in this zone will be engaged.
-- @param #table TargetTypes Table of target types. Default {"LightArmoredUnits"}.
-- @return #FLIGHTGROUP.MissionCAP The CAP mission table.
function FLIGHTGROUP:CreateMissionCAS(OrbitCoordinate, OrbitSpeed, Heading, Leg, ZoneCAS, TargetTypes)
TargetTypes=TargetTypes or "LightArmoredUnits"
ZoneCAS=ZoneCAS or ZONE_RADIUS:New("CAS Zone", OrbitCoordinate:GetVec2(), Leg)
local mission=self:CreateMissionCAP(OrbitCoordinate, OrbitSpeed, Heading, Leg, ZoneCAS, TargetTypes) --#FLIGHTGROUP.MissionCAP
return mission
end
--- Create a STRIKE mission. Flight will attack a specified coordinate. --- Create a STRIKE mission. Flight will attack a specified coordinate.
-- @param #FLIGHTGROUP self -- @param #FLIGHTGROUP self
-- @param Core.Point#COORDINATE Coordinate Target Coordinate. -- @param Core.Point#COORDINATE Coordinate Target Coordinate.
@@ -1291,10 +1317,11 @@ function FLIGHTGROUP:AddMission(Mission, WaypointCoordinate, WaypointIndex, Cloc
-- Add mission to queue. -- Add mission to queue.
table.insert(self.missionqueue, mission) table.insert(self.missionqueue, mission)
local text=string.format("Added %s mission %s at zone %s. Starting at %s. Stopping at %s", -- Info text.
mission.type, mission.name, mission.zone:GetName(), UTILS.SecondsToClock(mission.Tstart, true), mission.Tstop and UTILS.SecondsToClock(mission.Tstop, true) or "never") local text=string.format("Added %s mission %s at waypoint %s. Starting at %s. Stopping at %s",
--self:I(self.lid..text) tostring(mission.type), tostring(mission.name), tostring(mission.waypointindex), UTILS.SecondsToClock(mission.Tstart, true), mission.Tstop and UTILS.SecondsToClock(mission.Tstop, true) or "never")
self:I(text) self:I(self.lid..text)
--self:I(text)
return mission return mission
end end
@@ -1405,6 +1432,20 @@ function FLIGHTGROUP:GetDCSMissionTask(Mission)
table.insert(DCStasks, DCStask) table.insert(DCStasks, DCStask)
end end
elseif Mission.type==FLIGHTGROUP.MissionType.ORBIT then
-------------------
-- ORBIT Mission --
-------------------
local mission=Mission --#FLIGHTGROUP.MissionORBIT
local CoordRaceTrack=mission.coordOrbit:Translate(mission.leg, mission.heading, true)
local DCStask=CONTROLLABLE.TaskOrbit(self.group, mission.coordOrbit, mission.coordOrbit.y, mission.speedOrbit, CoordRaceTrack)
table.insert(DCStasks, DCStask)
elseif Mission.type==FLIGHTGROUP.MissionType.RECON then elseif Mission.type==FLIGHTGROUP.MissionType.RECON then
@@ -1433,13 +1474,16 @@ function FLIGHTGROUP:GetDCSMissionTask(Mission)
-------------------- --------------------
elseif Mission.type==FLIGHTGROUP.MissionType.TRANSPORT then elseif Mission.type==FLIGHTGROUP.MissionType.TRANSPORT then
else
self:E(self.lid..string.format("ERROR: Unknown mission task!"))
return nil
end end
if #DCStasks==1 then if #DCStasks==1 then
return DCStasks[1] return DCStasks[1]
else else
return self.group:TaskCombo(DCStasks) return CONTROLLABLE.TaskCombo(self.group, DCStasks)
end end
end end
@@ -2668,14 +2712,8 @@ function FLIGHTGROUP:onafterPassingWaypoint(From, Event, To, n, N)
-- Tasks at this waypoints. -- Tasks at this waypoints.
local taskswp={} local taskswp={}
-- Enroute tasks -- TODO: maybe set waypoint enroute tasks?
if self.taskenroute and false then
for _,taskE in pairs(self.taskenroute) do
--self:I(self.lid..string.format("Adding enroute task %s", tostring(taskE.id)))
--table.insert(taskswp, taskE)
end
end
for _,task in pairs(tasks) do for _,task in pairs(tasks) do
local Task=task --#FLIGHTGROUP.Task local Task=task --#FLIGHTGROUP.Task
@@ -2698,10 +2736,16 @@ function FLIGHTGROUP:onafterPassingWaypoint(From, Event, To, n, N)
-- At the final AIR waypoint, we set the flight to hold. -- At the final AIR waypoint, we set the flight to hold.
if self.destbase and n>1 and n==N-1 then if n==N then
self:__Hold(-1, self.destbase) if self.destbase then
self:__RTB(-1, self.destbase)
elseif self.destzone then
self:__RTZ(-1, self.destzone)
else
self:E(self.lid.."ERROR: Reached final waypoint but no destination set! Don't know what to do?!")
end
else else
-- Waypoint task combo. -- Execute waypoint tasks.
if #taskswp>0 then if #taskswp>0 then
self:SetTask(self.group:TaskCombo(taskswp)) self:SetTask(self.group:TaskCombo(taskswp))
end end
+75 -134
View File
@@ -450,7 +450,6 @@ end
-- @param #number lastWayPoint Last waypoint. -- @param #number lastWayPoint Last waypoint.
-- return DCS#Task -- return DCS#Task
function CONTROLLABLE:TaskCondition( time, userFlag, userFlagValue, condition, duration, lastWayPoint ) function CONTROLLABLE:TaskCondition( time, userFlag, userFlagValue, condition, duration, lastWayPoint )
self:F2( { time, userFlag, userFlagValue, condition, duration, lastWayPoint } )
--[[ --[[
StopCondition = { StopCondition = {
@@ -471,7 +470,6 @@ function CONTROLLABLE:TaskCondition( time, userFlag, userFlagValue, condition, d
DCSStopCondition.duration = duration DCSStopCondition.duration = duration
DCSStopCondition.lastWayPoint = lastWayPoint DCSStopCondition.lastWayPoint = lastWayPoint
self:T3( { DCSStopCondition } )
return DCSStopCondition return DCSStopCondition
end end
@@ -481,11 +479,8 @@ end
-- @param DCS#DCSStopCondition DCSStopCondition -- @param DCS#DCSStopCondition DCSStopCondition
-- @return DCS#Task -- @return DCS#Task
function CONTROLLABLE:TaskControlled( DCSTask, DCSStopCondition ) function CONTROLLABLE:TaskControlled( DCSTask, DCSStopCondition )
self:F2( { DCSTask, DCSStopCondition } )
local DCSTaskControlled local DCSTaskControlled = {
DCSTaskControlled = {
id = 'ControlledTask', id = 'ControlledTask',
params = { params = {
task = DCSTask, task = DCSTask,
@@ -493,7 +488,6 @@ function CONTROLLABLE:TaskControlled( DCSTask, DCSStopCondition )
} }
} }
self:T3( { DCSTaskControlled } )
return DCSTaskControlled return DCSTaskControlled
end end
@@ -502,22 +496,14 @@ end
-- @param DCS#TaskArray DCSTasks Array of @{DCSTasking.Task#Task} -- @param DCS#TaskArray DCSTasks Array of @{DCSTasking.Task#Task}
-- @return DCS#Task -- @return DCS#Task
function CONTROLLABLE:TaskCombo( DCSTasks ) function CONTROLLABLE:TaskCombo( DCSTasks )
self:F2( { DCSTasks } )
local DCSTaskCombo local DCSTaskCombo = {
DCSTaskCombo = {
id = 'ComboTask', id = 'ComboTask',
params = { params = {
tasks = DCSTasks tasks = DCSTasks
} }
} }
for TaskID, Task in ipairs( DCSTasks ) do
self:T( Task )
end
self:T3( { DCSTaskCombo } )
return DCSTaskCombo return DCSTaskCombo
end end
@@ -526,11 +512,8 @@ end
-- @param DCS#Command DCSCommand -- @param DCS#Command DCSCommand
-- @return DCS#Task -- @return DCS#Task
function CONTROLLABLE:TaskWrappedAction( DCSCommand, Index ) function CONTROLLABLE:TaskWrappedAction( DCSCommand, Index )
self:F2( { DCSCommand } )
local DCSTaskWrappedAction local DCSTaskWrappedAction = {
DCSTaskWrappedAction = {
id = "WrappedAction", id = "WrappedAction",
enabled = true, enabled = true,
number = Index or 1, number = Index or 1,
@@ -540,7 +523,6 @@ function CONTROLLABLE:TaskWrappedAction( DCSCommand, Index )
}, },
} }
self:T3( { DCSTaskWrappedAction } )
return DCSTaskWrappedAction return DCSTaskWrappedAction
end end
@@ -704,7 +686,6 @@ end
-- @param #number Delay (Optional) Delay in seconds before the ICLS is deactivated. -- @param #number Delay (Optional) Delay in seconds before the ICLS is deactivated.
-- @return #CONTROLLABLE self -- @return #CONTROLLABLE self
function CONTROLLABLE:CommandActivateICLS(Channel, UnitID, Callsign, Delay) function CONTROLLABLE:CommandActivateICLS(Channel, UnitID, Callsign, Delay)
self:F()
-- Command to activate ICLS system. -- Command to activate ICLS system.
local CommandActivateICLS= { local CommandActivateICLS= {
@@ -732,7 +713,6 @@ end
-- @param #number Delay (Optional) Delay in seconds before the beacon is deactivated. -- @param #number Delay (Optional) Delay in seconds before the beacon is deactivated.
-- @return #CONTROLLABLE self -- @return #CONTROLLABLE self
function CONTROLLABLE:CommandDeactivateBeacon(Delay) function CONTROLLABLE:CommandDeactivateBeacon(Delay)
self:F()
-- Command to deactivate -- Command to deactivate
local CommandDeactivateBeacon={id='DeactivateBeacon', params={}} local CommandDeactivateBeacon={id='DeactivateBeacon', params={}}
@@ -751,7 +731,6 @@ end
-- @param #number Delay (Optional) Delay in seconds before the ICLS is deactivated. -- @param #number Delay (Optional) Delay in seconds before the ICLS is deactivated.
-- @return #CONTROLLABLE self -- @return #CONTROLLABLE self
function CONTROLLABLE:CommandDeactivateICLS(Delay) function CONTROLLABLE:CommandDeactivateICLS(Delay)
self:F()
-- Command to deactivate -- Command to deactivate
local CommandDeactivateICLS={id='DeactivateICLS', params={}} local CommandDeactivateICLS={id='DeactivateICLS', params={}}
@@ -772,7 +751,6 @@ end
-- @param #number Delay (Optional) Delay in seconds before the callsign is set. Default is immediately. -- @param #number Delay (Optional) Delay in seconds before the callsign is set. Default is immediately.
-- @return #CONTROLLABLE self -- @return #CONTROLLABLE self
function CONTROLLABLE:CommandSetCallsign(CallName, CallNumber, Delay) function CONTROLLABLE:CommandSetCallsign(CallName, CallNumber, Delay)
self:F()
-- Command to set the callsign. -- Command to set the callsign.
local CommandSetCallsign={id='SetCallsign', params={callname=CallName, callnumber=CallNumber or 1}} local CommandSetCallsign={id='SetCallsign', params={callname=CallName, callnumber=CallNumber or 1}}
@@ -792,17 +770,19 @@ end
-- @param #number Delay (Optional) Delay in seconds before the callsign is set. Default is immediately. -- @param #number Delay (Optional) Delay in seconds before the callsign is set. Default is immediately.
-- @return #CONTROLLABLE self -- @return #CONTROLLABLE self
function CONTROLLABLE:CommandEPLRS(SwitchOnOff, Delay) function CONTROLLABLE:CommandEPLRS(SwitchOnOff, Delay)
self:F()
if SwitchOnOff==nil then if SwitchOnOff==nil then
SwitchOnOff=true SwitchOnOff=true
end end
-- ID
local _id=self:GetID()
-- Command to set the callsign. -- Command to set the callsign.
local CommandEPLRS={id='EPLRS', params={value=SwitchOnOff, groupId=_id}} local CommandEPLRS={
id='EPLRS',
params={
value=SwitchOnOff,
groupId=self:GetID()
}
}
if Delay and Delay>0 then if Delay and Delay>0 then
SCHEDULER:New(nil, self.CommandEPLRS, {self, SwitchOnOff}, Delay) SCHEDULER:New(nil, self.CommandEPLRS, {self, SwitchOnOff}, Delay)
@@ -821,14 +801,20 @@ end
-- @return #table Task wrapped action. -- @return #table Task wrapped action.
function CONTROLLABLE:TaskEPLRS(SwitchOnOff, idx) function CONTROLLABLE:TaskEPLRS(SwitchOnOff, idx)
-- ID if SwitchOnOff==nil then
local _id=self:GetID() SwitchOnOff=true
end
-- Command to set the callsign. -- Command to set the callsign.
local CommandEPLRS={id='EPLRS', params={value=SwitchOnOff, groupId=_id}} local CommandEPLRS={
id='EPLRS',
params={
value=SwitchOnOff,
groupId=self:GetID()
}
}
return self:TaskWrappedAction(CommandEPLRS, idx or 1) return self:TaskWrappedAction(CommandEPLRS, idx or 1)
end end
@@ -875,9 +861,8 @@ function CONTROLLABLE:TaskAttackGroup( AttackGroup, WeaponType, WeaponExpend, At
altitudeEnabled = Altitude and true or false, altitudeEnabled = Altitude and true or false,
altitude = Altitude, altitude = Altitude,
}, },
}, }
self:T3( { DCSTask } )
return DCSTask return DCSTask
end end
@@ -892,10 +877,8 @@ end
-- @param #number WeaponType (optional) The WeaponType. See [DCS Enumerator Weapon Type](https://wiki.hoggitworld.com/view/DCS_enum_weapon_flag) on Hoggit. -- @param #number WeaponType (optional) The WeaponType. See [DCS Enumerator Weapon Type](https://wiki.hoggitworld.com/view/DCS_enum_weapon_flag) on Hoggit.
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskAttackUnit(AttackUnit, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType) function CONTROLLABLE:TaskAttackUnit(AttackUnit, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType)
self:F2({self.ControllableName, AttackUnit, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType})
local DCSTask local DCSTask = {
DCSTask = {
id = 'AttackUnit', id = 'AttackUnit',
params = { params = {
unitId = AttackUnit:GetID(), unitId = AttackUnit:GetID(),
@@ -910,9 +893,7 @@ function CONTROLLABLE:TaskAttackUnit(AttackUnit, GroupAttack, WeaponExpend, Atta
weaponType = WeaponType or 1073741822, weaponType = WeaponType or 1073741822,
} }
} }
self:T3( DCSTask )
return DCSTask return DCSTask
end end
@@ -929,16 +910,8 @@ end
-- @param #boolean Divebomb (optional) Perform dive bombing. Default false. -- @param #boolean Divebomb (optional) Perform dive bombing. Default false.
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskBombing( Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType, Divebomb ) function CONTROLLABLE:TaskBombing( Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType, Divebomb )
self:F( { self.ControllableName, Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType, Divebomb } )
local _attacktype=nil local DCSTask = {
if Divebomb then
_attacktype="Dive"
end
local DCSTask
DCSTask = {
id = 'Bombing', id = 'Bombing',
params = { params = {
point = Vec2, point = Vec2,
@@ -953,11 +926,10 @@ function CONTROLLABLE:TaskBombing( Vec2, GroupAttack, WeaponExpend, AttackQty, D
altitudeEnabled = Altitude and true or false, altitudeEnabled = Altitude and true or false,
altitude = Altitude, altitude = Altitude,
weaponType = WeaponType or 1073741822, weaponType = WeaponType or 1073741822,
attackType = _attacktype, attackType = Divebomb and "Dive" or nil,
}, },
} }
self:F( { TaskBombing=DCSTask } )
return DCSTask return DCSTask
end end
@@ -972,10 +944,8 @@ end
-- @param #number WeaponType (Optional) The WeaponType. Default Auto=1073741822. -- @param #number WeaponType (Optional) The WeaponType. Default Auto=1073741822.
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskAttackMapObject( Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType ) function CONTROLLABLE:TaskAttackMapObject( Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType )
self:F2( { self.ControllableName, Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType } )
local DCSTask local DCSTask = {
DCSTask = {
id = 'AttackMapObject', id = 'AttackMapObject',
params = { params = {
point = Vec2, point = Vec2,
@@ -991,9 +961,8 @@ function CONTROLLABLE:TaskAttackMapObject( Vec2, GroupAttack, WeaponExpend, Atta
altitude = Altitude, altitude = Altitude,
weaponType = WeaponType or 1073741822, weaponType = WeaponType or 1073741822,
}, },
}, }
self:T3( { DCSTask } )
return DCSTask return DCSTask
end end
@@ -1108,7 +1077,6 @@ function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, Distri
} }
} }
self:T3( { DCSTask } )
return DCSTask return DCSTask
end end
@@ -1219,7 +1187,6 @@ end
-- @param #boolean GroupAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the controllable. Has effect only if the task is assigned to a group and not to a single aircraft. -- @param #boolean GroupAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the controllable. Has effect only if the task is assigned to a group and not to a single aircraft.
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskBombingRunway(Airbase, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack) function CONTROLLABLE:TaskBombingRunway(Airbase, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack)
self:F2( { self.ControllableName, Airbase, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack } )
local DCSTask = { local DCSTask = {
id = 'BombingRunway', id = 'BombingRunway',
@@ -1242,7 +1209,10 @@ end
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskRefueling() function CONTROLLABLE:TaskRefueling()
local DCSTask={id='Refueling', params={}} local DCSTask={
id='Refueling',
params={}
}
return DCSTask return DCSTask
end end
@@ -1263,6 +1233,7 @@ function CONTROLLABLE:TaskLandAtVec2(Vec2, Duration)
duration = Duration, duration = Duration,
}, },
} }
return DCSTask return DCSTask
end end
@@ -1272,18 +1243,12 @@ end
-- @param #number Duration The duration in seconds to stay on the ground. -- @param #number Duration The duration in seconds to stay on the ground.
-- @return #CONTROLLABLE self -- @return #CONTROLLABLE self
function CONTROLLABLE:TaskLandAtZone( Zone, Duration, RandomPoint ) function CONTROLLABLE:TaskLandAtZone( Zone, Duration, RandomPoint )
self:F2( { self.ControllableName, Zone, Duration, RandomPoint } )
local Point -- Get landing point
if RandomPoint then local Point=RandomPoint and Zone:GetRandomVec2() or Zone:GetVec2()
Point = Zone:GetRandomVec2()
else
Point = Zone:GetVec2()
end
local DCSTask = self:TaskLandAtVec2( Point, Duration ) local DCSTask = CONTROLLABLE.TaskLandAtVec2( self, Point, Duration )
self:T3( DCSTask )
return DCSTask return DCSTask
end end
@@ -1344,7 +1309,6 @@ end
-- @param DCS#AttributeNameArray TargetTypes Array of AttributeName that is contains threat categories allowed to engage. Default {"Air"}. -- @param DCS#AttributeNameArray TargetTypes Array of AttributeName that is contains threat categories allowed to engage. Default {"Air"}.
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskEscort( FollowControllable, Vec3, LastWaypointIndex, EngagementDistance, TargetTypes ) function CONTROLLABLE:TaskEscort( FollowControllable, Vec3, LastWaypointIndex, EngagementDistance, TargetTypes )
self:F2( { self.ControllableName, FollowControllable, Vec3, LastWaypointIndex, EngagementDistance, TargetTypes } )
-- Escort = { -- Escort = {
-- id = 'Escort', -- id = 'Escort',
@@ -1369,9 +1333,8 @@ function CONTROLLABLE:TaskEscort( FollowControllable, Vec3, LastWaypointIndex, E
engagementDistMax = EngagementDistance, engagementDistMax = EngagementDistance,
targetTypes = TargetTypes or {"Air"}, targetTypes = TargetTypes or {"Air"},
}, },
}, }
self:T3( { DCSTask } )
return DCSTask return DCSTask
end end
@@ -1386,7 +1349,6 @@ end
-- @param #number WeaponType (optional) Enum for weapon type ID. This value is only required if you want the group firing to use a specific weapon, for instance using the task on a ship to force it to fire guided missiles at targets within cannon range. See http://wiki.hoggit.us/view/DCS_enum_weapon_flag -- @param #number WeaponType (optional) Enum for weapon type ID. This value is only required if you want the group firing to use a specific weapon, for instance using the task on a ship to force it to fire guided missiles at targets within cannon range. See http://wiki.hoggit.us/view/DCS_enum_weapon_flag
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskFireAtPoint( Vec2, Radius, AmmoCount, WeaponType ) function CONTROLLABLE:TaskFireAtPoint( Vec2, Radius, AmmoCount, WeaponType )
self:F2( { self.ControllableName, Vec2, Radius, AmmoCount, WeaponType } )
-- FireAtPoint = { -- FireAtPoint = {
-- id = 'FireAtPoint', -- id = 'FireAtPoint',
@@ -1398,13 +1360,12 @@ function CONTROLLABLE:TaskFireAtPoint( Vec2, Radius, AmmoCount, WeaponType )
-- } -- }
-- } -- }
local DCSTask local DCSTask = {
DCSTask = {
id = 'FireAtPoint', id = 'FireAtPoint',
params = { params = {
point = Vec2, point = Vec2,
zoneRadius = Radius, zoneRadius = Radius,
expendQty = 100, -- dummy value expendQty = 100, -- dummy value
expendQtyEnabled = false, expendQtyEnabled = false,
} }
} }
@@ -1443,7 +1404,6 @@ end
-- @param #boolean Datalink (optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default. -- @param #boolean Datalink (optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default.
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskFAC_AttackGroup( AttackGroup, WeaponType, Designation, Datalink ) function CONTROLLABLE:TaskFAC_AttackGroup( AttackGroup, WeaponType, Designation, Datalink )
self:F2( { self.ControllableName, AttackGroup, WeaponType, Designation, Datalink } )
local DCSTask = { local DCSTask = {
id = 'FAC_AttackGroup', id = 'FAC_AttackGroup',
@@ -1455,7 +1415,6 @@ function CONTROLLABLE:TaskFAC_AttackGroup( AttackGroup, WeaponType, Designation,
} }
} }
self:T3( { DCSTask } )
return DCSTask return DCSTask
end end
@@ -1468,7 +1427,6 @@ end
-- @param #number Priority All enroute tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. Default 0. -- @param #number Priority All enroute tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. Default 0.
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:EnRouteTaskEngageTargets( Distance, TargetTypes, Priority ) function CONTROLLABLE:EnRouteTaskEngageTargets( Distance, TargetTypes, Priority )
self:F2( { self.ControllableName, Distance, TargetTypes, Priority } )
local DCSTask = { local DCSTask = {
id = 'EngageTargets', id = 'EngageTargets',
@@ -1480,7 +1438,6 @@ function CONTROLLABLE:EnRouteTaskEngageTargets( Distance, TargetTypes, Priority
} }
} }
self:T3( { DCSTask } )
return DCSTask return DCSTask
end end
@@ -1494,7 +1451,6 @@ end
-- @param #number Priority (Optional) All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. Default 0. -- @param #number Priority (Optional) All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. Default 0.
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:EnRouteTaskEngageTargetsInZone( Vec2, Radius, TargetTypes, Priority ) function CONTROLLABLE:EnRouteTaskEngageTargetsInZone( Vec2, Radius, TargetTypes, Priority )
self:F2( { self.ControllableName, Vec2, Radius, TargetTypes, Priority } )
local DCSTask = { local DCSTask = {
id = 'EngageTargetsInZone', id = 'EngageTargetsInZone',
@@ -1506,7 +1462,6 @@ function CONTROLLABLE:EnRouteTaskEngageTargetsInZone( Vec2, Radius, TargetTypes,
} }
} }
self:T3( { DCSTask } )
return DCSTask return DCSTask
end end
@@ -1523,7 +1478,6 @@ end
-- @param #boolean AttackQtyLimit (optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks. -- @param #boolean AttackQtyLimit (optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks.
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:EnRouteTaskEngageGroup( AttackGroup, Priority, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit ) function CONTROLLABLE:EnRouteTaskEngageGroup( AttackGroup, Priority, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit )
self:F2( { self.ControllableName, AttackGroup, Priority, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit } )
-- EngageControllable = { -- EngageControllable = {
-- id = 'EngageControllable ', -- id = 'EngageControllable ',
@@ -1555,9 +1509,8 @@ function CONTROLLABLE:EnRouteTaskEngageGroup( AttackGroup, Priority, WeaponType,
attackQty = AttackQty, attackQty = AttackQty,
priority = Priority or 1, priority = Priority or 1,
}, },
}, }
self:T3( { DCSTask } )
return DCSTask return DCSTask
end end
@@ -1575,7 +1528,6 @@ end
-- @param #boolean ControllableAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the controllable. Has effect only if the task is assigned to a controllable, not to a single aircraft. -- @param #boolean ControllableAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the controllable. Has effect only if the task is assigned to a controllable, not to a single aircraft.
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:EnRouteTaskEngageUnit( EngageUnit, Priority, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, Visible, ControllableAttack ) function CONTROLLABLE:EnRouteTaskEngageUnit( EngageUnit, Priority, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, Visible, ControllableAttack )
self:F2( { self.ControllableName, EngageUnit, Priority, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, Visible, ControllableAttack } )
local DCSTask = { local DCSTask = {
id = 'EngageUnit', id = 'EngageUnit',
@@ -1593,9 +1545,8 @@ function CONTROLLABLE:EnRouteTaskEngageUnit( EngageUnit, Priority, GroupAttack,
attackQty = AttackQty, attackQty = AttackQty,
controllableAttack = ControllableAttack, controllableAttack = ControllableAttack,
}, },
}, }
self:T3( { DCSTask } )
return DCSTask return DCSTask
end end
@@ -1605,11 +1556,12 @@ end
-- @param #CONTROLLABLE self -- @param #CONTROLLABLE self
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:EnRouteTaskAWACS( ) function CONTROLLABLE:EnRouteTaskAWACS( )
self:F2( { self.ControllableName } )
local DCSTask = {id = 'AWACS', params = {}} local DCSTask = {
id = 'AWACS',
params = {}
}
self:T3( { DCSTask } )
return DCSTask return DCSTask
end end
@@ -1618,11 +1570,12 @@ end
-- @param #CONTROLLABLE self -- @param #CONTROLLABLE self
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:EnRouteTaskTanker( ) function CONTROLLABLE:EnRouteTaskTanker( )
self:F2( { self.ControllableName } )
local DCSTask = {id = 'Tanker', params = {}} local DCSTask = {
id = 'Tanker',
params = {}
}
self:T3( { DCSTask } )
return DCSTask return DCSTask
end end
@@ -1633,11 +1586,12 @@ end
-- @param #CONTROLLABLE self -- @param #CONTROLLABLE self
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:EnRouteTaskEWR( ) function CONTROLLABLE:EnRouteTaskEWR( )
self:F2( { self.ControllableName } )
local DCSTask = {id = 'EWR', params = {}} local DCSTask = {
id = 'EWR',
params = {}
}
self:T3( { DCSTask } )
return DCSTask return DCSTask
end end
@@ -1655,7 +1609,6 @@ end
-- @param #boolean Datalink (optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default. -- @param #boolean Datalink (optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default.
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:EnRouteTaskFAC_EngageGroup( AttackGroup, Priority, WeaponType, Designation, Datalink ) function CONTROLLABLE:EnRouteTaskFAC_EngageGroup( AttackGroup, Priority, WeaponType, Designation, Datalink )
self:F2( { self.ControllableName, AttackGroup, WeaponType, Priority, Designation, Datalink } )
local DCSTask = { local DCSTask = {
id = 'FAC_EngageControllable', id = 'FAC_EngageControllable',
@@ -1668,7 +1621,6 @@ function CONTROLLABLE:EnRouteTaskFAC_EngageGroup( AttackGroup, Priority, WeaponT
} }
} }
self:T3( { DCSTask } )
return DCSTask return DCSTask
end end
@@ -1681,7 +1633,6 @@ end
-- @param #number Priority All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. -- @param #number Priority All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first.
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:EnRouteTaskFAC( Radius, Priority ) function CONTROLLABLE:EnRouteTaskFAC( Radius, Priority )
self:F2( { self.ControllableName, Radius, Priority } )
-- FAC = { -- FAC = {
-- id = 'FAC', -- id = 'FAC',
@@ -1691,15 +1642,14 @@ function CONTROLLABLE:EnRouteTaskFAC( Radius, Priority )
-- } -- }
-- } -- }
local DCSTask local DCSTask = {
DCSTask = { id = 'FAC', id = 'FAC',
params = { params = {
radius = Radius, radius = Radius,
priority = Priority priority = Priority
} }
} }
self:T3( { DCSTask } )
return DCSTask return DCSTask
end end
@@ -1807,21 +1757,20 @@ end
-- @param #CONTROLLABLE EmbarkingControllable The controllable to be embarked. -- @param #CONTROLLABLE EmbarkingControllable The controllable to be embarked.
-- @return DCS#Task The DCS task structure -- @return DCS#Task The DCS task structure
function CONTROLLABLE:TaskEmbarking( Point, Duration, EmbarkingControllable ) function CONTROLLABLE:TaskEmbarking( Point, Duration, EmbarkingControllable )
self:F2( { self.ControllableName, Point, Duration, EmbarkingControllable.DCSControllable } )
local DCSTask local DCSTask = {
DCSTask = { id = 'Embarking', id = 'Embarking',
params = { x = Point.x, params = {
y = Point.y, x = Point.x,
duration = Duration, y = Point.y,
duration = Duration,
controllablesForEmbarking = { EmbarkingControllable.ControllableID }, controllablesForEmbarking = { EmbarkingControllable.ControllableID },
durationFlag = true, durationFlag = true,
distributionFlag = false, distributionFlag = false,
distribution = {}, distribution = {},
} }
} }
self:T3( { DCSTask } )
return DCSTask return DCSTask
end end
@@ -1832,10 +1781,8 @@ end
-- @param #number Radius The radius of the embarking zone around the Point. -- @param #number Radius The radius of the embarking zone around the Point.
-- @return DCS#Task The DCS task structure. -- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskEmbarkToTransport( Point, Radius ) function CONTROLLABLE:TaskEmbarkToTransport( Point, Radius )
self:F2( { self.ControllableName, Point, Radius } )
local DCSTask --DCS#Task local DCSTask = {
DCSTask = {
id = 'EmbarkToTransport', id = 'EmbarkToTransport',
params = { params = {
point = Point, point = Point,
@@ -1845,7 +1792,6 @@ function CONTROLLABLE:TaskEmbarkToTransport( Point, Radius )
} }
} }
self:T3( { DCSTask } )
return DCSTask return DCSTask
end end
@@ -1900,12 +1846,9 @@ end
-- --
function CONTROLLABLE:TaskFunction( FunctionString, ... ) function CONTROLLABLE:TaskFunction( FunctionString, ... )
local DCSTask -- Script
local DCSScript = {} local DCSScript = {}
DCSScript[#DCSScript+1] = "local MissionControllable = GROUP:Find( ... ) " DCSScript[#DCSScript+1] = "local MissionControllable = GROUP:Find( ... ) "
--DCSScript[#DCSScript+1] = "env.info( 'TaskFunction: ' .. ( MissionControllable and MissionControllable:GetName() ) or 'No Group' )"
if arg and arg.n > 0 then if arg and arg.n > 0 then
local ArgumentKey = '_' .. tostring( arg ):match("table: (.*)") local ArgumentKey = '_' .. tostring( arg ):match("table: (.*)")
self:SetState( self, ArgumentKey, arg ) self:SetState( self, ArgumentKey, arg )
@@ -1915,12 +1858,10 @@ function CONTROLLABLE:TaskFunction( FunctionString, ... )
DCSScript[#DCSScript+1] = FunctionString .. "( MissionControllable )" DCSScript[#DCSScript+1] = FunctionString .. "( MissionControllable )"
end end
DCSTask = self:TaskWrappedAction(self:CommandDoScript(table.concat( DCSScript ))) -- DCS task.
local DCSTask = self:TaskWrappedAction(self:CommandDoScript(table.concat( DCSScript )))
self:T( DCSTask )
return DCSTask return DCSTask
end end
@@ -1930,12 +1871,12 @@ end
-- @param #table TaskMission A table containing the mission task. -- @param #table TaskMission A table containing the mission task.
-- @return DCS#Task -- @return DCS#Task
function CONTROLLABLE:TaskMission( TaskMission ) function CONTROLLABLE:TaskMission( TaskMission )
self:F2( Points )
local DCSTask local DCSTask = {
DCSTask = { id = 'Mission', params = { TaskMission, }, } id = 'Mission',
params = { TaskMission, },
}
self:T3( { DCSTask } )
return DCSTask return DCSTask
end end