Version 2.4.2

Player Score Update, Guardian Angel Update, new planeGuard
This commit is contained in:
Christian Franz
2025-01-29 07:18:10 +01:00
parent 4e78dfcb65
commit 3a87f7b784
22 changed files with 26464 additions and 24787 deletions

View File

@@ -1,5 +1,5 @@
cfxMX = {}
cfxMX.version = "3.0.0"
cfxMX.version = "3.0.1"
cfxMX.verbose = false
--[[--
Mission data decoder. Access to ME-built mission structures
@@ -22,6 +22,7 @@ cfxMX.verbose = false
3.0.0 - patch coalition.addGroup() to build unit table for wasUnit
- pre-populate spawnedUnits coa, cat from MX
- spawnedUnitGroupNameByName
3.0.1 - new getClosestUnitToPoint()
--]]--
@@ -33,7 +34,7 @@ cfxMX.groupNamesByID = {}
cfxMX.groupIDbyName = {}
cfxMX.unitIDbyName = {}
cfxMX.groupCatByName = {}
cfxMX.groupDataByName = {}
cfxMX.groupDataByName = {} -- includes static groups!
cfxMX.groupTypeByName = {} -- category of group: "helicopter", "plane", "ship"...
cfxMX.groupCoalitionByName = {}
cfxMX.groupHotByName = {}
@@ -413,6 +414,34 @@ function cfxMX.allGroupsInZoneByData(theZone, cat) -- returns groups indexed by
return theGroupsInZone, count
end
function cfxMX.getClosestUnitToPoint(A, filter) -- uses MX!
if not A then return nil end
if not filter then filter = "all" end
local theUnit = nil
local uIdx = nil
local theGroup = nil
local ax = A.x
local az = A.z
local closest = math.huge
for name, gData in pairs(cfxMX.groupDataByName) do
if filter == "all" or filter == cfxMX.groupTypeByName[name] then
for idx, uData in pairs(gData.units) do
-- use square delta, immediate
local dx = ax - uData.x
local dz = az - uData.y -- !!
local d = dx * dx + dz * dz
if d < closest then
theUnit = uData
theGroup = gData
closest = d
uIdx = idx
end
end
end
end
return theUnit, theGroup, uIdx, closest^0.5
end
function cfxMX.isDynamicPlayer(theUnit)
if not theUnit then return false end
if not theUnit.getName then return false end