Difference between revisions of "DCS func isTargetDetected"

From DCS World Wiki - Hoggitworld.com
m (1 revision imported)
 
 
(4 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
|fName= isTargetDetected
 
|fName= isTargetDetected
  
|vNum= 1.2.4
+
|vNum= 1.2.6
  
 
|par1= [[DCS_Class_Controller|Controller]]
 
|par1= [[DCS_Class_Controller|Controller]]
Line 53: Line 53:
  
 
|related= [[DCS_Class_Controller|'''Controller:''']] {{listofScriptingControllerFuncs}}
 
|related= [[DCS_Class_Controller|'''Controller:''']] {{listofScriptingControllerFuncs}}
|examples=  
+
|examples= The following returns al of the entries:
  
 
local detected , visible , lastTime , type , distance , lastPos , lastVel = uCon:isTargetDetected(target)
 
local detected , visible , lastTime , type , distance , lastPos , lastVel = uCon:isTargetDetected(target)
  
 +
To output a list of how the aircraft is detecting the target as a message:
 +
  local con = Unit.getController(Unit.getByName('whatever'))
 +
  local target = Unit.getByName('target')
 +
  local m = {}
 +
  for det, enum in pairs(Controller.Detection) do
 +
      m[#m+1] = det .. " : "
 +
      m[#m+1] = tostring(con:isTargetDetected(target, enum))
 +
      m[#m+1] = "\n"
 +
  end
 +
  trigger.action.outText(table.concat(m), 20, true)
  
 
|notes= Detection Types
 
|notes= Detection Types
  
  Conroller.Detection = {  
+
  Conroller.Detection   
   VISUAL,
+
   VISUAL 1
   OPTIC,
+
   OPTIC   2
   RADAR,
+
   RADAR   4
   IRST,
+
   IRST   8
   RWR,
+
   RWR     16
   DLINK
+
   DLINK   32
}
+
 
 
}}
 
}}
 
[[Category:Class Functions|isTargetDetected]]
 
[[Category:Class Functions|isTargetDetected]]
 +
[[Category:Game Patch 1.2.6|isTargetDetected]]

Latest revision as of 23:39, 1 April 2022

Scripting Root

Envrioment: Mission Scripting
Function: isTargetDetected Added with: 1.2.6
Member Of: Controller
Syntax: multiple Controller.isTargetDetected(Class self , Object Target , enum detectionType1, enum detectionType2, enum detectionType3 ...)
Description: Returns multiple entries that define a number of values if the target is detected by the Unit or group associated with the controller.

Values returned are:

 boolean detected, -- boolean value if the target is detected
 boolean visible, -- boolean value if target is visible by line of sight
 ModelTime lastTime, -- the last model time that the target was detected
 boolean type, -- if the type of target is known
 boolean distance, -- if distance to the target is known
 Vec3 lastPos, -- last known position of the target
 Vec3 lastVel -- last know velocity vector of the target

Function is available at the unit level for all unit types.

When used with a Group Controller the function will return expected values only with Ground and Ship groups.


Return Value: multiple
Return Example:
Examples: The following returns al of the entries:

local detected , visible , lastTime , type , distance , lastPos , lastVel = uCon:isTargetDetected(target)

To output a list of how the aircraft is detecting the target as a message:

  local con = Unit.getController(Unit.getByName('whatever'))
  local target = Unit.getByName('target')
  local m = {}
  for det, enum in pairs(Controller.Detection) do
     m[#m+1] = det .. " : "
     m[#m+1] = tostring(con:isTargetDetected(target, enum))
     m[#m+1] = "\n"
  end
  trigger.action.outText(table.concat(m), 20, true)
Related Functions: Controller: setTask, resetTask, pushTask, popTask, hasTask, setCommand, setOption, setOnOff, setAltitude, setSpeed, knowTarget, isTargetDetected, getDetectedTargets
Notes: Detection Types
Conroller.Detection  
  VISUAL  1
  OPTIC   2
  RADAR   4
  IRST    8
  RWR     16
  DLINK   32