mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Reverted automerge errors.
This commit is contained in:
parent
de5238e89a
commit
00ea8ac4e1
@ -1,13 +1,14 @@
|
|||||||
from typing import Set
|
from typing import Set
|
||||||
|
|
||||||
|
from dcs.countries import country_dict
|
||||||
|
from dcs.lua.parse import loads
|
||||||
|
from dcs.terrain.terrain import Terrain
|
||||||
|
|
||||||
from gen import *
|
from gen import *
|
||||||
from gen.airfields import AIRFIELD_DATA
|
from gen.airfields import AIRFIELD_DATA
|
||||||
from gen.beacons import load_beacons_for_terrain
|
from gen.beacons import load_beacons_for_terrain
|
||||||
from gen.radios import RadioRegistry
|
from gen.radios import RadioRegistry
|
||||||
from gen.tacan import TacanRegistry
|
from gen.tacan import TacanRegistry
|
||||||
from dcs.countries import country_dict
|
|
||||||
from dcs.lua.parse import loads
|
|
||||||
from dcs.terrain.terrain import Terrain
|
|
||||||
from userdata.debriefing import *
|
from userdata.debriefing import *
|
||||||
|
|
||||||
|
|
||||||
@ -68,8 +69,26 @@ class Operation:
|
|||||||
def initialize(self, mission: Mission, conflict: Conflict):
|
def initialize(self, mission: Mission, conflict: Conflict):
|
||||||
self.current_mission = mission
|
self.current_mission = mission
|
||||||
self.conflict = conflict
|
self.conflict = conflict
|
||||||
self.briefinggen = BriefingGenerator(self.current_mission,
|
self.radio_registry = RadioRegistry()
|
||||||
self.conflict, self.game)
|
self.tacan_registry = TacanRegistry()
|
||||||
|
self.airgen = AircraftConflictGenerator(
|
||||||
|
mission, conflict, self.game.settings, self.game,
|
||||||
|
self.radio_registry)
|
||||||
|
self.airsupportgen = AirSupportConflictGenerator(
|
||||||
|
mission, conflict, self.game, self.radio_registry,
|
||||||
|
self.tacan_registry)
|
||||||
|
self.triggersgen = TriggersGenerator(mission, conflict, self.game)
|
||||||
|
self.visualgen = VisualGenerator(mission, conflict, self.game)
|
||||||
|
self.envgen = EnviromentGenerator(mission, conflict, self.game)
|
||||||
|
self.forcedoptionsgen = ForcedOptionsGenerator(mission, conflict, self.game)
|
||||||
|
self.groundobjectgen = GroundObjectsGenerator(
|
||||||
|
mission,
|
||||||
|
conflict,
|
||||||
|
self.game,
|
||||||
|
self.radio_registry,
|
||||||
|
self.tacan_registry
|
||||||
|
)
|
||||||
|
self.briefinggen = BriefingGenerator(mission, conflict, self.game)
|
||||||
|
|
||||||
def prepare(self, terrain: Terrain, is_quick: bool):
|
def prepare(self, terrain: Terrain, is_quick: bool):
|
||||||
with open("resources/default_options.lua", "r") as f:
|
with open("resources/default_options.lua", "r") as f:
|
||||||
@ -109,9 +128,6 @@ class Operation:
|
|||||||
self.defenders_starting_position = self.to_cp.at
|
self.defenders_starting_position = self.to_cp.at
|
||||||
|
|
||||||
def generate(self):
|
def generate(self):
|
||||||
radio_registry = RadioRegistry()
|
|
||||||
tacan_registry = TacanRegistry()
|
|
||||||
|
|
||||||
# Dedup beacon/radio frequencies, since some maps have some frequencies
|
# Dedup beacon/radio frequencies, since some maps have some frequencies
|
||||||
# used multiple times.
|
# used multiple times.
|
||||||
beacons = load_beacons_for_terrain(self.game.theater.terrain.name)
|
beacons = load_beacons_for_terrain(self.game.theater.terrain.name)
|
||||||
@ -123,7 +139,7 @@ class Operation:
|
|||||||
logging.error(
|
logging.error(
|
||||||
f"TACAN beacon has no channel: {beacon.callsign}")
|
f"TACAN beacon has no channel: {beacon.callsign}")
|
||||||
else:
|
else:
|
||||||
tacan_registry.reserve(beacon.tacan_channel)
|
self.tacan_registry.reserve(beacon.tacan_channel)
|
||||||
|
|
||||||
for airfield, data in AIRFIELD_DATA.items():
|
for airfield, data in AIRFIELD_DATA.items():
|
||||||
if data.theater == self.game.theater.terrain.name:
|
if data.theater == self.game.theater.terrain.name:
|
||||||
@ -135,26 +151,16 @@ class Operation:
|
|||||||
# beacon list.
|
# beacon list.
|
||||||
|
|
||||||
for frequency in unique_map_frequencies:
|
for frequency in unique_map_frequencies:
|
||||||
radio_registry.reserve(frequency)
|
self.radio_registry.reserve(frequency)
|
||||||
|
|
||||||
# Generate meteo
|
# Generate meteo
|
||||||
envgen = EnviromentGenerator(self.current_mission, self.conflict,
|
|
||||||
self.game)
|
|
||||||
if self.environment_settings is None:
|
if self.environment_settings is None:
|
||||||
self.environment_settings = envgen.generate()
|
self.environment_settings = self.envgen.generate()
|
||||||
else:
|
else:
|
||||||
envgen.load(self.environment_settings)
|
self.envgen.load(self.environment_settings)
|
||||||
|
|
||||||
# Generate ground object first
|
# Generate ground object first
|
||||||
|
self.groundobjectgen.generate()
|
||||||
groundobjectgen = GroundObjectsGenerator(
|
|
||||||
self.current_mission,
|
|
||||||
self.conflict,
|
|
||||||
self.game,
|
|
||||||
radio_registry,
|
|
||||||
tacan_registry
|
|
||||||
)
|
|
||||||
groundobjectgen.generate()
|
|
||||||
|
|
||||||
# Generate destroyed units
|
# Generate destroyed units
|
||||||
for d in self.game.get_destroyed_units():
|
for d in self.game.get_destroyed_units():
|
||||||
@ -176,10 +182,7 @@ class Operation:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Air Support (Tanker & Awacs)
|
# Air Support (Tanker & Awacs)
|
||||||
airsupportgen = AirSupportConflictGenerator(
|
self.airsupportgen.generate(self.is_awacs_enabled)
|
||||||
self.current_mission, self.conflict, self.game, radio_registry,
|
|
||||||
tacan_registry)
|
|
||||||
airsupportgen.generate(self.is_awacs_enabled)
|
|
||||||
|
|
||||||
# Generate Activity on the map
|
# Generate Activity on the map
|
||||||
self.airgen.generate_flights(
|
self.airgen.generate_flights(
|
||||||
@ -193,7 +196,6 @@ class Operation:
|
|||||||
self.groundobjectgen.runways
|
self.groundobjectgen.runways
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Generate ground units on frontline everywhere
|
# Generate ground units on frontline everywhere
|
||||||
jtacs: List[JtacInfo] = []
|
jtacs: List[JtacInfo] = []
|
||||||
for player_cp, enemy_cp in self.game.theater.conflicts(True):
|
for player_cp, enemy_cp in self.game.theater.conflicts(True):
|
||||||
@ -204,32 +206,32 @@ class Operation:
|
|||||||
# Generate frontline ops
|
# Generate frontline ops
|
||||||
player_gp = self.game.ground_planners[player_cp.id].units_per_cp[enemy_cp.id]
|
player_gp = self.game.ground_planners[player_cp.id].units_per_cp[enemy_cp.id]
|
||||||
enemy_gp = self.game.ground_planners[enemy_cp.id].units_per_cp[player_cp.id]
|
enemy_gp = self.game.ground_planners[enemy_cp.id].units_per_cp[player_cp.id]
|
||||||
groundConflictGen = GroundConflictGenerator(self.current_mission, conflict, self.game, player_gp, enemy_gp, player_cp.stances[enemy_cp.id])
|
groundConflictGen = GroundConflictGenerator(self.current_mission, conflict, self.game, player_gp, enemy_gp,
|
||||||
|
player_cp.stances[enemy_cp.id])
|
||||||
groundConflictGen.generate()
|
groundConflictGen.generate()
|
||||||
jtacs.extend(groundConflictGen.jtacs)
|
jtacs.extend(groundConflictGen.jtacs)
|
||||||
|
|
||||||
# Setup combined arms parameters
|
# Setup combined arms parameters
|
||||||
self.current_mission.groundControl.pilot_can_control_vehicles = self.ca_slots > 0
|
self.current_mission.groundControl.pilot_can_control_vehicles = self.ca_slots > 0
|
||||||
if self.game.player_country in [country.name for country in self.current_mission.coalition["blue"].countries.values()]:
|
if self.game.player_country in [country.name for country in
|
||||||
|
self.current_mission.coalition["blue"].countries.values()]:
|
||||||
self.current_mission.groundControl.blue_tactical_commander = self.ca_slots
|
self.current_mission.groundControl.blue_tactical_commander = self.ca_slots
|
||||||
else:
|
else:
|
||||||
self.current_mission.groundControl.red_tactical_commander = self.ca_slots
|
self.current_mission.groundControl.red_tactical_commander = self.ca_slots
|
||||||
|
|
||||||
# Triggers
|
# Triggers
|
||||||
triggersgen = TriggersGenerator(self.current_mission, self.conflict,
|
if self.game.is_player_attack(self.conflict.attackers_country):
|
||||||
self.game)
|
cp = self.conflict.from_cp
|
||||||
triggersgen.generate()
|
else:
|
||||||
|
cp = self.conflict.to_cp
|
||||||
|
self.triggersgen.generate()
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
forcedoptionsgen = ForcedOptionsGenerator(self.current_mission,
|
self.forcedoptionsgen.generate()
|
||||||
self.conflict, self.game)
|
|
||||||
forcedoptionsgen.generate()
|
|
||||||
|
|
||||||
# Generate Visuals Smoke Effects
|
# Generate Visuals Smoke Effects
|
||||||
visualgen = VisualGenerator(self.current_mission, self.conflict,
|
|
||||||
self.game)
|
|
||||||
if self.game.settings.perf_smoke_gen:
|
if self.game.settings.perf_smoke_gen:
|
||||||
visualgen.generate()
|
self.visualgen.generate()
|
||||||
|
|
||||||
# Inject Plugins Lua Scripts
|
# Inject Plugins Lua Scripts
|
||||||
listOfPluginsScripts = []
|
listOfPluginsScripts = []
|
||||||
@ -237,7 +239,7 @@ class Operation:
|
|||||||
if plugin_file_path.exists():
|
if plugin_file_path.exists():
|
||||||
for line in plugin_file_path.read_text().splitlines():
|
for line in plugin_file_path.read_text().splitlines():
|
||||||
name = line.strip()
|
name = line.strip()
|
||||||
if not name.startswith( '#' ):
|
if not name.startswith('#'):
|
||||||
trigger = TriggerStart(comment="Load " + name)
|
trigger = TriggerStart(comment="Load " + name)
|
||||||
listOfPluginsScripts.append(name)
|
listOfPluginsScripts.append(name)
|
||||||
fileref = self.current_mission.map_resource.add_resource_file("./resources/scripts/plugins/" + name)
|
fileref = self.current_mission.map_resource.add_resource_file("./resources/scripts/plugins/" + name)
|
||||||
@ -248,21 +250,21 @@ class Operation:
|
|||||||
f"Not loading plugins, {plugin_file_path} does not exist")
|
f"Not loading plugins, {plugin_file_path} does not exist")
|
||||||
|
|
||||||
# Inject Mist Script if not done already in the plugins
|
# Inject Mist Script if not done already in the plugins
|
||||||
if not "mist.lua" in listOfPluginsScripts and not "mist_4_3_74.lua" in listOfPluginsScripts: # don't load the script twice
|
if not "mist.lua" in listOfPluginsScripts and not "mist_4_3_74.lua" in listOfPluginsScripts: # don't load the script twice
|
||||||
trigger = TriggerStart(comment="Load Mist Lua framework")
|
trigger = TriggerStart(comment="Load Mist Lua framework")
|
||||||
fileref = self.current_mission.map_resource.add_resource_file("./resources/scripts/mist_4_3_74.lua")
|
fileref = self.current_mission.map_resource.add_resource_file("./resources/scripts/mist_4_3_74.lua")
|
||||||
trigger.add_action(DoScriptFile(fileref))
|
trigger.add_action(DoScriptFile(fileref))
|
||||||
self.current_mission.triggerrules.triggers.append(trigger)
|
self.current_mission.triggerrules.triggers.append(trigger)
|
||||||
|
|
||||||
# Inject JSON library if not done already in the plugins
|
# Inject JSON library if not done already in the plugins
|
||||||
if not "json.lua" in listOfPluginsScripts : # don't load the script twice
|
if not "json.lua" in listOfPluginsScripts: # don't load the script twice
|
||||||
trigger = TriggerStart(comment="Load JSON Lua library")
|
trigger = TriggerStart(comment="Load JSON Lua library")
|
||||||
fileref = self.current_mission.map_resource.add_resource_file("./resources/scripts/json.lua")
|
fileref = self.current_mission.map_resource.add_resource_file("./resources/scripts/json.lua")
|
||||||
trigger.add_action(DoScriptFile(fileref))
|
trigger.add_action(DoScriptFile(fileref))
|
||||||
self.current_mission.triggerrules.triggers.append(trigger)
|
self.current_mission.triggerrules.triggers.append(trigger)
|
||||||
|
|
||||||
# Inject Ciribob's JTACAutoLase if not done already in the plugins
|
# Inject Ciribob's JTACAutoLase if not done already in the plugins
|
||||||
if not "JTACAutoLase.lua" in listOfPluginsScripts : # don't load the script twice
|
if not "JTACAutoLase.lua" in listOfPluginsScripts: # don't load the script twice
|
||||||
trigger = TriggerStart(comment="Load JTACAutoLase.lua script")
|
trigger = TriggerStart(comment="Load JTACAutoLase.lua script")
|
||||||
fileref = self.current_mission.map_resource.add_resource_file("./resources/scripts/JTACAutoLase.lua")
|
fileref = self.current_mission.map_resource.add_resource_file("./resources/scripts/JTACAutoLase.lua")
|
||||||
trigger.add_action(DoScriptFile(fileref))
|
trigger.add_action(DoScriptFile(fileref))
|
||||||
@ -275,20 +277,20 @@ class Operation:
|
|||||||
lua = """
|
lua = """
|
||||||
-- setting configuration table
|
-- setting configuration table
|
||||||
env.info("DCSLiberation|: setting configuration table")
|
env.info("DCSLiberation|: setting configuration table")
|
||||||
|
|
||||||
-- all data in this table is overridable.
|
-- all data in this table is overridable.
|
||||||
dcsLiberation = {}
|
dcsLiberation = {}
|
||||||
|
|
||||||
-- the base location for state.json; if non-existent, it'll be replaced with LIBERATION_EXPORT_DIR, TEMP, or DCS working directory
|
-- the base location for state.json; if non-existent, it'll be replaced with LIBERATION_EXPORT_DIR, TEMP, or DCS working directory
|
||||||
dcsLiberation.installPath=""" + state_location + """
|
dcsLiberation.installPath=""" + state_location + """
|
||||||
|
|
||||||
-- you can override dcsLiberation.JTACAutoLase to make it use your own function ; it will be called with these parameters : ({jtac.unit_name}, {jtac.code}, {smoke}, 'vehicle') for all JTACs
|
-- you can override dcsLiberation.JTACAutoLase to make it use your own function ; it will be called with these parameters : ({jtac.unit_name}, {jtac.code}, {smoke}, 'vehicle') for all JTACs
|
||||||
if ctld then
|
if ctld then
|
||||||
dcsLiberation.JTACAutoLase=ctld.JTACAutoLase
|
dcsLiberation.JTACAutoLase=ctld.JTACAutoLase
|
||||||
elseif JTACAutoLase then
|
elseif JTACAutoLase then
|
||||||
dcsLiberation.JTACAutoLase=JTACAutoLase
|
dcsLiberation.JTACAutoLase=JTACAutoLase
|
||||||
end
|
end
|
||||||
|
|
||||||
-- later, we'll add more data to the table
|
-- later, we'll add more data to the table
|
||||||
--dcsLiberation.POIs = {}
|
--dcsLiberation.POIs = {}
|
||||||
--dcsLiberation.BASEs = {}
|
--dcsLiberation.BASEs = {}
|
||||||
@ -300,7 +302,7 @@ class Operation:
|
|||||||
self.current_mission.triggerrules.triggers.append(trigger)
|
self.current_mission.triggerrules.triggers.append(trigger)
|
||||||
|
|
||||||
# Inject DCS-Liberation script if not done already in the plugins
|
# Inject DCS-Liberation script if not done already in the plugins
|
||||||
if not "dcs_liberation.lua" in listOfPluginsScripts : # don't load the script twice
|
if not "dcs_liberation.lua" in listOfPluginsScripts: # don't load the script twice
|
||||||
trigger = TriggerStart(comment="Load DCS Liberation script")
|
trigger = TriggerStart(comment="Load DCS Liberation script")
|
||||||
fileref = self.current_mission.map_resource.add_resource_file("./resources/scripts/dcs_liberation.lua")
|
fileref = self.current_mission.map_resource.add_resource_file("./resources/scripts/dcs_liberation.lua")
|
||||||
trigger.add_action(DoScriptFile(fileref))
|
trigger.add_action(DoScriptFile(fileref))
|
||||||
@ -324,20 +326,19 @@ class Operation:
|
|||||||
trigger.add_action(DoScript(String(lua)))
|
trigger.add_action(DoScript(String(lua)))
|
||||||
self.current_mission.triggerrules.triggers.append(trigger)
|
self.current_mission.triggerrules.triggers.append(trigger)
|
||||||
|
|
||||||
self.assign_channels_to_flights(airgen.flights,
|
self.assign_channels_to_flights()
|
||||||
airsupportgen.air_support)
|
|
||||||
|
|
||||||
kneeboard_generator = KneeboardGenerator(self.current_mission)
|
kneeboard_generator = KneeboardGenerator(self.current_mission)
|
||||||
|
|
||||||
for dynamic_runway in groundobjectgen.runways.values():
|
for dynamic_runway in self.groundobjectgen.runways.values():
|
||||||
self.briefinggen.add_dynamic_runway(dynamic_runway)
|
self.briefinggen.add_dynamic_runway(dynamic_runway)
|
||||||
|
|
||||||
for tanker in airsupportgen.air_support.tankers:
|
for tanker in self.airsupportgen.air_support.tankers:
|
||||||
self.briefinggen.add_tanker(tanker)
|
self.briefinggen.add_tanker(tanker)
|
||||||
kneeboard_generator.add_tanker(tanker)
|
kneeboard_generator.add_tanker(tanker)
|
||||||
|
|
||||||
if self.is_awacs_enabled:
|
if self.is_awacs_enabled:
|
||||||
for awacs in airsupportgen.air_support.awacs:
|
for awacs in self.airsupportgen.air_support.awacs:
|
||||||
self.briefinggen.add_awacs(awacs)
|
self.briefinggen.add_awacs(awacs)
|
||||||
kneeboard_generator.add_awacs(awacs)
|
kneeboard_generator.add_awacs(awacs)
|
||||||
|
|
||||||
@ -345,23 +346,21 @@ class Operation:
|
|||||||
self.briefinggen.add_jtac(jtac)
|
self.briefinggen.add_jtac(jtac)
|
||||||
kneeboard_generator.add_jtac(jtac)
|
kneeboard_generator.add_jtac(jtac)
|
||||||
|
|
||||||
for flight in airgen.flights:
|
for flight in self.airgen.flights:
|
||||||
self.briefinggen.add_flight(flight)
|
self.briefinggen.add_flight(flight)
|
||||||
kneeboard_generator.add_flight(flight)
|
kneeboard_generator.add_flight(flight)
|
||||||
|
|
||||||
self.briefinggen.generate()
|
self.briefinggen.generate()
|
||||||
kneeboard_generator.generate()
|
kneeboard_generator.generate()
|
||||||
|
|
||||||
def assign_channels_to_flights(self, flights: List[FlightData],
|
def assign_channels_to_flights(self) -> None:
|
||||||
air_support: AirSupport) -> None:
|
|
||||||
"""Assigns preset radio channels for client flights."""
|
"""Assigns preset radio channels for client flights."""
|
||||||
for flight in flights:
|
for flight in self.airgen.flights:
|
||||||
if not flight.client_units:
|
if not flight.client_units:
|
||||||
continue
|
continue
|
||||||
self.assign_channels_to_flight(flight, air_support)
|
self.assign_channels_to_flight(flight)
|
||||||
|
|
||||||
def assign_channels_to_flight(self, flight: FlightData,
|
def assign_channels_to_flight(self, flight: FlightData) -> None:
|
||||||
air_support: AirSupport) -> None:
|
|
||||||
"""Assigns preset radio channels for a client flight."""
|
"""Assigns preset radio channels for a client flight."""
|
||||||
airframe = flight.aircraft_type
|
airframe = flight.aircraft_type
|
||||||
|
|
||||||
@ -372,5 +371,4 @@ class Operation:
|
|||||||
return
|
return
|
||||||
|
|
||||||
aircraft_data.channel_allocator.assign_channels_for_flight(
|
aircraft_data.channel_allocator.assign_channels_for_flight(
|
||||||
flight, air_support
|
flight, self.airsupportgen.air_support)
|
||||||
)
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user