Prefer buying aircraft at safe airbases.

Fixes https://github.com/Khopa/dcs_liberation/issues/652
This commit is contained in:
Dan Albert 2020-12-23 22:23:40 -08:00
parent 8c1ebfda02
commit 6aa1f1cca0
2 changed files with 6 additions and 0 deletions

View File

@ -6,6 +6,7 @@ Saves from 2.3 are not compatible with 2.4.
* **[Flight Planner]** Air-to-air and SEAD escorts will no longer be automatically planned for packages that are not in range of threats.
* **[Flight Planner]** Non-custom flight plans will now navigate around threat areas en route to the target area when practical.
* **[Campaign AI]** Auto-purchase now prefers airfields that are not within range of the enemy.
# 2.3.3

View File

@ -42,6 +42,7 @@ class ProcurementAi:
self.manage_runways = manage_runways
self.manage_front_line = manage_front_line
self.manage_aircraft = manage_aircraft
self.threat_zones = self.game.threat_zone_for(not self.is_player)
def spend_budget(
self, budget: int,
@ -176,6 +177,7 @@ class ProcurementAi:
distance_cache = ObjectiveDistanceCache.get_closest_airfields(
request.near
)
threatened = []
for cp in distance_cache.airfields_within(request.range):
if not cp.is_friendly(self.is_player):
continue
@ -183,7 +185,10 @@ class ProcurementAi:
continue
if cp.unclaimed_parking(self.game) < request.number:
continue
if self.threat_zones.threatened(cp.position):
threatened.append(cp)
yield cp
yield from threatened
def front_line_candidates(self) -> List[ControlPoint]:
candidates = []