mirror of
https://github.com/akaAgar/the-universal-mission-for-dcs-world.git
synced 2026-08-26 04:45:19 +00:00
Added DCSEx.envMission.getPlayerGroupsCenterPoint(coalitionId)
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
-- DCSEx.envMission.getGroup(groupID)
|
-- DCSEx.envMission.getGroup(groupID)
|
||||||
-- DCSEx.envMission.getGroups(sideID)
|
-- DCSEx.envMission.getGroups(sideID)
|
||||||
-- DCSEx.envMission.getPlayerGroups(coalitionId)
|
-- DCSEx.envMission.getPlayerGroups(coalitionId)
|
||||||
|
-- DCSEx.envMission.getPlayerGroupsCenterPoint(coalitionId)
|
||||||
-- ====================================================================================
|
-- ====================================================================================
|
||||||
|
|
||||||
DCSEx.envMission = {}
|
DCSEx.envMission = {}
|
||||||
@@ -111,6 +112,7 @@ function DCSEx.envMission.getPlayerGroups(coalitionId)
|
|||||||
for _, u in pairs(g.units) do
|
for _, u in pairs(g.units) do
|
||||||
if u.skill == "Player" or u.skill == "Client" then
|
if u.skill == "Player" or u.skill == "Client" then
|
||||||
isPlayerGroup = true
|
isPlayerGroup = true
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -122,6 +124,27 @@ function DCSEx.envMission.getPlayerGroups(coalitionId)
|
|||||||
return playerGroups
|
return playerGroups
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-------------------------------------
|
||||||
|
-- Return the center 2D point of all player groups
|
||||||
|
-- @param coalitionId Coalition ID (coalition.side.*), or nil to use unit groups from all coalitions
|
||||||
|
-- @return A 2D point, or nil if no player groups
|
||||||
|
-------------------------------------
|
||||||
|
function DCSEx.envMission.getPlayerGroupsCenterPoint(coalitionId)
|
||||||
|
local pGroups = DCSEx.envMission.getPlayerGroups(coalitionId)
|
||||||
|
if #pGroups == 0 then return nil end
|
||||||
|
|
||||||
|
local center = { x = 0, y = 0 }
|
||||||
|
for _,g in ipairs(pGroups) do
|
||||||
|
center.x = center.x + g.x
|
||||||
|
center.y = center.y + g.y
|
||||||
|
end
|
||||||
|
|
||||||
|
center.x = center.x / #pGroups
|
||||||
|
center.y = center.y / #pGroups
|
||||||
|
|
||||||
|
return center
|
||||||
|
end
|
||||||
|
|
||||||
-- TODO: description & file header
|
-- TODO: description & file header
|
||||||
function DCSEx.envMission.setBriefing(side, text, picture)
|
function DCSEx.envMission.setBriefing(side, text, picture)
|
||||||
text = text or ""
|
text = text or ""
|
||||||
|
|||||||
Reference in New Issue
Block a user