mirror of
https://github.com/akaAgar/the-universal-mission-for-dcs-world.git
synced 2025-11-25 19:31:01 +00:00
Added function DCSEx.zones.getAirbases(zoneTable, coalition)
This commit is contained in:
parent
ff15793f06
commit
b392c55828
@ -2,6 +2,7 @@
|
|||||||
-- DCSEX.ZONES - FUNCTIONS RELATED TO MAP TRIGGER ZONES
|
-- DCSEX.ZONES - FUNCTIONS RELATED TO MAP TRIGGER ZONES
|
||||||
-- ====================================================================================
|
-- ====================================================================================
|
||||||
-- DCSEx.zones.drawOnMap(zoneTable, lineColor, fillColor, lineType, drawName, readOnly)
|
-- DCSEx.zones.drawOnMap(zoneTable, lineColor, fillColor, lineType, drawName, readOnly)
|
||||||
|
-- DCSEx.zones.getAirbases(zone, coalition)
|
||||||
-- DCSEx.zones.getAll()
|
-- DCSEx.zones.getAll()
|
||||||
-- DCSEx.zones.getByName(name)
|
-- DCSEx.zones.getByName(name)
|
||||||
-- DCSEx.zones.getCenter(zoneTable)
|
-- DCSEx.zones.getCenter(zoneTable)
|
||||||
@ -72,6 +73,30 @@ function DCSEx.zones.drawOnMap(zoneTable, lineColor, fillColor, lineType, drawNa
|
|||||||
return markerID
|
return markerID
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-------------------------------------
|
||||||
|
-- Returns all airbases in the zone
|
||||||
|
-------------------------------------
|
||||||
|
-- @param zoneTable Table of the zone in which to search
|
||||||
|
-- @param coalition Coalition (from the coalition.side enum) the airbase must belong to. Default is nil, which means "all coalitions"
|
||||||
|
-- @return Table of airbases
|
||||||
|
-------------------------------------
|
||||||
|
function DCSEx.zones.getAirbases(zoneTable, coalition)
|
||||||
|
coalition = coalition or nil
|
||||||
|
|
||||||
|
local coalitions = { coalition.side.RED, coalition.side.BLUE }
|
||||||
|
if coalition then coalitions = { coalition } end
|
||||||
|
|
||||||
|
local validAirbases = {}
|
||||||
|
for _,side in ipairs(coalitions) do
|
||||||
|
for _,ab in ipairs(coalition.getAirbases(side)) do
|
||||||
|
if DCSEx.zones.isPointInside(zoneTable, ab:getPoint()) then
|
||||||
|
table.insert(validAirbases, ab)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return validAirbases
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
-- Returns all trigger zones
|
-- Returns all trigger zones
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
|||||||
@ -41,20 +41,6 @@ do
|
|||||||
return possiblePoints[1]
|
return possiblePoints[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
local function getEnemyAirbaseInZone(zone)
|
|
||||||
local validAirbases = {}
|
|
||||||
|
|
||||||
for _,ab in ipairs(coalition.getAirbases(TUM.settings.getEnemyCoalition())) do
|
|
||||||
if DCSEx.zones.isPointInside(zone, ab:getPoint()) then
|
|
||||||
table.insert(validAirbases, ab)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if #validAirbases == 0 then return nil end
|
|
||||||
|
|
||||||
return DCSEx.table.getRandom(validAirbases)
|
|
||||||
end
|
|
||||||
|
|
||||||
function TUM.objectivesMaker.create()
|
function TUM.objectivesMaker.create()
|
||||||
local zone = DCSEx.zones.getByName(TUM.settings.getValue(TUM.settings.id.TARGET_LOCATION, true))
|
local zone = DCSEx.zones.getByName(TUM.settings.getValue(TUM.settings.id.TARGET_LOCATION, true))
|
||||||
|
|
||||||
@ -83,20 +69,22 @@ do
|
|||||||
spawnPoint2 = DCSEx.math.vec3ToVec2(spawnPoint3)
|
spawnPoint2 = DCSEx.math.vec3ToVec2(spawnPoint3)
|
||||||
isSceneryTarget = true
|
isSceneryTarget = true
|
||||||
elseif DCSEx.table.contains(objectiveDB.flags, DCSEx.enums.taskFlag.AIRBASE_TARGET) then
|
elseif DCSEx.table.contains(objectiveDB.flags, DCSEx.enums.taskFlag.AIRBASE_TARGET) then
|
||||||
local pickedAirbase = getEnemyAirbaseInZone(zone)
|
local validAirbases = DCSEx.zones.getAirbases(zone, TUM.settings.getEnemyCoalition())
|
||||||
if not pickedAirbase then
|
if #validAirbases == 0 then
|
||||||
TUM.log("Failed to find a valid airbase to use as target.", TUM.logger.logLevel.WARNING)
|
TUM.log("Failed to find a valid airbase to use as target.", TUM.logger.logLevel.WARNING)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
local pickedAirbase = DCSEx.table.getRandom(validAirbases)
|
||||||
spawnPoint3 = DCSEx.table.deepCopy(pickedAirbase:getPoint())
|
spawnPoint3 = DCSEx.table.deepCopy(pickedAirbase:getPoint())
|
||||||
spawnPoint2 = DCSEx.math.vec3ToVec2(spawnPoint3)
|
spawnPoint2 = DCSEx.math.vec3ToVec2(spawnPoint3)
|
||||||
isAirbaseTarget = true
|
isAirbaseTarget = true
|
||||||
elseif DCSEx.table.contains(objectiveDB.flags, DCSEx.enums.taskFlag.PARKED_AIRCRAFT_TARGET) then
|
elseif DCSEx.table.contains(objectiveDB.flags, DCSEx.enums.taskFlag.PARKED_AIRCRAFT_TARGET) then
|
||||||
local pickedAirbase = getEnemyAirbaseInZone(zone)
|
local validAirbases = DCSEx.zones.getAirbases(zone, TUM.settings.getEnemyCoalition())
|
||||||
if not pickedAirbase then
|
if #validAirbases == 0 then
|
||||||
TUM.log("Failed to find a valid airbase to use as target.", TUM.logger.logLevel.WARNING)
|
TUM.log("Failed to find a valid airbase to use as target.", TUM.logger.logLevel.WARNING)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
local pickedAirbase = DCSEx.table.getRandom(validAirbases)
|
||||||
local parkings = pickedAirbase:getParking()
|
local parkings = pickedAirbase:getParking()
|
||||||
local validParkings = {}
|
local validParkings = {}
|
||||||
for _,p in pairs(parkings) do
|
for _,p in pairs(parkings) do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user