Skip to content

Commit

Permalink
Generate random TACAN frequency for ships at start.
Browse files Browse the repository at this point in the history
TACAN infos are displayed in briefing.
  • Loading branch information
Khopa committed May 29, 2020
1 parent 8afdf5e commit 59986d7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
17 changes: 0 additions & 17 deletions game/operation/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 12 additions & 0 deletions gen/briefinggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions gen/groundobjectsgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
15 changes: 13 additions & 2 deletions theater/controlpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down

0 comments on commit 59986d7

Please sign in to comment.