mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
* A Bluefor EWR 55GS in the campaign miz defines an optional EWR site. There is no distinction between how close or far it is to a base, so it's possible that there will be many EWRs within an airbase. * A Redfor EWR 1L13 in the campaign miz defines a required EWR site. It would be a good future idea to limit the amount of EWRs within a certain distance from an airbase. That way there's no chance of 5 EWRs all at the same airbase. Even better if there were something preventing any two EWRs from being right next to each other. No campaigns take advantage of this yet. Fixes https://github.com/Khopa/dcs_liberation/issues/524
64 lines
1.9 KiB
Python
64 lines
1.9 KiB
Python
import random
|
|
from typing import List, Optional, Type
|
|
|
|
from dcs.unitgroup import VehicleGroup
|
|
|
|
from game import Game
|
|
from game.factions.faction import Faction
|
|
from game.theater.theatergroundobject import EwrGroundObject
|
|
from gen.sam.ewrs import (
|
|
BigBirdGenerator,
|
|
BoxSpringGenerator,
|
|
DogEarGenerator,
|
|
FlatFaceGenerator,
|
|
HawkEwrGenerator,
|
|
PatriotEwrGenerator,
|
|
RolandEwrGenerator,
|
|
SnowDriftGenerator,
|
|
StraightFlushGenerator,
|
|
TallRackGenerator,
|
|
)
|
|
from gen.sam.group_generator import GroupGenerator
|
|
|
|
EWR_MAP = {
|
|
"BoxSpringGenerator": BoxSpringGenerator,
|
|
"TallRackGenerator": TallRackGenerator,
|
|
"DogEarGenerator": DogEarGenerator,
|
|
"RolandEwrGenerator": RolandEwrGenerator,
|
|
"FlatFaceGenerator": FlatFaceGenerator,
|
|
"PatriotEwrGenerator": PatriotEwrGenerator,
|
|
"BigBirdGenerator": BigBirdGenerator,
|
|
"SnowDriftGenerator": SnowDriftGenerator,
|
|
"StraightFlushGenerator": StraightFlushGenerator,
|
|
"HawkEwrGenerator": HawkEwrGenerator,
|
|
}
|
|
|
|
|
|
def get_faction_possible_ewrs_generator(
|
|
faction: Faction,
|
|
) -> List[Type[GroupGenerator]]:
|
|
"""
|
|
Return the list of possible EWR generators for the given faction
|
|
:param faction: Faction name to search units for
|
|
"""
|
|
return [EWR_MAP[s] for s in faction.ewrs]
|
|
|
|
|
|
def generate_ewr_group(
|
|
game: Game, ground_object: EwrGroundObject, faction: Faction
|
|
) -> Optional[VehicleGroup]:
|
|
"""Generates an early warning radar group.
|
|
|
|
:param game: The Game.
|
|
:param ground_object: The ground object which will own the EWR group.
|
|
:param faction: Owner faction.
|
|
:return: The generated group, or None if one could not be generated.
|
|
"""
|
|
generators = get_faction_possible_ewrs_generator(faction)
|
|
if len(generators) > 0:
|
|
generator_class = random.choice(generators)
|
|
generator = generator_class(game, ground_object)
|
|
generator.generate()
|
|
return generator.get_generated_group()
|
|
return None
|