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!##
|
##!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
|
## 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/>
|
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.farp_zones = {}
|
||||||
o.tables.cap_route_zones = {}
|
o.tables.cap_route_zones = {}
|
||||||
o.tables.carrier_route_zones = {}
|
o.tables.carrier_route_zones = {}
|
||||||
|
o.tables.blue_sams = {}
|
||||||
|
|
||||||
o.tables.stage_zonesByNumer = {}
|
o.tables.stage_zonesByNumer = {}
|
||||||
o.tables.stage_numberPerzone = {}
|
o.tables.stage_numberPerzone = {}
|
||||||
@@ -70,6 +71,10 @@ do -- DB
|
|||||||
if string.lower(split_string[1]) == "carrierroute" then
|
if string.lower(split_string[1]) == "carrierroute" then
|
||||||
table.insert(o.tables.carrier_route_zones, zone_name)
|
table.insert(o.tables.carrier_route_zones, zone_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if string.lower(split_string[1]) == "bluesam" then
|
||||||
|
table.insert(o.tables.blue_sams, zone_name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -103,6 +108,21 @@ do -- DB
|
|||||||
end
|
end
|
||||||
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 = {}
|
o.tables.missionZonesPerStage = {}
|
||||||
for key, missionZone in pairs(o.tables.mission_zones) do
|
for key, missionZone in pairs(o.tables.mission_zones) do
|
||||||
local found = false
|
local found = false
|
||||||
@@ -258,6 +278,21 @@ do -- DB
|
|||||||
end
|
end
|
||||||
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[]
|
--- missionZoneName <> groupname[]
|
||||||
o.tables.groupsInMissionZone = {}
|
o.tables.groupsInMissionZone = {}
|
||||||
local loadMissionzoneUnits = function()
|
local loadMissionzoneUnits = function()
|
||||||
@@ -394,6 +429,7 @@ do -- DB
|
|||||||
end
|
end
|
||||||
|
|
||||||
loadCapUnits()
|
loadCapUnits()
|
||||||
|
loadBlueSamUnits()
|
||||||
loadMissionzoneUnits()
|
loadMissionzoneUnits()
|
||||||
loadRandomMissionzoneUnits()
|
loadRandomMissionzoneUnits()
|
||||||
loadFarpGroups()
|
loadFarpGroups()
|
||||||
@@ -572,7 +608,6 @@ do -- DB
|
|||||||
return self.tables.descriptions[missionZoneName] or ""
|
return self.tables.descriptions[missionZoneName] or ""
|
||||||
end
|
end
|
||||||
|
|
||||||
---comment
|
|
||||||
---@param self table
|
---@param self table
|
||||||
---@param stageName string
|
---@param stageName string
|
||||||
---@return table result airbase IDs. Use Spearhead.DcsUtil.getAirbaseById
|
---@return table result airbase IDs. Use Spearhead.DcsUtil.getAirbaseById
|
||||||
@@ -584,7 +619,6 @@ do -- DB
|
|||||||
return self.tables.farpZonesPerStage[stageName]
|
return self.tables.farpZonesPerStage[stageName]
|
||||||
end
|
end
|
||||||
|
|
||||||
---comment
|
|
||||||
---@param self table
|
---@param self table
|
||||||
---@param airbaseId number
|
---@param airbaseId number
|
||||||
---@return table
|
---@return table
|
||||||
@@ -592,6 +626,20 @@ do -- DB
|
|||||||
return self.tables.capGroupsOnAirbase[airbaseId] or {}
|
return self.tables.capGroupsOnAirbase[airbaseId] or {}
|
||||||
end
|
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)
|
o.getRedGroupsAtAirbase = function(self, airbaseId)
|
||||||
local baseId = tostring(airbaseId)
|
local baseId = tostring(airbaseId)
|
||||||
return self.tables.redAirbaseGroupsPerAirbase[baseId] or {}
|
return self.tables.redAirbaseGroupsPerAirbase[baseId] or {}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ do --init STAGE DIRECTOR
|
|||||||
o.db.sams = {}
|
o.db.sams = {}
|
||||||
o.db.redAirbasegroups = {}
|
o.db.redAirbasegroups = {}
|
||||||
o.db.blueAirbasegroups = {}
|
o.db.blueAirbasegroups = {}
|
||||||
|
o.db.blueSamGroups = {}
|
||||||
o.db.airbaseIds = {}
|
o.db.airbaseIds = {}
|
||||||
o.db.farps = {}
|
o.db.farps = {}
|
||||||
o.activeStage = -99
|
o.activeStage = -99
|
||||||
@@ -105,6 +106,13 @@ do --init STAGE DIRECTOR
|
|||||||
end
|
end
|
||||||
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)
|
local miscGroups = database:getMiscGroupsAtStage(o.zoneName)
|
||||||
for _, groupName in pairs(miscGroups) do
|
for _, groupName in pairs(miscGroups) do
|
||||||
Spearhead.DcsUtil.DestroyGroup(groupName)
|
Spearhead.DcsUtil.DestroyGroup(groupName)
|
||||||
@@ -301,6 +309,10 @@ do --init STAGE DIRECTOR
|
|||||||
self:MarkStage(true)
|
self:MarkStage(true)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
for _, blueSamGroupName in pairs(self.db.blueSamGroups) do
|
||||||
|
Spearhead.DcsUtil.SpawnGroupTemplate(blueSamGroupName)
|
||||||
|
end
|
||||||
|
|
||||||
for key, airbaseId in pairs(self.db.airbaseIds) do
|
for key, airbaseId in pairs(self.db.airbaseIds) do
|
||||||
local airbase = Spearhead.DcsUtil.getAirbaseById(airbaseId)
|
local airbase = Spearhead.DcsUtil.getAirbaseById(airbaseId)
|
||||||
|
|
||||||
@@ -316,6 +328,7 @@ do --init STAGE DIRECTOR
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
---Sets airfields to blue and spawns friendly farps
|
---Sets airfields to blue and spawns friendly farps
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ local SetStageDelayed = function(number, time)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
timer.scheduleFunction(SetStageDelayed, 1, timer.getTime() + 3)
|
timer.scheduleFunction(SetStageDelayed, 2, timer.getTime() + 3)
|
||||||
|
|
||||||
Spearhead.LoadingDone()
|
Spearhead.LoadingDone()
|
||||||
--Check lines of code in directory per file:
|
--Check lines of code in directory per file:
|
||||||
|
|||||||
Reference in New Issue
Block a user