You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-- Use: ctld.countDroppedUnitsInZone("Zone Name", flagBlue, flagRed)
function ctld.countDroppedUnitsInZone(_zone, _blueFlag, _redFlag)
local _triggerZone = trigger.misc.getZone(_zone) -- trigger to use as reference position
if _triggerZone == nil then
trigger.action.outText("CTLD.lua ERROR: Cant find zone called " .. _zone, 10)
return
end
local _zonePos = mist.utils.zoneToVec3(_zone)
local _redCount = 0;
local _blueCount = 0;
local _allGroups = { ctld.droppedTroopsRED, ctld.droppedTroopsBLUE, ctld.droppedVehiclesRED, ctld
.droppedVehiclesBLUE }
for _, _extractGroups in pairs(_allGroups) do
for _, _groupName in pairs(_extractGroups) do
local _groupUnits = ctld.getGroup(_groupName)
if #_groupUnits > 0 then
local _zonePos = mist.utils.zoneToVec3(_zone)
for _, _unit in pairs(_groupUnits) do
local _dist = ctld.getDistance(_unit:getPoint(), _zonePos)
if _dist <= _triggerZone.radius then
if (_unit:getCoalition() == 1) then
_redCount = _redCount + 1;
else
_blueCount = _blueCount + 1;
end
end
end
end
end
end
--set flag stuff
trigger.action.setUserFlag(_blueFlag, _blueCount)
trigger.action.setUserFlag(_redFlag, _redCount)
-- env.info("Units in zone ".._blueCount.." ".._redCount)
end
function ctld.countDroppedUnitsInZone does not count properly.
Dropping 8 troops resulted in a count of 72 (factor of 9)
Dropping 24 troops resulted in a count of 600 (factor of 25)
The text was updated successfully, but these errors were encountered: