Sweep cap (#54)

* Added initial implementation of Sweep groups

* Added initial implementation of Sweep groups

* Added initial implementation of Sweep groups

* Added initial implementation of Sweep groups

* fixed issues when testing

* Intercept cap (#55)

* First intial WIP for intercept units

* First intial WIP for intercept units

* major updates

---------

Co-authored-by: ex61wi <tim.rorije@ing.com>
Co-authored-by: dutchie032 <dutchie032>

---------

Co-authored-by: ex61wi <tim.rorije@ing.com>
Co-authored-by: dutchie032 <dutchie032>
This commit is contained in:
2025-06-12 22:40:55 +02:00
committed by GitHub
co-authored by ex61wi dutchie032 <dutchie032>
parent bdf7154333
commit ef65f5a353
22 changed files with 1834 additions and 353 deletions
+63 -14
View File
@@ -7,8 +7,10 @@
---@field MissionZonesLocations table<string, Vec2> All Mission Zone Locations
---@field StageZonesByNumber table<string, Array<string>> Stage zones grouped by index number
---@field AllFarpZones Array<string>
---@field CapRoutes Array<string> All Cap route zone names
---@field capZonesByCapZoneID table<string, CapRoute> table<StageNumber, table>
---@field AllCapRoutes Array<string> All Cap route zone names
---@field AllInterceptZones Array<string> All intercept zones
---@field capZonesByCapZoneID table<string, CapRoute>
---@field interceptZonesByZoneID table<string, Array<SpearheadTriggerZone>>
---@field CarrierRouteZones Array<string> All Carrier routes zones
---@field BlueSams Array<string> All blue sam zones
---@field SupplyHubZones Array<string> All supply hub zones
@@ -43,6 +45,8 @@
---@class AirbaseData
---@field CapGroups Array<string>
---@field SweepGroups Array<string>
---@field InterceptGroups Array<string>
---@field RedGroups Array<string>
---@field BlueGroups Array<string>
---@field supplyHubNames Array<string>
@@ -78,8 +82,10 @@ function Database.New(Logger)
local tables = {
AllZoneNames = {},
BlueSams = {},
CapRoutes = {},
AllCapRoutes = {},
capZonesByCapZoneID = {},
AllInterceptZones = {},
interceptZonesByZoneID = {},
CarrierRouteZones = {},
MissionZones = {},
MissionZonesLocations = {},
@@ -141,37 +147,43 @@ function Database.New(Logger)
end
end
if string.lower(split_string[1]) == "waitingstage" then
local lowered = string.lower(split_string[1])
if lowered == "waitingstage" then
table.insert(self._tables.StageZoneNames, zone_name)
end
if string.lower(split_string[1]) == "mission" then
if lowered == "mission" then
table.insert(self._tables.MissionZones, zone_name)
self._tables.MissionZonesLocations[zone_name] = zoneLocation
end
if string.lower(split_string[1]) == "randommission" then
if lowered == "randommission" then
table.insert(self._tables.RandomMissionZones, zone_name)
self._tables.MissionZonesLocations[zone_name] = zoneLocation
end
if string.lower(split_string[1]) == "farp" then
if lowered == "farp" then
table.insert(self._tables.AllFarpZones, zone_name)
end
if string.lower(split_string[1]) == "caproute" then
table.insert(self._tables.CapRoutes, zone_name)
if lowered == "caproute" then
table.insert(self._tables.AllCapRoutes, zone_name)
end
if string.lower(split_string[1]) == "carrierroute" then
if lowered == "interceptzone" then
table.insert(self._tables.AllInterceptZones, zone_name)
end
if lowered == "carrierroute" then
table.insert(self._tables.CarrierRouteZones, zone_name)
end
if string.lower(split_string[1]) == "bluesam" then
if lowered == "bluesam" then
table.insert(self._tables.BlueSams, zone_name)
end
if string.lower(split_string[1]) == "supplyhub" then
if lowered == "supplyhub" then
table.insert(self._tables.SupplyHubZones, zone_name)
end
end
@@ -364,7 +376,7 @@ function Database.New(Logger)
self:loadMiscGroupsInStages()
for _, cap_route_zone in pairs(self._tables.CapRoutes) do
for _, cap_route_zone in pairs(self._tables.AllCapRoutes) do
local split = Spearhead.Util.split_string(cap_route_zone, "_")
local zoneID = split[2]
@@ -383,6 +395,22 @@ function Database.New(Logger)
end
end
for _, interceptZone in pairs(self._tables.AllInterceptZones) do
local split = Spearhead.Util.split_string(interceptZone, "_")
local zoneID = split[2]
if zoneID then
if tables.interceptZonesByZoneID[zoneID] == nil then
tables.interceptZonesByZoneID[zoneID] = {}
end
local zone = Spearhead.DcsUtil.getZoneByName(interceptZone)
if zone then
table.insert(tables.interceptZonesByZoneID[zoneID], zone)
end
end
end
local totalUnits = 0
local missions = 0
for _, data in pairs(self._tables.MissionZoneData) do
@@ -525,6 +553,8 @@ function Database:getOrCreateAirbaseData(baseName)
if baseData == nil then
baseData = {
CapGroups = {},
InterceptGroups = {},
SweepGroups = {},
RedGroups = {},
BlueGroups = {},
supplyHubNames = {}
@@ -591,7 +621,14 @@ function Database:loadCapUnits()
local groups = Spearhead.DcsUtil.areGroupsInCustomZone(all_groups, zone)
for _, groupName in pairs(groups) do
is_group_taken[groupName] = true
table.insert(baseData.CapGroups, groupName)
if Spearhead.Util.startswith(groupName, "CAP_A", true) or Spearhead.Util.startswith(groupName, "CAP_B", true) then
table.insert(baseData.CapGroups, groupName)
elseif Spearhead.Util.startswith(groupName, "CAP_I", true) then
table.insert(baseData.InterceptGroups, groupName)
elseif Spearhead.Util.startswith(groupName, "CAP_S", true) then
table.insert(baseData.SweepGroups, groupName)
end
end
self._tables.AirbaseDataPerAirfield[airbase:getName()] = baseData
@@ -832,6 +869,18 @@ function Database:GetCapZoneForZoneID(zoneID)
return nil
end
function Database:GetInterceptZonesForZoneID(zoneID)
zoneID = tostring(zoneID) or "nothing"
local interceptZonesForID = self._tables.interceptZonesByZoneID[zoneID]
if not interceptZonesForID then
return {}
end
return interceptZonesForID
end
---@return Array<string> result a list of stage zone names
function Database:getStagezoneNames()
return self._tables.StageZoneNames