Merge pull request #4 from dutchie032/feature/blueSams
added BLUESAM zone
This commit is contained in:
@@ -77,6 +77,30 @@ Overwrite the values in your own script (before spearhead runs) or <a download="
|
||||
##!config!##
|
||||
```
|
||||
|
||||
## All Trigger zone name options:
|
||||
|
||||
<details>
|
||||
<summary>MISSIONSTAGE_</summary>
|
||||
A mission stage that encapsulates multiple missions, airbases and other objects.
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>MISSION_</summary>
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>BLUESAM_</summary>
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>CAPROUTE_</summary>
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>CAPZONE_</summary>
|
||||
</details>
|
||||
|
||||
|
||||
## Stage
|
||||
|
||||
A stage is a logical part of a mission. It's isn't anything special per se, but everything revolves around stages in Spearhead. <br/>
|
||||
|
||||
@@ -29,6 +29,7 @@ do -- DB
|
||||
o.tables.farp_zones = {}
|
||||
o.tables.cap_route_zones = {}
|
||||
o.tables.carrier_route_zones = {}
|
||||
o.tables.blue_sams = {}
|
||||
|
||||
o.tables.stage_zonesByNumer = {}
|
||||
o.tables.stage_numberPerzone = {}
|
||||
@@ -70,6 +71,10 @@ do -- DB
|
||||
if string.lower(split_string[1]) == "carrierroute" then
|
||||
table.insert(o.tables.carrier_route_zones, zone_name)
|
||||
end
|
||||
|
||||
if string.lower(split_string[1]) == "bluesam" then
|
||||
table.insert(o.tables.blue_sams, zone_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -103,6 +108,21 @@ do -- DB
|
||||
end
|
||||
end
|
||||
|
||||
o.tables.blueSamZonesPerStage = {}
|
||||
for _, stageZoneName in pairs(o.tables.stage_zones) do
|
||||
|
||||
if o.tables.blueSamZonesPerStage[stageZoneName] == nil then
|
||||
o.tables.blueSamZonesPerStage[stageZoneName] = {}
|
||||
end
|
||||
|
||||
for _, blueSamStageName in pairs(o.tables.blue_sams) do
|
||||
|
||||
if Spearhead.DcsUtil.isZoneInZone(blueSamStageName, stageZoneName) == true then
|
||||
table.insert(o.tables.blueSamZonesPerStage[stageZoneName], blueSamStageName)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
o.tables.missionZonesPerStage = {}
|
||||
for key, missionZone in pairs(o.tables.mission_zones) do
|
||||
local found = false
|
||||
@@ -258,6 +278,21 @@ do -- DB
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
o.tables.samUnitsPerSamZone = {}
|
||||
local loadBlueSamUnits = function()
|
||||
local all_groups = getAvailableGroups()
|
||||
for _, blueSamZone in pairs(o.tables.blue_sams) do
|
||||
o.tables.samUnitsPerSamZone[blueSamZone] = {}
|
||||
local groups = Spearhead.DcsUtil.getGroupsInZone(all_groups, blueSamZone)
|
||||
for _, groupName in pairs(groups) do
|
||||
is_group_taken[groupName] = true
|
||||
table.insert(o.tables.samUnitsPerSamZone[blueSamZone], groupName)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--- missionZoneName <> groupname[]
|
||||
o.tables.groupsInMissionZone = {}
|
||||
local loadMissionzoneUnits = function()
|
||||
@@ -394,6 +429,7 @@ do -- DB
|
||||
end
|
||||
|
||||
loadCapUnits()
|
||||
loadBlueSamUnits()
|
||||
loadMissionzoneUnits()
|
||||
loadRandomMissionzoneUnits()
|
||||
loadFarpGroups()
|
||||
@@ -572,7 +608,6 @@ do -- DB
|
||||
return self.tables.descriptions[missionZoneName] or ""
|
||||
end
|
||||
|
||||
---comment
|
||||
---@param self table
|
||||
---@param stageName string
|
||||
---@return table result airbase IDs. Use Spearhead.DcsUtil.getAirbaseById
|
||||
@@ -584,7 +619,6 @@ do -- DB
|
||||
return self.tables.farpZonesPerStage[stageName]
|
||||
end
|
||||
|
||||
---comment
|
||||
---@param self table
|
||||
---@param airbaseId number
|
||||
---@return table
|
||||
@@ -592,6 +626,20 @@ do -- DB
|
||||
return self.tables.capGroupsOnAirbase[airbaseId] or {}
|
||||
end
|
||||
|
||||
---@param self table
|
||||
---@param stageName string
|
||||
---@return table
|
||||
o.getBlueSamsInStage = function(self, stageName)
|
||||
return self.tables.blueSamZonesPerStage[stageName] or {}
|
||||
end
|
||||
|
||||
---@param self table
|
||||
---@param samZone string
|
||||
---@return table
|
||||
o.getBlueSamGroupsInZone = function(self, samZone)
|
||||
return self.tables.samUnitsPerSamZone[samZone] or {}
|
||||
end
|
||||
|
||||
o.getRedGroupsAtAirbase = function(self, airbaseId)
|
||||
local baseId = tostring(airbaseId)
|
||||
return self.tables.redAirbaseGroupsPerAirbase[baseId] or {}
|
||||
|
||||
@@ -38,6 +38,7 @@ do --init STAGE DIRECTOR
|
||||
o.db.sams = {}
|
||||
o.db.redAirbasegroups = {}
|
||||
o.db.blueAirbasegroups = {}
|
||||
o.db.blueSamGroups = {}
|
||||
o.db.airbaseIds = {}
|
||||
o.db.farps = {}
|
||||
o.activeStage = -99
|
||||
@@ -105,6 +106,13 @@ do --init STAGE DIRECTOR
|
||||
end
|
||||
end
|
||||
|
||||
for _, samZoneName in pairs(database:getBlueSamsInStage(o.zoneName)) do
|
||||
for _, samGroup in pairs(database:getBlueSamGroupsInZone(samZoneName)) do
|
||||
table.insert(o.db.blueSamGroups, samGroup)
|
||||
Spearhead.DcsUtil.DestroyGroup(samGroup)
|
||||
end
|
||||
end
|
||||
|
||||
local miscGroups = database:getMiscGroupsAtStage(o.zoneName)
|
||||
for _, groupName in pairs(miscGroups) do
|
||||
Spearhead.DcsUtil.DestroyGroup(groupName)
|
||||
@@ -301,6 +309,10 @@ do --init STAGE DIRECTOR
|
||||
self:MarkStage(true)
|
||||
end)
|
||||
|
||||
for _, blueSamGroupName in pairs(self.db.blueSamGroups) do
|
||||
Spearhead.DcsUtil.SpawnGroupTemplate(blueSamGroupName)
|
||||
end
|
||||
|
||||
for key, airbaseId in pairs(self.db.airbaseIds) do
|
||||
local airbase = Spearhead.DcsUtil.getAirbaseById(airbaseId)
|
||||
|
||||
@@ -316,6 +328,7 @@ do --init STAGE DIRECTOR
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
---Sets airfields to blue and spawns friendly farps
|
||||
|
||||
@@ -26,7 +26,7 @@ local SetStageDelayed = function(number, time)
|
||||
return nil
|
||||
end
|
||||
|
||||
timer.scheduleFunction(SetStageDelayed, 1, timer.getTime() + 3)
|
||||
timer.scheduleFunction(SetStageDelayed, 2, timer.getTime() + 3)
|
||||
|
||||
Spearhead.LoadingDone()
|
||||
--Check lines of code in directory per file:
|
||||
|
||||
Reference in New Issue
Block a user