Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions spawn_zone_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from panda3d.core import Vec3
from p3d_libmap.map_parser import MapParser

ZONE_FORMAT_VERSION = "1.1.0"


# ---------------------------------------------------------------------------
# Data Structures
Expand All @@ -32,6 +34,7 @@ class Zone:
target: str
fog: str = ""
adjacent_zones: List[int] = field(default_factory=list)
door_waypoint_targets: List[str] = field(default_factory=list)
brushes: List[ZoneBrush] = field(default_factory=list)


Expand Down Expand Up @@ -175,7 +178,7 @@ def get_aabb_for_brush(brush, epsilon=0.05):
def write_zones_to_file(zones: List[Zone], output_path: Path):
"""Write all zones to an .nsz file."""
with output_path.open("w") as f:
f.write("zone_file_version: 1.0.0\n")
f.write(f"zone_file_version: {ZONE_FORMAT_VERSION}\n")
f.write(f"number_of_zones: {len(zones)}\n")

for zone in zones:
Expand All @@ -193,6 +196,10 @@ def write_zones_to_file(zones: List[Zone], output_path: Path):
f.write(f"{b.mins[0]} {b.mins[1]} {b.mins[2]}\n")
f.write(f"{b.maxs[0]} {b.maxs[1]} {b.maxs[2]}\n")

f.write(f"{len(zone.door_waypoint_targets)}\n")
for d in zone.door_waypoint_targets:
f.write(f"{d}\n")


# ---------------------------------------------------------------------------
# Main Processing Logic
Expand Down Expand Up @@ -221,9 +228,9 @@ def get_id_for_zone(name: str) -> int:
zone_fog = ent.properties.get("zone_fog", "")

print(f"+ Found a spawn_zone entity:")
print(f" - Name: {zone_name}")
print(f" - Target: {zone_target}")
print(f" - Fog: {zone_fog}")
print(f" - Name: {zone_name}")
print(f" - Target: {zone_target}")
print(f" - Fog: [{zone_fog}]")

# Resolve adjacent zones
adjacents = ent.properties.get("adjacent_zones", "")
Expand All @@ -233,7 +240,15 @@ def get_id_for_zone(name: str) -> int:
if z.strip()
]

print(f" - Adjacent: {adjacent_zones}")
print(f" - Adjacent: {adjacent_zones}")

# Resolve door waypoint targets
door_waypoints = ent.properties.get("door_way_targets", "")
door_waypoint_targets = [
z.strip() for z in door_waypoints.split(",") if z.strip()
]

print(f" - Door Targets: {door_waypoint_targets}")

# Zone brushes
brushes = []
Expand All @@ -255,6 +270,7 @@ def get_id_for_zone(name: str) -> int:
target=zone_target,
fog=zone_fog,
adjacent_zones=adjacent_zones,
door_waypoint_targets=door_waypoint_targets,
brushes=brushes,
)
)
Expand Down
11 changes: 10 additions & 1 deletion tests/nszs/nzp_warehouse2.nsz
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
zone_file_version: 1.0.0
zone_file_version: 1.1.0
number_of_zones: 9
spawn_zone
2
Expand All @@ -9,6 +9,7 @@ z1
1
-1104.0 -852.0 304.0
-4.0 -348.0 440.0
0
spawn_zone_up
1
z9
Expand All @@ -18,6 +19,7 @@ z9
1
-1108.0 -852.0 440.0
-4.0 -348.0 576.0
0
trench_zone
4
z5
Expand All @@ -27,6 +29,7 @@ z5
1
-2220.0 -852.0 304.0
-1120.0 -348.0 440.0
0
trench_zone_up
3
z11
Expand All @@ -36,6 +39,7 @@ z11
1
-2220.0 -852.0 440.0
-1116.0 -348.0 576.0
0
outdoor_zone
6
z6
Expand All @@ -46,6 +50,7 @@ z6
1
-2224.0 -332.0 304.0
-1124.0 172.0 440.0
0
mule_zone
5
z7
Expand All @@ -56,6 +61,7 @@ z7
1
-1104.0 -324.0 304.0
-4.0 180.0 576.0
0
big_zone_left
9
z8
Expand All @@ -67,6 +73,7 @@ z8
1
12.0 -888.0 208.0
1436.0 -192.0 568.0
0
big_zone_right
7
z12
Expand All @@ -78,6 +85,7 @@ z12
1
12.0 -192.0 208.0
1436.0 504.0 568.0
0
box_zone
8
z10
Expand All @@ -88,3 +96,4 @@ z10
1
1452.0 -336.0 208.0
1996.0 828.0 476.0
0
11 changes: 10 additions & 1 deletion tests/nszs/nzp_zone_test.nsz
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
zone_file_version: 1.0.0
zone_file_version: 1.1.0
number_of_zones: 9
number_1
4
Expand All @@ -15,6 +15,7 @@ activate_zombs_1
-12.0 64.0 144.0
-12.0 -96.0 -0.0
44.0 64.0 144.0
0
number_2
3
activate_zombs_2
Expand All @@ -32,6 +33,7 @@ activate_zombs_2
148.0 64.0 144.0
148.0 -96.0 -0.0
204.0 64.0 144.0
0
number_3
6
activate_zombs_3
Expand All @@ -47,6 +49,7 @@ activate_zombs_3
308.0 64.0 144.0
308.0 -96.0 -0.0
364.0 64.0 144.0
0
number_4
1
activate_zombs_4
Expand All @@ -64,6 +67,7 @@ activate_zombs_4
-12.0 -96.0 144.0
-12.0 -256.0 -0.0
44.0 -96.0 144.0
0
number_5
2
activate_zombs_5
Expand All @@ -84,6 +88,7 @@ activate_zombs_5
148.0 -96.0 144.0
148.0 -256.0 -0.0
204.0 -96.0 144.0
0
number_6
5
activate_zombs_6
Expand All @@ -101,6 +106,7 @@ activate_zombs_6
308.0 -96.0 144.0
308.0 -256.0 -0.0
364.0 -96.0 144.0
0
number_7
7
activate_zombs_7
Expand All @@ -116,6 +122,7 @@ activate_zombs_7
-12.0 -256.0 144.0
-12.0 -416.0 -0.0
44.0 -256.0 144.0
0
number_8
8
activate_zombs_8
Expand All @@ -133,6 +140,7 @@ activate_zombs_8
148.0 -256.0 144.0
148.0 -416.0 -0.0
204.0 -256.0 144.0
0
number_9
9
activate_zombs_9
Expand All @@ -148,3 +156,4 @@ activate_zombs_9
308.0 -256.0 144.0
308.0 -416.0 -0.0
364.0 -256.0 144.0
0