mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
DCS 2.5.6 fixes
This commit is contained in:
@@ -861,34 +861,18 @@ function CONTROLLABLE:TaskAttackGroup( AttackGroup, WeaponType, WeaponExpend, At
|
||||
-- }
|
||||
-- }
|
||||
|
||||
local DirectionEnabled = nil
|
||||
if Direction then
|
||||
DirectionEnabled = true
|
||||
else
|
||||
DirectionEnabled = false
|
||||
Direction=0
|
||||
end
|
||||
|
||||
local AltitudeEnabled = nil
|
||||
if Altitude then
|
||||
AltitudeEnabled = true
|
||||
else
|
||||
AltitudeEnabled = false
|
||||
Altitude=0
|
||||
end
|
||||
|
||||
local DCSTask
|
||||
DCSTask = { id = 'AttackGroup',
|
||||
local DCSTask = { id = 'AttackGroup',
|
||||
params = {
|
||||
groupId = AttackGroup:GetID(),
|
||||
weaponType = WeaponType,
|
||||
expend = WeaponExpend,
|
||||
weaponType = WeaponType or 1073741822,
|
||||
expend = WeaponExpend or "Auto",
|
||||
attackQtyLimit = AttackQty and true or false,
|
||||
attackQty = AttackQty,
|
||||
directionEnabled = DirectionEnabled,
|
||||
direction = Direction,
|
||||
altitudeEnabled = AltitudeEnabled,
|
||||
directionEnabled = Direction and true or false,
|
||||
direction = Direction and math.rad(Direction) or nil,
|
||||
altitudeEnabled = Altitude and true or false,
|
||||
altitude = Altitude,
|
||||
attackQtyLimit = AttackQtyLimit,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -914,15 +898,15 @@ function CONTROLLABLE:TaskAttackUnit(AttackUnit, GroupAttack, WeaponExpend, Atta
|
||||
id = 'AttackUnit',
|
||||
params = {
|
||||
unitId = AttackUnit:GetID(),
|
||||
groupAttack = GroupAttack or false,
|
||||
groupAttack = GroupAttack and GroupAttack or false,
|
||||
expend = WeaponExpend or "Auto",
|
||||
directionEnabled = Direction and true or false,
|
||||
direction = math.rad(Direction or 0),
|
||||
direction = Direction and math.rad(Direction) or nil,
|
||||
altitudeEnabled = Altitude and true or false,
|
||||
altitude = Altitude or math.max(1000, AttackUnit:GetAltitude()),
|
||||
altitude = Altitude,
|
||||
attackQtyLimit = AttackQty and true or false,
|
||||
attackQty = AttackQty,
|
||||
weaponType = WeaponType
|
||||
weaponType = WeaponType or 1073741822,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -946,25 +930,6 @@ end
|
||||
function CONTROLLABLE:TaskBombing( Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType, Divebomb )
|
||||
self:F( { self.ControllableName, Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType, Divebomb } )
|
||||
|
||||
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=5000
|
||||
local _altitudeenabled=false
|
||||
if Altitude then
|
||||
_altitude=Altitude
|
||||
_altitudeenabled=true
|
||||
end
|
||||
|
||||
local _attacktype=nil
|
||||
if Divebomb then
|
||||
_attacktype="Dive"
|
||||
@@ -975,17 +940,18 @@ function CONTROLLABLE:TaskBombing( Vec2, GroupAttack, WeaponExpend, AttackQty, D
|
||||
DCSTask = {
|
||||
id = 'Bombing',
|
||||
params = {
|
||||
point = Vec2,
|
||||
x = Vec2.x,
|
||||
y = Vec2.y,
|
||||
groupAttack = _groupattack,
|
||||
groupAttack = GroupAttack and GroupAttack or false,
|
||||
expend = WeaponExpend or "Auto",
|
||||
attackQtyLimit = false,
|
||||
attackQty = AttackQty or 1,
|
||||
directionEnabled = _directionenabled,
|
||||
direction = _direction,
|
||||
altitudeEnabled = _altitudeenabled,
|
||||
altitude = _altitude,
|
||||
weaponType = WeaponType,
|
||||
attackQtyLimit = AttackQty and true or false,
|
||||
attackQty = AttackQty,
|
||||
directionEnabled = Direction and true or false,
|
||||
direction = Direction and math.rad(Direction) or nil,
|
||||
altitudeEnabled = Altitude and true or false,
|
||||
altitude = Altitude,
|
||||
weaponType = WeaponType or 1073741822,
|
||||
attackType = _attacktype,
|
||||
},
|
||||
}
|
||||
@@ -998,7 +964,7 @@ end
|
||||
-- @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 DCS#AI.Task.WeaponExpend WeaponExpend (Optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit 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 [meters] from where to attack. Default 30 m.
|
||||
@@ -1021,7 +987,7 @@ function CONTROLLABLE:TaskAttackMapObject( Vec2, GroupAttack, WeaponExpend, Atta
|
||||
directionEnabled = Direction and true or false,
|
||||
direction = Direction,
|
||||
altitudeEnabled = Altitude and true or false,
|
||||
altitude = Altitude or 30,
|
||||
altitude = Altitude,
|
||||
weaponType = WeaponType or 1073741822,
|
||||
},
|
||||
},
|
||||
@@ -1035,93 +1001,62 @@ end
|
||||
-- @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 DCS#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit 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.
|
||||
-- @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 = {
|
||||
local 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
|
||||
y = Vec2.y,
|
||||
groupAttack = GroupAttack and GroupAttack or false,
|
||||
carpetLength = CarpetLength or 500,
|
||||
weaponType = WeaponType or ENUMS.WeaponFlag.AnyBomb,
|
||||
expend = WeaponExpend or "All",
|
||||
attackQtyLimit = AttackQty and true or false,
|
||||
attackQty = AttackQty,
|
||||
directionEnabled = Direction and true or false,
|
||||
direction = Direction and math.rad(Direction) or nil,
|
||||
altitudeEnabled = Altitude and true or false,
|
||||
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
|
||||
--- (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 = {
|
||||
|
||||
local DCSTask = {
|
||||
id = 'FollowBigFormation',
|
||||
params = {
|
||||
groupId = FollowControllable:GetID(),
|
||||
pos = Vec3,
|
||||
pos = Vec3,
|
||||
lastWptIndexFlag = LastWaypointIndex and true or false,
|
||||
lastWptIndex = LastWaypointIndex
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return DCSTask
|
||||
end
|
||||
|
||||
@@ -1137,7 +1072,7 @@ function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, Distri
|
||||
|
||||
-- Table of group IDs for embarking.
|
||||
local g4e={}
|
||||
|
||||
|
||||
if GroupSetForEmbarking then
|
||||
for _,_group in pairs(GroupSetForEmbarking:GetSet()) do
|
||||
local group=_group --Wrapper.Group#GROUP
|
||||
@@ -1147,9 +1082,17 @@ function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, Distri
|
||||
self:E("ERROR: No groups for embarking specified!")
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-- Table of group IDs for embarking.
|
||||
local Distribution={}
|
||||
|
||||
if DistributionGroupSet then
|
||||
for _,_group in pairs(DistributionGroupSet:GetSet()) do
|
||||
local group=_group --Wrapper.Group#GROUP
|
||||
table.insert(Distribution, group:GetID())
|
||||
end
|
||||
end
|
||||
|
||||
local DCSTask = {
|
||||
id = 'Embarking',
|
||||
params = {
|
||||
@@ -1157,7 +1100,7 @@ function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, Distri
|
||||
x = Vec2.x,
|
||||
y = Vec2.y,
|
||||
groupsForEmbarking = g4e,
|
||||
durationFlag = Duration and true or false,
|
||||
durationFlag = Duration and true or false,
|
||||
duration = Duration,
|
||||
distributionFlag = DistributionGroupSet and true or false,
|
||||
distribution = Distribution,
|
||||
@@ -1169,68 +1112,22 @@ function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, Distri
|
||||
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.
|
||||
-- @param #number Altitude The altitude [m] to hold the position.
|
||||
-- @param #number Altitude The altitude AGL in meters to hold the position.
|
||||
-- @param #number Speed The speed [m/s] flying when holding the position.
|
||||
-- @return #CONTROLLABLE self
|
||||
function CONTROLLABLE:TaskOrbitCircleAtVec2( Point, Altitude, Speed )
|
||||
self:F2( { self.ControllableName, Point, Altitude, Speed } )
|
||||
|
||||
local LandHeight = land.getHeight( Point )
|
||||
|
||||
self:T3( { LandHeight } )
|
||||
|
||||
local DCSTask = {
|
||||
id = 'Orbit',
|
||||
params = {
|
||||
pattern = AI.Task.OrbitPattern.CIRCLE,
|
||||
point = Point,
|
||||
speed = Speed,
|
||||
altitude = Altitude + LandHeight
|
||||
altitude = Altitude + land.getHeight( Point )
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1331,7 +1228,7 @@ function CONTROLLABLE:TaskBombingRunway(Airbase, WeaponType, WeaponExpend, Attac
|
||||
expend = WeaponExpend or AI.Task.WeaponExpend.ALL,
|
||||
attackQty = AttackQty or 1,
|
||||
direction = Direction and math.rad(Direction) or nil,
|
||||
groupAttack = GroupAttack,
|
||||
groupAttack = GroupAttack and GroupAttack or false,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1345,7 +1242,7 @@ end
|
||||
function CONTROLLABLE:TaskRefueling()
|
||||
|
||||
local DCSTask={id='Refueling', params={}}
|
||||
|
||||
|
||||
return DCSTask
|
||||
end
|
||||
|
||||
@@ -1419,14 +1316,13 @@ function CONTROLLABLE:TaskFollow( FollowControllable, Vec3, LastWaypointIndex )
|
||||
lastWptIndexFlagChangedManually = true
|
||||
end
|
||||
|
||||
local DCSTask
|
||||
DCSTask = {
|
||||
local DCSTask = {
|
||||
id = 'Follow',
|
||||
params = {
|
||||
groupId = FollowControllable:GetID(),
|
||||
pos = Vec3,
|
||||
lastWptIndexFlag = LastWaypointIndexFlag,
|
||||
lastWptIndex = LastWaypointIndex,
|
||||
groupId = FollowControllable:GetID(),
|
||||
pos = Vec3,
|
||||
lastWptIndexFlag = LastWaypointIndexFlag,
|
||||
lastWptIndex = LastWaypointIndex,
|
||||
lastWptIndexFlagChangedManually = lastWptIndexFlagChangedManually,
|
||||
}
|
||||
}
|
||||
@@ -1444,7 +1340,7 @@ end
|
||||
-- @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.
|
||||
-- @param #number EngagementDistance Maximal distance from escorted controllable to threat. If the threat is already engaged by escort escort will disengage if the distance becomes greater than 1.5 * engagementDistMax.
|
||||
-- @param DCS#AttributeNameArray TargetTypes Array of AttributeName that is contains threat categories allowed to engage.
|
||||
-- @param DCS#AttributeNameArray TargetTypes Array of AttributeName that is contains threat categories allowed to engage. Default {"Air"}.
|
||||
-- @return DCS#Task The DCS task structure.
|
||||
function CONTROLLABLE:TaskEscort( FollowControllable, Vec3, LastWaypointIndex, EngagementDistance, TargetTypes )
|
||||
self:F2( { self.ControllableName, FollowControllable, Vec3, LastWaypointIndex, EngagementDistance, TargetTypes } )
|
||||
@@ -1461,22 +1357,16 @@ function CONTROLLABLE:TaskEscort( FollowControllable, Vec3, LastWaypointIndex, E
|
||||
-- }
|
||||
-- }
|
||||
|
||||
local LastWaypointIndexFlag = false
|
||||
if LastWaypointIndex then
|
||||
LastWaypointIndexFlag = true
|
||||
end
|
||||
|
||||
TargetTypes=TargetTypes or {}
|
||||
|
||||
local DCSTask
|
||||
DCSTask = { id = 'Escort',
|
||||
DCSTask = {
|
||||
id = 'Escort',
|
||||
params = {
|
||||
groupId = FollowControllable:GetID(),
|
||||
pos = Vec3,
|
||||
lastWptIndexFlag = LastWaypointIndexFlag,
|
||||
lastWptIndex = LastWaypointIndex,
|
||||
groupId = FollowControllable:GetID(),
|
||||
pos = Vec3,
|
||||
lastWptIndexFlag = LastWaypointIndex and true or false,
|
||||
lastWptIndex = LastWaypointIndex,
|
||||
engagementDistMax = EngagementDistance,
|
||||
targetTypes = TargetTypes,
|
||||
targetTypes = TargetTypes or {"Air"},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1582,7 +1472,7 @@ function CONTROLLABLE:EnRouteTaskEngageTargets( Distance, TargetTypes, Priority
|
||||
local DCSTask = {
|
||||
id = 'EngageTargets',
|
||||
params = {
|
||||
maxDistEnabled = Distance and true or false,
|
||||
maxDistEnabled = Distance and true or false,
|
||||
maxDist = Distance,
|
||||
targetTypes = TargetTypes or {"Air"},
|
||||
priority = Priority or 0,
|
||||
@@ -1650,29 +1540,19 @@ function CONTROLLABLE:EnRouteTaskEngageGroup( AttackGroup, Priority, WeaponType,
|
||||
-- }
|
||||
-- }
|
||||
|
||||
local DirectionEnabled = nil
|
||||
if Direction then
|
||||
DirectionEnabled = true
|
||||
end
|
||||
|
||||
local AltitudeEnabled = nil
|
||||
if Altitude then
|
||||
AltitudeEnabled = true
|
||||
end
|
||||
|
||||
local DCSTask
|
||||
DCSTask = { id = 'EngageControllable',
|
||||
local DCSTask = {
|
||||
id = 'EngageControllable',
|
||||
params = {
|
||||
groupId = AttackGroup:GetID(),
|
||||
weaponType = WeaponType,
|
||||
expend = WeaponExpend,
|
||||
attackQty = AttackQty,
|
||||
directionEnabled = DirectionEnabled,
|
||||
direction = Direction,
|
||||
altitudeEnabled = AltitudeEnabled,
|
||||
altitude = Altitude,
|
||||
attackQtyLimit = AttackQtyLimit,
|
||||
priority = Priority,
|
||||
groupId = AttackGroup:GetID(),
|
||||
weaponType = WeaponType,
|
||||
expend = WeaponExpend or "Auto",
|
||||
directionEnabled = Direction and true or false,
|
||||
direction = Direction,
|
||||
altitudeEnabled = Altitude and true or false,
|
||||
altitude = Altitude,
|
||||
attackQtyLimit = AttackQty and true or false,
|
||||
attackQty = AttackQty,
|
||||
priority = Priority or 1,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1694,36 +1574,22 @@ 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.
|
||||
-- @return DCS#Task The DCS task structure.
|
||||
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 } )
|
||||
self:F2( { self.ControllableName, EngageUnit, Priority, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, Visible, ControllableAttack } )
|
||||
|
||||
-- EngageUnit = {
|
||||
-- id = 'EngageUnit',
|
||||
-- params = {
|
||||
-- unitId = Unit.ID,
|
||||
-- weaponType = number,
|
||||
-- expend = enum AI.Task.WeaponExpend
|
||||
-- attackQty = number,
|
||||
-- direction = Azimuth,
|
||||
-- attackQtyLimit = boolean,
|
||||
-- controllableAttack = boolean,
|
||||
-- priority = number,
|
||||
-- }
|
||||
-- }
|
||||
|
||||
local DCSTask
|
||||
DCSTask = { id = 'EngageUnit',
|
||||
local DCSTask = {
|
||||
id = 'EngageUnit',
|
||||
params = {
|
||||
unitId = EngageUnit:GetID(),
|
||||
priority = Priority or 1,
|
||||
groupAttack = GroupAttack or false,
|
||||
visible = Visible or false,
|
||||
expend = WeaponExpend or "Auto",
|
||||
directionEnabled = Direction and true or false,
|
||||
direction = Direction,
|
||||
altitudeEnabled = Altitude and true or false,
|
||||
altitude = Altitude,
|
||||
attackQtyLimit = AttackQty and true or false,
|
||||
attackQty = AttackQty,
|
||||
unitId = EngageUnit:GetID(),
|
||||
priority = Priority or 1,
|
||||
groupAttack = GroupAttack and GroupAttack or false,
|
||||
visible = Visible and Visible or false,
|
||||
expend = WeaponExpend or "Auto",
|
||||
directionEnabled = Direction and true or false,
|
||||
direction = Direction and math.rad(Direction) or nil,
|
||||
altitudeEnabled = Altitude and true or false,
|
||||
altitude = Altitude,
|
||||
attackQtyLimit = AttackQty and true or false,
|
||||
attackQty = AttackQty,
|
||||
controllableAttack = ControllableAttack,
|
||||
},
|
||||
},
|
||||
@@ -1739,7 +1605,7 @@ end
|
||||
-- @return DCS#Task The DCS task structure.
|
||||
function CONTROLLABLE:EnRouteTaskAWACS( )
|
||||
self:F2( { self.ControllableName } )
|
||||
|
||||
|
||||
local DCSTask = {id = 'AWACS', params = {}}
|
||||
|
||||
self:T3( { DCSTask } )
|
||||
@@ -1782,33 +1648,22 @@ end
|
||||
-- If the task is assigned to the controllable lead unit will be a FAC.
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @param Wrapper.Controllable#CONTROLLABLE AttackGroup Target CONTROLLABLE.
|
||||
-- @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 WeaponType Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage.
|
||||
-- @param DCS#AI.Task.Designation Designation (optional) Designation type.
|
||||
-- @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 is 0.
|
||||
-- @param #number WeaponType (Optional) Bitmask of weapon types those allowed to use. Default is "Auto".
|
||||
-- @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.
|
||||
-- @return DCS#Task The DCS task structure.
|
||||
function CONTROLLABLE:EnRouteTaskFAC_EngageGroup( AttackGroup, Priority, WeaponType, Designation, Datalink )
|
||||
self:F2( { self.ControllableName, AttackGroup, WeaponType, Priority, Designation, Datalink } )
|
||||
|
||||
-- FAC_EngageControllable = {
|
||||
-- id = 'FAC_EngageControllable',
|
||||
-- params = {
|
||||
-- groupId = Group.ID,
|
||||
-- weaponType = number,
|
||||
-- designation = enum AI.Task.Designation,
|
||||
-- datalink = boolean,
|
||||
-- priority = number,
|
||||
-- }
|
||||
-- }
|
||||
|
||||
local DCSTask
|
||||
DCSTask = { id = 'FAC_EngageControllable',
|
||||
local DCSTask = {
|
||||
id = 'FAC_EngageControllable',
|
||||
params = {
|
||||
groupId = AttackGroup:GetID(),
|
||||
weaponType = WeaponType,
|
||||
groupId = AttackGroup:GetID(),
|
||||
weaponType = WeaponType or "Auto",
|
||||
designation = Designation,
|
||||
datalink = Datalink,
|
||||
priority = Priority,
|
||||
datalink = Datalink and Datalink or false,
|
||||
priority = Priority or 0,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1979,9 +1834,12 @@ function CONTROLLABLE:TaskEmbarkToTransport( Point, Radius )
|
||||
self:F2( { self.ControllableName, Point, Radius } )
|
||||
|
||||
local DCSTask --DCS#Task
|
||||
DCSTask = { id = 'EmbarkToTransport',
|
||||
params = { x = Point.x,
|
||||
y = Point.y,
|
||||
DCSTask = {
|
||||
id = 'EmbarkToTransport',
|
||||
params = {
|
||||
point = Point,
|
||||
x = Point.x,
|
||||
y = Point.y,
|
||||
zoneRadius = Radius,
|
||||
}
|
||||
}
|
||||
@@ -2190,12 +2048,12 @@ do -- Patrol methods
|
||||
if not self:IsInstanceOf( "GROUP" ) then
|
||||
PatrolGroup = self:GetGroup() -- Wrapper.Group#GROUP
|
||||
end
|
||||
|
||||
|
||||
DelayMin=DelayMin or 1
|
||||
if not DelayMax or DelayMax<DelayMin then
|
||||
DelayMax=DelayMin
|
||||
end
|
||||
|
||||
|
||||
local Delay=math.random(DelayMin, DelayMax)
|
||||
|
||||
self:F( { PatrolGroup = PatrolGroup:GetName() } )
|
||||
@@ -2233,8 +2091,13 @@ end
|
||||
function CONTROLLABLE:TaskRoute( Points )
|
||||
self:F2( Points )
|
||||
|
||||
local DCSTask
|
||||
DCSTask = { id = 'Mission', params = { route = { points = Points, }, }, }
|
||||
local DCSTask = {
|
||||
id = 'Mission',
|
||||
params = {
|
||||
airborne = self:IsAir(),
|
||||
route = {points = Points},
|
||||
},
|
||||
}
|
||||
|
||||
self:T3( { DCSTask } )
|
||||
return DCSTask
|
||||
@@ -2434,7 +2297,7 @@ do -- Route methods
|
||||
waypoint.task = {}
|
||||
waypoint.task.id = "ComboTask"
|
||||
waypoint.task.params = {}
|
||||
waypoint.task.params.tasks = {self:TaskFunction("CONTROLLABLE.___PassingWaypoint", n, N, WaypointFunction, unpack(WaypointFunctionArguments or {}))}
|
||||
waypoint.task.params.tasks = {self:TaskFunction("CONTROLLABLE.___PassingWaypoint", n, N, WaypointFunction, unpack(WaypointFunctionArguments or {}))}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2555,7 +2418,7 @@ do -- Route methods
|
||||
if LongRoad and Shortcut then
|
||||
|
||||
-- Road is long ==> we take the short cut.
|
||||
|
||||
|
||||
table.insert(route, FromCoordinate:WaypointGround(Speed, OffRoadFormation))
|
||||
table.insert(route, ToCoordinate:WaypointGround(Speed, OffRoadFormation))
|
||||
|
||||
@@ -2584,7 +2447,7 @@ do -- Route methods
|
||||
table.insert(route, ToCoordinate:WaypointGround(Speed, OffRoadFormation))
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Add passing waypoint function.
|
||||
if WaypointFunction then
|
||||
local N=#route
|
||||
@@ -2592,10 +2455,10 @@ do -- Route methods
|
||||
waypoint.task = {}
|
||||
waypoint.task.id = "ComboTask"
|
||||
waypoint.task.params = {}
|
||||
waypoint.task.params.tasks = {self:TaskFunction("CONTROLLABLE.___PassingWaypoint", n, N, WaypointFunction, unpack(WaypointFunctionArguments or {}))}
|
||||
waypoint.task.params.tasks = {self:TaskFunction("CONTROLLABLE.___PassingWaypoint", n, N, WaypointFunction, unpack(WaypointFunctionArguments or {}))}
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return route, canroad
|
||||
end
|
||||
|
||||
@@ -2631,7 +2494,7 @@ do -- Route methods
|
||||
table.insert(route, PathOnRail[2]:WaypointGround(Speed, "On Railroad"))
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Add passing waypoint function.
|
||||
if WaypointFunction then
|
||||
local N=#route
|
||||
@@ -2639,7 +2502,7 @@ do -- Route methods
|
||||
waypoint.task = {}
|
||||
waypoint.task.id = "ComboTask"
|
||||
waypoint.task.params = {}
|
||||
waypoint.task.params.tasks = {self:TaskFunction("CONTROLLABLE.___PassingWaypoint", n, N, WaypointFunction, unpack(WaypointFunctionArguments or {}))}
|
||||
waypoint.task.params.tasks = {self:TaskFunction("CONTROLLABLE.___PassingWaypoint", n, N, WaypointFunction, unpack(WaypointFunctionArguments or {}))}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2904,9 +2767,9 @@ function CONTROLLABLE:GetDetectedTargets( DetectVisual, DetectOptical, DetectRad
|
||||
self:F2( self.ControllableName )
|
||||
|
||||
local DCSControllable = self:GetDCSObject()
|
||||
|
||||
|
||||
if DCSControllable then
|
||||
|
||||
|
||||
local DetectionVisual = ( DetectVisual and DetectVisual == true ) and Controller.Detection.VISUAL or nil
|
||||
local DetectionOptical = ( DetectOptical and DetectOptical == true ) and Controller.Detection.OPTICAL or nil
|
||||
local DetectionRadar = ( DetectRadar and DetectRadar == true ) and Controller.Detection.RADAR or nil
|
||||
@@ -3038,9 +2901,9 @@ function CONTROLLABLE:IsGroupDetected( Group, DetectVisual, DetectOptical, Detec
|
||||
for _,_unit in pairs(Group:GetUnits()) do
|
||||
local unit=_unit --Wrapper.Unit#UNIT
|
||||
if unit and unit:IsAlive() then
|
||||
|
||||
|
||||
local isdetected=self:IsUnitDetected(unit, DetectVisual, DetectOptical, DetectRadar, DetectIRST, DetectRWR, DetectDLINK)
|
||||
|
||||
|
||||
if isdetected then
|
||||
return true
|
||||
end
|
||||
@@ -3071,23 +2934,23 @@ function CONTROLLABLE:GetDetectedUnitSet(DetectVisual, DetectOptical, DetectRada
|
||||
local detectedtargets=self:GetDetectedTargets(DetectVisual, DetectOptical, DetectRadar, DetectIRST, DetectRWR, DetectDLINK)
|
||||
|
||||
local unitset=SET_UNIT:New()
|
||||
|
||||
|
||||
for DetectionObjectID, Detection in pairs(detectedtargets or {}) do
|
||||
local DetectedObject=Detection.object -- DCS#Object
|
||||
|
||||
if DetectedObject and DetectedObject:isExist() and DetectedObject.id_<50000000 then
|
||||
local unit=UNIT:Find(DetectedObject)
|
||||
|
||||
|
||||
if unit and unit:IsAlive() then
|
||||
|
||||
|
||||
if not unitset:FindUnit(unit:GetName()) then
|
||||
unitset:AddUnit(unit)
|
||||
unitset:AddUnit(unit)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return unitset
|
||||
end
|
||||
|
||||
@@ -3108,24 +2971,24 @@ function CONTROLLABLE:GetDetectedGroupSet(DetectVisual, DetectOptical, DetectRad
|
||||
local detectedtargets=self:GetDetectedTargets(DetectVisual, DetectOptical, DetectRadar, DetectIRST, DetectRWR, DetectDLINK)
|
||||
|
||||
local groupset=SET_GROUP:New()
|
||||
|
||||
|
||||
for DetectionObjectID, Detection in pairs(detectedtargets or {}) do
|
||||
local DetectedObject=Detection.object -- DCS#Object
|
||||
|
||||
if DetectedObject and DetectedObject:isExist() and DetectedObject.id_<50000000 then
|
||||
local unit=UNIT:Find(DetectedObject)
|
||||
|
||||
|
||||
if unit and unit:IsAlive() then
|
||||
local group=unit:GetGroup()
|
||||
|
||||
|
||||
if group and not groupset:FindGroup(group:GetName()) then
|
||||
groupset:AddGroup(group)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return groupset
|
||||
end
|
||||
|
||||
@@ -3749,30 +3612,30 @@ end
|
||||
-- @return #boolean true if Controllable contains Helicopters.
|
||||
function CONTROLLABLE:IsHelicopter()
|
||||
self:F2()
|
||||
|
||||
|
||||
local DCSObject = self:GetDCSObject()
|
||||
|
||||
|
||||
if DCSObject then
|
||||
local Category = DCSObject:getDesc().category
|
||||
return Category == Unit.Category.HELICOPTER
|
||||
end
|
||||
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Sets Controllable Option for Restriction of Afterburner.
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @param #boolean RestrictBurner If true, restrict burner. If false or nil, allow (unrestrict) burner.
|
||||
-- @param #boolean RestrictBurner If true, restrict burner. If false or nil, allow (unrestrict) burner.
|
||||
function CONTROLLABLE:OptionRestrictBurner(RestrictBurner)
|
||||
self:F2({self.ControllableName})
|
||||
|
||||
|
||||
local DCSControllable = self:GetDCSObject()
|
||||
|
||||
|
||||
if DCSControllable then
|
||||
local Controller = self:_GetController()
|
||||
|
||||
|
||||
if Controller then
|
||||
|
||||
|
||||
-- Issue https://github.com/FlightControl-Master/MOOSE/issues/1216
|
||||
if RestrictBurner == true then
|
||||
if self:IsAir() then
|
||||
@@ -3783,8 +3646,8 @@ function CONTROLLABLE:OptionRestrictBurner(RestrictBurner)
|
||||
Controller:setOption(16, false)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user