diff --git a/changelog.md b/changelog.md index 6f3e0523..ef62090d 100644 --- a/changelog.md +++ b/changelog.md @@ -211,6 +211,8 @@ BAI/ANTISHIP/DEAD/STRIKE/BARCAP/CAS/OCA/AIR-ASSAULT (main) missions * **[Flight Planning]** Improved IP selection for targets that are near the center of a threat zone. * **[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. +* **[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 4410bed5..af808962 100644 --- a/game/factions/faction.py +++ b/game/factions/faction.py @@ -45,6 +45,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: Country @@ -194,7 +197,11 @@ class Faction: "country ID" ) from ex - faction = Faction(locales=json.get("locales"), country=country) + faction = Faction( + locales=json.get("locales"), + country=country, + cargo_ship=ShipUnitType.named(json.get("cargo_ship", "Handy Wind")) + ) faction.name = json.get("name", "") if not faction.name: diff --git a/game/missiongenerator/cargoshipgenerator.py b/game/missiongenerator/cargoshipgenerator.py index 26e6eff0..f3aeaadb 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 @@ -30,15 +29,16 @@ class CargoShipGenerator: self.generate_cargo_ship(ship) def generate_cargo_ship(self, ship: CargoShip) -> ShipGroup: + coalition = self.game.coalition_for(ship.player_owned) waypoints = ship.route - country = self.game.coalition_for(ship.player_owned).faction.country + country = coalition.faction.country country = self.mission.country(country.name) group = self.mission.ship_group( country, ship.name, - HandyWind, + coalition.faction.cargo_ship.dcs_unit_type, position=waypoints[0], group_size=1, )