mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Add EWR generation.
Fixes https://github.com/Khopa/dcs_liberation/issues/66
This commit is contained in:
98
gen/sam/ewrs.py
Normal file
98
gen/sam/ewrs.py
Normal file
@@ -0,0 +1,98 @@
|
||||
from dcs.vehicles import AirDefence
|
||||
from dcs.unittype import VehicleType
|
||||
|
||||
from gen.sam.group_generator import GroupGenerator
|
||||
|
||||
|
||||
class EwrGenerator(GroupGenerator):
|
||||
@property
|
||||
def unit_type(self) -> VehicleType:
|
||||
raise NotImplementedError
|
||||
|
||||
def generate(self) -> None:
|
||||
self.add_unit(self.unit_type, "EWR", self.position.x, self.position.y,
|
||||
self.heading)
|
||||
|
||||
|
||||
class BoxSpringGenerator(EwrGenerator):
|
||||
"""1L13 "Box Spring" EWR."""
|
||||
|
||||
unit_type = AirDefence.EWR_1L13
|
||||
|
||||
|
||||
class TallRackGenerator(EwrGenerator):
|
||||
"""55G6 "Tall Rack" EWR."""
|
||||
|
||||
unit_type = AirDefence.EWR_55G6
|
||||
|
||||
|
||||
class DogEarGenerator(EwrGenerator):
|
||||
"""9S80M1 "Dog Ear" EWR.
|
||||
|
||||
This is the SA-8 search radar, but used as an early warning radar.
|
||||
"""
|
||||
|
||||
unit_type = AirDefence.CP_9S80M1_Sborka
|
||||
|
||||
|
||||
class RolandEwrGenerator(EwrGenerator):
|
||||
"""Roland EWR.
|
||||
|
||||
This is the Roland search radar, but used as an early warning radar.
|
||||
"""
|
||||
|
||||
unit_type = AirDefence.SAM_Roland_EWR
|
||||
|
||||
|
||||
class FlatFaceGenerator(EwrGenerator):
|
||||
"""P-19 "Flat Face" EWR.
|
||||
|
||||
This is the SA-3 search radar, but used as an early warning radar.
|
||||
"""
|
||||
|
||||
unit_type = AirDefence.SAM_SR_P_19
|
||||
|
||||
|
||||
class PatriotEwrGenerator(EwrGenerator):
|
||||
"""Patriot EWR.
|
||||
|
||||
This is the Patriot search/track radar, but used as an early warning radar.
|
||||
"""
|
||||
|
||||
unit_type = AirDefence.SAM_Patriot_STR_AN_MPQ_53
|
||||
|
||||
|
||||
class BigBirdGenerator(EwrGenerator):
|
||||
"""64H6E "Big Bird" EWR.
|
||||
|
||||
This is the SA-10 track radar, but used as an early warning radar.
|
||||
"""
|
||||
|
||||
unit_type = AirDefence.SAM_SA_10_S_300PS_SR_64H6E
|
||||
|
||||
|
||||
class SnowDriftGenerator(EwrGenerator):
|
||||
"""9S18M1 "Snow Drift" EWR.
|
||||
|
||||
This is the SA-11 search radar, but used as an early warning radar.
|
||||
"""
|
||||
|
||||
unit_type = AirDefence.SAM_SA_11_Buk_SR_9S18M1
|
||||
|
||||
|
||||
class StraightFlushGenerator(EwrGenerator):
|
||||
"""1S91 "Straight Flush" EWR.
|
||||
|
||||
This is the SA-6 search/track radar, but used as an early warning radar.
|
||||
"""
|
||||
|
||||
unit_type = AirDefence.SAM_SA_6_Kub_STR_9S91
|
||||
|
||||
|
||||
class HawkEwrGenerator(EwrGenerator):
|
||||
"""Hawk EWR.
|
||||
|
||||
This is the Hawk search radar, but used as an early warning radar.
|
||||
"""
|
||||
|
||||
unit_type = AirDefence.SAM_Hawk_SR_AN_MPQ_50
|
||||
@@ -11,6 +11,20 @@ from gen.sam.aaa_flak18 import Flak18Generator
|
||||
from gen.sam.aaa_ww2_ally_flak import AllyWW2FlakGenerator
|
||||
from gen.sam.aaa_zu23_insurgent import ZU23InsurgentGenerator
|
||||
from gen.sam.cold_war_flak import EarlyColdWarFlakGenerator, ColdWarFlakGenerator
|
||||
|
||||
|
||||
from gen.sam.ewrs import (
|
||||
BigBirdGenerator,
|
||||
BoxSpringGenerator,
|
||||
DogEarGenerator,
|
||||
FlatFaceGenerator,
|
||||
HawkEwrGenerator,
|
||||
PatriotEwrGenerator,
|
||||
RolandEwrGenerator,
|
||||
SnowDriftGenerator,
|
||||
StraightFlushGenerator,
|
||||
TallRackGenerator,
|
||||
)
|
||||
from gen.sam.group_generator import GroupGenerator
|
||||
from gen.sam.sam_avenger import AvengerGenerator
|
||||
from gen.sam.sam_chaparral import ChaparralGenerator
|
||||
@@ -109,13 +123,34 @@ SAM_PRICES = {
|
||||
AirDefence.HQ_7_Self_Propelled_LN: 35
|
||||
}
|
||||
|
||||
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_sams_generator(faction: str) -> List[Type[GroupGenerator]]:
|
||||
"""
|
||||
Return the list of possible SAM generator for the given faction
|
||||
:param faction: Faction name to search units for
|
||||
"""
|
||||
return [SAM_MAP[s] for s in db.FACTIONS[faction].sams if s in SAM_MAP.keys()]
|
||||
return [SAM_MAP[s] for s in db.FACTIONS[faction].sams if s in SAM_MAP]
|
||||
|
||||
|
||||
def get_faction_possible_ewrs_generator(faction: str) -> List[Type[GroupGenerator]]:
|
||||
"""
|
||||
Return the list of possible SAM generator for the given faction
|
||||
:param faction: Faction name to search units for
|
||||
"""
|
||||
return [EWR_MAP[s] for s in db.FACTIONS[faction].ewrs if s in EWR_MAP]
|
||||
|
||||
|
||||
def generate_anti_air_group(game: Game, ground_object: TheaterGroundObject,
|
||||
@@ -136,6 +171,24 @@ def generate_anti_air_group(game: Game, ground_object: TheaterGroundObject,
|
||||
return None
|
||||
|
||||
|
||||
def generate_ewr_group(game: Game, ground_object: TheaterGroundObject,
|
||||
faction: str) -> 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
|
||||
|
||||
|
||||
def generate_shorad_group(game: Game, ground_object: SamGroundObject,
|
||||
faction_name: str) -> Optional[VehicleGroup]:
|
||||
faction = db.FACTIONS[faction_name]
|
||||
|
||||
Reference in New Issue
Block a user