From e26b692631fb4d42c9af7ac549edf0f8a1058f3d Mon Sep 17 00:00:00 2001 From: Khopa Date: Mon, 16 Nov 2020 23:57:12 +0100 Subject: [PATCH] MAde it possible to setup liveries in faction files. --- changelog.md | 1 + game/factions/faction.py | 11 +++++++++++ gen/aircraft.py | 11 +++++++++++ resources/factions/us_aggressors.json | 21 ++++++++++++++++++++- resources/factions/usa_2005.json | 22 +++++++++++++++++++++- resources/factions/usn_1985.json | 16 +++++++++++++++- 6 files changed, 79 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 4f71438e..f87dbeb2 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ # Features/Improvements * **[Flight Planner]** Added fighter sweep missions. * **[Flight Planner]** Differentiated BARCAP and TARCAP. TARCAP is now for hostile areas and will arrive before the package. +* **[Modding]** Possible to setup liveries overrides for factions # 2.2.1 diff --git a/game/factions/faction.py b/game/factions/faction.py index 5a056bf1..b0caf4bb 100644 --- a/game/factions/faction.py +++ b/game/factions/faction.py @@ -105,6 +105,9 @@ class Faction: # List of available buildings for this faction building_set: List[str] = field(default_factory=list) + # List of default livery overrides + liveries_overrides: Dict[UnitType, List[str]] = field(default_factory=dict) + @classmethod def from_json(cls: Type[Faction], json: Dict[str, Any]) -> Faction: @@ -183,6 +186,14 @@ class Faction: else: faction.building_set = DEFAULT_AVAILABLE_BUILDINGS + # Load liveries override + faction.liveries_overrides = {} + liveries_overrides = json.get("liveries_overrides", {}) + for k, v in liveries_overrides.items(): + k = load_aircraft(k) + if k is not None: + faction.liveries_overrides[k] = [s.lower() for s in v] + return faction @property diff --git a/gen/aircraft.py b/gen/aircraft.py index 5aa6ba55..03a9e619 100644 --- a/gen/aircraft.py +++ b/gen/aircraft.py @@ -714,6 +714,17 @@ class AircraftConflictGenerator: for unit_instance in group.units: unit_instance.livery_id = db.PLANE_LIVERY_OVERRIDES[unit_type] + # Override livery by faction file data + if flight.from_cp.captured: + faction = self.game.player_faction + else: + faction = self.game.enemy_faction + + if unit_type in faction.liveries_overrides: + livery = random.choice(faction.liveries_overrides[unit_type]) + for unit_instance in group.units: + unit_instance.livery_id = livery + for idx in range(0, min(len(group.units), flight.client_count)): unit = group.units[idx] if self.use_client: diff --git a/resources/factions/us_aggressors.json b/resources/factions/us_aggressors.json index 9e2b41a2..e3bf8108 100644 --- a/resources/factions/us_aggressors.json +++ b/resources/factions/us_aggressors.json @@ -61,5 +61,24 @@ "OliverHazardPerryGroupGenerator" ], "has_jtac": true, - "jtac_unit": "MQ_9_Reaper" + "jtac_unit": "MQ_9_Reaper", + "liveries_overrides": { + "FA_18C_hornet": [ + "NSAWC brown splinter", + "NAWDC black", + "VFC-12" + ], + "F_15C": [ + "65th Aggressor SQN (WA) MiG", + "65th Aggressor SQN (WA) MiG", + "65th Aggressor SQN (WA) SUPER_Flanker" + ], + "F_16C_50": [ + "usaf 64th aggressor sqn - shark", + "usaf 64th aggressor sqn-splinter", + "64th_aggressor_squadron_ghost" + ], "F_14B": [ + "vf-74 adversary" + ] + } } \ No newline at end of file diff --git a/resources/factions/usa_2005.json b/resources/factions/usa_2005.json index 59c3a4f2..f10e36bb 100644 --- a/resources/factions/usa_2005.json +++ b/resources/factions/usa_2005.json @@ -86,5 +86,25 @@ "OliverHazardPerryGroupGenerator" ], "has_jtac": true, - "jtac_unit": "MQ_9_Reaper" + "jtac_unit": "MQ_9_Reaper", + "liveries_overrides": { + "FA_18C_hornet": [ + "VFA-37", + "VFA-106", + "VFA-113", + "VFA-122", + "VFA-131", + "VFA-192", + "VFA-34", + "VFA-83", + "VFA-87", + "VFA-97", + "VMFA-122", + "VMFA-132", + "VMFA-251", + "VMFA-312", + "VMFA-314", + "VMFA-323" + ] + } } \ No newline at end of file diff --git a/resources/factions/usn_1985.json b/resources/factions/usn_1985.json index 6ca2f2f1..24d0e2ea 100644 --- a/resources/factions/usn_1985.json +++ b/resources/factions/usn_1985.json @@ -69,5 +69,19 @@ "OliverHazardPerryGroupGenerator" ], "requirements": {}, - "doctrine": "coldwar" + "doctrine": "coldwar", + "liveries_overrides": { + "FA_18C_hornet": [ + "VFA-37", + "VFA-106", + "VFA-113", + "VFA-122", + "VFA-131", + "VFA-192", + "VFA-34", + "VFA-83", + "VFA-87", + "VFA-97" + ] + } } \ No newline at end of file