Add all helipads to single group per FARP allowing take off from parking behavour and fixes #1910

This commit is contained in:
Ben Birch 2022-01-30 15:04:53 +11:00
parent 3afc6ba24b
commit a70a951192
2 changed files with 26 additions and 21 deletions

View File

@ -228,6 +228,7 @@ class FlightGroupSpawner:
def _generate_at_cp_helipad(self, name: str, cp: ControlPoint) -> FlyingGroup[Any]: def _generate_at_cp_helipad(self, name: str, cp: ControlPoint) -> FlyingGroup[Any]:
try: try:
# helipad = self.helipads[cp][0]
helipad = self.helipads[cp].pop() helipad = self.helipads[cp].pop()
except IndexError as ex: except IndexError as ex:
raise RuntimeError(f"Not enough helipads available at {cp}") from ex raise RuntimeError(f"Not enough helipads available at {cp}") from ex
@ -235,18 +236,18 @@ class FlightGroupSpawner:
group = self._generate_at_group(name, helipad) group = self._generate_at_group(name, helipad)
# Note : A bit dirty, need better support in pydcs # Note : A bit dirty, need better support in pydcs
group.points[0].action = PointAction.FromGroundArea group.points[0].action = PointAction.FromParkingArea
group.points[0].type = "TakeOffGround" group.points[0].type = "TakeOffParking"
group.units[0].heading = helipad.units[0].heading group.units[0].heading = helipad.units[0].heading
if self.start_type is not StartType.COLD: if self.start_type is not StartType.COLD:
group.points[0].action = PointAction.FromGroundAreaHot group.points[0].action = PointAction.FromParkingArea
group.points[0].type = "TakeOffGroundHot" group.points[0].type = "TakeOffParkingHot"
for i in range(self.flight.count - 1): for i in range(self.flight.count - 1):
try:
helipad = self.helipads[cp].pop()
group.units[1 + i].position = Point(helipad.x, helipad.y) group.units[1 + i].position = Point(helipad.x, helipad.y)
group.units[1 + i].heading = helipad.units[0].heading group.units[1 + i].heading = helipad.units[0].heading
try:
self.helipads[cp].pop()
except IndexError as ex: except IndexError as ex:
raise RuntimeError(f"Not enough helipads available at {cp}") from ex raise RuntimeError(f"Not enough helipads available at {cp}") from ex
return group return group

View File

@ -607,37 +607,40 @@ class HelipadGenerator:
self.helipads: list[StaticGroup] = [] self.helipads: list[StaticGroup] = []
def generate(self) -> None: def generate(self) -> None:
# This gets called for every control point, so we don't want to add an empty group (causes DCS mission editor to crash)
if len(self.cp.helipads) == 0:
return
# Note: Helipad are generated as neutral object in order not to interfer with # Note: Helipad are generated as neutral object in order not to interfer with
# capture triggers # capture triggers
neutral_country = self.m.country(self.game.neutral_country.name) neutral_country = self.m.country(self.game.neutral_country.name)
country = self.m.country(self.game.coalition_for(self.cp.captured).country_name) country = self.m.country(self.game.coalition_for(self.cp.captured).country_name)
name = self.cp.name + "_helipad"
sg = unitgroup.StaticGroup(self.m.next_group_id(), name)
sp = StaticPoint()
sp.position = self.cp.position
sg.add_point(sp)
for i, helipad in enumerate(self.cp.helipads): for i, helipad in enumerate(self.cp.helipads):
name = self.cp.name + "_helipad_" + str(i) # This is used as a trigger of the number of available pads when spawning flights
logging.info("Generating helipad static : " + name) self.helipads.append(sg)
pad = InvisibleFARP(unit_id=self.m.next_unit_id(), name=name) name_i = name + "_" + str(i)
logging.info("Generating helipad static : " + name_i)
pad = InvisibleFARP(unit_id=self.m.next_unit_id(), name=name_i)
pad.position = Point(helipad.x, helipad.y) pad.position = Point(helipad.x, helipad.y)
pad.heading = helipad.heading.degrees pad.heading = helipad.heading.degrees
sg = unitgroup.StaticGroup(self.m.next_group_id(), name)
sg.add_unit(pad) sg.add_unit(pad)
sp = StaticPoint()
sp.position = pad.position
sg.add_point(sp)
neutral_country.add_static_group(sg)
self.helipads.append(sg)
# Generate a FARP Ammo and Fuel stack for each pad # Generate a FARP Ammo and Fuel stack for each pad
self.m.static_group( self.m.static_group(
country=country, country=country,
name=(name + "_fuel"), name=(name_i + "_fuel"),
_type=Fortification.FARP_Fuel_Depot, _type=Fortification.FARP_Fuel_Depot,
position=pad.position.point_from_heading(helipad.heading.degrees, 35), position=pad.position.point_from_heading(helipad.heading.degrees, 35),
heading=pad.heading, heading=pad.heading,
) )
self.m.static_group( self.m.static_group(
country=country, country=country,
name=(name + "_ammo"), name=(name_i + "_ammo"),
_type=Fortification.FARP_Ammo_Dump_Coating, _type=Fortification.FARP_Ammo_Dump_Coating,
position=pad.position.point_from_heading( position=pad.position.point_from_heading(
helipad.heading.degrees, 35 helipad.heading.degrees, 35
@ -646,13 +649,14 @@ class HelipadGenerator:
) )
self.m.static_group( self.m.static_group(
country=country, country=country,
name=(name + "_ws"), name=(name_i + "_ws"),
_type=Fortification.Windsock, _type=Fortification.Windsock,
position=pad.position.point_from_heading( position=pad.position.point_from_heading(
helipad.heading.degrees + 45, 35 helipad.heading.degrees + 45, 35
), ),
heading=pad.heading, heading=pad.heading,
) )
neutral_country.add_static_group(sg)
class TgoGenerator: class TgoGenerator: