diff --git a/game/settings/settings.py b/game/settings/settings.py index c2b94619..80d6a0b4 100644 --- a/game/settings/settings.py +++ b/game/settings/settings.py @@ -378,6 +378,12 @@ class Settings: section=PERFORMANCE_SECTION, default=True, ) + convoys_travel_full_distance: bool = boolean_option( + "Convoys drive the full distance between control points", + page=MISSION_GENERATOR_PAGE, + section=PERFORMANCE_SECTION, + default=True, + ) perf_infantry: bool = boolean_option( "Generate infantry squads alongside vehicles", page=MISSION_GENERATOR_PAGE, diff --git a/gen/convoygen.py b/gen/convoygen.py index b695d144..a9f38df7 100644 --- a/gen/convoygen.py +++ b/gen/convoygen.py @@ -10,6 +10,7 @@ from dcs.unit import Vehicle from dcs.unitgroup import VehicleGroup from game.dcs.groundunittype import GroundUnitType +from game.theater import FrontLine from game.transfers import Convoy from game.unitmap import UnitMap from game.utils import kph @@ -38,11 +39,26 @@ class ConvoyGenerator: convoy.units, convoy.player_owned, ) + + if self.game.settings.convoys_travel_full_distance: + end_point = convoy.route_end + else: + # convoys_travel_full_distance is disabled, so have the convoy only move the first segment on the route. + # This option aims to remove long routes for ground vehicles between control points, + # since the CPU load for pathfinding long routes on DCS can be pretty heavy. + frontline = FrontLine(convoy.origin, convoy.destination) + + # Select the first route segment from the origin towards the destination + # so the convoy spawns at the origin CP. This allows the convoy to be + # targeted by BAI flights and starts it within the protection umbrella of the CP. + end_point = frontline.segments[0].point_b + group.add_waypoint( - convoy.route_end, + end_point, speed=kph(40).kph, move_formation=PointAction.OnRoad, ) + self.make_drivable(group) self.unit_map.add_convoy_units(group, convoy) return group