diff --git a/changelog.md b/changelog.md index 96ec035a..63899ac2 100644 --- a/changelog.md +++ b/changelog.md @@ -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. diff --git a/game/factions/faction.py b/game/factions/faction.py index 8bab8211..48be6c41 100644 --- a/game/factions/faction.py +++ b/game/factions/faction.py @@ -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()]: diff --git a/game/missiongenerator/cargoshipgenerator.py b/game/missiongenerator/cargoshipgenerator.py index ec7e6577..bf2f6250 100644 --- a/game/missiongenerator/cargoshipgenerator.py +++ b/game/missiongenerator/cargoshipgenerator.py @@ -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, )