Add AFAC task to JTAC unit.

This causes the JTAC unit that's used for autolase to also work as
a FAC over the radio.
This commit is contained in:
Kangwook Lee (이강욱) 2021-08-01 04:37:18 +09:00 committed by GitHub
parent 6034c899d3
commit 0370aa8df5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 7 deletions

View File

@ -399,6 +399,7 @@ class Operation:
player_cp.stances[enemy_cp.id], player_cp.stances[enemy_cp.id],
enemy_cp.stances[player_cp.id], enemy_cp.stances[player_cp.id],
cls.unit_map, cls.unit_map,
cls.radio_registry,
) )
ground_conflict_gen.generate() ground_conflict_gen.generate()
cls.jtacs.extend(ground_conflict_gen.jtacs) cls.jtacs.extend(ground_conflict_gen.jtacs)
@ -454,6 +455,7 @@ class Operation:
"zone": jtac.region, "zone": jtac.region,
"dcsUnit": jtac.unit_name, "dcsUnit": jtac.unit_name,
"laserCode": jtac.code, "laserCode": jtac.code,
"radio": jtac.freq.mhz,
} }
flight_count = 0 flight_count = 0
for flight in airgen.flights: for flight in airgen.flights:
@ -570,7 +572,8 @@ class Operation:
zone = data["zone"] zone = data["zone"]
laserCode = data["laserCode"] laserCode = data["laserCode"]
dcsUnit = data["dcsUnit"] dcsUnit = data["dcsUnit"]
lua += f" {{dcsGroupName='{dcsGroupName}', callsign='{callsign}', zone={repr(zone)}, laserCode='{laserCode}', dcsUnit='{dcsUnit}' }}, \n" radio = data["radio"]
lua += f" {{dcsGroupName='{dcsGroupName}', callsign='{callsign}', zone={repr(zone)}, laserCode='{laserCode}', dcsUnit='{dcsUnit}', radio='{radio}' }}, \n"
lua += "}" lua += "}"
# Process the Target Points # Process the Target Points

View File

@ -13,9 +13,11 @@ from dcs.country import Country
from dcs.mapping import Point from dcs.mapping import Point
from dcs.point import PointAction from dcs.point import PointAction
from dcs.task import ( from dcs.task import (
AFAC,
EPLRS, EPLRS,
AttackGroup, AttackGroup,
ControlledTask, ControlledTask,
FAC,
FireAtPoint, FireAtPoint,
GoToWaypoint, GoToWaypoint,
Hold, Hold,
@ -42,6 +44,7 @@ from .callsigns import callsign_for_support_unit
from .conflictgen import Conflict from .conflictgen import Conflict
from .ground_forces.combat_stance import CombatStance from .ground_forces.combat_stance import CombatStance
from .naming import namegen from .naming import namegen
from .radios import MHz, RadioFrequency, RadioRegistry
if TYPE_CHECKING: if TYPE_CHECKING:
from game import Game from game import Game
@ -74,7 +77,7 @@ class JtacInfo:
region: str region: str
code: str code: str
blue: bool blue: bool
# TODO: Radio info? Type? freq: RadioFrequency
class GroundConflictGenerator: class GroundConflictGenerator:
@ -88,6 +91,7 @@ class GroundConflictGenerator:
player_stance: CombatStance, player_stance: CombatStance,
enemy_stance: CombatStance, enemy_stance: CombatStance,
unit_map: UnitMap, unit_map: UnitMap,
radio_registry: RadioRegistry,
) -> None: ) -> None:
self.mission = mission self.mission = mission
self.conflict = conflict self.conflict = conflict
@ -97,6 +101,7 @@ class GroundConflictGenerator:
self.enemy_stance = enemy_stance self.enemy_stance = enemy_stance
self.game = game self.game = game
self.unit_map = unit_map self.unit_map = unit_map
self.radio_registry = radio_registry
self.jtacs: List[JtacInfo] = [] self.jtacs: List[JtacInfo] = []
def generate(self) -> None: def generate(self) -> None:
@ -147,6 +152,7 @@ class GroundConflictGenerator:
if self.game.blue.faction.has_jtac: if self.game.blue.faction.has_jtac:
n = "JTAC" + str(self.conflict.blue_cp.id) + str(self.conflict.red_cp.id) n = "JTAC" + str(self.conflict.blue_cp.id) + str(self.conflict.red_cp.id)
code = 1688 - len(self.jtacs) code = 1688 - len(self.jtacs)
freq = self.radio_registry.alloc_uhf()
utype = self.game.blue.faction.jtac_unit utype = self.game.blue.faction.jtac_unit
if utype is None: if utype is None:
@ -159,6 +165,10 @@ class GroundConflictGenerator:
position=position[0], position=position[0],
airport=None, airport=None,
altitude=5000, altitude=5000,
maintask=AFAC,
)
jtac.points[0].tasks.append(
FAC(callsign=len(self.jtacs) + 1, frequency=int(freq.mhz))
) )
jtac.points[0].tasks.append(SetInvisibleCommand(True)) jtac.points[0].tasks.append(SetInvisibleCommand(True))
jtac.points[0].tasks.append(SetImmortalCommand(True)) jtac.points[0].tasks.append(SetImmortalCommand(True))
@ -178,6 +188,7 @@ class GroundConflictGenerator:
frontline, frontline,
str(code), str(code),
blue=True, blue=True,
freq=freq,
) )
) )

View File

@ -487,8 +487,15 @@ class SupportPage(KneeboardPage):
writer.heading("JTAC") writer.heading("JTAC")
jtacs = [] jtacs = []
for jtac in self.jtacs: for jtac in self.jtacs:
jtacs.append([jtac.callsign, jtac.region, jtac.code]) jtacs.append(
writer.table(jtacs, headers=["Callsign", "Region", "Laser Code"]) [
jtac.callsign,
jtac.region,
jtac.code,
self.format_frequency(jtac.freq),
]
)
writer.table(jtacs, headers=["Callsign", "Region", "Laser Code", "FREQ"])
writer.write(path) writer.write(path)

View File

@ -109,6 +109,6 @@ AWACS:
{%- if jtacs|length > 0 %} {%- if jtacs|length > 0 %}
JTACS [F-10 菜单] : JTACS [F-10 菜单] :
==================== ====================
{% for jtac in jtacs %}前线 {{ jtac.region }} -- 激光编码 : {{ jtac.code }} {% for jtac in jtacs %}前线 {{ jtac.region }} -- 激光编码 : {{ jtac.code }}, 频率 : {{ jtac.freq.mhz }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}

View File

@ -109,6 +109,6 @@ AWACS:
{%- if jtacs|length > 0 %} {%- if jtacs|length > 0 %}
JTACS [F-10 Menu] : JTACS [F-10 Menu] :
==================== ====================
{% for jtac in jtacs %}Frontline {{ jtac.region }} -- Code : {{ jtac.code }} {% for jtac in jtacs %}Frontline {{ jtac.region }} -- Code : {{ jtac.code }}, Freq : {{ jtac.freq.mhz }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}

View File

@ -109,6 +109,6 @@ AWACS:
{%- if jtacs|length > 0 %} {%- if jtacs|length > 0 %}
JTACS [Menu F-10] : JTACS [Menu F-10] :
==================== ====================
{% for jtac in jtacs %}Ligne de front {{ jtac.region }} -- Code : {{ jtac.code }} {% for jtac in jtacs %}Ligne de front {{ jtac.region }} -- Code : {{ jtac.code }}, Fréq : {{ jtac.freq.mhz }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}