MAde it possible to setup liveries in faction files.

This commit is contained in:
Khopa 2020-11-16 23:57:12 +01:00 committed by walterroach
parent 0b6b40a358
commit a52dc43c9e
6 changed files with 79 additions and 3 deletions

View File

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

View File

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

View File

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

View File

@ -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"
]
}
}

View File

@ -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"
]
}
}

View File

@ -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"
]
}
}