Updates Misc

This commit is contained in:
Frank 2020-04-24 16:03:28 +02:00
parent df512f7a58
commit 7360c51a8f
10 changed files with 1026 additions and 517 deletions

View File

@ -655,6 +655,28 @@ do -- COORDINATE
return Angle
end
--- Return an intermediate COORDINATE between this an another coordinate.
-- @param #COORDINATE self
-- @param #COORDINATE ToCoordinate The other coordinate.
-- @param #number Fraction The fraction (0,1) where the new coordinate is created. Default 0.5, i.e. in the middle.
-- @return #COORDINATE Coordinate between this and the other coordinate.
function COORDINATE:GetIntermediateCoordinate( ToCoordinate, Fraction )
local f=Fraction or 0.5
-- Get the vector from A to B
local vec=UTILS.VecSubstract(ToCoordinate, self)
-- Scale the vector.
vec.x=f*vec.x
vec.y=f*vec.y
vec.z=f*vec.z
-- Move the vector to start at the end of A.
vec=UTILS.VecAdd(self, vec)
return self:New(vec.x,vec.y,vec.z)
end
--- Return the 2D distance in meters between the target COORDINATE and the COORDINATE.
-- @param #COORDINATE self

View File

@ -113,18 +113,20 @@ end
-- @param #number dt (Optional) Time step in seconds for checking the queue. Default 0.01 sec.
-- @return #RADIOQUEUE self The RADIOQUEUE object.
function RADIOQUEUE:Start(delay, dt)
-- Delay before start.
self.delay=delay or 1
-- Time interval for queue check.
self.dt=dt or 0.01
-- Debug message.
self:I(self.lid..string.format("Starting RADIOQUEUE %s on Frequency %.2f MHz [modulation=%d] in %.1f seconds (dt=%.3f sec)", self.alias, self.frequency/1000000, self.modulation, delay, dt))
-- Start Scheduler.
if self.schedonce then
self:_CheckRadioQueueDelayed(self.delta)
self:_CheckRadioQueueDelayed(delay)
else
--self.RQid=self.scheduler:Schedule(self, self._CheckRadioQueue, {}, delay, dt)
self.RQid=self.scheduler:Schedule(nil, RADIOQUEUE._CheckRadioQueue, {self}, delay, dt)
end
@ -279,10 +281,6 @@ end
-- @return #number Duration of the call in seconds.
function RADIOQUEUE:Number2Transmission(number, delay, interval)
if not number then
self:E("ERROR: Number is nil!")
end
--- Split string into characters.
local function _split(str)
local chars={}

File diff suppressed because it is too large Load Diff

View File

@ -326,9 +326,27 @@ end -- coalition
do -- Types
--- @type Desc
-- @field #TypeName typeName type name
-- @field #string displayName localized display name
-- @field #table attributes object type attributes
-- @field #number speedMax0 Max speed in meters/second at zero altitude.
-- @field #number massEmpty Empty mass in kg.
-- @field #number tankerType Type of refueling system: 0=boom, 1=probe.
-- @field #number range Range in km(?).
-- @field #table box Bounding box.
-- @field #number Hmax Max height in meters.
-- @field #number Kmax ?
-- @field #number speedMax10K Max speed in meters/second at 10k altitude.
-- @field #number NyMin ?
-- @field #number NyMax ?
-- @field #number fuelMassMax Max fuel mass in kg.
-- @field #number speedMax10K Max speed in meters/second.
-- @field #number massMax Max mass of unit.
-- @field #number RCS ?
-- @field #number life Life points.
-- @field #number VyMax Max vertical velocity in m/s.
-- @field #number Kab ?
-- @field #table attributes Table of attributes.
-- @field #TypeName typeName Type Name.
-- @field #string displayName Localized display name.
-- @field #number category Unit category.
--- A distance type
-- @type Distance

View File

@ -1,49 +1,163 @@
--- **Utilities** Enumerators.
--
-- See the [Simulator Scripting Engine Documentation](https://wiki.hoggitworld.com/view/Simulator_Scripting_Engine_Documentation) on Hoggit for further explanation and examples.
-- An enumerator is a variable that holds a constant value. Enumerators are very useful because they make the code easier to read and to change in general.
--
-- @module DCS
-- For example, instead of using the same value at multiple different places in your code, you should use a variable set to that value.
-- If, for whatever reason, the value needs to be changed, you only have to change the variable once and do not have to search through you code and reset
-- every value by hand.
--
-- Another big advantage is that the LDT intellisense "knows" the enumerators. So you can use the autocompletion feature and do not have to keep all the
-- values in your head or look them up in the docs.
--
-- DCS itself provides a lot of enumerators for various things. See [Enumerators](https://wiki.hoggitworld.com/view/Category:Enumerators) on Hoggit.
--
-- Other Moose classe also have enumerators. For example, the AIRBASE class has enumerators for airbase names.
--
-- @module ENUMS
-- @image MOOSE.JPG
--- [DCS Enum world](https://wiki.hoggitworld.com/view/DCS_enum_world)
-- @type ENUMS
--- Because ENUMS are just better practice.
--
-- The ENUMS class adds some handy variables, which help you to make your code better and more general.
--
-- @field #ENUMS
ENUMS = {}
--- Rules of Engagement.
-- @type ENUMS.ROE
-- @field #number WeaponFree AI will engage any enemy group it detects. Target prioritization is based based on the threat of the target.
-- @field #number OpenFireWeaponFree AI will engage any enemy group it detects, but will prioritize targets specified in the groups tasking.
-- @field #number OpenFire AI will engage only targets specified in its taskings.
-- @field #number ReturnFire AI will only engage threats that shoot first.
-- @field #number WeaponHold AI will hold fire under all circumstances.
ENUMS.ROE = {
HoldFire = 1,
ReturnFire = 2,
OpenFire = 3,
WeaponFree = 4
WeaponFree=0,
OpenFireWeaponFree=1,
OpenFire=2,
ReturnFire=3,
WeaponHold=4,
}
--- Reaction On Threat.
-- @type ENUMS.ROT
-- @field #number NoReaction No defensive actions will take place to counter threats.
-- @field #number PassiveDefense AI will use jammers and other countermeasures in an attempt to defeat the threat. AI will not attempt a maneuver to defeat a threat.
-- @field #number EvadeFire AI will react by performing defensive maneuvers against incoming threats. AI will also use passive defense.
-- @field #number BypassAndEscape AI will attempt to avoid enemy threat zones all together. This includes attempting to fly above or around threats.
-- @field #number AllowAbortMission If a threat is deemed severe enough the AI will abort its mission and return to base.
ENUMS.ROT = {
NoReaction = 1,
PassiveDefense = 2,
EvadeFire = 3,
Vertical = 4
NoReaction=0,
PassiveDefense=1,
EvadeFire=2,
BypassAndEscape=3,
AllowAbortMission=4,
}
--- Weapon types. See the [Weapon Flag](https://wiki.hoggitworld.com/view/DCS_enum_weapon_flag) enumerotor on hoggit wiki.
-- @type ENUMS.WeaponFlag
ENUMS.WeaponFlag={
-- Auto
Auto=1073741822,
-- Bombs
LGB=2,
TvGB=4,
SNSGB=8,
HEBomb=16,
Penetrator=32,
NapalmBomb=64,
FAEBomb=128,
ClusterBomb=256,
Dispencer=512,
CandleBomb=1024,
ParachuteBomb=2147483648,
GuidedBomb=14, -- (LGB + TvGB + SNSGB)
AnyUnguidedBomb=2147485680, -- (HeBomb + Penetrator + NapalmBomb + FAEBomb + ClusterBomb + Dispencer + CandleBomb + ParachuteBomb)
AnyBomb=2147485694, -- (GuidedBomb + AnyUnguidedBomb)
LGB = 2,
TvGB = 4,
SNSGB = 8,
HEBomb = 16,
Penetrator = 32,
NapalmBomb = 64,
FAEBomb = 128,
ClusterBomb = 256,
Dispencer = 512,
CandleBomb = 1024,
ParachuteBomb = 2147483648,
-- Rockets
LightRocket=2048,
MarkerRocket=4096,
CandleRocket=8192,
HeavyRocket=16384,
AnyRocket=30720 -- (LightRocket + MarkerRocket + CandleRocket + HeavyRocket)
LightRocket = 2048,
MarkerRocket = 4096,
CandleRocket = 8192,
HeavyRocket = 16384,
-- Air-To-Surface Missiles
AntiRadarMissile = 32768,
AntiShipMissile = 65536,
AntiTankMissile = 131072,
FireAndForgetASM = 262144,
LaserASM = 524288,
TeleASM = 1048576,
CruiseMissile = 2097152,
AntiRadarMissile2 = 1073741824,
-- Air-To-Air Missiles
SRAM = 4194304,
MRAAM = 8388608,
LRAAM = 16777216,
IR_AAM = 33554432,
SAR_AAM = 67108864,
AR_AAM = 134217728,
--- Guns
GunPod = 268435456,
BuiltInCannon = 536870912,
---
-- Combinations
--
-- Bombs
GuidedBomb = 14, -- (LGB + TvGB + SNSGB)
AnyUnguidedBomb = 2147485680, -- (HeBomb + Penetrator + NapalmBomb + FAEBomb + ClusterBomb + Dispencer + CandleBomb + ParachuteBomb)
AnyBomb = 2147485694, -- (GuidedBomb + AnyUnguidedBomb)
--- Rockets
AnyRocket = 30720, -- LightRocket + MarkerRocket + CandleRocket + HeavyRocket
--- Air-To-Surface Missiles
GuidedASM = 1572864, -- (LaserASM + TeleASM)
TacticalASM = 1835008, -- (GuidedASM + FireAndForgetASM)
AnyASM = 4161536, -- (AntiRadarMissile + AntiShipMissile + AntiTankMissile + FireAndForgetASM + GuidedASM + CruiseMissile)
AnyASM2 = 1077903360, -- 4161536+1073741824,
--- Air-To-Air Missiles
AnyAAM = 264241152, -- IR_AAM + SAR_AAM + AR_AAM + SRAAM + MRAAM + LRAAM
AnyAutonomousMissile = 36012032, -- IR_AAM + AntiRadarMissile + AntiShipMissile + FireAndForgetASM + CruiseMissile
AnyMissile = 268402688, -- AnyASM + AnyAAM
--- Guns
Cannons = 805306368, -- GUN_POD + BuiltInCannon
---
-- Even More Genral
Auto = 3221225470, -- Any Weapon (AnyBomb + AnyRocket + AnyMissile + Cannons)
AutoDCS = 1073741822, -- Something if often see
AnyAG = 2956984318, -- Any Air-To-Ground Weapon
AnyAA = 264241152, -- Any Air-To-Air Weapon
AnyUnguided = 2952822768, -- Any Unguided Weapon
AnyGuided = 268402702, -- Any Guided Weapon
}
--- Mission tasks.
-- @type ENUMS.MissionTask
-- @field #string NOTHING No special task. Group can perform the minimal tasks: Orbit, Refuelling, Follow and Aerobatics.
-- @field #string AFAC Forward Air Controller Air. Can perform the tasks: Attack Group, Attack Unit, FAC assign group, Bombing, Attack Map Object.
-- @field #string ANTISHIPSTRIKE Naval ops. Can perform the tasks: Attack Group, Attack Unit.
-- @field #string AWACS AWACS.
-- @field #string CAP Combat Air Patrol.
-- @field #string CAS Close Air Support.
-- @field #string ESCORT Escort another group.
-- @field #string FIGHTERSWEEP Fighter sweep.
-- @field #string GROUNDATTACK Ground attack.
-- @field #string INTERCEPT Intercept.
-- @field #string PINPOINTSTRIKE Pinpoint strike.
-- @field #string RECONNAISSANCE Reconnaissance mission.
-- @field #string REFUELING Refueling mission.
-- @field #string RUNWAYATTACK Attack the runway of an airdrome.
-- @field #string SEAD Suppression of Enemy Air Defenses.
-- @field #string TRANSPORT Troop transport.
ENUMS.MissionTask={
NOTHING="Nothing",
AFAC="AFAC",
ANTISHIPSTRIKE="Antiship Strike",
AWACS="AWACS",
CAP="CAP",
CAS="CAS",
ESCORT="Escort",
FIGHTERSWEEP="Fighter Sweep",
GROUNDATTACK="Ground Attack",
INTERCEPT="Intercept",
PINPOINTSTRIKE="Pinpoint Strike",
RECONNAISSANCE="Reconnaissance",
REFUELING="Refueling",
RUNWAYATTACK="Runway Attack",
SEAD="SEAD",
TRANSPORT="Transport",
}

View File

@ -312,7 +312,6 @@ function CONTROLLABLE:ClearTasks()
if DCSControllable then
local Controller = self:_GetController()
env.info("FF clearing tasks!")
Controller:resetTask()
return self
end
@ -450,7 +449,6 @@ end
-- @param #number lastWayPoint Last waypoint.
-- return DCS#Task
function CONTROLLABLE:TaskCondition( time, userFlag, userFlagValue, condition, duration, lastWayPoint )
self:F2( { time, userFlag, userFlagValue, condition, duration, lastWayPoint } )
--[[
StopCondition = {
@ -471,7 +469,6 @@ function CONTROLLABLE:TaskCondition( time, userFlag, userFlagValue, condition, d
DCSStopCondition.duration = duration
DCSStopCondition.lastWayPoint = lastWayPoint
self:T3( { DCSStopCondition } )
return DCSStopCondition
end
@ -481,11 +478,8 @@ end
-- @param DCS#DCSStopCondition DCSStopCondition
-- @return DCS#Task
function CONTROLLABLE:TaskControlled( DCSTask, DCSStopCondition )
self:F2( { DCSTask, DCSStopCondition } )
local DCSTaskControlled
DCSTaskControlled = {
local DCSTaskControlled = {
id = 'ControlledTask',
params = {
task = DCSTask,
@ -493,7 +487,6 @@ function CONTROLLABLE:TaskControlled( DCSTask, DCSStopCondition )
}
}
self:T3( { DCSTaskControlled } )
return DCSTaskControlled
end
@ -502,22 +495,14 @@ end
-- @param DCS#TaskArray DCSTasks Array of @{DCSTasking.Task#Task}
-- @return DCS#Task
function CONTROLLABLE:TaskCombo( DCSTasks )
self:F2( { DCSTasks } )
local DCSTaskCombo
DCSTaskCombo = {
local DCSTaskCombo = {
id = 'ComboTask',
params = {
tasks = DCSTasks
}
}
for TaskID, Task in ipairs( DCSTasks ) do
self:T( Task )
end
self:T3( { DCSTaskCombo } )
return DCSTaskCombo
end
@ -526,11 +511,8 @@ end
-- @param DCS#Command DCSCommand
-- @return DCS#Task
function CONTROLLABLE:TaskWrappedAction( DCSCommand, Index )
self:F2( { DCSCommand } )
local DCSTaskWrappedAction
DCSTaskWrappedAction = {
local DCSTaskWrappedAction = {
id = "WrappedAction",
enabled = true,
number = Index or 1,
@ -540,7 +522,6 @@ function CONTROLLABLE:TaskWrappedAction( DCSCommand, Index )
},
}
self:T3( { DCSTaskWrappedAction } )
return DCSTaskWrappedAction
end
@ -703,7 +684,6 @@ end
-- @param #number Delay (Optional) Delay in seconds before the ICLS is deactivated.
-- @return #CONTROLLABLE self
function CONTROLLABLE:CommandActivateICLS(Channel, UnitID, Callsign, Delay)
self:F()
-- Command to activate ICLS system.
local CommandActivateICLS= {
@ -731,7 +711,6 @@ end
-- @param #number Delay (Optional) Delay in seconds before the beacon is deactivated.
-- @return #CONTROLLABLE self
function CONTROLLABLE:CommandDeactivateBeacon(Delay)
self:F()
-- Command to deactivate
local CommandDeactivateBeacon={id='DeactivateBeacon', params={}}
@ -750,7 +729,6 @@ end
-- @param #number Delay (Optional) Delay in seconds before the ICLS is deactivated.
-- @return #CONTROLLABLE self
function CONTROLLABLE:CommandDeactivateICLS(Delay)
self:F()
-- Command to deactivate
local CommandDeactivateICLS={id='DeactivateICLS', params={}}
@ -771,7 +749,6 @@ end
-- @param #number Delay (Optional) Delay in seconds before the callsign is set. Default is immediately.
-- @return #CONTROLLABLE self
function CONTROLLABLE:CommandSetCallsign(CallName, CallNumber, Delay)
self:F()
-- Command to set the callsign.
local CommandSetCallsign={id='SetCallsign', params={callname=CallName, callnumber=CallNumber or 1}}
@ -791,28 +768,56 @@ end
-- @param #number Delay (Optional) Delay in seconds before the callsign is set. Default is immediately.
-- @return #CONTROLLABLE self
function CONTROLLABLE:CommandEPLRS(SwitchOnOff, Delay)
self:F()
if SwitchOnOff==nil then
SwitchOnOff=true
end
-- ID
local _id=self:GetID()
-- 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
SCHEDULER:New(nil, self.CommandEPLRS, {self, SwitchOnOff}, Delay)
else
self:T(string.format("EPLRS=%s for controllable %s (id=%s)", tostring(SwitchOnOff), tostring(self:GetName()), tostring(_id)))
self:T(string.format("EPLRS=%s for controllable %s (id=%s)", tostring(SwitchOnOff), tostring(self:GetName()), tostring(self:GetID())))
self:SetCommand(CommandEPLRS)
end
return self
end
--- Set radio frequency. See [DCS command EPLRS](https://wiki.hoggitworld.com/view/DCS_command_setFrequency)
-- @param #CONTROLLABLE self
-- @param #number Frequency Radio frequency in MHz.
-- @param #number Modulation Radio modulation. Default `radio.modulation.AM`.
-- @param #number Delay (Optional) Delay in seconds before the frequncy is set. Default is immediately.
-- @return #CONTROLLABLE self
function CONTROLLABLE:CommandSetFrequency(Frequency, Modulation, Delay)
local CommandSetFrequency = {
id = 'SetFrequency',
params = {
frequency = Frequency,
modulation = Modulation or radio.modulation.AM,
}
}
if Delay and Delay>0 then
SCHEDULER:New(nil, self.CommandSetFrequency, {self, Frequency, Modulation}, Delay)
else
self:SetCommand(CommandSetFrequency)
end
return self
end
--- Set EPLRS data link on/off.
-- @param #CONTROLLABLE self
-- @param #boolean SwitchOnOff If true (or nil) switch EPLRS on. If false switch off.
@ -820,14 +825,20 @@ end
-- @return #table Task wrapped action.
function CONTROLLABLE:TaskEPLRS(SwitchOnOff, idx)
-- ID
local _id=self:GetID()
if SwitchOnOff==nil then
SwitchOnOff=true
end
-- 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)
end
@ -835,16 +846,17 @@ end
--- (AIR) Attack a Controllable.
-- @param #CONTROLLABLE self
-- @param Wrapper.Controllable#CONTROLLABLE AttackGroup The Controllable to be attacked.
-- @param Wrapper.Group#GROUP AttackGroup The Group to be attacked.
-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage.
-- @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 DCS#Distance Altitude (optional) Desired attack start altitude. Controllable/aircraft will make its attacks from the altitude. If the altitude is too low or too high to use weapon aircraft/controllable will choose closest altitude to the desired attack start altitude. If the desired altitude is defined controllable/aircraft will not attack from safe altitude.
-- @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 GroupAttack (Optional) If true, attack as group.
-- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskAttackGroup( AttackGroup, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit )
self:F2( { self.ControllableName, AttackGroup, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit } )
function CONTROLLABLE:TaskAttackGroup( AttackGroup, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit, GroupAttack )
--self:F2( { self.ControllableName, AttackGroup, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit } )
-- AttackGroup = {
-- id = 'AttackGroup',
@ -868,15 +880,15 @@ function CONTROLLABLE:TaskAttackGroup( AttackGroup, WeaponType, WeaponExpend, At
weaponType = WeaponType or 1073741822,
expend = WeaponExpend or "Auto",
attackQtyLimit = AttackQty and true or false,
attackQty = AttackQty,
attackQty = AttackQty or 1,
directionEnabled = Direction and true or false,
direction = Direction and math.rad(Direction) or nil,
direction = Direction and math.rad(Direction) or 0,
altitudeEnabled = Altitude and true or false,
altitude = Altitude,
groupAttack = GroupAttack and true or false,
},
},
}
self:T3( { DCSTask } )
return DCSTask
end
@ -891,17 +903,15 @@ end
-- @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.
function CONTROLLABLE:TaskAttackUnit(AttackUnit, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType)
self:F2({self.ControllableName, AttackUnit, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType})
local DCSTask
DCSTask = {
local DCSTask = {
id = 'AttackUnit',
params = {
unitId = AttackUnit:GetID(),
groupAttack = GroupAttack and GroupAttack or false,
expend = WeaponExpend or "Auto",
directionEnabled = Direction and true or false,
direction = Direction and math.rad(Direction) or nil,
direction = Direction and math.rad(Direction) or 0,
altitudeEnabled = Altitude and true or false,
altitude = Altitude,
attackQtyLimit = AttackQty and true or false,
@ -909,9 +919,7 @@ function CONTROLLABLE:TaskAttackUnit(AttackUnit, GroupAttack, WeaponExpend, Atta
weaponType = WeaponType or 1073741822,
}
}
self:T3( DCSTask )
return DCSTask
end
@ -928,16 +936,8 @@ end
-- @param #boolean Divebomb (optional) Perform dive bombing. Default false.
-- @return DCS#Task The DCS task structure.
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
if Divebomb then
_attacktype="Dive"
end
local DCSTask
DCSTask = {
local DCSTask = {
id = 'Bombing',
params = {
point = Vec2,
@ -946,17 +946,16 @@ function CONTROLLABLE:TaskBombing( Vec2, GroupAttack, WeaponExpend, AttackQty, D
groupAttack = GroupAttack and GroupAttack or false,
expend = WeaponExpend or "Auto",
attackQtyLimit = AttackQty and true or false,
attackQty = AttackQty,
attackQty = AttackQty or 1,
directionEnabled = Direction and true or false,
direction = Direction and math.rad(Direction) or nil,
direction = Direction and math.rad(Direction) or 0,
altitudeEnabled = Altitude and true or false,
altitude = Altitude,
altitude = Altitude or 2000,
weaponType = WeaponType or 1073741822,
attackType = _attacktype,
attackType = Divebomb and "Dive" or nil,
},
}
self:F( { TaskBombing=DCSTask } )
return DCSTask
end
@ -971,10 +970,8 @@ end
-- @param #number WeaponType (Optional) The WeaponType. Default Auto=1073741822.
-- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskAttackMapObject( Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType )
self:F2( { self.ControllableName, Vec2, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, WeaponType } )
local DCSTask
DCSTask = {
local DCSTask = {
id = 'AttackMapObject',
params = {
point = Vec2,
@ -985,14 +982,13 @@ function CONTROLLABLE:TaskAttackMapObject( Vec2, GroupAttack, WeaponExpend, Atta
attackQtyLimit = AttackQty and true or false,
attackQty = AttackQty,
directionEnabled = Direction and true or false,
direction = Direction,
direction = Direction and math.rad(Direction) or 0,
altitudeEnabled = Altitude and true or false,
altitude = Altitude,
weaponType = WeaponType or 1073741822,
},
},
}
self:T3( { DCSTask } )
return DCSTask
end
@ -1009,7 +1005,6 @@ end
-- @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 } )
-- Build Task Structure
local DCSTask = {
@ -1026,7 +1021,7 @@ function CONTROLLABLE:TaskCarpetBombing(Vec2, GroupAttack, WeaponExpend, AttackQ
attackQtyLimit = AttackQty and true or false,
attackQty = AttackQty,
directionEnabled = Direction and true or false,
direction = Direction and math.rad(Direction) or nil,
direction = Direction and math.rad(Direction) or 0,
altitudeEnabled = Altitude and true or false,
altitude = Altitude,
}
@ -1064,9 +1059,9 @@ 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 Core.Set#SET_GROUP GroupSetForEmbarking 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.
-- @param Core.Set#SET_GROUP DistributionGroupSet (Optional) 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)
@ -1107,7 +1102,6 @@ function CONTROLLABLE:TaskEmbarking(Vec2, GroupSetForEmbarking, Duration, Distri
}
}
self:T3( { DCSTask } )
return DCSTask
end
@ -1218,7 +1212,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.
-- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskBombingRunway(Airbase, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack)
self:F2( { self.ControllableName, Airbase, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack } )
local DCSTask = {
id = 'BombingRunway',
@ -1227,8 +1220,8 @@ function CONTROLLABLE:TaskBombingRunway(Airbase, WeaponType, WeaponExpend, Attac
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 and GroupAttack or false,
direction = Direction and math.rad(Direction) or 0,
groupAttack = GroupAttack and true or false,
},
}
@ -1241,7 +1234,10 @@ end
-- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskRefueling()
local DCSTask={id='Refueling', params={}}
local DCSTask={
id='Refueling',
params={}
}
return DCSTask
end
@ -1249,7 +1245,7 @@ end
--- (AIR HELICOPTER) Landing at the ground. For helicopters only.
-- @param #CONTROLLABLE self
-- @param DCS#Vec2 Point The point where to land.
-- @param DCS#Vec2 Vec2 The point where to land.
-- @param #number Duration The duration in seconds to stay on the ground.
-- @return #CONTROLLABLE self
function CONTROLLABLE:TaskLandAtVec2(Vec2, Duration)
@ -1262,6 +1258,7 @@ function CONTROLLABLE:TaskLandAtVec2(Vec2, Duration)
duration = Duration,
},
}
return DCSTask
end
@ -1271,18 +1268,12 @@ end
-- @param #number Duration The duration in seconds to stay on the ground.
-- @return #CONTROLLABLE self
function CONTROLLABLE:TaskLandAtZone( Zone, Duration, RandomPoint )
self:F2( { self.ControllableName, Zone, Duration, RandomPoint } )
local Point
if RandomPoint then
Point = Zone:GetRandomVec2()
else
Point = Zone:GetVec2()
end
-- Get landing point
local Point=RandomPoint and Zone:GetRandomVec2() or Zone:GetVec2()
local DCSTask = self:TaskLandAtVec2( Point, Duration )
local DCSTask = CONTROLLABLE.TaskLandAtVec2( self, Point, Duration )
self:T3( DCSTask )
return DCSTask
end
@ -1343,7 +1334,6 @@ end
-- @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 } )
-- Escort = {
-- id = 'Escort',
@ -1368,9 +1358,8 @@ function CONTROLLABLE:TaskEscort( FollowControllable, Vec3, LastWaypointIndex, E
engagementDistMax = EngagementDistance,
targetTypes = TargetTypes or {"Air"},
},
},
}
self:T3( { DCSTask } )
return DCSTask
end
@ -1385,7 +1374,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
-- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskFireAtPoint( Vec2, Radius, AmmoCount, WeaponType )
self:F2( { self.ControllableName, Vec2, Radius, AmmoCount, WeaponType } )
-- FireAtPoint = {
-- id = 'FireAtPoint',
@ -1397,13 +1385,12 @@ function CONTROLLABLE:TaskFireAtPoint( Vec2, Radius, AmmoCount, WeaponType )
-- }
-- }
local DCSTask
DCSTask = {
local DCSTask = {
id = 'FireAtPoint',
params = {
point = Vec2,
zoneRadius = Radius,
expendQty = 100, -- dummy value
point = Vec2,
zoneRadius = Radius,
expendQty = 100, -- dummy value
expendQtyEnabled = false,
}
}
@ -1436,13 +1423,16 @@ end
-- The killer is player-controlled allied CAS-aircraft that is in contact with the FAC.
-- If the task is assigned to the controllable lead unit will be a FAC.
-- @param #CONTROLLABLE self
-- @param Wrapper.Controllable#CONTROLLABLE AttackGroup Target CONTROLLABLE.
-- @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 #boolean Datalink (optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default.
-- @param Wrapper.Group#GROUP AttackGroup Target GROUP object.
-- @param #number WeaponType Bitmask of weapon types, which are allowed to use.
-- @param DCS#AI.Task.Designation Designation (Optional) Designation type.
-- @param #boolean Datalink (Optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default.
-- @param #number Frequency Frequency used to communicate with the FAC.
-- @param #number Modulation Modulation of radio for communication.
-- @param #number CallsignName Callsign enumerator name of the FAC.
-- @param #number CallsignNumber Callsign number, e.g. Axeman-**1**.
-- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskFAC_AttackGroup( AttackGroup, WeaponType, Designation, Datalink )
self:F2( { self.ControllableName, AttackGroup, WeaponType, Designation, Datalink } )
function CONTROLLABLE:TaskFAC_AttackGroup( AttackGroup, WeaponType, Designation, Datalink, Frequency, Modulation, CallsignName, CallsignNumber )
local DCSTask = {
id = 'FAC_AttackGroup',
@ -1451,10 +1441,13 @@ function CONTROLLABLE:TaskFAC_AttackGroup( AttackGroup, WeaponType, Designation,
weaponType = WeaponType,
designation = Designation,
datalink = Datalink,
frequency = Frequency,
modulation = Modulation,
callname = CallsignName,
number = CallsignNumber,
}
}
self:T3( { DCSTask } )
return DCSTask
end
@ -1467,7 +1460,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.
-- @return DCS#Task The DCS task structure.
function CONTROLLABLE:EnRouteTaskEngageTargets( Distance, TargetTypes, Priority )
self:F2( { self.ControllableName, Distance, TargetTypes, Priority } )
local DCSTask = {
id = 'EngageTargets',
@ -1479,7 +1471,6 @@ function CONTROLLABLE:EnRouteTaskEngageTargets( Distance, TargetTypes, Priority
}
}
self:T3( { DCSTask } )
return DCSTask
end
@ -1489,11 +1480,10 @@ end
-- @param #CONTROLLABLE self
-- @param DCS#Vec2 Vec2 2D-coordinates of the zone.
-- @param DCS#Distance Radius Radius of the zone.
-- @param DCS#AttributeNameArray (Optional) TargetTypes Array of target categories allowed to engage. Default {"Air"}.
-- @param DCS#AttributeNameArray TargetTypes (Optional) 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 } )
local DCSTask = {
id = 'EngageTargetsInZone',
@ -1505,7 +1495,6 @@ function CONTROLLABLE:EnRouteTaskEngageTargetsInZone( Vec2, Radius, TargetTypes,
}
}
self:T3( { DCSTask } )
return DCSTask
end
@ -1522,7 +1511,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.
-- @return DCS#Task The DCS task structure.
function CONTROLLABLE:EnRouteTaskEngageGroup( AttackGroup, Priority, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit )
self:F2( { self.ControllableName, AttackGroup, Priority, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit } )
-- EngageControllable = {
-- id = 'EngageControllable ',
@ -1554,9 +1542,8 @@ function CONTROLLABLE:EnRouteTaskEngageGroup( AttackGroup, Priority, WeaponType,
attackQty = AttackQty,
priority = Priority or 1,
},
},
}
self:T3( { DCSTask } )
return DCSTask
end
@ -1574,7 +1561,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.
-- @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 } )
local DCSTask = {
id = 'EngageUnit',
@ -1592,9 +1578,8 @@ function CONTROLLABLE:EnRouteTaskEngageUnit( EngageUnit, Priority, GroupAttack,
attackQty = AttackQty,
controllableAttack = ControllableAttack,
},
},
}
self:T3( { DCSTask } )
return DCSTask
end
@ -1604,11 +1589,12 @@ end
-- @param #CONTROLLABLE self
-- @return DCS#Task The DCS task structure.
function CONTROLLABLE:EnRouteTaskAWACS( )
self:F2( { self.ControllableName } )
local DCSTask = {id = 'AWACS', params = {}}
local DCSTask = {
id = 'AWACS',
params = {},
}
self:T3( { DCSTask } )
return DCSTask
end
@ -1617,11 +1603,12 @@ end
-- @param #CONTROLLABLE self
-- @return DCS#Task The DCS task structure.
function CONTROLLABLE:EnRouteTaskTanker( )
self:F2( { self.ControllableName } )
local DCSTask = {id = 'Tanker', params = {}}
local DCSTask = {
id = 'Tanker',
params = {},
}
self:T3( { DCSTask } )
return DCSTask
end
@ -1632,11 +1619,12 @@ end
-- @param #CONTROLLABLE self
-- @return DCS#Task The DCS task structure.
function CONTROLLABLE:EnRouteTaskEWR( )
self:F2( { self.ControllableName } )
local DCSTask = {id = 'EWR', params = {}}
local DCSTask = {
id = 'EWR',
params = {},
}
self:T3( { DCSTask } )
return DCSTask
end
@ -1654,7 +1642,6 @@ end
-- @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 } )
local DCSTask = {
id = 'FAC_EngageControllable',
@ -1667,7 +1654,6 @@ function CONTROLLABLE:EnRouteTaskFAC_EngageGroup( AttackGroup, Priority, WeaponT
}
}
self:T3( { DCSTask } )
return DCSTask
end
@ -1680,7 +1666,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.
-- @return DCS#Task The DCS task structure.
function CONTROLLABLE:EnRouteTaskFAC( Radius, Priority )
self:F2( { self.ControllableName, Radius, Priority } )
-- FAC = {
-- id = 'FAC',
@ -1690,15 +1675,14 @@ function CONTROLLABLE:EnRouteTaskFAC( Radius, Priority )
-- }
-- }
local DCSTask
DCSTask = { id = 'FAC',
local DCSTask = {
id = 'FAC',
params = {
radius = Radius,
priority = Priority
}
}
self:T3( { DCSTask } )
return DCSTask
end
@ -1799,30 +1783,6 @@ function CONTROLLABLE:TaskDisembarkFromTransport(Coordinate, Radius)
end
]]
--- (AIR) Move the controllable to a Vec2 Point, wait for a defined duration and embark a controllable.
-- @param #CONTROLLABLE self
-- @param DCS#Vec2 Point 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:TaskEmbarking( Point, Duration, EmbarkingControllable )
self:F2( { self.ControllableName, Point, Duration, EmbarkingControllable.DCSControllable } )
local DCSTask
DCSTask = { id = 'Embarking',
params = { x = Point.x,
y = Point.y,
duration = Duration,
controllablesForEmbarking = { EmbarkingControllable.ControllableID },
durationFlag = true,
distributionFlag = false,
distribution = {},
}
}
self:T3( { DCSTask } )
return DCSTask
end
--- (GROUND) Embark to a Transport landed at a location.
-- Move to a defined Vec2 Point, and embark to a controllable when arrived within a defined Radius.
@ -1831,10 +1791,8 @@ end
-- @param #number Radius The radius of the embarking zone around the Point.
-- @return DCS#Task The DCS task structure.
function CONTROLLABLE:TaskEmbarkToTransport( Point, Radius )
self:F2( { self.ControllableName, Point, Radius } )
local DCSTask --DCS#Task
DCSTask = {
local DCSTask = {
id = 'EmbarkToTransport',
params = {
point = Point,
@ -1844,7 +1802,6 @@ function CONTROLLABLE:TaskEmbarkToTransport( Point, Radius )
}
}
self:T3( { DCSTask } )
return DCSTask
end
@ -1899,12 +1856,9 @@ end
--
function CONTROLLABLE:TaskFunction( FunctionString, ... )
local DCSTask
-- Script
local DCSScript = {}
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
local ArgumentKey = '_' .. tostring( arg ):match("table: (.*)")
self:SetState( self, ArgumentKey, arg )
@ -1914,12 +1868,10 @@ function CONTROLLABLE:TaskFunction( FunctionString, ... )
DCSScript[#DCSScript+1] = FunctionString .. "( MissionControllable )"
end
DCSTask = self:TaskWrappedAction(self:CommandDoScript(table.concat( DCSScript )))
self:T( DCSTask )
-- DCS task.
local DCSTask = self:TaskWrappedAction(self:CommandDoScript(table.concat( DCSScript )))
return DCSTask
end
@ -1929,12 +1881,12 @@ end
-- @param #table TaskMission A table containing the mission task.
-- @return DCS#Task
function CONTROLLABLE:TaskMission( TaskMission )
self:F2( Points )
local DCSTask
DCSTask = { id = 'Mission', params = { TaskMission, }, }
local DCSTask = {
id = 'Mission',
params = { TaskMission, },
}
self:T3( { DCSTask } )
return DCSTask
end
@ -2995,6 +2947,51 @@ end
-- Options
--- Set option.
-- @param #CONTROLLABLE self
-- @param #number OptionID ID/Type of the option.
-- @param #number OptionValue Value of the option
-- @return #CONTROLLABLE self
function CONTROLLABLE:SetOption(OptionID, OptionValue)
local DCSControllable = self:GetDCSObject()
if DCSControllable then
local Controller = self:_GetController()
Controller:setOption( OptionID, OptionValue )
return self
end
return nil
end
--- Set option for Rules of Engagement (ROE).
-- @param Wrapper.Controllable#CONTROLLABLE self
-- @param #number ROEvalue ROE value. See ENUMS.ROE.
-- @return Wrapper.Controllable#CONTROLLABLE self
function CONTROLLABLE:OptionROE(ROEvalue)
local DCSControllable = self:GetDCSObject()
if DCSControllable then
local Controller = self:_GetController()
if self:IsAir() then
Controller:setOption(AI.Option.Air.id.ROE, ROEvalue )
elseif self:IsGround() then
Controller:setOption(AI.Option.Ground.id.ROE, ROEvalue )
elseif self:IsShip() then
Controller:setOption(AI.Option.Naval.id.ROE, ROEvalue )
end
return self
end
return nil
end
--- Can the CONTROLLABLE hold their weapons?
-- @param #CONTROLLABLE self
-- @return #boolean
@ -3237,6 +3234,27 @@ function CONTROLLABLE:OptionROTNoReaction()
return nil
end
--- Set Reation On Threat behaviour.
-- @param #CONTROLLABLE self
-- @param #number ROTvalue ROT value. See ENUMS.ROT.
-- @return #CONTROLLABLE self
function CONTROLLABLE:OptionROT(ROTvalue)
self:F2( { self.ControllableName } )
local DCSControllable = self:GetDCSObject()
if DCSControllable then
local Controller = self:_GetController()
if self:IsAir() then
Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, ROTvalue )
end
return self
end
return nil
end
--- Can the CONTROLLABLE evade using passive defenses?
-- @param #CONTROLLABLE self
-- @return #boolean
@ -3515,8 +3533,76 @@ function CONTROLLABLE:OptionKeepWeaponsOnThreat()
return nil
end
--- Prohibit Afterburner.
-- @param #CONTROLLABLE self
-- @param #boolean Prohibit If true or nil, prohibit. If false, do not prohibit.
-- @return #CONTROLLABLE self
function CONTROLLABLE:OptionProhibitAfterburner(Prohibit)
self:F2( { self.ControllableName } )
if Prohibit==nil then
Prohibit=true
end
if self:IsAir() then
self:SetOption(AI.Option.Air.id.PROHIBIT_AB, Prohibit)
end
return self
end
--- Defines the usage of Electronic Counter Measures by airborne forces. Disables the ability for AI to use their ECM.
-- @param #CONTROLLABLE self
-- @return #CONTROLLABLE self
function CONTROLLABLE:OptionECM_Never()
self:F2( { self.ControllableName } )
if self:IsAir() then
self:SetOption(AI.Option.Air.id.ECM_USING, 0)
end
return self
end
--- Defines the usage of Electronic Counter Measures by airborne forces. If the AI is actively being locked by an enemy radar they will enable their ECM jammer.
-- @param #CONTROLLABLE self
-- @return #CONTROLLABLE self
function CONTROLLABLE:OptionECM_OnlyLockByRadar()
self:F2( { self.ControllableName } )
if self:IsAir() then
self:SetOption(AI.Option.Air.id.ECM_USING, 1)
end
return self
end
--- Defines the usage of Electronic Counter Measures by airborne forces. If the AI is being detected by a radar they will enable their ECM.
-- @param #CONTROLLABLE self
-- @return #CONTROLLABLE self
function CONTROLLABLE:OptionECM_DetectedLockByRadar()
self:F2( { self.ControllableName } )
if self:IsAir() then
self:SetOption(AI.Option.Air.id.ECM_USING, 2)
end
return self
end
--- Defines the usage of Electronic Counter Measures by airborne forces. AI will leave their ECM on all the time.
-- @param #CONTROLLABLE self
-- @return #CONTROLLABLE self
function CONTROLLABLE:OptionECM_AlwaysOn()
self:F2( { self.ControllableName } )
if self:IsAir() then
self:SetOption(AI.Option.Air.id.ECM_USING, 3)
end
return self
end
--- Retrieve the controllable mission and allow to place function hooks within the mission waypoint plan.
-- Use the method @{Wrapper.Controllable#CONTROLLABLE:WayPointFunction} to define the hook functions for specific waypoints.

View File

@ -440,9 +440,16 @@ function GROUP:Destroy( GenerateEvent, delay )
end
--- Returns category of the DCS Group.
--- Returns category of the DCS Group. Returns one of
--
-- * Group.Category.AIRPLANE
-- * Group.Category.HELICOPTER
-- * Group.Category.GROUND
-- * Group.Category.SHIP
-- * Group.Category.TRAIN
--
-- @param #GROUP self
-- @return DCS#Group.Category The category ID
-- @return DCS#Group.Category The category ID.
function GROUP:GetCategory()
self:F2( self.GroupName )
@ -458,7 +465,7 @@ end
--- Returns the category name of the #GROUP.
-- @param #GROUP self
-- @return #string Category name = Helicopter, Airplane, Ground Unit, Ship
-- @return #string Category name = Helicopter, Airplane, Ground Unit, Ship, Train.
function GROUP:GetCategoryName()
self:F2( self.GroupName )
@ -469,6 +476,7 @@ function GROUP:GetCategoryName()
[Group.Category.HELICOPTER] = "Helicopter",
[Group.Category.GROUND] = "Ground Unit",
[Group.Category.SHIP] = "Ship",
[Group.Category.TRAIN] = "Train",
}
local GroupCategory = DCSGroup:getCategory()
self:T3( GroupCategory )
@ -867,10 +875,15 @@ end
--- Activates a late activated GROUP.
-- @param #GROUP self
-- @param #number delay Delay in seconds, before the group is activated.
-- @return #GROUP self
function GROUP:Activate()
function GROUP:Activate(delay)
self:F2( { self.GroupName } )
trigger.action.activateGroup( self:GetDCSObject() )
if delay and delay>0 then
self:ScheduleOnce(delay, GROUP.Activate, self)
else
trigger.action.activateGroup( self:GetDCSObject() )
end
return self
end

View File

@ -90,7 +90,6 @@ end
--- Returns the type name of the DCS Identifiable.
-- @param #IDENTIFIABLE self
-- @return #string The type name of the DCS Identifiable.
-- @return #nil The DCS Identifiable is not existing or alive.
function IDENTIFIABLE:GetTypeName()
self:F2( self.IdentifiableName )
@ -107,9 +106,17 @@ function IDENTIFIABLE:GetTypeName()
end
--- Returns category of the DCS Identifiable.
--- Returns object category of the DCS Identifiable. One of
--
-- * Object.Category.UNIT = 1
-- * Object.Category.WEAPON = 2
-- * Object.Category.STATIC = 3
-- * Object.Category.BASE = 4
-- * Object.Category.SCENERY = 5
-- * Object.Category.Cargo = 6
--
-- @param #IDENTIFIABLE self
-- @return DCS#Object.Category The category ID
-- @return DCS#Object.Category The category ID, i.e. a number.
function IDENTIFIABLE:GetCategory()
self:F2( self.ObjectName )

View File

@ -4,7 +4,7 @@
--
-- ### Author: **FlightControl**
--
-- ### Contributions:
-- ### Contributions: **funkyfranky**
--
-- ===
--
@ -48,6 +48,10 @@ STATIC = {
}
--- Register a static object.
-- @param #STATIC self
-- @param #string StaticName Name of the static object.
-- @return #STATIC self
function STATIC:Register( StaticName )
local self = BASE:Inherit( self, POSITIONABLE:New( StaticName ) )
self.StaticName = StaticName
@ -71,21 +75,19 @@ end
-- @param #STATIC self
-- @param #string StaticName Name of the DCS **Static** as defined within the Mission Editor.
-- @param #boolean RaiseError Raise an error if not found.
-- @return #STATIC
function STATIC:FindByName( StaticName, RaiseError )
-- @return #STATIC self or *nil*
function STATIC:FindByName( StaticName )
-- Find static in DB.
local StaticFound = _DATABASE:FindStatic( StaticName )
-- Set static name.
self.StaticName = StaticName
if StaticFound then
StaticFound:F3( { StaticName } )
return StaticFound
end
if RaiseError == nil or RaiseError == true then
error( "STATIC not found for: " .. StaticName )
end
return nil
end

View File

@ -424,9 +424,9 @@ function UNIT:GetRange()
local Desc = self:GetDesc()
if Desc then
local Range = Desc.range --This is in nautical miles for some reason. But should check again!
local Range = Desc.range --This is in kilometers (not meters) for some reason. But should check again!
if Range then
Range=UTILS.NMToMeters(Range)
Range=Range*1000 -- convert to meters.
else
Range=10000000 --10.000 km if no range
end
@ -436,6 +436,64 @@ function UNIT:GetRange()
return nil
end
--- Check if the unit is refuelable. Also retrieves the refuelling system (boom or probe) if applicable.
-- @param #UNIT self
-- @return #boolean If true, unit is refuelable (checks for the attribute "Refuelable").
-- @return #number Refueling system (if any): 0=boom, 1=probe.
function UNIT:IsRefuelable()
self:F2( self.UnitName )
local refuelable=self:HasAttribute("Refuelable")
local system=nil
local Desc=self:GetDesc()
if Desc and Desc.tankerType then
system=Desc.tankerType
end
return refuelable, system
end
--- Check if the unit is a tanker. Also retrieves the refuelling system (boom or probe) if applicable.
-- @param #UNIT self
-- @return #boolean If true, unit is refuelable (checks for the attribute "Refuelable").
-- @return #number Refueling system (if any): 0=boom, 1=probe.
function UNIT:IsTanker()
self:F2( self.UnitName )
local tanker=self:HasAttribute("Tankers")
local system=nil
if tanker then
local Desc=self:GetDesc()
if Desc and Desc.tankerType then
system=Desc.tankerType
end
local typename=self:GetTypeName()
-- Some hard coded data as this is not in the descriptors...
if typename=="IL-78M" then
system=1 --probe
elseif typename=="KC130" then
system=1 --probe
elseif typename=="KC135BDA" then
system=1 --probe
elseif typename=="KC135MPRS" then
system=1 --probe
elseif typename=="S-3B Tanker" then
system=1 --probe
end
end
return tanker, system
end
--- Returns the unit's group if it exist and nil otherwise.
-- @param Wrapper.Unit#UNIT self
-- @return Wrapper.Group#GROUP The Group of the Unit.
@ -756,6 +814,27 @@ function UNIT:GetDamageRelative()
return 1
end
--- Returns the category of the #UNIT from descriptor. Returns one of
--
-- * Unit.Category.AIRPLANE
-- * Unit.Category.HELICOPTER
-- * Unit.Category.GROUND_UNIT
-- * Unit.Category.SHIP
-- * Unit.Category.STRUCTURE
--
-- @param #UNIT self
-- @return #number Unit category from `getDesc().category`.
function UNIT:GetUnitCategory()
self:F3( self.UnitName )
local DCSUnit = self:GetDCSObject()
if DCSUnit then
return DCSUnit:getDesc().category
end
return nil
end
--- Returns the category name of the #UNIT.
-- @param #UNIT self
-- @return #string Category name = Helicopter, Airplane, Ground Unit, Ship
@ -833,7 +912,9 @@ end
-- * Threat level 10: Unit is AAA.
--
--
-- @param #UNIT self
-- @param #UNIT self
-- @return #number Number between 0 (low threat level) and 10 (high threat level).
-- @return #string Some text.
function UNIT:GetThreatLevel()