mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Now connects more isolated zones in Pretense.
This commit is contained in:
parent
ddc5709a17
commit
a975e2c2dc
@ -305,7 +305,7 @@ class PretenseLuaGenerator(LuaGenerator):
|
|||||||
lua_string_zones += " }\n"
|
lua_string_zones += " }\n"
|
||||||
lua_string_zones += "})\n"
|
lua_string_zones += "})\n"
|
||||||
|
|
||||||
lua_string_connman = " cm = ConnectionManager:new()"
|
lua_string_connman = " cm = ConnectionManager:new()\n"
|
||||||
|
|
||||||
# Generate ConnectionManager connections
|
# Generate ConnectionManager connections
|
||||||
for cp in self.game.theater.controlpoints:
|
for cp in self.game.theater.controlpoints:
|
||||||
@ -313,14 +313,32 @@ class PretenseLuaGenerator(LuaGenerator):
|
|||||||
lua_string_connman += (
|
lua_string_connman += (
|
||||||
f" cm: addConnection('{cp.name}', '{other_cp.name}')\n"
|
f" cm: addConnection('{cp.name}', '{other_cp.name}')\n"
|
||||||
)
|
)
|
||||||
# Also connect carrier and LHA control points to adjacent friendly points
|
for sea_connection in cp.shipping_lanes:
|
||||||
if cp.is_fleet and len(cp.connected_points) == 0:
|
if sea_connection.is_friendly_to(cp):
|
||||||
for other_cp in self.game.theater.closest_friendly_control_points_to(
|
|
||||||
cp
|
|
||||||
):
|
|
||||||
lua_string_connman += (
|
lua_string_connman += (
|
||||||
f" cm: addConnection('{cp.name}', '{other_cp.name}')\n"
|
f" cm: addConnection('{cp.name}', '{sea_connection.name}')\n"
|
||||||
)
|
)
|
||||||
|
if len(cp.connected_points) == 0 and len(cp.shipping_lanes) == 0:
|
||||||
|
# Also connect carrier and LHA control points to adjacent friendly points
|
||||||
|
if cp.is_fleet:
|
||||||
|
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"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# Finally, connect remaining non-connected points
|
||||||
|
(
|
||||||
|
closest_cp,
|
||||||
|
second_closest_cp,
|
||||||
|
) = self.game.theater.closest_friendly_control_points_to(cp)
|
||||||
|
lua_string_connman += (
|
||||||
|
f" cm: addConnection('{cp.name}', '{closest_cp.name}')\n"
|
||||||
|
)
|
||||||
|
lua_string_connman += (
|
||||||
|
f" cm: addConnection('{cp.name}', '{second_closest_cp.name}')\n"
|
||||||
|
)
|
||||||
|
|
||||||
init_body_1_file = open("./resources/plugins/pretense/init_body_1.lua", "r")
|
init_body_1_file = open("./resources/plugins/pretense/init_body_1.lua", "r")
|
||||||
init_body_1 = init_body_1_file.read()
|
init_body_1 = init_body_1_file.read()
|
||||||
|
|||||||
@ -202,10 +202,9 @@ class ConflictTheater:
|
|||||||
Returns a tuple of the two nearest friendly ControlPoints in theater to ControlPoint cp.
|
Returns a tuple of the two nearest friendly ControlPoints in theater to ControlPoint cp.
|
||||||
(closest_cp, second_closest_cp)
|
(closest_cp, second_closest_cp)
|
||||||
"""
|
"""
|
||||||
seen = set()
|
|
||||||
min_distance = math.inf
|
|
||||||
closest_cp = None
|
closest_cp = None
|
||||||
second_closest_cp = None
|
second_closest_cp = None
|
||||||
|
distances_to_cp = dict()
|
||||||
if cp.captured:
|
if cp.captured:
|
||||||
control_points = self.player_points()
|
control_points = self.player_points()
|
||||||
else:
|
else:
|
||||||
@ -213,11 +212,21 @@ class ConflictTheater:
|
|||||||
for other_cp in control_points:
|
for other_cp in control_points:
|
||||||
if cp == other_cp:
|
if cp == other_cp:
|
||||||
continue
|
continue
|
||||||
|
print(f"{cp}: {other_cp} being evaluated...")
|
||||||
|
|
||||||
dist = other_cp.position.distance_to_point(cp.position)
|
dist = other_cp.position.distance_to_point(cp.position)
|
||||||
if dist < min_distance:
|
print(f" {other_cp} is at {dist} meters")
|
||||||
second_closest_cp = closest_cp
|
distances_to_cp[dist] = other_cp
|
||||||
|
for i in sorted(distances_to_cp.keys()):
|
||||||
|
other_cp = distances_to_cp[i]
|
||||||
|
print(f" {other_cp} is at {i} meters")
|
||||||
|
if closest_cp is None:
|
||||||
closest_cp = other_cp
|
closest_cp = other_cp
|
||||||
min_distance = dist
|
continue
|
||||||
|
elif second_closest_cp is None:
|
||||||
|
second_closest_cp = other_cp
|
||||||
|
break
|
||||||
|
break
|
||||||
|
|
||||||
assert closest_cp is not None
|
assert closest_cp is not None
|
||||||
assert second_closest_cp is not None
|
assert second_closest_cp is not None
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user