#EASYGCICAP - avoid launching intercepts if airwing conquered by other coalition

This commit is contained in:
Applevangelist 2024-07-12 09:36:29 +02:00
parent 6e917049af
commit df6c97bec8

View File

@ -7,6 +7,7 @@
-- --
------------------------------------------------------------------------- -------------------------------------------------------------------------
-- Date: September 2023 -- Date: September 2023
-- Last Update: July 2024
------------------------------------------------------------------------- -------------------------------------------------------------------------
-- --
--- **Ops** - Easy GCI & CAP Manager --- **Ops** - Easy GCI & CAP Manager
@ -248,7 +249,7 @@ EASYGCICAP = {
--- EASYGCICAP class version. --- EASYGCICAP class version.
-- @field #string version -- @field #string version
EASYGCICAP.version="0.1.11" EASYGCICAP.version="0.1.12"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list
@ -1156,7 +1157,7 @@ function EASYGCICAP:_TryAssignIntercept(ReadyFlightGroups,InterceptAuftrag,Group
return assigned, wingsize return assigned, wingsize
end end
--- Add a zone to the rejected zones set. --- Here, we'll decide if we need to launch an intercepting flight, and from where
-- @param #EASYGCICAP self -- @param #EASYGCICAP self
-- @param Ops.Intel#INTEL.Cluster Cluster -- @param Ops.Intel#INTEL.Cluster Cluster
-- @return #EASYGCICAP self -- @return #EASYGCICAP self
@ -1200,9 +1201,11 @@ function EASYGCICAP:_AssignIntercept(Cluster)
local zone = _data[2] -- Core.Zone#ZONE local zone = _data[2] -- Core.Zone#ZONE
local zonecoord = zone:GetCoordinate() local zonecoord = zone:GetCoordinate()
local name = _data[3] -- #string local name = _data[3] -- #string
local coa = AIRBASE:FindByName(name):GetCoalition()
local distance = position:DistanceFromPointVec2(zonecoord) local distance = position:DistanceFromPointVec2(zonecoord)
local airframes = airwing:CountAssets(true) local airframes = airwing:CountAssets(true)
if distance < bestdistance and airframes >= wingsize then local samecoalitionab = coa == self.coalition and true or false
if distance < bestdistance and airframes >= wingsize and samecoalitionab == true then
bestdistance = distance bestdistance = distance
targetairwing = airwing targetairwing = airwing
targetawname = name targetawname = name
@ -1218,10 +1221,11 @@ function EASYGCICAP:_AssignIntercept(Cluster)
local name = data.AirbaseName local name = data.AirbaseName
local zonecoord = data.Coordinate local zonecoord = data.Coordinate
local airwing = wings[name][1] local airwing = wings[name][1]
local coa = AIRBASE:FindByName(name):GetCoalition()
local samecoalitionab = coa == self.coalition and true or false
local distance = position:DistanceFromPointVec2(zonecoord) local distance = position:DistanceFromPointVec2(zonecoord)
local airframes = airwing:CountAssets(true) local airframes = airwing:CountAssets(true)
if distance < bestdistance and airframes >= wingsize then if distance < bestdistance and airframes >= wingsize and samecoalitionab == true then
bestdistance = distance bestdistance = distance
targetairwing = airwing -- Ops.Airwing#AIRWING targetairwing = airwing -- Ops.Airwing#AIRWING
targetawname = name targetawname = name