Also connect carrier and LHA control points to adjacent friendly points in Pretense. Enlarged the carrier trigger zones.

This commit is contained in:
MetalStormGhost 2023-09-16 15:06:14 +03:00
parent 60fde46249
commit a869c2a758
3 changed files with 47 additions and 5 deletions

View File

@ -93,9 +93,9 @@ class PretenseLuaGenerator(LuaGenerator):
max_resource = 30000
if isinstance(cp, Airfield) or cp.has_ground_spawns:
lua_string_zones += f"zones.{cp_name_trimmed}.isPlaneSpawn = true\n"
if cp.has_ground_spawns:
if cp.has_ground_spawns or cp.is_lha:
max_resource = 40000
if isinstance(cp, Airfield):
if isinstance(cp, Airfield) or cp.is_carrier:
max_resource = 50000
lua_string_zones += (
f"zones.{cp_name_trimmed}.maxResource = {max_resource}\n"
@ -114,7 +114,7 @@ class PretenseLuaGenerator(LuaGenerator):
lua_string_zones += " }),\n"
lua_string_zones += " presets.upgrades.basic.comPost:extend({\n"
lua_string_zones += f" name = '{cp_name_trimmed}-com-red',\n"
lua_string_zones += " products = {"
lua_string_zones += " products = {\n"
lua_string_zones += (
" presets.special.red.infantry:extend({ name='"
+ cp_name_trimmed
@ -307,11 +307,20 @@ class PretenseLuaGenerator(LuaGenerator):
lua_string_connman = " cm = ConnectionManager:new()"
# Generate ConnectionManager connections
for cp in self.game.theater.controlpoints:
for other_cp in cp.connected_points:
lua_string_connman += (
f" cm: addConnection('{cp.name}', '{other_cp.name}')"
f" cm: addConnection('{cp.name}', '{other_cp.name}')\n"
)
# Also connect carrier and LHA control points to adjacent friendly points
if cp.is_fleet and len(cp.connected_points) == 0:
for other_cp in self.game.theater.closest_friendly_control_points_to(
cp
):
lua_string_connman += (
f" cm: addConnection('{cp.name}', '{other_cp.name}')\n"
)
init_body_1_file = open("./resources/plugins/pretense/init_body_1.lua", "r")
init_body_1 = init_body_1_file.read()

View File

@ -53,6 +53,7 @@ TRIGGER_RADIUS_CLEAR_SCENERY = 1000
TRIGGER_RADIUS_PRETENSE_TGO = 500
TRIGGER_RADIUS_PRETENSE_SUPPLY = 500
TRIGGER_RADIUS_PRETENSE_HELI = 1000
TRIGGER_RADIUS_PRETENSE_CARRIER = 50000
class Silence(Option):
@ -157,12 +158,16 @@ class PretenseTriggerGenerator:
Directly appends to the global `base_capture_events` var declared by `dcs_libaration.lua`
"""
for cp in self.game.theater.controlpoints:
if cp.is_fleet:
trigger_radius = TRIGGER_RADIUS_PRETENSE_CARRIER
else:
trigger_radius = TRIGGER_RADIUS_CAPTURE
if not isinstance(cp, OffMapSpawn):
zone_color = {1: 0.0, 2: 0.0, 3: 0.0, 4: 0.15}
trigger_zone = self.mission.triggers.add_triggerzone(
cp.position,
radius=TRIGGER_RADIUS_CAPTURE,
radius=trigger_radius,
hidden=False,
name=cp.name,
color=zone_color,

View File

@ -202,6 +202,34 @@ class ConflictTheater:
assert closest_red is not None
return closest_blue, closest_red
def closest_friendly_control_points_to(
self, cp: ControlPoint
) -> Tuple[ControlPoint, ControlPoint]:
"""
Returns a tuple of the two nearest friendly ControlPoints in theater to ControlPoint cp.
(closest_cp, second_closest_cp)
"""
seen = set()
min_distance = math.inf
closest_cp = None
second_closest_cp = None
if cp.captured:
control_points = self.player_points()
else:
control_points = self.enemy_points()
for other_cp in control_points:
if cp == other_cp:
continue
dist = other_cp.position.distance_to_point(cp.position)
if dist < min_distance:
second_closest_cp = closest_cp
closest_cp = other_cp
min_distance = dist
assert closest_cp is not None
assert second_closest_cp is not None
return closest_cp, second_closest_cp
def find_control_point_by_id(self, cp_id: UUID) -> ControlPoint:
for i in self.controlpoints:
if i.id == cp_id: