From 54bf9357bf158c02d16d0bd81245b47610d6c140 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/settings/settings.py | 6 ++++++ gen/convoygen.py | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) 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