From 417fc3af5b855d8710d3005567f0449ef97bd76e Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Sun, 30 May 2021 19:29:59 -0700 Subject: [PATCH] Allow objects near missile launchers to be culled. We want the scud to not be culled, but we should still cull things nearby. Rather than making the scud the center of a 2.5km unculled zone, just exclude missile objectives from culling. --- game/game.py | 33 +++++------------------------ gen/groundobjectsgen.py | 16 +++++++++++--- qt_ui/widgets/map/QLiberationMap.py | 14 ------------ 3 files changed, 18 insertions(+), 45 deletions(-) diff --git a/game/game.py b/game/game.py index 7ddf3733..65019a1e 100644 --- a/game/game.py +++ b/game/game.py @@ -113,8 +113,6 @@ class Game: self.informations.append(Information("Game Start", "-" * 40, 0)) # Culling Zones are for areas around points of interest that contain things we may not wish to cull. self.__culling_zones: List[Point] = [] - # Culling Points are for individual theater ground objects that we don't wish to cull. - self.__culling_points: List[Point] = [] self.__destroyed_units: List[str] = [] self.savepath = "" self.budget = player_budget @@ -519,7 +517,6 @@ class Game: :return: List of points of interests """ zones = [] - points = [] # By default, use the existing frontline conflict position for front_line in self.theater.conflicts(): @@ -529,11 +526,6 @@ class Game: zones.append(front_line.red_cp.position) for cp in self.theater.controlpoints: - # Don't cull missile sites - their range is long enough to make them - # easily culled despite being a threat. - for tgo in cp.ground_objects: - if isinstance(tgo, MissileSiteGroundObject): - points.append(tgo.position) # If do_not_cull_carrier is enabled, add carriers as culling point if self.settings.perf_do_not_cull_carrier: if cp.is_carrier or cp.is_lha: @@ -577,7 +569,6 @@ class Game: zones.append(Point(0, 0)) self.__culling_zones = zones - self.__culling_points = points def add_destroyed_units(self, data): pos = Point(data["x"], data["z"]) @@ -593,19 +584,12 @@ class Game: :param pos: Position you are tryng to spawn stuff at :return: True if units can not be added at given position """ - if self.settings.perf_culling == False: + if not self.settings.perf_culling: return False - else: - for z in self.__culling_zones: - if ( - z.distance_to_point(pos) - < self.settings.perf_culling_distance * 1000 - ): - return False - for p in self.__culling_points: - if p.distance_to_point(pos) < 2500: - return False - return True + for z in self.__culling_zones: + if z.distance_to_point(pos) < self.settings.perf_culling_distance * 1000: + return False + return True def get_culling_zones(self): """ @@ -614,13 +598,6 @@ class Game: """ return self.__culling_zones - def get_culling_points(self): - """ - Check culling points - :return: List of culling points - """ - return self.__culling_points - # 1 = red, 2 = blue def get_player_coalition_id(self): return 2 diff --git a/gen/groundobjectsgen.py b/gen/groundobjectsgen.py index d6349c8e..f3cf94f3 100644 --- a/gen/groundobjectsgen.py +++ b/gen/groundobjectsgen.py @@ -15,7 +15,7 @@ from dcs import Mission, Point, unitgroup from dcs.action import SceneryDestructionZone from dcs.country import Country from dcs.point import StaticPoint -from dcs.statics import Fortification, fortification_map, warehouse_map, Warehouse +from dcs.statics import Fortification, fortification_map, warehouse_map from dcs.task import ( ActivateBeaconCommand, ActivateICLSCommand, @@ -24,7 +24,7 @@ from dcs.task import ( FireAtPoint, ) from dcs.triggers import TriggerStart, TriggerZone -from dcs.unit import Ship, Unit, Vehicle, SingleHeliPad, Static +from dcs.unit import Ship, Unit, Vehicle, SingleHeliPad from dcs.unitgroup import Group, ShipGroup, StaticGroup, VehicleGroup from dcs.unittype import StaticType, UnitType from dcs.vehicles import vehicle_map @@ -76,8 +76,12 @@ class GenericGroundObjectGenerator: self.m = mission self.unit_map = unit_map + @property + def culled(self) -> bool: + return self.game.position_culled(self.ground_object.position) + def generate(self) -> None: - if self.game.position_culled(self.ground_object.position): + if self.culled: return for group in self.ground_object.groups: @@ -130,6 +134,12 @@ class GenericGroundObjectGenerator: class MissileSiteGenerator(GenericGroundObjectGenerator): + @property + def culled(self) -> bool: + # Don't cull missile sites - their range is long enough to make them easily + # culled despite being a threat. + return False + def generate(self) -> None: super(MissileSiteGenerator, self).generate() # Note : Only the SCUD missiles group can fire (V1 site cannot fire in game right now) diff --git a/qt_ui/widgets/map/QLiberationMap.py b/qt_ui/widgets/map/QLiberationMap.py index 51a00d18..94fe115d 100644 --- a/qt_ui/widgets/map/QLiberationMap.py +++ b/qt_ui/widgets/map/QLiberationMap.py @@ -337,22 +337,8 @@ class QLiberationMap(QGraphicsView, LiberationMap): def display_culling(self, scene: QGraphicsScene) -> None: """Draws the culling distance rings on the map""" - culling_points = self.game_model.game.get_culling_points() culling_zones = self.game_model.game.get_culling_zones() culling_distance = self.game_model.game.settings.perf_culling_distance - for point in culling_points: - culling_distance_point = Point(point.x + 2500, point.y + 2500) - distance_point = self._transform_point(culling_distance_point) - transformed = self._transform_point(point) - radius = distance_point[0] - transformed[0] - scene.addEllipse( - transformed[0] - radius, - transformed[1] - radius, - 2 * radius, - 2 * radius, - CONST.COLORS["transparent"], - CONST.COLORS["light_green_transparent"], - ) for zone in culling_zones: culling_distance_zone = Point( zone.x + culling_distance * 1000, zone.y + culling_distance * 1000