mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Generate battle environment : SEAD + CAS flight.
Added more factions.
This commit is contained in:
112
gen/aircraft.py
112
gen/aircraft.py
@@ -299,13 +299,13 @@ class AircraftConflictGenerator:
|
||||
def generate_patrol_group(self, cp: ControlPoint, country):
|
||||
|
||||
aircraft = dict({k:v for k,v in cp.base.aircraft.items() if k in [u for u in db.UNIT_BY_TASK[CAP]]})
|
||||
delta = random.randint(1, 20)
|
||||
delta = random.randint(1, 7)
|
||||
|
||||
for i in range(8):
|
||||
for i in range(6):
|
||||
if(len(aircraft.keys())) > 0:
|
||||
print(aircraft.keys())
|
||||
type = random.choice(list(aircraft.keys()))
|
||||
number = random.choice([2, 4])
|
||||
number = random.choice([2, 2, 2, 4])
|
||||
if(number > aircraft[type]):
|
||||
del aircraft[type]
|
||||
else:
|
||||
@@ -333,8 +333,7 @@ class AircraftConflictGenerator:
|
||||
|
||||
patrol_alt = random.randint(3600, 7000)
|
||||
group.points[0].alt = patrol_alt
|
||||
group.points[0].ETA = delta*60 + i*10*60
|
||||
|
||||
group.points[0].ETA = delta*60 + i*random.randint(18,23)*60
|
||||
|
||||
patrolled = []
|
||||
for ground_object in cp.ground_objects:
|
||||
@@ -342,6 +341,109 @@ class AircraftConflictGenerator:
|
||||
group.add_waypoint(ground_object.position, patrol_alt)
|
||||
patrolled.append(ground_object.group_id)
|
||||
|
||||
def generate_patrol_cas(self, cp: ControlPoint, country):
|
||||
connected_enemy_cp = [c for c in cp.connected_points if c.captured != cp.captured]
|
||||
if len(connected_enemy_cp) <= 0: return
|
||||
|
||||
aircraft = dict({k: v for k, v in cp.base.aircraft.items() if k in [u for u in db.UNIT_BY_TASK[CAS]]})
|
||||
delta = random.randint(1, 7)
|
||||
|
||||
for i in range(3):
|
||||
target_cp = random.choice(connected_enemy_cp)
|
||||
if (len(aircraft.keys())) > 0:
|
||||
type = random.choice(list(aircraft.keys()))
|
||||
number = random.choice([2, 2, 2, 2, 2, 4])
|
||||
if (number > aircraft[type]):
|
||||
del aircraft[type]
|
||||
else:
|
||||
aircraft[type] = aircraft[type] - number
|
||||
|
||||
try:
|
||||
group = self._generate_at_airport(
|
||||
name=namegen.next_unit_name(country, type),
|
||||
side=country,
|
||||
unit_type=type,
|
||||
count=number,
|
||||
client_count=0,
|
||||
airport=self.m.terrain.airport_by_id(cp.at.id),
|
||||
start_type=StartType.Runway)
|
||||
except Exception:
|
||||
group = self._generate_group(
|
||||
name=namegen.next_unit_name(country, type),
|
||||
side=country,
|
||||
unit_type=type,
|
||||
count=number,
|
||||
client_count=0,
|
||||
at=cp.position)
|
||||
|
||||
group.task = CAS.name
|
||||
self._setup_group(group, CAS, 0)
|
||||
|
||||
alt = random.randint(500, 2500)
|
||||
group.points[0].alt = 4000
|
||||
group.points[0].ETA = delta * 60 + i * random.randint(36, 46) * 60
|
||||
group.points[0].tasks.clear()
|
||||
group.points[0].tasks.append(CASTaskAction())
|
||||
group.points[0].tasks.append(OptReactOnThreat(OptReactOnThreat.Values.EvadeFire))
|
||||
group.points[0].tasks.append(OptROE(OptROE.Values.OpenFireWeaponFree))
|
||||
|
||||
target_cas_point_x = (cp.position.x + target_cp.position.x) / 2
|
||||
target_cas_point_y = (cp.position.y + target_cp.position.y) / 2
|
||||
|
||||
group.add_waypoint(Point(target_cas_point_x, target_cas_point_y), alt)
|
||||
|
||||
def generate_dead_sead(self, cp: ControlPoint, country):
|
||||
connected_enemy_cp = [c for c in cp.connected_points if c.captured != cp.captured]
|
||||
if len(connected_enemy_cp) <= 0: return
|
||||
|
||||
possible_sead_units = [craft for craft in db.PLANE_PAYLOAD_OVERRIDES if SEAD in db.PLANE_PAYLOAD_OVERRIDES[craft].keys()]
|
||||
aircraft = dict({k: v for k, v in cp.base.aircraft.items() if k in possible_sead_units})
|
||||
|
||||
delta = random.randint(1, 7)
|
||||
|
||||
for i in range(3):
|
||||
target_cp = random.choice(connected_enemy_cp)
|
||||
if (len(aircraft.keys())) > 0:
|
||||
type = random.choice(list(aircraft.keys()))
|
||||
number = random.choice([2, 2, 2, 2, 2, 4])
|
||||
if (number > aircraft[type]):
|
||||
del aircraft[type]
|
||||
else:
|
||||
aircraft[type] = aircraft[type] - number
|
||||
|
||||
try:
|
||||
group = self._generate_at_airport(
|
||||
name=namegen.next_unit_name(country, type),
|
||||
side=country,
|
||||
unit_type=type,
|
||||
count=number,
|
||||
client_count=0,
|
||||
airport=self.m.terrain.airport_by_id(cp.at.id),
|
||||
start_type=StartType.Runway)
|
||||
except Exception:
|
||||
group = self._generate_group(
|
||||
name=namegen.next_unit_name(country, type),
|
||||
side=country,
|
||||
unit_type=type,
|
||||
count=number,
|
||||
client_count=0,
|
||||
at=cp.position)
|
||||
|
||||
group.task = SEAD.name
|
||||
self._setup_group(group, SEAD, 0)
|
||||
|
||||
patrol_alt = random.randint(3600, 7000)
|
||||
group.points[0].alt = patrol_alt
|
||||
group.points[0].ETA = delta * 60 + i * random.randint(36, 46) * 6
|
||||
group.points[0].tasks.clear()
|
||||
group.points[0].tasks.append(SEADTaskAction())
|
||||
group.points[0].tasks.append(OptReactOnThreat(OptReactOnThreat.Values.EvadeFire))
|
||||
group.points[0].tasks.append(OptROE(OptROE.Values.WeaponFree))
|
||||
|
||||
target_cas_point_x = (cp.position.x + target_cp.position.x) / 2
|
||||
target_cas_point_y = (cp.position.y + target_cp.position.y) / 2
|
||||
|
||||
group.add_waypoint(Point(target_cas_point_x, target_cas_point_y), patrol_alt)
|
||||
|
||||
def generate_ground_attack_strikegroup(self, strikegroup: db.PlaneDict, clients: db.PlaneDict, targets: typing.List[typing.Tuple[str, Point]], at: db.StartingPosition = None, escort=True):
|
||||
assert not escort or len(self.escort_targets) == 0
|
||||
|
||||
25
gen/sam/aaa_bofors.py
Normal file
25
gen/sam/aaa_bofors.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import random
|
||||
|
||||
from dcs.vehicles import AirDefence
|
||||
|
||||
from gen.sam.group_generator import AntiAirGroupGenerator
|
||||
|
||||
|
||||
class BoforsGenerator(AntiAirGroupGenerator):
|
||||
"""
|
||||
This generate a Bofors flak artillery group
|
||||
"""
|
||||
|
||||
def generate(self):
|
||||
grid_x = random.randint(2, 4)
|
||||
grid_y = random.randint(2, 4)
|
||||
|
||||
spacing = random.randint(10,40)
|
||||
|
||||
index = 0
|
||||
for i in range(grid_x):
|
||||
for j in range(grid_y):
|
||||
index = index+1
|
||||
self.add_unit(AirDefence.AAA_Bofors_40mm, "AAA#" + str(index),
|
||||
self.position.x + spacing*i,
|
||||
self.position.y + spacing*j, self.heading)
|
||||
25
gen/sam/aaa_flak36.py
Normal file
25
gen/sam/aaa_flak36.py
Normal file
@@ -0,0 +1,25 @@
|
||||
import random
|
||||
|
||||
from dcs.vehicles import AirDefence
|
||||
|
||||
from gen.sam.group_generator import AntiAirGroupGenerator
|
||||
|
||||
|
||||
class Flak36Generator(AntiAirGroupGenerator):
|
||||
"""
|
||||
This generate a Bofors flak artillery group
|
||||
"""
|
||||
|
||||
def generate(self):
|
||||
grid_x = random.randint(2, 4)
|
||||
grid_y = random.randint(2, 4)
|
||||
|
||||
spacing = random.randint(10,40)
|
||||
|
||||
index = 0
|
||||
for i in range(grid_x):
|
||||
for j in range(grid_y):
|
||||
index = index+1
|
||||
self.add_unit(AirDefence.AAA_Flak_36, "AAA#" + str(index),
|
||||
self.position.x + spacing*i,
|
||||
self.position.y + spacing*j, self.heading)
|
||||
@@ -8,6 +8,8 @@ from dcs.unittype import UnitType
|
||||
from dcs.vehicles import AirDefence
|
||||
|
||||
from game import db
|
||||
from gen.sam.aaa_bofors import BoforsGenerator
|
||||
from gen.sam.aaa_flak36 import Flak36Generator
|
||||
from gen.sam.sam_avenger import AvengerGenerator
|
||||
from gen.sam.sam_chaparral import ChaparralGenerator
|
||||
from gen.sam.sam_gepard import GepardGenerator
|
||||
@@ -57,6 +59,8 @@ def generate_anti_air_group(game, parent_cp, ground_object, faction:str):
|
||||
AirDefence.SAM_Patriot_LN_M901: PatriotGenerator,
|
||||
AirDefence.SAM_Patriot_EPP_III: PatriotGenerator,
|
||||
AirDefence.SAM_Chaparral_M48: ChaparralGenerator,
|
||||
AirDefence.AAA_Bofors_40mm: BoforsGenerator,
|
||||
AirDefence.AAA_Flak_36: Flak36Generator,
|
||||
|
||||
AirDefence.SAM_SA_2_LN_SM_90: SA2Generator,
|
||||
AirDefence.SAM_SA_3_S_125_LN_5P73: SA3Generator,
|
||||
|
||||
@@ -15,11 +15,11 @@ class HQ7Generator(AntiAirGroupGenerator):
|
||||
self.add_unit(AirDefence.HQ_7_Self_Propelled_LN, "LN", self.position.x + 20, self.position.y, self.heading)
|
||||
|
||||
# Triple A for close range defense
|
||||
self.add_unit(AirDefence.AAA_ZU_23_on_Ural_375, "AAA", self.position.x + 20, self.position.y+30, self.heading)
|
||||
self.add_unit(AirDefence.AAA_ZU_23_on_Ural_375, "AAA", self.position.x - 20, self.position.y-30, self.heading)
|
||||
self.add_unit(AirDefence.AAA_ZU_23_on_Ural_375, "AAA1", self.position.x + 20, self.position.y+30, self.heading)
|
||||
self.add_unit(AirDefence.AAA_ZU_23_on_Ural_375, "AAA2", self.position.x - 20, self.position.y-30, self.heading)
|
||||
|
||||
num_launchers = random.randint(0, 3)
|
||||
positions = self.get_circular_position(num_launchers, launcher_distance=120, coverage=360)
|
||||
|
||||
for i, position in enumerate(positions):
|
||||
self.add_unit(AirDefence.HQ_7_Self_Propelled_LN, "LN#" + str(i), position[0], position[1], position[2])
|
||||
if num_launchers > 0:
|
||||
positions = self.get_circular_position(num_launchers, launcher_distance=120, coverage=360)
|
||||
for i, position in enumerate(positions):
|
||||
self.add_unit(AirDefence.HQ_7_Self_Propelled_LN, "LN#" + str(i), position[0], position[1], position[2])
|
||||
@@ -15,10 +15,10 @@ class SA10Generator(AntiAirGroupGenerator):
|
||||
self.add_unit(AirDefence.SAM_SA_10_S_300PS_CP_54K6, "CP", self.position.x, self.position.y, self.heading)
|
||||
|
||||
# Search Radar
|
||||
self.add_unit(AirDefence.SAM_SA_10_S_300PS_SR_5N66M, "SR", self.position.x, self.position.y, self.heading)
|
||||
self.add_unit(AirDefence.SAM_SA_10_S_300PS_SR_5N66M, "SR1", self.position.x, self.position.y + 40, self.heading)
|
||||
|
||||
# Search radar for missiles (optionnal)
|
||||
self.add_unit(AirDefence.SAM_SA_10_S_300PS_SR_64H6E, "SR", self.position.x, self.position.y, self.heading)
|
||||
self.add_unit(AirDefence.SAM_SA_10_S_300PS_SR_64H6E, "SR2", self.position.x - 40, self.position.y, self.heading)
|
||||
|
||||
# 2 different launcher type (C & D)
|
||||
num_launchers = random.randint(6, 8)
|
||||
|
||||
@@ -187,7 +187,7 @@ class TriggersGenerator:
|
||||
self.mission.triggerrules.triggers.append(trigger_two)
|
||||
|
||||
def generate(self, player_cp: ControlPoint, is_quick: bool, activation_trigger_radius: int, awacs_enabled: bool):
|
||||
player_coalition = self.game.player_country in ["USA", "France", "Germany", "Uk"] and "blue" or "red"
|
||||
player_coalition = self.game.player_country in ["USA", "France", "Germany", "UK", "The Netherlands", "Italy", "Spain", "India"] and "blue" or "red"
|
||||
enemy_coalition = player_coalition == "blue" and "red" or "blue"
|
||||
|
||||
self.mission.coalition[player_coalition].bullseye = {"x": self.conflict.position.x,
|
||||
|
||||
Reference in New Issue
Block a user