Add Controller.Detection and knowTarget.

Add Spot (laser).
Various minor improvements
This commit is contained in:
omltcat 2024-06-24 01:47:56 -04:00
parent 8b7b276480
commit 5f4f565b72
6 changed files with 91 additions and 3 deletions

View File

@ -2,6 +2,7 @@
---@class Controller
Controller = {}
---@enum Controller.Detection
Controller.Detection = {
VISUAL = 1,
OPTIC = 2,
@ -54,3 +55,10 @@ function Controller:setSpeed(speed, keep) end
---[Available Tasks](https://wiki.hoggitworld.com/view/DCS_func_setTask)
---@param task table -- The task to be set.
function Controller:setTask(task) end
---Forces the controller to become aware of the specified target, without the controller manually detecting the object itself.<br>
---Applies only to a Unit Controller. Cannot be used at the group level.
---@param target Object
---@param knowType boolean
---@param knowDistance boolean
function Controller:knowTarget(target, knowType, knowDistance) end

78
library/mission/spot.lua Normal file
View File

@ -0,0 +1,78 @@
---@meta
---@class Spot
Spot = {}
---Creates an infrared ray emanating from the given object to a point in 3d space. Can be seen with night vision goggles.<br>
---localRef is technically an optional variable, however the function's format requires an entry to be made. If not used, simply replace with nil.<br>
---Example:
---```
---local jtac = Unit.getByName('jtacBob')
---local target = Unit.getByName('BMPAirDefenseSystemGroup1_unit1'):getPoint()
---local ray = Spot.createInfraRed(jtac, {x = 0, y = 1, z = 0}, target)
---```
---@param source Object -- The object from which the infrared ray emanates.
---@param localRef vec3? -- The local reference point. If not used, replace with nil.
---@param point vec3 -- The point in 3D space where the infrared ray ends.
---@return Spot Object
function Spot.createInfraRed(source, localRef, point) end
---Creates a laser ray emanating from the given object to a point in 3d space.<br>
---localRef is technically an optional variable, however the function's format requires an entry to be made. If not used, simply replace with nil.<br>
---If optional variable laserCode is not present the beam will automatically be set to an IR beam. If laserCode is specified, the beam is a laser which can be used to guide laser guided bombs.<br>
---Laser code is any 4 digit number between 1111 and 1788.<br>
---Example:
---```
---local jtac = Unit.getByName('jtacBob')
---local target = Unit.getByName('BMPAirDefenseSystemGroup1_unit1'):getPoint()
---local ray = Spot.createLaser(jtac, {x = 0, y = 1, z = 0}, target, 1337)
---```
---@param source Object -- The object from which the laser ray emanates.
---@param localRef vec3? -- The local reference point. If not used, replace with nil.
---@param point vec3 -- The point in 3D space where the laser ray ends.
---@param laseCode integer? -- The laser code for guiding laser guided bombs. Optional.
---@return Spot Object
function Spot.createLaser(source, localRef, point, laseCode) end
---Sets the destination point from which the source of the spot is drawn toward.<br>
---Example:
---```
---local jtac = Unit.getByName('jtacBob')
---local target = Unit.getByName('BMPAirDefenseSystemGroup1_unit1')
---local ray = Spot.createLaser(jtac, {x = 0, y = 1, z = 0}, target:getPoint(), 1337)
---local function updateRay()
--- if Object.isExist(target) then
--- ray:setPoint(target:getPoint())
--- timer.scheduleFunction(updateRay, {}, timer.getTime() + 0.5)
--- else
--- ray:destroy()
--- end
---end
---timer.scheduleFunction(updateRay, {}, timer.getTime() + 0.5)
---```
---@param vec3 table -- The destination point in 3D space.
function Spot:setPoint(vec3) end
---Returns the laser code used for laser designation tracking.<br>
---The default and maximum value is 1688.<br>
---Example:
---```
---local jtac = Unit.getByName('jtacBob')
---local target = Unit.getByName('BMPAirDefenseSystemGroup1_unit1')
---local ray = Spot.createLaser(jtac, {x = 0, y = 1, z = 0}, target:getPoint(), 1337)
---local laserCode = ray:getCode()
---print("Laser code is: " .. laserCode)
---```
---@return number
function Spot:getCode() end
---Sets the laser code for the spot. If no code is provided, a default value is used.<br>
---Example:
---```
---local ray = Spot.createLaser(jtac, {x = 0, y = 1, z = 0}, Unit.getByName('target'):getPoint(), 1337)
---local function changeCodePlease(code)
--- local c = code or 1234 -- Default code if none provided
--- ray:setCode(c)
---end
---```
---@param code number -- The laser code to set. Default and max value is 1688.
function Spot:setCode(code) end

View File

@ -316,7 +316,7 @@ function trigger.misc.getUserFlag(flagNumOrName) end
---Returns a trigger zone table of a given name.
---@param zoneName string -- The name of the trigger zone.
---@return zone -- The trigger zone table. Format: { point = vec3, radius = distance }
---@return zone? -- The trigger zone table. Format: { point = vec3, radius = distance }
function trigger.misc.getZone(zoneName) end
---Sets a user flag to the specified value.

View File

@ -19,7 +19,7 @@ function Unit.getByName(name) end
---Returns an ammo table for all types of loaded ammunition on a given object.
---@return table -- Ammo table is indexed by ammo type and contains a weapon description table and a count variable defining "how many" is on board.
---@return {count: integer, desc: WeaponDesc}[] -- Ammo table is indexed by ammo type and contains a weapon description table and a count variable defining "how many" is on board.
function Unit:getAmmo() end
---Returns a localized string of the unit's callsign.<br>

View File

@ -43,6 +43,8 @@ Weapon.WarheadType = {
---@class WeaponDesc: ObjectDesc
---@field category Weapon.Category
---@field warhead WeaponDesc.warhead
---@field missileCategory Weapon.MissileCategory?
---@field guidance Weapon.GuidanceType?
---@class WeaponDesc.warhead
---@field explosiveMass number?

View File

@ -106,7 +106,7 @@ world.BirthPlace = {
--- myBaseTbl[info.callsign] = info
---end
---```
---@return table
---@return Airbase[]
function world.getAirbases() end
---Returns a table of mark panels and drawn shapes indexed numerically that are present within the mission.<br>