mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
randomized strike objects with templates; forbid ground objects and vehicles placement on mountains and in forests; updated push trigger so it include player group; adjacent CP missions could be initiated from carriers
This commit is contained in:
Binary file not shown.
Binary file not shown.
49
resources/tools/generate_groundobject_templates.py
Normal file
49
resources/tools/generate_groundobject_templates.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import pickle
|
||||
import typing
|
||||
|
||||
from dcs.mission import Mission
|
||||
from dcs.mapping import Point
|
||||
from dcs.unit import *
|
||||
from dcs.statics import warehouse_map, fortification_map
|
||||
|
||||
|
||||
def load_templates():
|
||||
temp_mis = Mission()
|
||||
temp_mis.load_file("resources/tools/groundobject_templates.miz")
|
||||
|
||||
groups = {} # type: typing.Dict[str, typing.Dict[int, typing.Collection[Static]]]
|
||||
|
||||
for static_group in temp_mis.country("USA").static_group:
|
||||
for static in static_group.units:
|
||||
static_name = str(static.name).split()[0]
|
||||
tpl_name, tpl_idx = static_name[:-1], int(static_name[-1])
|
||||
|
||||
groups[tpl_name] = groups.get(tpl_name, {})
|
||||
groups[tpl_name][tpl_idx] = groups[tpl_name].get(tpl_idx, [])
|
||||
groups[tpl_name][tpl_idx].append(static)
|
||||
|
||||
tpls = {name: {idx: [] for idx in groups[name].keys()} for name in groups.keys()}
|
||||
for category_name, category_groups in groups.items():
|
||||
for idx, static_groups in category_groups.items():
|
||||
dist = -1
|
||||
a, b = None, None
|
||||
for aa in static_groups:
|
||||
for bb in static_groups:
|
||||
if aa.position.distance_to_point(bb.position) > dist:
|
||||
dist = aa.position.distance_to_point(bb.position)
|
||||
a = aa
|
||||
b = bb
|
||||
|
||||
center = a.position.point_from_heading(a.position.heading_between_point(b.position), dist / 2)
|
||||
for static in static_groups:
|
||||
tpls[category_name][idx].append({
|
||||
"type": static.type,
|
||||
"offset": Point(center.x - static.position.x, center.y - static.position.y),
|
||||
"heading": static.heading,
|
||||
})
|
||||
|
||||
return tpls
|
||||
|
||||
|
||||
with open("resources/groundobject_templates.p", "wb") as f:
|
||||
pickle.dump(load_templates(), f)
|
||||
@@ -5,6 +5,7 @@ from dcs.mission import Mission
|
||||
from dcs.mapping import Point
|
||||
from dcs.terrain import *
|
||||
from dcs.unitgroup import VehicleGroup, StaticGroup
|
||||
from dcs import vehicles
|
||||
from dcs.unit import *
|
||||
from dcs.statics import warehouse_map, fortification_map
|
||||
|
||||
@@ -51,7 +52,7 @@ if __name__ == "__main__":
|
||||
theater_object.position = unit.position
|
||||
theater_object.heading = unit.heading
|
||||
|
||||
if isinstance(unit, Vehicle):
|
||||
if isinstance(unit, Vehicle) and unit.type in vehicles.AirDefence.__dict__.values():
|
||||
theater_object.dcs_identifier = "AA"
|
||||
else:
|
||||
theater_object.dcs_identifier = unit.type
|
||||
|
||||
@@ -1,14 +1,26 @@
|
||||
import pickle
|
||||
|
||||
from dcs.mission import Mission
|
||||
from dcs.planes import A_10C
|
||||
|
||||
for terrain in ["cau", "gulf"]:
|
||||
m = Mission()
|
||||
m.load_file("./{}_terrain.miz".format(terrain))
|
||||
|
||||
landmap = []
|
||||
inclusion_zones = []
|
||||
exclusion_zones = []
|
||||
for plane_group in m.country("USA").plane_group:
|
||||
landmap.append([(x.position.x, x.position.y) for x in plane_group.points])
|
||||
zone = [(x.position.x, x.position.y) for x in plane_group.points]
|
||||
|
||||
if terrain == "cau" and inclusion_zones:
|
||||
# legacy
|
||||
exclusion_zones.append(zone)
|
||||
else:
|
||||
if plane_group.units[0].type == "F-15C":
|
||||
exclusion_zones.append(zone)
|
||||
else:
|
||||
inclusion_zones.append(zone)
|
||||
|
||||
with open("../{}landmap.p".format(terrain), "wb") as f:
|
||||
pickle.dump(landmap, f)
|
||||
print(len(inclusion_zones), len(exclusion_zones))
|
||||
pickle.dump((inclusion_zones, exclusion_zones), f)
|
||||
|
||||
BIN
resources/tools/groundobject_templates.miz
Normal file
BIN
resources/tools/groundobject_templates.miz
Normal file
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user