From d11d3b58f735e4806dddb4680845565d102f454e Mon Sep 17 00:00:00 2001 From: MetalStormGhost <89945461+MetalStormGhost@users.noreply.github.com> Date: Sat, 27 Nov 2021 11:40:06 +0200 Subject: [PATCH] Add option to limit convoy travel distances. CPU load seems to scale with route length, so add an option to limit the length of the convoy route. The tradeoff is that the performance sensitive route won't necessarily be a correct route. --- game/missiongenerator/convoygenerator.py | 18 +++++++++++++++++- game/settings/settings.py | 6 ++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/game/missiongenerator/convoygenerator.py b/game/missiongenerator/convoygenerator.py index b695d144..a9f38df7 100644 --- a/game/missiongenerator/convoygenerator.py +++ b/game/missiongenerator/convoygenerator.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 diff --git a/game/settings/settings.py b/game/settings/settings.py index 2e4168e2..9517d1e1 100644 --- a/game/settings/settings.py +++ b/game/settings/settings.py @@ -407,6 +407,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,