mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Implemented dynamic outputting of JTAC units to the Pretense init script.
This commit is contained in:
parent
545210b35d
commit
daa3259e59
@ -305,9 +305,6 @@ class PretenseLuaGenerator(LuaGenerator):
|
|||||||
lua_string_zones += " }\n"
|
lua_string_zones += " }\n"
|
||||||
lua_string_zones += "})\n"
|
lua_string_zones += "})\n"
|
||||||
|
|
||||||
init_body_file = open("./resources/plugins/pretense/init_body.lua", "r")
|
|
||||||
init_body = init_body_file.read()
|
|
||||||
|
|
||||||
lua_string_connman = " cm = ConnectionManager:new()"
|
lua_string_connman = " cm = ConnectionManager:new()"
|
||||||
|
|
||||||
for cp in self.game.theater.controlpoints:
|
for cp in self.game.theater.controlpoints:
|
||||||
@ -316,6 +313,19 @@ class PretenseLuaGenerator(LuaGenerator):
|
|||||||
f" cm: addConnection('{cp.name}', '{other_cp.name}')"
|
f" cm: addConnection('{cp.name}', '{other_cp.name}')"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
init_body_1_file = open("./resources/plugins/pretense/init_body_1.lua", "r")
|
||||||
|
init_body_1 = init_body_1_file.read()
|
||||||
|
|
||||||
|
lua_string_jtac = ""
|
||||||
|
for jtac in self.mission_data.jtacs:
|
||||||
|
lua_string_jtac = f"Group.getByName('{jtac.group_name}'): destroy()"
|
||||||
|
lua_string_jtac += (
|
||||||
|
"CommandFunctions.jtac = JTAC:new({name = '" + jtac.group_name + "'})"
|
||||||
|
)
|
||||||
|
|
||||||
|
init_body_2_file = open("./resources/plugins/pretense/init_body_2.lua", "r")
|
||||||
|
init_body_2 = init_body_2_file.read()
|
||||||
|
|
||||||
init_footer_file = open("./resources/plugins/pretense/init_footer.lua", "r")
|
init_footer_file = open("./resources/plugins/pretense/init_footer.lua", "r")
|
||||||
init_footer = init_footer_file.read()
|
init_footer = init_footer_file.read()
|
||||||
|
|
||||||
@ -323,7 +333,9 @@ class PretenseLuaGenerator(LuaGenerator):
|
|||||||
init_header
|
init_header
|
||||||
+ lua_string_zones
|
+ lua_string_zones
|
||||||
+ lua_string_connman
|
+ lua_string_connman
|
||||||
+ init_body
|
+ init_body_1
|
||||||
|
+ lua_string_jtac
|
||||||
|
+ init_body_2
|
||||||
+ init_footer
|
+ init_footer
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -42,14 +42,20 @@ from .pretensetgogenerator import PretenseTgoGenerator
|
|||||||
from .pretensetriggergenerator import PretenseTriggerGenerator
|
from .pretensetriggergenerator import PretenseTriggerGenerator
|
||||||
from game.missiongenerator.visualsgenerator import VisualsGenerator
|
from game.missiongenerator.visualsgenerator import VisualsGenerator
|
||||||
from ..ato import Flight
|
from ..ato import Flight
|
||||||
|
from ..missiongenerator import MissionGenerator
|
||||||
from ..radio.TacanContainer import TacanContainer
|
from ..radio.TacanContainer import TacanContainer
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from game import Game
|
from game import Game
|
||||||
|
|
||||||
|
|
||||||
class PretenseMissionGenerator:
|
class PretenseMissionGenerator(MissionGenerator):
|
||||||
def __init__(self, game: Game, time: datetime) -> None:
|
def __init__(self, game: Game, time: datetime) -> None:
|
||||||
|
super().__init__(
|
||||||
|
game,
|
||||||
|
time,
|
||||||
|
)
|
||||||
|
|
||||||
self.game = game
|
self.game = game
|
||||||
self.time = time
|
self.time = time
|
||||||
self.mission = Mission(game.theater.terrain)
|
self.mission = Mission(game.theater.terrain)
|
||||||
@ -143,51 +149,6 @@ class PretenseMissionGenerator:
|
|||||||
c = country_dict[country_id]()
|
c = country_dict[country_id]()
|
||||||
self.mission.coalition["neutrals"].add_country(c)
|
self.mission.coalition["neutrals"].add_country(c)
|
||||||
|
|
||||||
def add_airfields_to_unit_map(self) -> None:
|
|
||||||
for control_point in self.game.theater.controlpoints:
|
|
||||||
if isinstance(control_point, Airfield):
|
|
||||||
self.unit_map.add_airfield(control_point)
|
|
||||||
|
|
||||||
def initialize_registries(self) -> None:
|
|
||||||
unique_map_frequencies: set[RadioFrequency] = set()
|
|
||||||
self.initialize_tacan_registry(unique_map_frequencies)
|
|
||||||
self.initialize_radio_registry(unique_map_frequencies)
|
|
||||||
# Allocate UHF/VHF Guard Freq first!
|
|
||||||
unique_map_frequencies.add(MHz(243))
|
|
||||||
unique_map_frequencies.add(MHz(121, 500))
|
|
||||||
for frequency in unique_map_frequencies:
|
|
||||||
self.radio_registry.reserve(frequency)
|
|
||||||
|
|
||||||
def initialize_tacan_registry(
|
|
||||||
self, unique_map_frequencies: set[RadioFrequency]
|
|
||||||
) -> None:
|
|
||||||
"""
|
|
||||||
Dedup beacon/radio frequencies, since some maps have some frequencies
|
|
||||||
used multiple times.
|
|
||||||
"""
|
|
||||||
for beacon in Beacons.iter_theater(self.game.theater):
|
|
||||||
unique_map_frequencies.add(beacon.frequency)
|
|
||||||
if beacon.is_tacan:
|
|
||||||
if beacon.channel is None:
|
|
||||||
logging.warning(f"TACAN beacon has no channel: {beacon.callsign}")
|
|
||||||
else:
|
|
||||||
self.tacan_registry.mark_unavailable(beacon.tacan_channel)
|
|
||||||
for cp in self.game.theater.controlpoints:
|
|
||||||
if isinstance(cp, TacanContainer) and cp.tacan is not None:
|
|
||||||
self.tacan_registry.mark_unavailable(cp.tacan)
|
|
||||||
|
|
||||||
def initialize_radio_registry(
|
|
||||||
self, unique_map_frequencies: set[RadioFrequency]
|
|
||||||
) -> None:
|
|
||||||
for airport in self.game.theater.terrain.airport_list():
|
|
||||||
if (atc := AtcData.from_pydcs(airport)) is not None:
|
|
||||||
unique_map_frequencies.add(atc.hf)
|
|
||||||
unique_map_frequencies.add(atc.vhf_fm)
|
|
||||||
unique_map_frequencies.add(atc.vhf_am)
|
|
||||||
unique_map_frequencies.add(atc.uhf)
|
|
||||||
# No need to reserve ILS or TACAN because those are in the
|
|
||||||
# beacon list.
|
|
||||||
|
|
||||||
def generate_ground_conflicts(self) -> None:
|
def generate_ground_conflicts(self) -> None:
|
||||||
"""Generate FLOTs and JTACs for each active front line."""
|
"""Generate FLOTs and JTACs for each active front line."""
|
||||||
for front_line in self.game.theater.conflicts():
|
for front_line in self.game.theater.conflicts():
|
||||||
@ -247,7 +208,6 @@ class PretenseMissionGenerator:
|
|||||||
else:
|
else:
|
||||||
ato = self.game.red.ato
|
ato = self.game.red.ato
|
||||||
cp_country = self.e_country
|
cp_country = self.e_country
|
||||||
print(f"Generating flights for {cp_country.name} at {cp}")
|
|
||||||
aircraft_generator.generate_flights(
|
aircraft_generator.generate_flights(
|
||||||
cp_country,
|
cp_country,
|
||||||
cp,
|
cp,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user