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 committed by Raffson
parent d3b0ae30eb
commit a343bdef23
No known key found for this signature in database
GPG Key ID: B0402B2C9B764D99
3 changed files with 13 additions and 4 deletions

View File

@ -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.

View File

@ -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:

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
@ -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,
)