From 816d9696b55161d29a3129622a6bddc7bb5377ec Mon Sep 17 00:00:00 2001 From: Walter Date: Mon, 26 Oct 2020 13:59:55 -0500 Subject: [PATCH 1/9] Move Engage targets to ingress point for CAS --- gen/aircraft.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gen/aircraft.py b/gen/aircraft.py index e51964fa..6b8a2c01 100644 --- a/gen/aircraft.py +++ b/gen/aircraft.py @@ -935,10 +935,6 @@ class AircraftConflictGenerator: roe=OptROE.Values.OpenFireWeaponFree, rtb_winchester=OptRTBOnOutOfAmmo.Values.Unguided, restrict_jettison=True) - group.points[0].tasks.append( - EngageTargets(max_distance=nm_to_meter(10), - targets=[Targets.All.GroundUnits.GroundVehicles]) - ) def configure_sead(self, group: FlyingGroup, package: Package, flight: Flight, @@ -1114,7 +1110,7 @@ class PydcsWaypointBuilder: mission: Mission) -> PydcsWaypointBuilder: builders = { FlightWaypointType.EGRESS: EgressPointBuilder, - FlightWaypointType.INGRESS_CAS: IngressBuilder, + FlightWaypointType.INGRESS_CAS: CasIngressBuilder, FlightWaypointType.INGRESS_ESCORT: IngressBuilder, FlightWaypointType.INGRESS_SEAD: SeadIngressBuilder, FlightWaypointType.INGRESS_STRIKE: StrikeIngressBuilder, @@ -1162,6 +1158,14 @@ class IngressBuilder(PydcsWaypointBuilder): self.set_waypoint_tot(waypoint, self.timing.ingress) return waypoint +class CasIngressBuilder(PydcsWaypointBuilder): + def build(self) -> MovingPoint: + waypoint = super().build() + self.set_waypoint_tot(waypoint, self.timing.ingress) + waypoint.add_task(EngageTargets(max_distance=nm_to_meter(10), + targets=[Targets.All.GroundUnits.GroundVehicles]) + ) + return waypoint class SeadIngressBuilder(IngressBuilder): def build(self) -> MovingPoint: From fdaf3bc30fcb2615b1626c9888d10b52cc4b6eaf Mon Sep 17 00:00:00 2001 From: Walter Date: Mon, 26 Oct 2020 15:07:03 -0500 Subject: [PATCH 2/9] CAS Weapons Hold until Ingress --- gen/aircraft.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gen/aircraft.py b/gen/aircraft.py index 6b8a2c01..90e18c73 100644 --- a/gen/aircraft.py +++ b/gen/aircraft.py @@ -932,7 +932,7 @@ class AircraftConflictGenerator: self.configure_behavior( group, react_on_threat=OptReactOnThreat.Values.EvadeFire, - roe=OptROE.Values.OpenFireWeaponFree, + roe=OptROE.Values.WeaponHold, rtb_winchester=OptRTBOnOutOfAmmo.Values.Unguided, restrict_jettison=True) @@ -1165,6 +1165,7 @@ class CasIngressBuilder(PydcsWaypointBuilder): waypoint.add_task(EngageTargets(max_distance=nm_to_meter(10), targets=[Targets.All.GroundUnits.GroundVehicles]) ) + waypoint.add_task(OptROE(OptROE.Values.OpenFireWeaponFree)) return waypoint class SeadIngressBuilder(IngressBuilder): From 63d510f2ea7aec26254488aa846fa85e1ca8d19b Mon Sep 17 00:00:00 2001 From: Walter Date: Mon, 26 Oct 2020 15:48:22 -0500 Subject: [PATCH 3/9] Add Air Defenses to engage task --- gen/aircraft.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gen/aircraft.py b/gen/aircraft.py index 90e18c73..4d227ad2 100644 --- a/gen/aircraft.py +++ b/gen/aircraft.py @@ -1163,7 +1163,10 @@ class CasIngressBuilder(PydcsWaypointBuilder): waypoint = super().build() self.set_waypoint_tot(waypoint, self.timing.ingress) waypoint.add_task(EngageTargets(max_distance=nm_to_meter(10), - targets=[Targets.All.GroundUnits.GroundVehicles]) + targets=[ + Targets.All.GroundUnits.GroundVehicles, + Targets.All.GroundUnits.AirDefence, + ]) ) waypoint.add_task(OptROE(OptROE.Values.OpenFireWeaponFree)) return waypoint From 8583bbf893a5e21d0b39dcbcda51c31a431b140e Mon Sep 17 00:00:00 2001 From: Walter Date: Mon, 26 Oct 2020 17:19:52 -0500 Subject: [PATCH 4/9] Changed task to add AAA and infantry properly --- gen/aircraft.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gen/aircraft.py b/gen/aircraft.py index 4d227ad2..59774fcf 100644 --- a/gen/aircraft.py +++ b/gen/aircraft.py @@ -1165,7 +1165,8 @@ class CasIngressBuilder(PydcsWaypointBuilder): waypoint.add_task(EngageTargets(max_distance=nm_to_meter(10), targets=[ Targets.All.GroundUnits.GroundVehicles, - Targets.All.GroundUnits.AirDefence, + Targets.All.GroundUnits.AirDefence.AAA, + Targets.All.GroundUnits.Infantry, ]) ) waypoint.add_task(OptROE(OptROE.Values.OpenFireWeaponFree)) From 91bee4e6c27e0d901beeab965abeb4a32a6d4f41 Mon Sep 17 00:00:00 2001 From: walterroach <37820425+walterroach@users.noreply.github.com> Date: Mon, 26 Oct 2020 23:10:53 -0500 Subject: [PATCH 5/9] Changed CAS engage task to zone --- gen/aircraft.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/gen/aircraft.py b/gen/aircraft.py index 59774fcf..814b2209 100644 --- a/gen/aircraft.py +++ b/gen/aircraft.py @@ -40,6 +40,7 @@ from dcs.task import ( ControlledTask, EPLRS, EngageTargets, + EngageTargetsInZone, GroundAttack, OptROE, OptRTBOnBingoFuel, @@ -75,6 +76,7 @@ from gen.flights.flight import ( ) from gen.radios import MHz, Radio, RadioFrequency, RadioRegistry, get_radio from gen.runways import RunwayData +from dcs.mapping import Point from theater import TheaterGroundObject from theater.controlpoint import ControlPoint, ControlPointType from .conflictgen import Conflict @@ -1103,6 +1105,11 @@ class PydcsWaypointBuilder: waypoint.ETA = tot waypoint.ETA_locked = True waypoint.speed_locked = False + + def get_flight_point(self, name): + for i in self.flight.points: + if i.name == name: + return i @classmethod def for_waypoint(cls, waypoint: FlightWaypoint, group: FlyingGroup, @@ -1162,13 +1169,31 @@ class CasIngressBuilder(PydcsWaypointBuilder): def build(self) -> MovingPoint: waypoint = super().build() self.set_waypoint_tot(waypoint, self.timing.ingress) - waypoint.add_task(EngageTargets(max_distance=nm_to_meter(10), + ingress_waypoint = self.get_flight_point('INGRESS') + cas_waypoint = self.get_flight_point('CAS') + try: + ingress_point = Point(ingress_waypoint.position.x, ingress_waypoint.position.y) + + waypoint.add_task(EngageTargetsInZone( + position=cas_waypoint, + radius=ingress_point.distance_to_point( + cas_waypoint.position + ), + targets=[ + Targets.All.GroundUnits.GroundVehicles, + Targets.All.GroundUnits.AirDefence.AAA, + Targets.All.GroundUnits.Infantry, + ]) + ) + except AttributeError: + logging.error(f'Unable to create CAS target zone. Falling back to search and engage') + waypoint.add_task(EngageTargets(max_distance=nm_to_meter(10), targets=[ Targets.All.GroundUnits.GroundVehicles, Targets.All.GroundUnits.AirDefence.AAA, Targets.All.GroundUnits.Infantry, ]) - ) + ) waypoint.add_task(OptROE(OptROE.Values.OpenFireWeaponFree)) return waypoint From 1e5bd916d9a31a308e9b7910035db6d3d2aecee1 Mon Sep 17 00:00:00 2001 From: walterroach <37820425+walterroach@users.noreply.github.com> Date: Mon, 26 Oct 2020 23:33:56 -0500 Subject: [PATCH 6/9] CasIngressBuilder proper inheritence --- gen/aircraft.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gen/aircraft.py b/gen/aircraft.py index 814b2209..8bfb6f06 100644 --- a/gen/aircraft.py +++ b/gen/aircraft.py @@ -1165,10 +1165,9 @@ class IngressBuilder(PydcsWaypointBuilder): self.set_waypoint_tot(waypoint, self.timing.ingress) return waypoint -class CasIngressBuilder(PydcsWaypointBuilder): +class CasIngressBuilder(IngressBuilder): def build(self) -> MovingPoint: waypoint = super().build() - self.set_waypoint_tot(waypoint, self.timing.ingress) ingress_waypoint = self.get_flight_point('INGRESS') cas_waypoint = self.get_flight_point('CAS') try: From fa013034607b61aa3a09f446796d0128b6dd83e9 Mon Sep 17 00:00:00 2001 From: Walter Date: Tue, 27 Oct 2020 09:48:36 -0500 Subject: [PATCH 7/9] #257 CasIngressBuilder changes * Calculate radius from frontline length global * Determine CAS waypoint by waypoint type rather than name * Change logging from error to exception --- gen/aircraft.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/gen/aircraft.py b/gen/aircraft.py index 8bfb6f06..ec006bcb 100644 --- a/gen/aircraft.py +++ b/gen/aircraft.py @@ -76,6 +76,7 @@ from gen.flights.flight import ( ) from gen.radios import MHz, Radio, RadioFrequency, RadioRegistry, get_radio from gen.runways import RunwayData +from gen.conflictgen import FRONTLINE_LENGTH from dcs.mapping import Point from theater import TheaterGroundObject from theater.controlpoint import ControlPoint, ControlPointType @@ -1105,11 +1106,6 @@ class PydcsWaypointBuilder: waypoint.ETA = tot waypoint.ETA_locked = True waypoint.speed_locked = False - - def get_flight_point(self, name): - for i in self.flight.points: - if i.name == name: - return i @classmethod def for_waypoint(cls, waypoint: FlightWaypoint, group: FlyingGroup, @@ -1168,16 +1164,11 @@ class IngressBuilder(PydcsWaypointBuilder): class CasIngressBuilder(IngressBuilder): def build(self) -> MovingPoint: waypoint = super().build() - ingress_waypoint = self.get_flight_point('INGRESS') - cas_waypoint = self.get_flight_point('CAS') try: - ingress_point = Point(ingress_waypoint.position.x, ingress_waypoint.position.y) - + cas_waypoint = self.flight.waypoint_with_type((FlightWaypointType.CAS,)) waypoint.add_task(EngageTargetsInZone( - position=cas_waypoint, - radius=ingress_point.distance_to_point( - cas_waypoint.position - ), + position=cas_waypoint.position, + radius=FRONTLINE_LENGTH / 2, targets=[ Targets.All.GroundUnits.GroundVehicles, Targets.All.GroundUnits.AirDefence.AAA, @@ -1185,7 +1176,7 @@ class CasIngressBuilder(IngressBuilder): ]) ) except AttributeError: - logging.error(f'Unable to create CAS target zone. Falling back to search and engage') + logging.exception('Unable to create CAS target zone. Falling back to search and engage') waypoint.add_task(EngageTargets(max_distance=nm_to_meter(10), targets=[ Targets.All.GroundUnits.GroundVehicles, From 1620c602cf53cd12b1561bb94612b0a05ca2950c Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Tue, 27 Oct 2020 18:12:13 -0700 Subject: [PATCH 8/9] Fix mypy issue. --- gen/aircraft.py | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/gen/aircraft.py b/gen/aircraft.py index ec006bcb..854a73be 100644 --- a/gen/aircraft.py +++ b/gen/aircraft.py @@ -1161,32 +1161,36 @@ class IngressBuilder(PydcsWaypointBuilder): self.set_waypoint_tot(waypoint, self.timing.ingress) return waypoint + class CasIngressBuilder(IngressBuilder): def build(self) -> MovingPoint: waypoint = super().build() - try: - cas_waypoint = self.flight.waypoint_with_type((FlightWaypointType.CAS,)) - waypoint.add_task(EngageTargetsInZone( - position=cas_waypoint.position, - radius=FRONTLINE_LENGTH / 2, - targets=[ - Targets.All.GroundUnits.GroundVehicles, - Targets.All.GroundUnits.AirDefence.AAA, - Targets.All.GroundUnits.Infantry, - ]) + cas_waypoint = self.flight.waypoint_with_type((FlightWaypointType.CAS,)) + if cas_waypoint is None: + logging.error( + "No CAS waypoint found. Falling back to search and engage") + waypoint.add_task(EngageTargets( + max_distance=nm_to_meter(10), + targets=[ + Targets.All.GroundUnits.GroundVehicles, + Targets.All.GroundUnits.AirDefence.AAA, + Targets.All.GroundUnits.Infantry, + ]) ) - except AttributeError: - logging.exception('Unable to create CAS target zone. Falling back to search and engage') - waypoint.add_task(EngageTargets(max_distance=nm_to_meter(10), - targets=[ - Targets.All.GroundUnits.GroundVehicles, - Targets.All.GroundUnits.AirDefence.AAA, - Targets.All.GroundUnits.Infantry, - ]) + else: + waypoint.add_task(EngageTargetsInZone( + position=cas_waypoint.position, + radius=FRONTLINE_LENGTH / 2, + targets=[ + Targets.All.GroundUnits.GroundVehicles, + Targets.All.GroundUnits.AirDefence.AAA, + Targets.All.GroundUnits.Infantry, + ]) ) waypoint.add_task(OptROE(OptROE.Values.OpenFireWeaponFree)) return waypoint + class SeadIngressBuilder(IngressBuilder): def build(self) -> MovingPoint: waypoint = super().build() From 239b9f823458881c964e346c5b96a7180e835096 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Tue, 27 Oct 2020 22:45:38 -0700 Subject: [PATCH 9/9] Use python, not py. py is a shortcut that launches the *latest* version of Python on the machine. https://stackoverflow.com/a/50896577/632035 The build machines were updated to include python 3.9, so we were doing everything with 3.9 instead of 3.8. pyproj doesn't have a binary wheel for 3.9 on pypi yet, so we were falling back to building it from source, which we aren't able to do, breaking the build. --- .github/workflows/build.yml | 4 ++-- .github/workflows/release.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8e04aa8f..cab28472 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,12 +18,12 @@ jobs: - name: Install environment run: | - py -m venv ./venv + python -m venv ./venv - name: Install dependencies run: | ./venv/scripts/activate - pip install -r requirements.txt + python -m pip install -r requirements.txt # For some reason the shiboken2.abi3.dll is not found properly, so I copy it instead Copy-Item .\venv\Lib\site-packages\shiboken2\shiboken2.abi3.dll .\venv\Lib\site-packages\PySide2\ -Force diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 559d19a5..21806ed4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,12 +20,12 @@ jobs: - name: Install environment run: | - py -m venv ./venv + python -m venv ./venv - name: Install dependencies run: | ./venv/scripts/activate - pip install -r requirements.txt + python -m pip install -r requirements.txt # For some reason the shiboken2.abi3.dll is not found properly, so I copy it instead Copy-Item .\venv\Lib\site-packages\shiboken2\shiboken2.abi3.dll .\venv\Lib\site-packages\PySide2\ -Force