Fix easy going CAPs.

Fixes https://github.com/Khopa/dcs_liberation/issues/592

(cherry picked from commit 1ebe367e07898bd09833672fe45c12a6dcbae00a)
This commit is contained in:
Dan Albert 2020-12-15 22:27:19 -08:00
parent db229f25bf
commit a075e62bad
2 changed files with 21 additions and 9 deletions

View File

@ -1,3 +1,9 @@
# 2.3.1
## Fixes:
* **[AI]** CAP flights will engage enemies again.
# 2.3.0 # 2.3.0
# Features/Improvements # Features/Improvements

View File

@ -1756,15 +1756,11 @@ class RaceTrackBuilder(PydcsWaypointBuilder):
f"{flight_plan_type} does not define a patrol.") f"{flight_plan_type} does not define a patrol.")
return waypoint return waypoint
racetrack = ControlledTask(OrbitAction( # NB: It's important that the engage task comes before the orbit task.
altitude=waypoint.alt, # Though they're on the same waypoint, if the orbit task comes first it
pattern=OrbitAction.OrbitPattern.RaceTrack # is their first priority and they will not engage any targets because
)) # they're fully focused on orbiting. If the STE task is first, they will
self.set_waypoint_tot( # engage targets if available and orbit if they find nothing to shoot.
waypoint, self.flight.flight_plan.patrol_start_time)
racetrack.stop_after_time(
int(self.flight.flight_plan.patrol_end_time.total_seconds()))
waypoint.add_task(racetrack)
# TODO: Move the properties of this task into the flight plan? # TODO: Move the properties of this task into the flight plan?
# CAP is the only current user of this so it's not a big deal, but might # CAP is the only current user of this so it's not a big deal, but might
@ -1775,6 +1771,16 @@ class RaceTrackBuilder(PydcsWaypointBuilder):
waypoint.tasks.append(EngageTargets(max_distance=nm_to_meter(50), waypoint.tasks.append(EngageTargets(max_distance=nm_to_meter(50),
targets=[Targets.All.Air])) targets=[Targets.All.Air]))
racetrack = ControlledTask(OrbitAction(
altitude=waypoint.alt,
pattern=OrbitAction.OrbitPattern.RaceTrack
))
self.set_waypoint_tot(
waypoint, self.flight.flight_plan.patrol_start_time)
racetrack.stop_after_time(
int(self.flight.flight_plan.patrol_end_time.total_seconds()))
waypoint.add_task(racetrack)
return waypoint return waypoint