mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Automate transfers from factories.
The purchase system will seek out a source for its units when the purchase is completed. If no source is available the order will be refunded. Orders with no source available are prevented, so this only happens when the source was cut off from the destination during the turn. There's still some funkiness going on with the first turn (but possibly only when the first turn includes a cheat to capture) where the AI buys a ton of units somewhere other than the front line. First turn behavior should probably be different anyway, with the first turn allowing purchases anywhere to avoid empty front lines while troops reinforce if the front line isn't a factory. https://github.com/Khopa/dcs_liberation/issues/986
This commit is contained in:
@@ -313,13 +313,39 @@ class ControlPoint(MissionTarget, ABC):
|
||||
connected.extend(cp.transitive_connected_friendly_points(seen))
|
||||
return connected
|
||||
|
||||
@property
|
||||
def has_factory(self) -> bool:
|
||||
for tgo in self.connected_objectives:
|
||||
if isinstance(tgo, FactoryGroundObject) and not tgo.is_dead:
|
||||
return True
|
||||
return False
|
||||
|
||||
def can_recruit_ground_units(self, game: Game) -> bool:
|
||||
"""Returns True if this control point is capable of recruiting ground units."""
|
||||
if not self.can_deploy_ground_units:
|
||||
return False
|
||||
|
||||
if not game.settings.enable_new_ground_unit_recruitment:
|
||||
return True
|
||||
|
||||
for tgo in self.connected_objectives:
|
||||
if isinstance(tgo, FactoryGroundObject) and not tgo.is_dead:
|
||||
return self.has_factory
|
||||
|
||||
def has_ground_unit_source(self, game: Game) -> bool:
|
||||
"""Returns True if this control point has access to ground reinforcements."""
|
||||
if not self.can_deploy_ground_units:
|
||||
return False
|
||||
|
||||
if not game.settings.enable_new_ground_unit_recruitment:
|
||||
return True
|
||||
|
||||
from game.theater.supplyroutes import SupplyRoute
|
||||
|
||||
supply_route = SupplyRoute.for_control_point(self)
|
||||
if supply_route is None:
|
||||
return False
|
||||
|
||||
for cp in supply_route:
|
||||
if cp.can_recruit_ground_units(game):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user