mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Fix bug causing overpurchase of aircraft.
After fulfilling a request we were not exiting the loop, so we'd fulfill the request for the aircraft at _all_ the bases capable of operating it until either the bases were full or the budget ran out. In factions like Iraq 1991 this could cause the budget to be spent on tons of cheap MiG-19s while never buying the more expensive Su-17s or Su-24s that they need to actually complete a package. https://github.com/dcs-liberation/dcs_liberation/issues/1058
This commit is contained in:
parent
8320c6940b
commit
2cf3b3be2b
@ -12,9 +12,10 @@ Saves from 2.5 are not compatible with 3.0.
|
|||||||
* **[Modding]** Can now install custom factions to <DCS saved games>/Liberation/Factions instead of the Liberation install directory.
|
* **[Modding]** Can now install custom factions to <DCS saved games>/Liberation/Factions instead of the Liberation install directory.
|
||||||
* **[Performance Settings]** Added a settings to lower the number of smoke effects generated on frontlines. Lowered default settings for frontline smoke generators, so less smoke should be generated by default.
|
* **[Performance Settings]** Added a settings to lower the number of smoke effects generated on frontlines. Lowered default settings for frontline smoke generators, so less smoke should be generated by default.
|
||||||
|
|
||||||
|
|
||||||
## Fixes
|
## Fixes
|
||||||
|
|
||||||
|
* **[Campaign AI]** Fixed bug causing AI to over-purchase cheap aircraft.
|
||||||
|
|
||||||
# 2.5.1
|
# 2.5.1
|
||||||
|
|
||||||
## Features/Improvements
|
## Features/Improvements
|
||||||
|
|||||||
@ -192,21 +192,27 @@ class ProcurementAi:
|
|||||||
aircraft_for_task(request.task_capability), airbase, request.number, budget
|
aircraft_for_task(request.task_capability), airbase, request.number, budget
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def fulfill_aircraft_request(
|
||||||
|
self, request: AircraftProcurementRequest, budget: float
|
||||||
|
) -> float:
|
||||||
|
for airbase in self.best_airbases_for(request):
|
||||||
|
unit = self.affordable_aircraft_for(request, airbase, budget)
|
||||||
|
if unit is None:
|
||||||
|
# Can't afford any aircraft capable of performing the
|
||||||
|
# required mission that can operate from this airbase. We
|
||||||
|
# might be able to afford aircraft at other airbases though,
|
||||||
|
# in the case where the airbase we attempted to use is only
|
||||||
|
# able to operate expensive aircraft.
|
||||||
|
continue
|
||||||
|
|
||||||
|
budget -= db.PRICES[unit] * request.number
|
||||||
|
airbase.pending_unit_deliveries.order({unit: request.number})
|
||||||
|
break
|
||||||
|
return budget
|
||||||
|
|
||||||
def purchase_aircraft(self, budget: float) -> float:
|
def purchase_aircraft(self, budget: float) -> float:
|
||||||
for request in self.game.procurement_requests_for(self.is_player):
|
for request in self.game.procurement_requests_for(self.is_player):
|
||||||
for airbase in self.best_airbases_for(request):
|
budget = self.fulfill_aircraft_request(request, budget)
|
||||||
unit = self.affordable_aircraft_for(request, airbase, budget)
|
|
||||||
if unit is None:
|
|
||||||
# Can't afford any aircraft capable of performing the
|
|
||||||
# required mission that can operate from this airbase. We
|
|
||||||
# might be able to afford aircraft at other airbases though,
|
|
||||||
# in the case where the airbase we attempted to use is only
|
|
||||||
# able to operate expensive aircraft.
|
|
||||||
continue
|
|
||||||
|
|
||||||
budget -= db.PRICES[unit] * request.number
|
|
||||||
airbase.pending_unit_deliveries.order({unit: request.number})
|
|
||||||
|
|
||||||
return budget
|
return budget
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user