Allow factions to specify their cargo ship type.

https://github.com/dcs-liberation/dcs_liberation/issues/3039
This commit is contained in:
Dan Albert 2023-06-26 21:30:44 -07:00
parent c482b497db
commit bb36b8cad3
3 changed files with 12 additions and 6 deletions

View File

@ -4,6 +4,8 @@ Saves from 8.x are not compatible with 9.0.0.
## Features/Improvements
* **[Modding]** Factions can now specify the ship type to be used for cargo shipping. The Handy Wind will be used by default, but WW2 factions can pick something more appropriate.
## Fixes
* **[Data]** Fixed the class of the Samuel Chase so it can't be picked for a AAA or SHORAD site.

View File

@ -42,6 +42,9 @@ class Faction:
#: choose the default locale.
locales: Optional[List[str]]
# The unit type to spawn for cargo shipping.
cargo_ship: ShipUnitType
# Country used by this faction
country: str = field(default="")
@ -168,7 +171,10 @@ class Faction:
@classmethod
def from_dict(cls: Type[Faction], json: Dict[str, Any]) -> Faction:
faction = Faction(locales=json.get("locales"))
faction = Faction(
locales=json.get("locales"),
cargo_ship=ShipUnitType.named(json.get("cargo_ship", "Handy Wind")),
)
faction.country = json.get("country", "/")
if faction.country not in [c.name for c in country_dict.values()]:

View File

@ -4,7 +4,6 @@ import itertools
from typing import TYPE_CHECKING
from dcs import Mission
from dcs.ships import HandyWind
from dcs.unitgroup import ShipGroup
from game.transfers import CargoShip
@ -29,14 +28,13 @@ class CargoShipGenerator:
self.generate_cargo_ship(ship)
def generate_cargo_ship(self, ship: CargoShip) -> ShipGroup:
country = self.mission.country(
self.game.coalition_for(ship.player_owned).country_name
)
coalition = self.game.coalition_for(ship.player_owned)
country = self.mission.country(coalition.country_name)
waypoints = ship.route
group = self.mission.ship_group(
country,
ship.name,
HandyWind,
coalition.faction.cargo_ship.dcs_unit_type,
position=waypoints[0],
group_size=1,
)