mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
- Break down the remaining Anti Air Layouts. Now each layout.miz only contains 1 layout - Added a python script which can fix the orientation of a layout - Fix layout orientation. Now all aa layouts are oriented to the north. - Add small change so that whole carrier group will be rotated correctly with the BRC closes #2215
64 lines
1.9 KiB
Python
64 lines
1.9 KiB
Python
# Script to update a layout.miz which is not created with an orientation of Heading=0
|
|
# It loads the miz as and reorientates all objects
|
|
|
|
|
|
# Requirement: Only ONE Group has to be within the miz file.
|
|
# Load miz
|
|
# Determine Center and current heading (use first unit for that)
|
|
# Rotate everything around the center with the difference to heading 0
|
|
# Save the miz
|
|
|
|
import argparse
|
|
import itertools
|
|
from typing import Any
|
|
|
|
import dcs
|
|
|
|
from game.point_with_heading import PointWithHeading
|
|
from game.utils import Heading
|
|
|
|
|
|
def fix_orientation(miz_file: str) -> None:
|
|
mission = dcs.Mission()
|
|
mission.load_file(miz_file)
|
|
groups = []
|
|
# Load all units from the miz
|
|
for country in itertools.chain(
|
|
mission.coalition["red"].countries.values(),
|
|
mission.coalition["blue"].countries.values(),
|
|
):
|
|
for dcs_group in itertools.chain(
|
|
mission.country(country.name).vehicle_group,
|
|
mission.country(country.name).ship_group,
|
|
mission.country(country.name).static_group,
|
|
):
|
|
groups.append(dcs_group)
|
|
|
|
# Get the center which will be used as origin for the rotation
|
|
center_unit = groups[0].units[0]
|
|
|
|
# Calculate the rotation
|
|
rotation = Heading.from_degrees(360 - int(center_unit.heading))
|
|
|
|
# Rotate all units
|
|
for group in groups:
|
|
for unit in group.units:
|
|
unit.position = PointWithHeading.from_point(
|
|
unit.position, Heading.from_degrees(int(unit.heading)) + rotation
|
|
)
|
|
unit.heading = unit.position.heading.degrees
|
|
unit.position.rotate(center_unit.position, rotation)
|
|
group.points[0].position = group.units[0].position
|
|
# Save the miz
|
|
mission.save()
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("mission", type=str, help="The mission which will be fixed")
|
|
args = parser.parse_args()
|
|
fix_orientation(args.mission)
|
|
|
|
|
|
main()
|