mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Updates
This commit is contained in:
@@ -312,6 +312,7 @@ function CONTROLLABLE:ClearTasks()
|
||||
|
||||
if DCSControllable then
|
||||
local Controller = self:_GetController()
|
||||
env.info("FF clearing tasks!")
|
||||
Controller:resetTask()
|
||||
return self
|
||||
end
|
||||
@@ -879,15 +880,15 @@ function CONTROLLABLE:TaskAttackGroup( AttackGroup, WeaponType, WeaponExpend, At
|
||||
local DCSTask
|
||||
DCSTask = { id = 'AttackGroup',
|
||||
params = {
|
||||
groupId = AttackGroup:GetID(),
|
||||
weaponType = WeaponType,
|
||||
expend = WeaponExpend,
|
||||
attackQty = AttackQty,
|
||||
groupId = AttackGroup:GetID(),
|
||||
weaponType = WeaponType,
|
||||
expend = WeaponExpend,
|
||||
attackQty = AttackQty,
|
||||
directionEnabled = DirectionEnabled,
|
||||
direction = Direction,
|
||||
altitudeEnabled = AltitudeEnabled,
|
||||
altitude = Altitude,
|
||||
attackQtyLimit = AttackQtyLimit,
|
||||
direction = Direction,
|
||||
altitudeEnabled = AltitudeEnabled,
|
||||
altitude = Altitude,
|
||||
attackQtyLimit = AttackQtyLimit,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -912,16 +913,16 @@ function CONTROLLABLE:TaskAttackUnit(AttackUnit, GroupAttack, WeaponExpend, Atta
|
||||
DCSTask = {
|
||||
id = 'AttackUnit',
|
||||
params = {
|
||||
unitId = AttackUnit:GetID(),
|
||||
groupAttack = GroupAttack or false,
|
||||
expend = WeaponExpend or "Auto",
|
||||
unitId = AttackUnit:GetID(),
|
||||
groupAttack = GroupAttack or false,
|
||||
expend = WeaponExpend or "Auto",
|
||||
directionEnabled = Direction and true or false,
|
||||
direction = math.rad(Direction or 0),
|
||||
altitudeEnabled = Altitude and true or false,
|
||||
altitude = Altitude or math.max(1000, AttackUnit:GetAltitude()),
|
||||
attackQtyLimit = AttackQty and true or false,
|
||||
attackQty = AttackQty,
|
||||
weaponType = WeaponType
|
||||
direction = math.rad(Direction or 0),
|
||||
altitudeEnabled = Altitude and true or false,
|
||||
altitude = Altitude or math.max(1000, AttackUnit:GetAltitude()),
|
||||
attackQtyLimit = AttackQty and true or false,
|
||||
attackQty = AttackQty,
|
||||
weaponType = WeaponType
|
||||
}
|
||||
}
|
||||
|
||||
@@ -974,18 +975,18 @@ function CONTROLLABLE:TaskBombing( Vec2, GroupAttack, WeaponExpend, AttackQty, D
|
||||
DCSTask = {
|
||||
id = 'Bombing',
|
||||
params = {
|
||||
x = Vec2.x,
|
||||
y = Vec2.y,
|
||||
groupAttack = _groupattack,
|
||||
expend = WeaponExpend or "Auto",
|
||||
attackQtyLimit = false, --AttackQty and true or false,
|
||||
attackQty = AttackQty or 1,
|
||||
x = Vec2.x,
|
||||
y = Vec2.y,
|
||||
groupAttack = _groupattack,
|
||||
expend = WeaponExpend or "Auto",
|
||||
attackQtyLimit = false,
|
||||
attackQty = AttackQty or 1,
|
||||
directionEnabled = _directionenabled,
|
||||
direction = _direction,
|
||||
altitudeEnabled = _altitudeenabled,
|
||||
altitude = _altitude,
|
||||
weaponType = WeaponType,
|
||||
--attackType=_attacktype,
|
||||
direction = _direction,
|
||||
altitudeEnabled = _altitudeenabled,
|
||||
altitude = _altitude,
|
||||
weaponType = WeaponType,
|
||||
attackType = _attacktype,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1010,18 +1011,18 @@ function CONTROLLABLE:TaskAttackMapObject( Vec2, GroupAttack, WeaponExpend, Atta
|
||||
DCSTask = {
|
||||
id = 'AttackMapObject',
|
||||
params = {
|
||||
point = Vec2,
|
||||
x = Vec2.x,
|
||||
y = Vec2.y,
|
||||
groupAttack = GroupAttack or false,
|
||||
expend = WeaponExpend or "Auto",
|
||||
attackQtyLimit = AttackQty and true or false,
|
||||
attackQty = AttackQty,
|
||||
point = Vec2,
|
||||
x = Vec2.x,
|
||||
y = Vec2.y,
|
||||
groupAttack = GroupAttack or false,
|
||||
expend = WeaponExpend or "Auto",
|
||||
attackQtyLimit = AttackQty and true or false,
|
||||
attackQty = AttackQty,
|
||||
directionEnabled = Direction and true or false,
|
||||
direction = Direction,
|
||||
altitudeEnabled = Altitude and true or false,
|
||||
altitude = Altitude or 30,
|
||||
weaponType = WeaponType or 1073741822,
|
||||
direction = Direction,
|
||||
altitudeEnabled = Altitude and true or false,
|
||||
altitude = Altitude or 30,
|
||||
weaponType = WeaponType or 1073741822,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1030,6 +1031,186 @@ function CONTROLLABLE:TaskAttackMapObject( Vec2, GroupAttack, WeaponExpend, Atta
|
||||
end
|
||||
|
||||
|
||||
--- (AIR) Delivering weapon via CarpetBombing (all bombers in formation release at same time) at the point on the ground.
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @param DCS#Vec2 Vec2 2D-coordinates of the point to deliver weapon at.
|
||||
-- @param #boolean GroupAttack (optional) If true, all units in the group will attack the Unit when found.
|
||||
-- @param DCS#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / controllable will choose expend on its own discretion.
|
||||
-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/controllable will not make more attack than allowed even if the target controllable not destroyed and the aicraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo.
|
||||
-- @param DCS#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Controllable/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain controllable/aircraft will choose another direction.
|
||||
-- @param #number Altitude (optional) The altitude from where to attack.
|
||||
-- @param #number WeaponType (optional) The WeaponType.
|
||||
-- @param #number CarpetLength (optional) default to 500 m.
|
||||
-- @return DCS#Task The DCS task structure.
|
||||
function CONTROLLABLE:TaskCarpetBombing(Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType, CarpetLength)
|
||||
self:F2( { self.ControllableName, Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType, CarpetLength } )
|
||||
|
||||
local _groupattack=false
|
||||
if GroupAttack then
|
||||
_groupattack=GroupAttack
|
||||
end
|
||||
|
||||
local _direction=0
|
||||
local _directionenabled=false
|
||||
if Direction then
|
||||
_direction=math.rad(Direction)
|
||||
_directionenabled=true
|
||||
end
|
||||
|
||||
local _altitude=0
|
||||
local _altitudeenabled=false
|
||||
if Altitude then
|
||||
_altitude=Altitude
|
||||
_altitudeenabled=true
|
||||
end
|
||||
|
||||
-- default to 500m
|
||||
local _carpetLength = 500
|
||||
if CarpetLength then
|
||||
_carpetLength = CarpetLength
|
||||
end
|
||||
|
||||
local _weaponexpend = "Auto"
|
||||
if WeaponExpend then
|
||||
_weaponexpend = WeaponExpend
|
||||
end
|
||||
|
||||
-- Build Task Structure
|
||||
local DCSTask
|
||||
DCSTask = {
|
||||
id = 'CarpetBombing',
|
||||
params = {
|
||||
attackType = "Carpet",
|
||||
point = Vec2,
|
||||
x = Vec2.x,
|
||||
y = Vec2.y,
|
||||
groupAttack = _groupattack,
|
||||
carpetLength = _carpetLength,
|
||||
weaponType = WeaponType,
|
||||
expend = "All",
|
||||
attackQtyLimit = false, --AttackQty and true or false,
|
||||
attackQty = AttackQty or 1,
|
||||
directionEnabled = _directionenabled,
|
||||
direction = _direction,
|
||||
altitudeEnabled = _altitudeenabled,
|
||||
altitude = _altitude
|
||||
}
|
||||
}
|
||||
|
||||
return DCSTask
|
||||
end
|
||||
|
||||
|
||||
|
||||
--- (AIR) Following another airborne controllable.
|
||||
-- The unit / controllable will follow lead unit of another controllable, wingmens of both controllables will continue following their leaders.
|
||||
-- Used to support CarpetBombing Task
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @param #CONTROLLABLE FollowControllable The controllable to be followed.
|
||||
-- @param DCS#Vec3 Vec3 Position of the unit / lead unit of the controllable relative lead unit of another controllable in frame reference oriented by course of lead unit of another controllable. If another controllable is on land the unit / controllable will orbit around.
|
||||
-- @param #number LastWaypointIndex Detach waypoint of another controllable. Once reached the unit / controllable Follow task is finished.
|
||||
-- @return DCS#Task The DCS task structure.
|
||||
function CONTROLLABLE:TaskFollowBigFormation(FollowControllable, Vec3, LastWaypointIndex )
|
||||
|
||||
local DCSTask = {
|
||||
id = 'FollowBigFormation',
|
||||
params = {
|
||||
groupId = FollowControllable:GetID(),
|
||||
pos = Vec3,
|
||||
lastWptIndexFlag = LastWaypointIndex and true or false,
|
||||
lastWptIndex = LastWaypointIndex
|
||||
}
|
||||
}
|
||||
|
||||
return DCSTask
|
||||
end
|
||||
|
||||
|
||||
--- (AIR) Move the controllable to a Vec2 Point, wait for a defined duration and embark a controllable.
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @param DCS#Vec2 Vec2 The point where to wait. Needs to have x and y components.
|
||||
-- @param Core.Set#SET_GROUP GroupSetForEmparking Set of groups to embark.
|
||||
-- @param #number Duration (Optional) The maximum duration in seconds to wait until all groups have embarked.
|
||||
-- @param Core.Set#SET_GROUP (Optional) DistributionGroupSet Set of groups identifying the groups needing to board specific helicopters.
|
||||
-- @return DCS#Task The DCS task structure.
|
||||
function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, DistributionGroupSet)
|
||||
|
||||
-- Table of group IDs for embarking.
|
||||
local g4e={}
|
||||
|
||||
if GroupSetForEmbarking then
|
||||
for _,_group in pairs(GroupSetForEmbarking:GetSet()) do
|
||||
local group=_group --Wrapper.Group#GROUP
|
||||
table.insert(g4e, group:GetID())
|
||||
end
|
||||
else
|
||||
self:E("ERROR: No groups for embarking specified!")
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
local DCSTask = {
|
||||
id = 'Embarking',
|
||||
params = {
|
||||
Vec2 = Vec2,
|
||||
x = Vec2.x,
|
||||
y = Vec2.y,
|
||||
groupsForEmbarking = g4e,
|
||||
durationFlag = Duration and true or false,
|
||||
duration = Duration,
|
||||
distributionFlag = DistributionGroupSet and true or false,
|
||||
distribution = Distribution,
|
||||
}
|
||||
}
|
||||
|
||||
self:T3( { DCSTask } )
|
||||
return DCSTask
|
||||
end
|
||||
|
||||
|
||||
|
||||
--- (AIR) Move the controllable to a Vec2 Point, wait for a defined duration and embark a controllable.
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @param DCS#Vec2 Vec2 The point where to wait.
|
||||
-- @param #number Duration The duration in seconds to wait.
|
||||
-- @param #CONTROLLABLE EmbarkingControllable The controllable to be embarked.
|
||||
-- @return DCS#Task The DCS task structure
|
||||
function CONTROLLABLE:TaskDisembarking(Vec2, Duration, EmbarkingControllable)
|
||||
|
||||
-- Table of group IDs for embarking.
|
||||
local g4e={}
|
||||
|
||||
if GroupSetForEmbarking then
|
||||
for _,_group in pairs(GroupSetForEmbarking:GetSet()) do
|
||||
local group=_group --Wrapper.Group#GROUP
|
||||
table.insert(g4e, group:GetID())
|
||||
end
|
||||
else
|
||||
self:E("ERROR: No groups for embarking specified!")
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
local DCSTask = {
|
||||
id = 'Disembarking',
|
||||
params = {
|
||||
point = Vec2,
|
||||
x = Vec2.x,
|
||||
y = Vec2.y,
|
||||
duration = Duration,
|
||||
groupsForEmbarking = { EmbarkingControllable:GetID() },
|
||||
durationFlag = durationflag,
|
||||
distributionFlag = false,
|
||||
distribution = {},
|
||||
}
|
||||
}
|
||||
|
||||
return DCSTask
|
||||
end
|
||||
|
||||
----
|
||||
|
||||
--- (AIR) Orbit at a specified position at a specified alititude during a specified duration with a specified speed.
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @param DCS#Vec2 Point The point to hold the position.
|
||||
@@ -1039,39 +1220,20 @@ end
|
||||
function CONTROLLABLE:TaskOrbitCircleAtVec2( Point, Altitude, Speed )
|
||||
self:F2( { self.ControllableName, Point, Altitude, Speed } )
|
||||
|
||||
-- pattern = enum AI.Task.OribtPattern,
|
||||
-- point = Vec2,
|
||||
-- point2 = Vec2,
|
||||
-- speed = Distance,
|
||||
-- altitude = Distance
|
||||
|
||||
local LandHeight = land.getHeight( Point )
|
||||
|
||||
self:T3( { LandHeight } )
|
||||
|
||||
local DCSTask = { id = 'Orbit',
|
||||
params = { pattern = AI.Task.OrbitPattern.CIRCLE,
|
||||
point = Point,
|
||||
speed = Speed,
|
||||
local DCSTask = {
|
||||
id = 'Orbit',
|
||||
params = {
|
||||
pattern = AI.Task.OrbitPattern.CIRCLE,
|
||||
point = Point,
|
||||
speed = Speed,
|
||||
altitude = Altitude + LandHeight
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-- local AITask = { id = 'ControlledTask',
|
||||
-- params = { task = { id = 'Orbit',
|
||||
-- params = { pattern = AI.Task.OrbitPattern.CIRCLE,
|
||||
-- point = Point,
|
||||
-- speed = Speed,
|
||||
-- altitude = Altitude + LandHeight
|
||||
-- }
|
||||
-- },
|
||||
-- stopCondition = { duration = Duration
|
||||
-- }
|
||||
-- }
|
||||
-- }
|
||||
-- )
|
||||
|
||||
return DCSTask
|
||||
end
|
||||
|
||||
@@ -1111,7 +1273,7 @@ end
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @param #number Altitude The altitude [m] to hold the position.
|
||||
-- @param #number Speed The speed [m/s] flying when holding the position.
|
||||
-- @param Core.Point#COORDINATE Coordinate (optional) The coordinate where to orbit. If the coordinate is not given, then the current position of the controllable is used.
|
||||
-- @param Core.Point#COORDINATE Coordinate (Optional) The coordinate where to orbit. If the coordinate is not given, then the current position of the controllable is used.
|
||||
-- @return #CONTROLLABLE self
|
||||
function CONTROLLABLE:TaskOrbitCircle( Altitude, Speed, Coordinate )
|
||||
self:F2( { self.ControllableName, Altitude, Speed } )
|
||||
@@ -1139,10 +1301,6 @@ function CONTROLLABLE:TaskHoldPosition()
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--- (AIR) Delivering weapon on the runway. See [hoggit](https://wiki.hoggitworld.com/view/DCS_task_bombingRunway)
|
||||
--
|
||||
-- Make sure the aircraft has the following role:
|
||||
@@ -1165,36 +1323,18 @@ end
|
||||
function CONTROLLABLE:TaskBombingRunway(Airbase, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack)
|
||||
self:F2( { self.ControllableName, Airbase, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack } )
|
||||
|
||||
-- BombingRunway = {
|
||||
-- id = 'BombingRunway',
|
||||
-- params = {
|
||||
-- runwayId = AirdromeId,
|
||||
-- weaponType = number,
|
||||
-- expend = enum AI.Task.WeaponExpend,
|
||||
-- attackQty = number,
|
||||
-- direction = Azimuth,
|
||||
-- groupAttack = boolean,
|
||||
-- }
|
||||
-- }
|
||||
|
||||
-- Defaults.
|
||||
WeaponType=WeaponType or 2147485694
|
||||
WeaponExpend=WeaponExpend or AI.Task.WeaponExpend.ALL
|
||||
AttackQty=AttackQty or 1
|
||||
|
||||
local DCSTask
|
||||
DCSTask = { id = 'BombingRunway',
|
||||
local DCSTask = {
|
||||
id = 'BombingRunway',
|
||||
params = {
|
||||
runwayId = Airbase:GetID(),
|
||||
weaponType = WeaponType,
|
||||
expend = WeaponExpend,
|
||||
attackQty = AttackQty,
|
||||
direction = Direction,
|
||||
runwayId = Airbase:GetID(),
|
||||
weaponType = WeaponType or ENUMS.WeaponFlag.AnyBomb,
|
||||
expend = WeaponExpend or AI.Task.WeaponExpend.ALL,
|
||||
attackQty = AttackQty or 1,
|
||||
direction = Direction and math.rad(Direction) or nil,
|
||||
groupAttack = GroupAttack,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
self:T3( { DCSTask } )
|
||||
return DCSTask
|
||||
end
|
||||
|
||||
@@ -1203,16 +1343,9 @@ end
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @return DCS#Task The DCS task structure.
|
||||
function CONTROLLABLE:TaskRefueling()
|
||||
self:F2( { self.ControllableName } )
|
||||
|
||||
-- Refueling = {
|
||||
-- id = 'Refueling',
|
||||
-- params = {}
|
||||
-- }
|
||||
|
||||
local DCSTask={id='Refueling', params={}}
|
||||
|
||||
self:T3( { DCSTask } )
|
||||
|
||||
return DCSTask
|
||||
end
|
||||
|
||||
@@ -1222,37 +1355,16 @@ end
|
||||
-- @param DCS#Vec2 Point The point where to land.
|
||||
-- @param #number Duration The duration in seconds to stay on the ground.
|
||||
-- @return #CONTROLLABLE self
|
||||
function CONTROLLABLE:TaskLandAtVec2( Point, Duration )
|
||||
self:F2( { self.ControllableName, Point, Duration } )
|
||||
function CONTROLLABLE:TaskLandAtVec2(Vec2, Duration)
|
||||
|
||||
-- Land = {
|
||||
-- id= 'Land',
|
||||
-- params = {
|
||||
-- point = Vec2,
|
||||
-- durationFlag = boolean,
|
||||
-- duration = Time
|
||||
-- }
|
||||
-- }
|
||||
|
||||
local DCSTask
|
||||
if Duration and Duration > 0 then
|
||||
DCSTask = { id = 'Land',
|
||||
params = {
|
||||
point = Point,
|
||||
durationFlag = true,
|
||||
duration = Duration,
|
||||
},
|
||||
}
|
||||
else
|
||||
DCSTask = { id = 'Land',
|
||||
params = {
|
||||
point = Point,
|
||||
durationFlag = false,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
self:T3( DCSTask )
|
||||
local DCSTask = {
|
||||
id = 'Land',
|
||||
params = {
|
||||
point = Vec2,
|
||||
durationFlag = Duration and true or false,
|
||||
duration = Duration,
|
||||
},
|
||||
}
|
||||
return DCSTask
|
||||
end
|
||||
|
||||
@@ -1423,21 +1535,7 @@ end
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @return DCS#Task The DCS task structure.
|
||||
function CONTROLLABLE:TaskHold()
|
||||
self:F2( { self.ControllableName } )
|
||||
|
||||
-- Hold = {
|
||||
-- id = 'Hold',
|
||||
-- params = {
|
||||
-- }
|
||||
-- }
|
||||
|
||||
local DCSTask
|
||||
DCSTask = { id = 'Hold',
|
||||
params = {
|
||||
}
|
||||
}
|
||||
|
||||
self:T3( { DCSTask } )
|
||||
local DCSTask = {id = 'Hold', params = {}}
|
||||
return DCSTask
|
||||
end
|
||||
|
||||
@@ -1456,23 +1554,13 @@ end
|
||||
function CONTROLLABLE:TaskFAC_AttackGroup( AttackGroup, WeaponType, Designation, Datalink )
|
||||
self:F2( { self.ControllableName, AttackGroup, WeaponType, Designation, Datalink } )
|
||||
|
||||
-- FAC_AttackGroup = {
|
||||
-- id = 'FAC_AttackGroup',
|
||||
-- params = {
|
||||
-- groupId = Group.ID,
|
||||
-- weaponType = number,
|
||||
-- designation = enum AI.Task.Designation,
|
||||
-- datalink = boolean
|
||||
-- }
|
||||
-- }
|
||||
|
||||
local DCSTask
|
||||
DCSTask = { id = 'FAC_AttackGroup',
|
||||
local DCSTask = {
|
||||
id = 'FAC_AttackGroup',
|
||||
params = {
|
||||
groupId = AttackGroup:GetID(),
|
||||
weaponType = WeaponType,
|
||||
groupId = AttackGroup:GetID(),
|
||||
weaponType = WeaponType,
|
||||
designation = Designation,
|
||||
datalink = Datalink,
|
||||
datalink = Datalink,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1486,26 +1574,18 @@ end
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @param DCS#Distance Distance Maximal distance from the target to a route leg. If the target is on a greater distance it will be ignored.
|
||||
-- @param DCS#AttributeNameArray TargetTypes Array of target categories allowed to engage.
|
||||
-- @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.
|
||||
-- @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.
|
||||
function CONTROLLABLE:EnRouteTaskEngageTargets( Distance, TargetTypes, Priority )
|
||||
self:F2( { self.ControllableName, Distance, TargetTypes, Priority } )
|
||||
|
||||
-- EngageTargets ={
|
||||
-- id = 'EngageTargets',
|
||||
-- params = {
|
||||
-- maxDist = Distance,
|
||||
-- targetTypes = array of AttributeName,
|
||||
-- priority = number
|
||||
-- }
|
||||
-- }
|
||||
|
||||
local DCSTask
|
||||
DCSTask = { id = 'EngageTargets',
|
||||
local DCSTask = {
|
||||
id = 'EngageTargets',
|
||||
params = {
|
||||
maxDist = Distance,
|
||||
targetTypes = TargetTypes,
|
||||
priority = Priority
|
||||
maxDistEnabled = Distance and true or false,
|
||||
maxDist = Distance,
|
||||
targetTypes = TargetTypes or {"Air"},
|
||||
priority = Priority or 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1519,29 +1599,19 @@ end
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @param DCS#Vec2 Vec2 2D-coordinates of the zone.
|
||||
-- @param DCS#Distance Radius Radius of the zone.
|
||||
-- @param DCS#AttributeNameArray TargetTypes Array of target categories allowed to engage.
|
||||
-- @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 DCS#AttributeNameArray (Optional) TargetTypes Array of target categories allowed to engage. Default {"Air"}.
|
||||
-- @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.
|
||||
function CONTROLLABLE:EnRouteTaskEngageTargetsInZone( Vec2, Radius, TargetTypes, Priority )
|
||||
self:F2( { self.ControllableName, Vec2, Radius, TargetTypes, Priority } )
|
||||
|
||||
-- EngageTargetsInZone = {
|
||||
-- id = 'EngageTargetsInZone',
|
||||
-- params = {
|
||||
-- point = Vec2,
|
||||
-- zoneRadius = Distance,
|
||||
-- targetTypes = array of AttributeName,
|
||||
-- priority = number
|
||||
-- }
|
||||
-- }
|
||||
|
||||
local DCSTask
|
||||
DCSTask = { id = 'EngageTargetsInZone',
|
||||
local DCSTask = {
|
||||
id = 'EngageTargetsInZone',
|
||||
params = {
|
||||
point = Vec2,
|
||||
zoneRadius = Radius,
|
||||
targetTypes = TargetTypes,
|
||||
priority = Priority
|
||||
point = Vec2,
|
||||
zoneRadius = Radius,
|
||||
targetTypes = TargetTypes or {"Air"},
|
||||
priority = Priority or 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1669,18 +1739,8 @@ end
|
||||
-- @return DCS#Task The DCS task structure.
|
||||
function CONTROLLABLE:EnRouteTaskAWACS( )
|
||||
self:F2( { self.ControllableName } )
|
||||
|
||||
-- AWACS = {
|
||||
-- id = 'AWACS',
|
||||
-- params = {
|
||||
-- }
|
||||
-- }
|
||||
|
||||
local DCSTask
|
||||
DCSTask = { id = 'AWACS',
|
||||
params = {
|
||||
}
|
||||
}
|
||||
|
||||
local DCSTask = {id = 'AWACS', params = {}}
|
||||
|
||||
self:T3( { DCSTask } )
|
||||
return DCSTask
|
||||
@@ -1693,17 +1753,7 @@ end
|
||||
function CONTROLLABLE:EnRouteTaskTanker( )
|
||||
self:F2( { self.ControllableName } )
|
||||
|
||||
-- Tanker = {
|
||||
-- id = 'Tanker',
|
||||
-- params = {
|
||||
-- }
|
||||
-- }
|
||||
|
||||
local DCSTask
|
||||
DCSTask = { id = 'Tanker',
|
||||
params = {
|
||||
}
|
||||
}
|
||||
local DCSTask = {id = 'Tanker', params = {}}
|
||||
|
||||
self:T3( { DCSTask } )
|
||||
return DCSTask
|
||||
@@ -1718,17 +1768,7 @@ end
|
||||
function CONTROLLABLE:EnRouteTaskEWR( )
|
||||
self:F2( { self.ControllableName } )
|
||||
|
||||
-- EWR = {
|
||||
-- id = 'EWR',
|
||||
-- params = {
|
||||
-- }
|
||||
-- }
|
||||
|
||||
local DCSTask
|
||||
DCSTask = { id = 'EWR',
|
||||
params = {
|
||||
}
|
||||
}
|
||||
local DCSTask = {id = 'EWR', params = {}}
|
||||
|
||||
self:T3( { DCSTask } )
|
||||
return DCSTask
|
||||
|
||||
@@ -173,6 +173,62 @@ GROUPTEMPLATE.Takeoff = {
|
||||
[GROUP.Takeoff.Cold] = { "TakeOffParking", "From Parking Area" }
|
||||
}
|
||||
|
||||
--- Generalized group attributes. See [DCS attributes](https://wiki.hoggitworld.com/view/DCS_enum_attributes) on hoggit.
|
||||
-- @type GROUP.Attribute
|
||||
-- @field #string AIR_TRANSPORTPLANE Airplane with transport capability. This can be used to transport other assets.
|
||||
-- @field #string AIR_AWACS Airborne Early Warning and Control System.
|
||||
-- @field #string AIR_FIGHTER Fighter, interceptor, ... airplane.
|
||||
-- @field #string AIR_BOMBER Aircraft which can be used for strategic bombing.
|
||||
-- @field #string AIR_TANKER Airplane which can refuel other aircraft.
|
||||
-- @field #string AIR_TRANSPORTHELO Helicopter with transport capability. This can be used to transport other assets.
|
||||
-- @field #string AIR_ATTACKHELO Attack helicopter.
|
||||
-- @field #string AIR_UAV Unpiloted Aerial Vehicle, e.g. drones.
|
||||
-- @field #string AIR_OTHER Any airborne unit that does not fall into any other airborne category.
|
||||
-- @field #string GROUND_APC Infantry carriers, in particular Amoured Personell Carrier. This can be used to transport other assets.
|
||||
-- @field #string GROUND_TRUCK Unarmed ground vehicles, which has the DCS "Truck" attribute.
|
||||
-- @field #string GROUND_INFANTRY Ground infantry assets.
|
||||
-- @field #string GROUND_ARTILLERY Artillery assets.
|
||||
-- @field #string GROUND_TANK Tanks (modern or old).
|
||||
-- @field #string GROUND_TRAIN Trains. Not that trains are **not** yet properly implemented in DCS and cannot be used currently.
|
||||
-- @field #string GROUND_EWR Early Warning Radar.
|
||||
-- @field #string GROUND_AAA Anti-Aircraft Artillery.
|
||||
-- @field #string GROUND_SAM Surface-to-Air Missile system or components.
|
||||
-- @field #string GROUND_OTHER Any ground unit that does not fall into any other ground category.
|
||||
-- @field #string NAVAL_AIRCRAFTCARRIER Aircraft carrier.
|
||||
-- @field #string NAVAL_WARSHIP War ship, i.e. cruisers, destroyers, firgates and corvettes.
|
||||
-- @field #string NAVAL_ARMEDSHIP Any armed ship that is not an aircraft carrier, a cruiser, destroyer, firgatte or corvette.
|
||||
-- @field #string NAVAL_UNARMEDSHIP Any unarmed naval vessel.
|
||||
-- @field #string NAVAL_OTHER Any naval unit that does not fall into any other naval category.
|
||||
-- @field #string OTHER_UNKNOWN Anything that does not fall into any other category.
|
||||
GROUP.Attribute = {
|
||||
AIR_TRANSPORTPLANE="Air_TransportPlane",
|
||||
AIR_AWACS="Air_AWACS",
|
||||
AIR_FIGHTER="Air_Fighter",
|
||||
AIR_BOMBER="Air_Bomber",
|
||||
AIR_TANKER="Air_Tanker",
|
||||
AIR_TRANSPORTHELO="Air_TransportHelo",
|
||||
AIR_ATTACKHELO="Air_AttackHelo",
|
||||
AIR_UAV="Air_UAV",
|
||||
AIR_OTHER="Air_OtherAir",
|
||||
GROUND_APC="Ground_APC",
|
||||
GROUND_TRUCK="Ground_Truck",
|
||||
GROUND_INFANTRY="Ground_Infantry",
|
||||
GROUND_ARTILLERY="Ground_Artillery",
|
||||
GROUND_TANK="Ground_Tank",
|
||||
GROUND_TRAIN="Ground_Train",
|
||||
GROUND_EWR="Ground_EWR",
|
||||
GROUND_AAA="Ground_AAA",
|
||||
GROUND_SAM="Ground_SAM",
|
||||
GROUND_OTHER="Ground_OtherGround",
|
||||
NAVAL_AIRCRAFTCARRIER="Naval_AircraftCarrier",
|
||||
NAVAL_WARSHIP="Naval_WarShip",
|
||||
NAVAL_ARMEDSHIP="Naval_ArmedShip",
|
||||
NAVAL_UNARMEDSHIP="Naval_UnarmedShip",
|
||||
NAVAL_OTHER="Naval_OtherNaval",
|
||||
OTHER_UNKNOWN="Other_Unknown",
|
||||
}
|
||||
|
||||
|
||||
--- Create a new GROUP from a given GroupTemplate as a parameter.
|
||||
-- Note that the GroupTemplate is NOT spawned into the mission.
|
||||
-- It is merely added to the @{Core.Database}.
|
||||
@@ -810,7 +866,7 @@ end
|
||||
function GROUP:Activate()
|
||||
self:F2( { self.GroupName } )
|
||||
trigger.action.activateGroup( self:GetDCSObject() )
|
||||
return self:GetDCSObject()
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
@@ -1678,7 +1734,7 @@ function GROUP:Respawn( Template, Reset )
|
||||
self:F(GroupUnit:GetName())
|
||||
|
||||
if GroupUnit:IsAlive() then
|
||||
self:F("Alive")
|
||||
self:I("FF Alive")
|
||||
|
||||
-- Get unit position vector.
|
||||
local GroupUnitVec3 = GroupUnit:GetVec3()
|
||||
@@ -1722,7 +1778,7 @@ function GROUP:Respawn( Template, Reset )
|
||||
end
|
||||
end
|
||||
|
||||
else -- Reset=false or nil
|
||||
elseif Reset==false then -- Reset=false or nil
|
||||
|
||||
-- Loop over template units.
|
||||
for UnitID, TemplateUnitData in pairs( Template.units ) do
|
||||
@@ -1764,7 +1820,30 @@ function GROUP:Respawn( Template, Reset )
|
||||
self:F( { UnitID, Template.units[UnitID], Template.units[UnitID] } )
|
||||
end
|
||||
|
||||
end
|
||||
else
|
||||
|
||||
local units=self:GetUnits()
|
||||
|
||||
-- Loop over template units.
|
||||
for UnitID, Unit in pairs(Template.units) do
|
||||
|
||||
for _,_unit in pairs(units) do
|
||||
local unit=_unit --Wrapper.Unit#UNIT
|
||||
|
||||
if unit:GetName()==Unit.name then
|
||||
local coord=unit:GetCoordinate()
|
||||
local heading=unit:GetHeading()
|
||||
Unit.x=coord.x
|
||||
Unit.y=coord.z
|
||||
Unit.alt=coord.y
|
||||
Unit.heading=math.rad(heading)
|
||||
Unit.psi=-Unit.heading
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -2091,6 +2170,117 @@ function GROUP:GetDCSDesc(n)
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
--- Get the generalized attribute of a self.
|
||||
-- Note that for a heterogenious self, the attribute is determined from the attribute of the first unit!
|
||||
-- @param #GROUP self
|
||||
-- @return #string Generalized attribute of the self.
|
||||
function GROUP:GetAttribute()
|
||||
|
||||
-- Default
|
||||
local attribute=GROUP.Attribute.OTHER_UNKNOWN --#GROUP.Attribute
|
||||
|
||||
if self then
|
||||
|
||||
-----------
|
||||
--- Air ---
|
||||
-----------
|
||||
-- Planes
|
||||
local transportplane=self:HasAttribute("Transports") and self:HasAttribute("Planes")
|
||||
local awacs=self:HasAttribute("AWACS")
|
||||
local fighter=self:HasAttribute("Fighters") or self:HasAttribute("Interceptors") or self:HasAttribute("Multirole fighters") or (self:HasAttribute("Bombers") and not self:HasAttribute("Strategic bombers"))
|
||||
local bomber=self:HasAttribute("Strategic bombers")
|
||||
local tanker=self:HasAttribute("Tankers")
|
||||
local uav=self:HasAttribute("UAVs")
|
||||
-- Helicopters
|
||||
local transporthelo=self:HasAttribute("Transport helicopters")
|
||||
local attackhelicopter=self:HasAttribute("Attack helicopters")
|
||||
|
||||
--------------
|
||||
--- Ground ---
|
||||
--------------
|
||||
-- Ground
|
||||
local apc=self:HasAttribute("Infantry carriers")
|
||||
local truck=self:HasAttribute("Trucks") and self:GetCategory()==Group.Category.GROUND
|
||||
local infantry=self:HasAttribute("Infantry")
|
||||
local artillery=self:HasAttribute("Artillery")
|
||||
local tank=self:HasAttribute("Old Tanks") or self:HasAttribute("Modern Tanks")
|
||||
local aaa=self:HasAttribute("AAA")
|
||||
local ewr=self:HasAttribute("EWR")
|
||||
local sam=self:HasAttribute("SAM elements") and (not self:HasAttribute("AAA"))
|
||||
-- Train
|
||||
local train=self:GetCategory()==Group.Category.TRAIN
|
||||
|
||||
-------------
|
||||
--- Naval ---
|
||||
-------------
|
||||
-- Ships
|
||||
local aircraftcarrier=self:HasAttribute("Aircraft Carriers")
|
||||
local warship=self:HasAttribute("Heavy armed ships")
|
||||
local armedship=self:HasAttribute("Armed ships")
|
||||
local unarmedship=self:HasAttribute("Unarmed ships")
|
||||
|
||||
|
||||
-- Define attribute. Order is important.
|
||||
if transportplane then
|
||||
attribute=GROUP.Attribute.AIR_TRANSPORTPLANE
|
||||
elseif awacs then
|
||||
attribute=GROUP.Attribute.AIR_AWACS
|
||||
elseif fighter then
|
||||
attribute=GROUP.Attribute.AIR_FIGHTER
|
||||
elseif bomber then
|
||||
attribute=GROUP.Attribute.AIR_BOMBER
|
||||
elseif tanker then
|
||||
attribute=GROUP.Attribute.AIR_TANKER
|
||||
elseif transporthelo then
|
||||
attribute=GROUP.Attribute.AIR_TRANSPORTHELO
|
||||
elseif attackhelicopter then
|
||||
attribute=GROUP.Attribute.AIR_ATTACKHELO
|
||||
elseif uav then
|
||||
attribute=GROUP.Attribute.AIR_UAV
|
||||
elseif apc then
|
||||
attribute=GROUP.Attribute.GROUND_APC
|
||||
elseif infantry then
|
||||
attribute=GROUP.Attribute.GROUND_INFANTRY
|
||||
elseif artillery then
|
||||
attribute=GROUP.Attribute.GROUND_ARTILLERY
|
||||
elseif tank then
|
||||
attribute=GROUP.Attribute.GROUND_TANK
|
||||
elseif aaa then
|
||||
attribute=GROUP.Attribute.GROUND_AAA
|
||||
elseif ewr then
|
||||
attribute=GROUP.Attribute.GROUND_EWR
|
||||
elseif sam then
|
||||
attribute=GROUP.Attribute.GROUND_SAM
|
||||
elseif truck then
|
||||
attribute=GROUP.Attribute.GROUND_TRUCK
|
||||
elseif train then
|
||||
attribute=GROUP.Attribute.GROUND_TRAIN
|
||||
elseif aircraftcarrier then
|
||||
attribute=GROUP.Attribute.NAVAL_AIRCRAFTCARRIER
|
||||
elseif warship then
|
||||
attribute=GROUP.Attribute.NAVAL_WARSHIP
|
||||
elseif armedship then
|
||||
attribute=GROUP.Attribute.NAVAL_ARMEDSHIP
|
||||
elseif unarmedship then
|
||||
attribute=GROUP.Attribute.NAVAL_UNARMEDSHIP
|
||||
else
|
||||
if self:IsGround() then
|
||||
attribute=GROUP.Attribute.GROUND_OTHER
|
||||
elseif self:IsShip() then
|
||||
attribute=GROUP.Attribute.NAVAL_OTHER
|
||||
elseif self:IsAir() then
|
||||
attribute=GROUP.Attribute.AIR_OTHER
|
||||
else
|
||||
attribute=GROUP.Attribute.OTHER_UNKNOWN
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return attribute
|
||||
end
|
||||
|
||||
|
||||
do -- Route methods
|
||||
|
||||
--- (AIR) Return the Group to an @{Wrapper.Airbase#AIRBASE}.
|
||||
|
||||
@@ -31,6 +31,11 @@ SCENERY = {
|
||||
}
|
||||
|
||||
|
||||
--- Register scenery object as POSITIONABLE.
|
||||
--@param #SCENERY self
|
||||
--@param #string SceneryName Scenery name.
|
||||
--@param #DCS.Object SceneryObject DCS scenery object.
|
||||
--@return #SCENERY Scenery object.
|
||||
function SCENERY:Register( SceneryName, SceneryObject )
|
||||
local self = BASE:Inherit( self, POSITIONABLE:New( SceneryName ) )
|
||||
self.SceneryName = SceneryName
|
||||
@@ -38,11 +43,17 @@ function SCENERY:Register( SceneryName, SceneryObject )
|
||||
return self
|
||||
end
|
||||
|
||||
--- Register scenery object as POSITIONABLE.
|
||||
--@param #SCENERY self
|
||||
--@return #DCS.Object DCS scenery object.
|
||||
function SCENERY:GetDCSObject()
|
||||
return self.SceneryObject
|
||||
end
|
||||
|
||||
--- Register scenery object as POSITIONABLE.
|
||||
--@param #SCENERY self
|
||||
--@return #number Threat level 0.
|
||||
--@return #string "Scenery".
|
||||
function SCENERY:GetThreatLevel()
|
||||
|
||||
return 0, "Scenery"
|
||||
end
|
||||
|
||||
@@ -478,8 +478,7 @@ end
|
||||
|
||||
--- Returns the Unit's ammunition.
|
||||
-- @param #UNIT self
|
||||
-- @return DCS#Unit.Ammo
|
||||
-- @return #nil The DCS Unit is not existing or alive.
|
||||
-- @return DCS#Unit.Ammo Table with ammuntion of the unit (or nil). This can be a complex table!
|
||||
function UNIT:GetAmmo()
|
||||
self:F2( self.UnitName )
|
||||
|
||||
@@ -664,8 +663,7 @@ end
|
||||
|
||||
--- Returns relative amount of fuel (from 0.0 to 1.0) the UNIT has in its internal tanks. If there are additional fuel tanks the value may be greater than 1.0.
|
||||
-- @param #UNIT self
|
||||
-- @return #number The relative amount of fuel (from 0.0 to 1.0).
|
||||
-- @return #nil The DCS Unit is not existing or alive.
|
||||
-- @return #number The relative amount of fuel (from 0.0 to 1.0) or *nil* if the DCS Unit is not existing or alive.
|
||||
function UNIT:GetFuel()
|
||||
self:F3( self.UnitName )
|
||||
|
||||
@@ -1206,4 +1204,81 @@ do -- Detection
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
--- Get the unit table from a unit's template.
|
||||
-- @param #UNIT self
|
||||
-- @return #table Table of the unit template (deep copy) or #nil.
|
||||
function UNIT:GetTemplate()
|
||||
|
||||
local group=self:GetGroup()
|
||||
|
||||
local name=self:GetName()
|
||||
|
||||
if group then
|
||||
local template=group:GetTemplate()
|
||||
|
||||
if template then
|
||||
|
||||
for _,unit in pairs(template.units) do
|
||||
|
||||
if unit.name==name then
|
||||
return UTILS.DeepCopy(unit)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
--- Get the payload table from a unit's template.
|
||||
-- The payload table has elements:
|
||||
--
|
||||
-- * pylons
|
||||
-- * fuel
|
||||
-- * chaff
|
||||
-- * gun
|
||||
--
|
||||
-- @param #UNIT self
|
||||
-- @return #table Payload table (deep copy) or #nil.
|
||||
function UNIT:GetTemplatePayload()
|
||||
|
||||
local unit=self:GetTemplate()
|
||||
|
||||
if unit then
|
||||
return unit.payload
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Get the pylons table from a unit's template. This can be a complex table depending on the weapons the unit is carrying.
|
||||
-- @param #UNIT self
|
||||
-- @return #table Table of pylons (deepcopy) or #nil.
|
||||
function UNIT:GetTemplatePylons()
|
||||
|
||||
local payload=self:GetTemplatePayload()
|
||||
|
||||
if payload then
|
||||
return payload.pylons
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Get the fuel of the unit from its template.
|
||||
-- @param #UNIT self
|
||||
-- @return #number Fuel of unit in kg.
|
||||
function UNIT:GetTemplateFuel()
|
||||
|
||||
local payload=self:GetTemplatePayload()
|
||||
|
||||
if payload then
|
||||
return payload.fuel
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user