mirror of
https://github.com/akaAgar/the-universal-mission-for-dcs-world.git
synced 2025-11-25 19:31:01 +00:00
Cleaned up and added comments to DCSEx tables
This commit is contained in:
@@ -1,33 +1,32 @@
|
||||
-- ====================================================================================
|
||||
-- DCSTOOLS - FUNCTIONS LINKED TO DCS WORLD RULES AND TABLES
|
||||
-- DCSEX.DCS - FUNCTIONS HANDLING DCS WORLD'S GAME RULES AND TABLES
|
||||
-- ====================================================================================
|
||||
-- DCSEx.dcs.getBRAA(point, refPoint, showAltitude, metricSystem, casualFormat)
|
||||
-- DCSEx.dcs.getCJTFForCoalition(coalitionID)
|
||||
-- DCSEx.dcs.getCoalitionAsString(coalitionID)
|
||||
-- DCSEx.dcs.getCoalitionColor(coalitionID, alpha)
|
||||
-- DCSEx.dcs.getFirstUnitCallsign(group)
|
||||
-- DCSEx.dcs.getGroupCenterPoint(group)
|
||||
-- DCSEx.dcs.getGroupIDAsNumber(group)
|
||||
-- DCSEx.dcs.getNearestObject(refPoint, objectTable)
|
||||
-- DCSEx.dcs.getNearestObjects(refPoint, objectTable, maxCount)
|
||||
-- DCSEx.dcs.getNearestPoints(refPoint, pointsTable, maxCount)
|
||||
-- DCSEx.dcs.getObjectIDAsNumber(obj)
|
||||
-- DCSEx.dcs.getOppositeCoalition(coalitionID)
|
||||
-- DCSEx.dcs.getPlayerUnitsInGroup(group)
|
||||
-- DCSEx.dcs.getPlayerUnitsInGroupByID(groupID)
|
||||
-- DCSEx.dcs.getRadioModulationName(modulationID)
|
||||
-- DCSEx.dcs.getObjectIDAsNumber(obj)
|
||||
-- DCSEx.dcs.getUnitTypeFromFamily(unitFamily)
|
||||
-- DCSEx.dcs.getUnitFamilyForDecade(unitFamily, decade) -- TODO: remove?
|
||||
-- DCSEx.dcs.getUnitCategoryFromFamily(unitFamily)
|
||||
-- DCSEx.dcs.loadMission(fileName)
|
||||
-- DCSEx.dcs.outPicture(fileName, durationSeconds, clearView, startDelay, horizontalAlign, verticalAlign, size, sizeUnits)
|
||||
-- ====================================================================================
|
||||
|
||||
DCSEx.dcs = { }
|
||||
|
||||
-- TODO: add description and update file header
|
||||
function DCSEx.dcs.doNothing()
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Gets a BRAA (bearing, range, altitude, aspect) string about a point
|
||||
-- Format is "[bearing to unit] for [distance] at [altitude]"
|
||||
-------------------------------------
|
||||
-- @param unit A unit
|
||||
-- @param refPoint Reference point for the bearing and distance
|
||||
-- @param showAltitude Should altitude be displayed?
|
||||
@@ -86,6 +85,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the CJTF country for a given coalition
|
||||
-------------------------------------
|
||||
-- @param A coalition ID
|
||||
-- @return A country ID (country.id.CJTF_BLUE or country.id.CJTF_RED)
|
||||
-------------------------------------
|
||||
@@ -97,6 +97,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the name of a coalition, as a string ("blue", "red" or "neutral")
|
||||
-------------------------------------
|
||||
-- @param A coalition ID
|
||||
-- @return A string
|
||||
-------------------------------------
|
||||
@@ -109,8 +110,9 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the RGBA color table for the given coalition, accoding to NATO symbology colors
|
||||
-------------------------------------
|
||||
-- @param coalitionID A coalition side
|
||||
-- @param alpha (optional) Alpha. Default is 1
|
||||
-- @param alpha (optional) Alpha. Default is 1.0
|
||||
-- @return A RGBA color table
|
||||
-------------------------------------
|
||||
function DCSEx.dcs.getCoalitionColor(coalitionID, alpha)
|
||||
@@ -123,7 +125,12 @@ function DCSEx.dcs.getCoalitionColor(coalitionID, alpha)
|
||||
end
|
||||
end
|
||||
|
||||
-- TODO: description
|
||||
-------------------------------------
|
||||
-- Returns the callsign table for the first unit of the group
|
||||
-------------------------------------
|
||||
-- @param group A group
|
||||
-- @return A callsign table, or nil if no units or no group
|
||||
-------------------------------------
|
||||
function DCSEx.dcs.getFirstUnitCallsign(group)
|
||||
if not group then return nil end
|
||||
|
||||
@@ -137,6 +144,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns a vec3 point at the center of all units of a group
|
||||
-------------------------------------
|
||||
-- @param group A group object
|
||||
-- @return A vec3
|
||||
-------------------------------------
|
||||
@@ -162,6 +170,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the ID of a group as a number (here to fix a bug where sometimes ID is returned as a string)
|
||||
-------------------------------------
|
||||
-- @param group A group table
|
||||
-- @return An ID (as an number) or nil if group is nil or has no ID
|
||||
-------------------------------------
|
||||
@@ -175,6 +184,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the object nearest (in a 2D plane) from a given point
|
||||
-------------------------------------
|
||||
-- @param refPoint A reference point, as a vec2 or vec3
|
||||
-- @param objectTable A table of DCS objects
|
||||
-- @return The object nearest from the point, or nil if no object was found
|
||||
@@ -187,6 +197,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the nearest objects (in a 2D plane) from a given point
|
||||
-------------------------------------
|
||||
-- @param refPoint A reference point, as a vec2 or vec3
|
||||
-- @param objectTable A table of DCS objects
|
||||
-- @param maxCount (optional) Maximum number of objects to return
|
||||
@@ -218,6 +229,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the nearest points (in a 2D plane) from a given point
|
||||
-------------------------------------
|
||||
-- @param refPoint A reference point, as a vec2 or vec3
|
||||
-- @param objectTable A table of points (vec2 or vec3)
|
||||
-- @param maxCount (optional) Maximum number of points to return
|
||||
@@ -249,6 +261,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the coalition opposed to the provided coalition (coalition.side.NEUTRAL still returns NEUTRAL)
|
||||
-------------------------------------
|
||||
-- @param group A coalition
|
||||
-- @return Another coalition
|
||||
-------------------------------------
|
||||
@@ -260,6 +273,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns all player-controlled units in a group
|
||||
-------------------------------------
|
||||
-- @param group A group object
|
||||
-- @return A table of unit objects
|
||||
-------------------------------------
|
||||
@@ -280,6 +294,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns all player-controlled units in the group with the given ID
|
||||
-------------------------------------
|
||||
-- @param groupID A group ID
|
||||
-- @return A table of unit objects
|
||||
-------------------------------------
|
||||
@@ -289,6 +304,7 @@ end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns a radio modulation type as a string
|
||||
-------------------------------------
|
||||
-- @param modulationID A modulation ID (from radio.modulation enum)
|
||||
-- @return A string
|
||||
-------------------------------------
|
||||
@@ -297,66 +313,9 @@ function DCSEx.dcs.getRadioModulationName(modulationID)
|
||||
return "AM"
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns a remplacement unit family for given family if it's not available in this decade (e.g. SAMs in the 1940s). Else returns the original family.
|
||||
-- @param unitFamily An unit family
|
||||
-- @param decade (optional) A decade, or the current decade from env.mission.date.Year
|
||||
-- @return An unit family
|
||||
-------------------------------------
|
||||
function DCSEx.dcs.getUnitFamilyForDecade(unitFamily, decade)
|
||||
-- TODO
|
||||
-- decade = decade or envMission.getDecade()
|
||||
|
||||
-- if decade < 1990 then
|
||||
-- if unitFamily == DCSEx.enums.unitFamily.UAVs then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.AttackHelicopters
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- if decade < 1970 then
|
||||
-- if unitFamily == DCSEx.enums.unitFamily.AWACS then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.Transports
|
||||
-- elseif unitFamily == DCSEx.enums.unitFamily.SAMShort then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.MobileAAA
|
||||
-- elseif unitFamily == DCSEx.enums.unitFamily.SAMShortIR then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.MobileAAA
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- if decade < 1960 then
|
||||
-- if unitFamily == DCSEx.enums.unitFamily.AttackHelicopters then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.Fighters
|
||||
-- elseif unitFamily == DCSEx.enums.unitFamily.MANPADS then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.Infantry
|
||||
-- elseif unitFamily == DCSEx.enums.unitFamily.SAMLong then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.StaticAAA
|
||||
-- elseif unitFamily == DCSEx.enums.unitFamily.SAMMedium then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.StaticAAA
|
||||
-- elseif unitFamily == DCSEx.enums.unitFamily.SSMissiles then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.Artillery
|
||||
-- elseif unitFamily == DCSEx.enums.unitFamily.TransportHelicopters then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.Transports
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- if decade < 1950 then
|
||||
-- if unitFamily == DCSEx.enums.unitFamily.MobileAAA then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.APC
|
||||
-- elseif unitFamily == DCSEx.enums.unitFamily.Tankers then
|
||||
-- unitFamily = DCSEx.enums.unitFamily.Transports
|
||||
-- end
|
||||
-- end
|
||||
|
||||
return unitFamily
|
||||
end
|
||||
|
||||
-- TODO: description
|
||||
function DCSEx.dcs.getUnitTypeFromFamily(unitFamily)
|
||||
return math.floor(unitFamily / 100)
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Returns the ID of an object as a number (here to fix a bug where sometimes ID is returned as a string)
|
||||
-------------------------------------
|
||||
-- @param obj An object (unit, static object...)
|
||||
-- @return An ID (as an number) or nil if unit is nil or has no ID
|
||||
-------------------------------------
|
||||
@@ -365,21 +324,36 @@ function DCSEx.dcs.getObjectIDAsNumber(obj)
|
||||
return tonumber(obj:getID())
|
||||
end
|
||||
|
||||
-- TODO: description & file header
|
||||
-------------------------------------
|
||||
-- Returns a the unit category (Unit.Category enum) an unit family (DCSEx.enums.unitFamily) belongs to
|
||||
-------------------------------------
|
||||
-- @param unitFamily A value from the Unit.Category enum
|
||||
-- @return A value from the DCSEx.enums.unitFamily enum
|
||||
-------------------------------------
|
||||
function DCSEx.dcs.getUnitCategoryFromFamily(unitFamily)
|
||||
return math.floor(unitFamily / 100)
|
||||
end
|
||||
|
||||
-------------------------------------
|
||||
-- Loads another DCS World mission
|
||||
-------------------------------------
|
||||
-- @param fileName Filename of the mission
|
||||
-------------------------------------
|
||||
function DCSEx.dcs.loadMission(fileName)
|
||||
net.dostring_in("mission", string.format("a_load_mission(\"%s\")", fileName))
|
||||
end
|
||||
|
||||
-- TODO: description & file header
|
||||
-- function DCSEx.dcs.isMultiplayer()
|
||||
-- if #net.get_player_list() > 0 then return true end
|
||||
-- if dcs and dcs.isServer() == true then return true end
|
||||
-- return false
|
||||
-- end
|
||||
|
||||
-- TODO: a_end_mission
|
||||
|
||||
-- TODO: description & file header
|
||||
-------------------------------------
|
||||
-- Displays a picture on the screen of ALL players
|
||||
-------------------------------------
|
||||
-- @param fileName Filename/ResourceName of the image in the mission resources
|
||||
-- @param durationSeconds Duration (in seconds) during which the image should be displayed
|
||||
-- @param startDelay After how many seconds should the image be displayed? (default: 0)
|
||||
-- @param horizontalAlign Horizontal alignment of the image (0/1/2=left/center/right) (default: 1)
|
||||
-- @param verticalAlign Vertical alignment of the image (0/1/2=top/center/bottom) (default: 1)
|
||||
-- @param size Size of the image, in pixels or % of the screen (see sizeUnits) (default: 100)
|
||||
-- @param sizeUnits If 0, the size parameter is in pixels. If 1, it's in % of screen size (default: 0)
|
||||
-------------------------------------
|
||||
function DCSEx.dcs.outPicture(fileName, durationSeconds, clearView, startDelay, horizontalAlign, verticalAlign, size, sizeUnits)
|
||||
clearView = clearView or false
|
||||
startDelay = startDelay or 0
|
||||
|
||||
Reference in New Issue
Block a user