mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Allow factions to specify their cargo ship type.
https://github.com/dcs-liberation/dcs_liberation/issues/3039
This commit is contained in:
parent
c482b497db
commit
bb36b8cad3
@ -4,6 +4,8 @@ Saves from 8.x are not compatible with 9.0.0.
|
|||||||
|
|
||||||
## Features/Improvements
|
## 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
|
## Fixes
|
||||||
|
|
||||||
* **[Data]** Fixed the class of the Samuel Chase so it can't be picked for a AAA or SHORAD site.
|
* **[Data]** Fixed the class of the Samuel Chase so it can't be picked for a AAA or SHORAD site.
|
||||||
|
|||||||
@ -42,6 +42,9 @@ class Faction:
|
|||||||
#: choose the default locale.
|
#: choose the default locale.
|
||||||
locales: Optional[List[str]]
|
locales: Optional[List[str]]
|
||||||
|
|
||||||
|
# The unit type to spawn for cargo shipping.
|
||||||
|
cargo_ship: ShipUnitType
|
||||||
|
|
||||||
# Country used by this faction
|
# Country used by this faction
|
||||||
country: str = field(default="")
|
country: str = field(default="")
|
||||||
|
|
||||||
@ -168,7 +171,10 @@ class Faction:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls: Type[Faction], json: Dict[str, Any]) -> Faction:
|
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", "/")
|
faction.country = json.get("country", "/")
|
||||||
if faction.country not in [c.name for c in country_dict.values()]:
|
if faction.country not in [c.name for c in country_dict.values()]:
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import itertools
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from dcs import Mission
|
from dcs import Mission
|
||||||
from dcs.ships import HandyWind
|
|
||||||
from dcs.unitgroup import ShipGroup
|
from dcs.unitgroup import ShipGroup
|
||||||
|
|
||||||
from game.transfers import CargoShip
|
from game.transfers import CargoShip
|
||||||
@ -29,14 +28,13 @@ class CargoShipGenerator:
|
|||||||
self.generate_cargo_ship(ship)
|
self.generate_cargo_ship(ship)
|
||||||
|
|
||||||
def generate_cargo_ship(self, ship: CargoShip) -> ShipGroup:
|
def generate_cargo_ship(self, ship: CargoShip) -> ShipGroup:
|
||||||
country = self.mission.country(
|
coalition = self.game.coalition_for(ship.player_owned)
|
||||||
self.game.coalition_for(ship.player_owned).country_name
|
country = self.mission.country(coalition.country_name)
|
||||||
)
|
|
||||||
waypoints = ship.route
|
waypoints = ship.route
|
||||||
group = self.mission.ship_group(
|
group = self.mission.ship_group(
|
||||||
country,
|
country,
|
||||||
ship.name,
|
ship.name,
|
||||||
HandyWind,
|
coalition.faction.cargo_ship.dcs_unit_type,
|
||||||
position=waypoints[0],
|
position=waypoints[0],
|
||||||
group_size=1,
|
group_size=1,
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user