From 59986d74f4b8d1cb4e7807963ab1cd9cc8ef46bf Mon Sep 17 00:00:00 2001 From: Khopa Date: Fri, 29 May 2020 03:28:09 +0200 Subject: [PATCH] Generate random TACAN frequency for ships at start. TACAN infos are displayed in briefing. --- game/operation/operation.py | 17 ----------------- gen/briefinggen.py | 12 ++++++++++++ gen/groundobjectsgen.py | 5 +++++ theater/controlpoint.py | 15 +++++++++++++-- 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/game/operation/operation.py b/game/operation/operation.py index 14dd8d431..4b2457f3d 100644 --- a/game/operation/operation.py +++ b/game/operation/operation.py @@ -114,20 +114,6 @@ def prepare(self, terrain: Terrain, is_quick: bool): self.attackers_starting_position = self.departure_cp.at self.defenders_starting_position = self.to_cp.at - def prepare_carriers(self, for_units: db.UnitsDict): - if not self.departure_cp.is_global: - return - - ship = self.shipgen.generate_carrier(for_units=[t for t, c in for_units.items() if c > 0], - country=self.game.player_country, - at=self.departure_cp.at) - - if not self.is_quick: - if not self.to_cp.captured: - self.attackers_starting_position = ship - else: - self.defenders_starting_position = ship - def generate(self): # Generate ground object first @@ -136,9 +122,6 @@ def generate(self): # Air Support (Tanker & Awacs) self.airsupportgen.generate(self.is_awacs_enabled) - # Generate carrier groups & ships - - # Generate Activity on the map for cp in self.game.theater.controlpoints: side = cp.captured diff --git a/gen/briefinggen.py b/gen/briefinggen.py index 41f35539d..f73ca73fb 100644 --- a/gen/briefinggen.py +++ b/gen/briefinggen.py @@ -70,6 +70,18 @@ def generate(self): for name, freq in self.freqs: self.description += "\n{}: {}".format(name, freq) + for cp in self.game.theater.controlpoints: + if cp.captured and cp.cptype in [ControlPointType.LHA_GROUP, ControlPointType.AIRCRAFT_CARRIER_GROUP]: + self.description += "\n" + self.description += cp.name + " TACAN : " + + self.description += str(cp.tacanN) + if cp.tacanY: + self.description += "Y" + else: + self.description += "X" + self.description += " " + str(cp.tacanI) + "\n" + self.m.set_description_text(self.description) diff --git a/gen/groundobjectsgen.py b/gen/groundobjectsgen.py index 6f1cbd61f..33a2075bd 100644 --- a/gen/groundobjectsgen.py +++ b/gen/groundobjectsgen.py @@ -93,8 +93,13 @@ def generate(self): ship.heading = u.heading sg.add_unit(ship) + # TODO : make sure the point is not on Land sg.add_waypoint(sg.points[0].position.point_from_heading(g.units[0].heading, 100000)) + # SET UP TACAN + modeChannel = "X" if not cp.tacanY else "Y" + sg.points[0].tasks.append(ActivateBeaconCommand(channel=cp.tacanN, modechannel=modeChannel, callsign=cp.tacanI, unit_id=sg.units[0].id)) + else: if ground_object.dcs_identifier in warehouse_map: static_type = warehouse_map[ground_object.dcs_identifier] diff --git a/theater/controlpoint.py b/theater/controlpoint.py index da36e1615..d5ae27a88 100644 --- a/theater/controlpoint.py +++ b/theater/controlpoint.py @@ -57,6 +57,9 @@ def __init__(self, id: int, name: str, position: Point, at, radials: typing.Coll self.base = theater.base.Base() self.cptype = cptype self.stances = {} + self.tacanY = False + self.tacanN = None + self.tacanI = "TAC" @classmethod def from_airport(cls, airport: Airport, radials: typing.Collection[int], size: int, importance: float, has_frontline=True): @@ -66,14 +69,22 @@ def from_airport(cls, airport: Airport, radials: typing.Collection[int], size: i @classmethod def carrier(cls, name: str, at: Point, id: int = 1001): import theater.conflicttheater - return cls(id, name, at, at, theater.conflicttheater.LAND, theater.conflicttheater.SIZE_SMALL, 1, + cp = cls(id, name, at, at, theater.conflicttheater.LAND, theater.conflicttheater.SIZE_SMALL, 1, has_frontline=False, cptype=ControlPointType.AIRCRAFT_CARRIER_GROUP) + cp.tacanY = random.choice([True, False]) + cp.tacanN = random.randint(26, 49) + cp.tacanI = random.choice(["STE", "CVN", "CVH", "CCV", "ACC", "ARC", "GER", "ABR", "LIN", "TRU"]) + return cp @classmethod def lha(cls, name: str, at: Point, id: int = 1002): import theater.conflicttheater - return cls(id, name, at, at, theater.conflicttheater.LAND, theater.conflicttheater.SIZE_SMALL, 1, + cp = cls(id, name, at, at, theater.conflicttheater.LAND, theater.conflicttheater.SIZE_SMALL, 1, has_frontline=False, cptype=ControlPointType.LHA_GROUP) + cp.tacanY = random.choice([True, False]) + cp.tacanN = random.randint(1,25) + cp.tacanI = random.choice(["LHD", "LHA", "LHB", "LHC", "LHD", "LDS"]) + return cp def __str__(self): return self.name