Started refactoring on ground objects. WW2 factions will have WW2 style buildings. Added ground objects templates for : "village", "ww2bunker", "allycamp"
16
game/data/building_data.py
Normal file
@ -0,0 +1,16 @@
|
||||
import inspect
|
||||
import dcs
|
||||
|
||||
DEFAULT_AVAILABLE_BUILDINGS = ['fuel', 'ammo', 'comms', 'oil', 'ware', 'farp', 'fob', 'power', 'factory', 'derrick', 'aa']
|
||||
|
||||
WW2_GERMANY_BUILDINGS = ['fuel', 'factory', 'ww2bunker', 'ww2bunker', 'ww2bunker', 'allycamp', 'allycamp', 'aa']
|
||||
WW2_ALLIES_BUILDINGS = ['fuel', 'allycamp', 'allycamp', 'allycamp', 'allycamp', 'allycamp', 'aa']
|
||||
|
||||
FORTIFICATION_BUILDINGS = ['Siegfried Line', 'Concertina Wire', 'Czech hedgehogs 1', 'Czech hedgehogs 2',
|
||||
'Dragonteeth 1', 'Dragonteeth 2', 'Dragonteeth 3', 'Dragonteeth 4', 'Dragonteeth 5',
|
||||
'Haystack 1', 'Haystack 2', 'Haystack 3', 'Haystack 4', 'Hemmkurvenvenhindernis',
|
||||
'Log posts 1', 'Log posts 2', 'Log posts 3', 'Log ramps 1', 'Log ramps 2', 'Log ramps 3',
|
||||
'Belgian Gate', 'Container white']
|
||||
|
||||
FORTIFICATION_UNITS = [c for c in vars(dcs.vehicles.Fortification).values() if inspect.isclass(c)]
|
||||
FORTIFICATION_UNITS_ID = [c.id for c in vars(dcs.vehicles.Fortification).values() if inspect.isclass(c)]
|
||||
@ -1,6 +1,8 @@
|
||||
from dcs.planes import *
|
||||
from dcs.vehicles import *
|
||||
|
||||
from game.data.building_data import WW2_GERMANY_BUILDINGS
|
||||
|
||||
Germany_1944 = {
|
||||
"country": "Third Reich",
|
||||
"side": "red",
|
||||
@ -32,5 +34,9 @@ Germany_1944 = {
|
||||
],
|
||||
"shorad":[
|
||||
AirDefence.AAA_8_8cm_Flak_36,
|
||||
]
|
||||
],
|
||||
"objects": WW2_GERMANY_BUILDINGS,
|
||||
"doctrine": {
|
||||
# TODO
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,8 @@ from dcs.planes import *
|
||||
from dcs.ships import *
|
||||
from dcs.vehicles import *
|
||||
|
||||
from game.data.building_data import WW2_ALLIES_BUILDINGS
|
||||
|
||||
USA_1944 = {
|
||||
"country": "USA",
|
||||
"side": "blue",
|
||||
@ -36,5 +38,5 @@ USA_1944 = {
|
||||
AirDefence.AAA_Bofors_40mm,
|
||||
], "shorad":[
|
||||
AirDefence.AAA_Bofors_40mm,
|
||||
]
|
||||
], "objects": WW2_ALLIES_BUILDINGS
|
||||
}
|
||||
@ -460,11 +460,11 @@ class FlightPlanner:
|
||||
orbit0p = loc.position.point_from_heading(hdg - 90, radius)
|
||||
orbit1p = loc.position.point_from_heading(hdg + 90, radius)
|
||||
else:
|
||||
loc = for_cp.position.point_from_heading(random.randint(0, 360),random.randint(nm_to_meter(10), nm_to_meter(40)))
|
||||
hdg = for_cp.position.heading_between_point(loc.position)
|
||||
loc = for_cp.position.point_from_heading(random.randint(0, 360), random.randint(nm_to_meter(10), nm_to_meter(40)))
|
||||
hdg = for_cp.position.heading_between_point(loc)
|
||||
radius = nm_to_meter(random.randint(15, 40))
|
||||
orbit0p = loc.position.point_from_heading(hdg - 90, radius)
|
||||
orbit1p = loc.position.point_from_heading(hdg + 90, radius)
|
||||
orbit0p = loc.point_from_heading(hdg - 90, radius)
|
||||
orbit1p = loc.point_from_heading(hdg + 90, radius)
|
||||
|
||||
# Create points
|
||||
ascend = self.generate_ascend_point(flight.from_cp)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import logging
|
||||
|
||||
from game import db
|
||||
from game.data.building_data import FORTIFICATION_UNITS_ID, FORTIFICATION_UNITS
|
||||
from game.db import unit_type_from_name
|
||||
from .conflictgen import *
|
||||
from .naming import *
|
||||
@ -50,9 +51,6 @@ class GroundObjectsGenerator:
|
||||
else:
|
||||
cp = self.conflict.from_cp
|
||||
|
||||
consumed_farps = set()
|
||||
|
||||
|
||||
for cp in self.game.theater.controlpoints:
|
||||
|
||||
if cp.captured:
|
||||
@ -113,25 +111,42 @@ class GroundObjectsGenerator:
|
||||
sg.points[0].tasks.append(ActivateICLSCommand(cp.icls, unit_id=sg.units[0].id))
|
||||
|
||||
else:
|
||||
static_type = None
|
||||
if ground_object.dcs_identifier in warehouse_map:
|
||||
static_type = warehouse_map[ground_object.dcs_identifier]
|
||||
else:
|
||||
elif ground_object.dcs_identifier in fortification_map:
|
||||
static_type = fortification_map[ground_object.dcs_identifier]
|
||||
|
||||
if not static_type:
|
||||
elif ground_object.dcs_identifier in FORTIFICATION_UNITS_ID:
|
||||
for f in FORTIFICATION_UNITS:
|
||||
if f.id == ground_object.dcs_identifier:
|
||||
unit_type = f
|
||||
break
|
||||
else:
|
||||
print("Didn't find {} in static _map(s)!".format(ground_object.dcs_identifier))
|
||||
continue
|
||||
|
||||
group = self.m.static_group(
|
||||
country=side,
|
||||
name=ground_object.string_identifier,
|
||||
_type=static_type,
|
||||
position=ground_object.position,
|
||||
heading=ground_object.heading,
|
||||
dead=ground_object.is_dead,
|
||||
)
|
||||
if static_type is None:
|
||||
if not ground_object.is_dead:
|
||||
group = self.m.vehicle_group(
|
||||
country=side,
|
||||
name=ground_object.string_identifier,
|
||||
_type=unit_type,
|
||||
position=ground_object.position,
|
||||
heading=ground_object.heading,
|
||||
)
|
||||
logging.info("generated {}object identifier {} with mission id {}".format(
|
||||
"dead " if ground_object.is_dead else "", group.name, group.id))
|
||||
else:
|
||||
group = self.m.static_group(
|
||||
country=side,
|
||||
name=ground_object.string_identifier,
|
||||
_type=static_type,
|
||||
position=ground_object.position,
|
||||
heading=ground_object.heading,
|
||||
dead=ground_object.is_dead,
|
||||
)
|
||||
|
||||
logging.info("generated {}object identifier {} with mission id {}".format("dead " if ground_object.is_dead else "", group.name, group.id))
|
||||
logging.info("generated {}object identifier {} with mission id {}".format("dead " if ground_object.is_dead else "", group.name, group.id))
|
||||
|
||||
|
||||
def farp_aa(mission_obj, country, name, position: mapping.Point):
|
||||
|
||||
@ -41,6 +41,7 @@ class QLiberationMap(QGraphicsView):
|
||||
self.setMinimumSize(800,600)
|
||||
self.setMaximumHeight(2160)
|
||||
self._zoom = 0
|
||||
self.factor = 1
|
||||
self.init_scene()
|
||||
self.connectSignals()
|
||||
self.setGame(game)
|
||||
@ -222,6 +223,7 @@ class QLiberationMap(QGraphicsView):
|
||||
else:
|
||||
self._zoom = -5
|
||||
|
||||
|
||||
def _transform_point(self, p: Point, treshold=30) -> (int, int):
|
||||
point_a = list(self.game.theater.reference_points.keys())[0]
|
||||
point_a_img = self.game.theater.reference_points[point_a]
|
||||
|
||||
@ -17,7 +17,7 @@ class QMapGroundObject(QGraphicsRectItem):
|
||||
self.setAcceptHoverEvents(True)
|
||||
self.setZValue(2)
|
||||
self.buildings = buildings
|
||||
#self.setFlag(QGraphicsItem.ItemIgnoresTransformations, True)
|
||||
self.setFlag(QGraphicsItem.ItemIgnoresTransformations, False)
|
||||
|
||||
if len(self.model.groups) > 0:
|
||||
units = {}
|
||||
|
||||
@ -13,7 +13,7 @@ def load_templates():
|
||||
|
||||
groups = {} # type: typing.Dict[str, typing.Dict[int, typing.List[Static]]]
|
||||
|
||||
for static_group in temp_mis.country("USA").static_group:
|
||||
for static_group in temp_mis.country("USA").static_group + temp_mis.country("USAF Aggressors").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])
|
||||
|
||||
@ -1,19 +1,15 @@
|
||||
import pickle
|
||||
import typing
|
||||
|
||||
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.mapping import Point
|
||||
from dcs.mission import Mission
|
||||
from dcs.terrain import *
|
||||
from dcs.unit import *
|
||||
from dcs.statics import warehouse_map, fortification_map
|
||||
|
||||
from game import db
|
||||
from gen.groundobjectsgen import TheaterGroundObject
|
||||
from theater.caucasus import CaucasusTheater
|
||||
from theater.persiangulf import PersianGulfTheater
|
||||
from theater.nevada import NevadaTheater
|
||||
from theater.persiangulf import PersianGulfTheater
|
||||
|
||||
m = Mission()
|
||||
m.load_file("resources/tools/cau_groundobjects.miz")
|
||||
|
||||
BIN
resources/ui/ground_assets/allycamp.png
Normal file
|
After Width: | Height: | Size: 206 B |
BIN
resources/ui/ground_assets/allycamp_blue.png
Normal file
|
After Width: | Height: | Size: 206 B |
BIN
resources/ui/ground_assets/derrick.png
Normal file
|
After Width: | Height: | Size: 194 B |
BIN
resources/ui/ground_assets/derrick_blue.png
Normal file
|
After Width: | Height: | Size: 194 B |
BIN
resources/ui/ground_assets/village.png
Normal file
|
After Width: | Height: | Size: 231 B |
BIN
resources/ui/ground_assets/village_blue.png
Normal file
|
After Width: | Height: | Size: 239 B |
|
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 229 B |
|
Before Width: | Height: | Size: 229 B After Width: | Height: | Size: 229 B |
BIN
resources/ui/ground_assets/ww2bunker.png
Normal file
|
After Width: | Height: | Size: 210 B |
BIN
resources/ui/ground_assets/ww2bunker_blue.png
Normal file
|
After Width: | Height: | Size: 210 B |
@ -4,6 +4,7 @@ import random
|
||||
import typing
|
||||
import logging
|
||||
|
||||
from game.data.building_data import DEFAULT_AVAILABLE_BUILDINGS
|
||||
from gen import namegen
|
||||
from gen.defenses.armor_group_generator import generate_armor_group
|
||||
from gen.fleet.ship_group_generator import generate_carrier_group, generate_lha_group
|
||||
@ -74,7 +75,7 @@ def generate_groundobjects(theater: ConflictTheater, game):
|
||||
if cp.cptype == ControlPointType.AIRCRAFT_CARRIER_GROUP:
|
||||
# Create ground object group
|
||||
group_id = group_id + 1
|
||||
g = TheaterGroundObject()
|
||||
g = TheaterGroundObject("CARRIER")
|
||||
g.group_id = group_id
|
||||
g.object_id = 0
|
||||
g.cp_id = cp.id
|
||||
@ -94,7 +95,7 @@ def generate_groundobjects(theater: ConflictTheater, game):
|
||||
elif cp.cptype == ControlPointType.LHA_GROUP:
|
||||
# Create ground object group
|
||||
group_id = group_id + 1
|
||||
g = TheaterGroundObject()
|
||||
g = TheaterGroundObject("LHA")
|
||||
g.group_id = group_id
|
||||
g.object_id = 0
|
||||
g.cp_id = cp.id
|
||||
@ -125,7 +126,7 @@ def generate_groundobjects(theater: ConflictTheater, game):
|
||||
|
||||
group_id = group_id + 1
|
||||
|
||||
g = TheaterGroundObject()
|
||||
g = TheaterGroundObject("aa")
|
||||
g.group_id = group_id
|
||||
g.object_id = 0
|
||||
g.cp_id = cp.id
|
||||
@ -235,10 +236,22 @@ def generate_cp_ground_points(cp: ControlPoint, theater, game, group_id, templat
|
||||
if cp.is_global:
|
||||
return False
|
||||
|
||||
if cp.captured:
|
||||
faction = game.player_name
|
||||
else:
|
||||
faction = game.enemy_name
|
||||
faction_data = db.FACTIONS[faction]
|
||||
|
||||
available_categories = DEFAULT_AVAILABLE_BUILDINGS
|
||||
if "objects" in faction_data.keys():
|
||||
available_categories = faction_data["objects"]
|
||||
|
||||
if len(available_categories) == 0:
|
||||
return False
|
||||
|
||||
amount = random.randrange(3, 8)
|
||||
for i in range(0, amount):
|
||||
|
||||
available_categories = list(templates)
|
||||
obj_name = namegen.random_objective_name()
|
||||
|
||||
if i >= amount - 1:
|
||||
@ -264,7 +277,7 @@ def generate_cp_ground_points(cp: ControlPoint, theater, game, group_id, templat
|
||||
for object in tpl:
|
||||
object_id += 1
|
||||
|
||||
g = TheaterGroundObject()
|
||||
g = TheaterGroundObject(tpl_category)
|
||||
g.group_id = group_id
|
||||
g.object_id = object_id
|
||||
g.cp_id = cp.id
|
||||
@ -276,10 +289,6 @@ def generate_cp_ground_points(cp: ControlPoint, theater, game, group_id, templat
|
||||
g.position = Point(point.x + object["offset"].x, point.y + object["offset"].y)
|
||||
|
||||
if g.dcs_identifier == "AA":
|
||||
if cp.captured:
|
||||
faction = game.player_name
|
||||
else:
|
||||
faction = game.enemy_name
|
||||
g.groups = []
|
||||
group = generate_anti_air_group(game, cp, g, faction)
|
||||
if group is not None:
|
||||
|
||||
@ -1,19 +1,20 @@
|
||||
import typing
|
||||
|
||||
from dcs.mapping import Point
|
||||
from dcs.statics import *
|
||||
|
||||
NAME_BY_CATEGORY = {
|
||||
"power": "Power plant",
|
||||
"ammo": "Ammo depot",
|
||||
"fuel": "Fuel depot",
|
||||
"aa": "AA Defense Site",
|
||||
"warehouse": "Warehouse",
|
||||
"ware": "Warehouse",
|
||||
"farp": "FARP",
|
||||
"fob": "FOB",
|
||||
"factory": "Factory",
|
||||
"comms": "Comms. tower",
|
||||
"oil": "Oil platform"
|
||||
"oil": "Oil platform",
|
||||
"derrick": "Derrick",
|
||||
"ww2bunker": "Bunker",
|
||||
"village": "Village",
|
||||
"allycamp": "Camp"
|
||||
}
|
||||
|
||||
ABBREV_NAME = {
|
||||
@ -21,22 +22,28 @@ ABBREV_NAME = {
|
||||
"ammo": "AMMO",
|
||||
"fuel": "FUEL",
|
||||
"aa": "AA",
|
||||
"warehouse": "WARE",
|
||||
"ware": "WARE",
|
||||
"farp": "FARP",
|
||||
"fob": "FOB",
|
||||
"factory": "FACTORY",
|
||||
"comms": "COMMST",
|
||||
"oil": "OILP"
|
||||
"oil": "OILP",
|
||||
"derrick": "DERK",
|
||||
"ww2bunker": "BUNK",
|
||||
"village": "VLG",
|
||||
"allycamp": "CMP",
|
||||
}
|
||||
|
||||
CATEGORY_MAP = {
|
||||
|
||||
# Special cases
|
||||
"CARRIER": ["CARRIER"],
|
||||
"LHA": ["LHA"],
|
||||
"aa": ["AA"],
|
||||
|
||||
# Buildings
|
||||
"power": ["Workshop A", "Electric power box", "Garage small A", "Farm B", "Repair workshop", "Garage B"],
|
||||
"warehouse": ["Warehouse", "Hangar A"],
|
||||
"ware": ["Warehouse", "Hangar A"],
|
||||
"fuel": ["Tank", "Tank 2", "Tank 3", "Fuel tank"],
|
||||
"ammo": [".Ammunition depot", "Hangar B"],
|
||||
"farp": ["FARP Tent", "FARP Ammo Dump Coating", "FARP Fuel Depot", "FARP Command Post", "FARP CP Blindage"],
|
||||
@ -45,6 +52,9 @@ CATEGORY_MAP = {
|
||||
"comms": ["TV tower", "Comms tower M"],
|
||||
"oil": ["Oil platform"],
|
||||
"derrick": ["Oil derrick", "Pump station", "Subsidiary structure 2"],
|
||||
"ww2bunker": ["Siegfried Line", "Fire Control Bunker", "SK_C_28_naval_gun", "Concertina Wire", "Czech hedgehogs 1"],
|
||||
"village": ["Small house 1B", "Small House 1A", "Small warehouse 1"],
|
||||
"allycamp": [],
|
||||
}
|
||||
|
||||
|
||||
@ -60,12 +70,8 @@ class TheaterGroundObject:
|
||||
groups = []
|
||||
obj_name = ""
|
||||
|
||||
@property
|
||||
def category(self) -> str:
|
||||
for k, v in CATEGORY_MAP.items():
|
||||
if self.dcs_identifier in v:
|
||||
return k
|
||||
assert False, "Identifier not found in mapping: {}".format(self.dcs_identifier)
|
||||
def __init__(self, category: str):
|
||||
self.category = category
|
||||
|
||||
@property
|
||||
def string_identifier(self):
|
||||
|
||||