From bdf8bb2aaa3cc0935483aa828d6fd46efaec8403 Mon Sep 17 00:00:00 2001 From: Rolln Date: Mon, 22 Jul 2024 12:25:50 -0600 Subject: [PATCH] Added missing coalition functions --- library/mission/coalition.lua | 77 ++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/library/mission/coalition.lua b/library/mission/coalition.lua index 9913908..86c8be5 100644 --- a/library/mission/coalition.lua +++ b/library/mission/coalition.lua @@ -43,6 +43,16 @@ function coalition.addGroup(countryId, groupCategory, groupData) end function coalition.addStaticObject(countryId, groupData) end ---Returns a table of unit objects that are currently occupied by players. Function is useful in multiplayer to easily filter client aircraft from everything else. +---___ +---Example:
+---Print the names of client aircraft currently spawned on blue. +---```lua +--- local bluePlayers = coalition.getPlayers(2) +--- for i = 1, #bluePlayers do +--- env.info(Unit.getName(bluePlayers[i])) +--- end +---``` +---___ ---@param coalitionId coalition.side -- The id of the coalition. ---@return Unit[] -- A table of unit objects that are currently occupied by players. function coalition.getPlayers(coalitionId) end @@ -62,4 +72,69 @@ function coalition.getGroups(coalitionId, groupCategory) end ---Returns a table of static objects (StaticObject[]) belonging to the specified coalition. ---@param coalitionId coalition.side -- The id of the coalition. ---@return StaticObject[] -- A table of static objects. -function coalition.getStaticObjects(coalitionId) end \ No newline at end of file +function coalition.getStaticObjects(coalitionId) end + +---Returns a table of airbase objects belonging to the specified coalition. Objects can be ships, static objects(FARP), or airbases on the map. +---When the function is run as world.getAirbases() no input values required, and the function returns all airbases, ships, and farps on the map +---___ +---Example:
+---The following iterates the returned airbases via world.getAirbases() and stores callsign, id, and other useful information in another table. +---```lua +--- local base = world.getAirbases() +--- local myBaseTbl = {} +--- for i = 1, #base do +--- local info = {} +--- info.desc = Airbase.getDesc(base[i]) +--- info.callsign = Airbase.getCallsign(base[i]) +--- info.id = Airbase.getID(base[i]) +--- info.cat = Airbase.getCategory(base[i]) +--- info.point = Airbase.getPoint(base[i]) +--- if Airbase.getUnit(base[i]) then +--- info.unitId = Airbase.getUnit(base[i]):getID() +--- end +--- +--- myBaseTbl[info.callsign] = info +--- end +--- ``` +---___ +---@param coalitionId coalition.side Id of coalition. +---@return Airbase[] # Table of airbases for the given coalition. +function coalition.getAirbases(coalitionId ) end + +---Returns a table of unit objects that provide a given service to player controlled aircraft. Services are ATC, AWACS, TANKER, and FAC. +---___ +---@param coalitionId coalition.side Id of coalition. +---@param service coalition.service Type of service. +---@return Unit[] # Table of Unit objects of the given service. +function coalition.getServiceProviders(coalitionId , service ) end + +---A refPoint is a table format used in addRefPoints, getRefPoints and getMainRefPoint functions. +---@class coalition.refPoint +---@field callsign number +---@field type number +---@field point vec3 +coalition.refPoint = {} + +---Creates a new reference point belonging to the specified coalition. Reference points are used by JTACs. +---```lua +--- RefPoint = { +--- callsign = number, +--- type = number, +--- point = Vec3 +--- } +---``` +---@param coalitionId coalition.side +---@param refPoint coalition.refPoint +function coalition.addRefPoints(coalitionId , refPoint ) end + +---Returns a table of reference points as defined by the mission editor or added via scripting. Reference points are used by JTACs. +---___ +---@param coalitionId coalition.side +---@return coalition.refPoint[] # Table of refPoints for given coalition. +function coalition.getRefPoints(coalitionId ) end + +---Returns the position of a coalitions "bullseye" as specified in the mission editor. +---___ +---@param coalitionId coalition.side +---@return vec3 bullseye Bullseye of given coalition. +function coalition.getMainRefPoint(coalitionId ) end