mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
configure client slots on scramble + fixes
This commit is contained in:
@@ -6,6 +6,7 @@ from random import randint
|
||||
|
||||
import globals
|
||||
|
||||
from shop import db
|
||||
from .conflictgen import *
|
||||
from .naming import *
|
||||
|
||||
@@ -48,38 +49,44 @@ class AircraftConflictGenerator:
|
||||
self,
|
||||
name: str,
|
||||
side: Country,
|
||||
unit: UnitType,
|
||||
unit: PlaneType,
|
||||
count: int,
|
||||
client_count: int,
|
||||
at: Point = None,
|
||||
airport: Airport = None) -> PlaneGroup:
|
||||
starttype = airport == None and StartType.Warm or StartType.Cold
|
||||
print("generating {} ({}) at {} {}".format(unit, count, at, airport, side))
|
||||
airport: Airport = None) -> FlyingGroup:
|
||||
starttype = airport is None and StartType.Warm or StartType.Cold
|
||||
assert count > 0
|
||||
|
||||
return self.m.flight_group(
|
||||
country=side,
|
||||
name=name,
|
||||
aircraft_type=unit,
|
||||
airport=airport,
|
||||
position=at,
|
||||
altitude=WARM_START_ALTITUDE,
|
||||
speed=WARM_START_AIRSPEED,
|
||||
maintask=None,
|
||||
start_type=starttype,
|
||||
group_size=count)
|
||||
group = self.m.flight_group(
|
||||
country=side,
|
||||
name=name,
|
||||
aircraft_type=unit,
|
||||
airport=airport,
|
||||
position=at,
|
||||
altitude=WARM_START_ALTITUDE,
|
||||
speed=WARM_START_AIRSPEED,
|
||||
maintask=None,
|
||||
start_type=starttype,
|
||||
group_size=count)
|
||||
|
||||
def _generate_escort(self, units: typing.Dict[PlaneType, int], airport: Airport, side: Country, location: Point):
|
||||
for idx in range(client_count):
|
||||
group.units[idx].set_client()
|
||||
|
||||
return group
|
||||
|
||||
def _generate_escort(self, units: db.PlaneDict, clients: db.PlaneDict, airport: Airport, side: Country, location: Point):
|
||||
if len(self.escort_targets) == 0:
|
||||
return
|
||||
|
||||
for type, count in units.items():
|
||||
group = self._generate_group(
|
||||
name=namegen.next_escort_group_name(),
|
||||
side=side,
|
||||
unit=type,
|
||||
count=count,
|
||||
at=location,
|
||||
airport=airport)
|
||||
name=namegen.next_escort_group_name(),
|
||||
side=side,
|
||||
unit=type,
|
||||
count=count,
|
||||
client_count=clients.get(type, 0),
|
||||
at=location,
|
||||
airport=airport)
|
||||
|
||||
group.task = Escort.name
|
||||
group.load_task_default_loadout(dcs.task.Escort)
|
||||
@@ -91,7 +98,7 @@ class AircraftConflictGenerator:
|
||||
for group in self.escort_targets:
|
||||
wayp.tasks.append(EscortTaskAction(group.id, engagement_max_dist=ESCORT_MAX_DIST))
|
||||
|
||||
def generate_cas(self, attackers: typing.Dict[PlaneType, int], airport: Airport = None):
|
||||
def generate_cas(self, attackers: db.PlaneDict, clients: db.PlaneDict, airport: Airport = None):
|
||||
assert len(self.escort_targets) == 0
|
||||
|
||||
for type, count in attackers.items():
|
||||
@@ -100,6 +107,7 @@ class AircraftConflictGenerator:
|
||||
side=self.conflict.attackers_side,
|
||||
unit=type,
|
||||
count=count,
|
||||
client_count=clients.get(type, 0),
|
||||
at=airport is None and self._group_point(self.conflict.air_attackers_location) or None,
|
||||
airport=airport)
|
||||
self.escort_targets.append(group)
|
||||
@@ -108,29 +116,32 @@ class AircraftConflictGenerator:
|
||||
group.task = CAS.name
|
||||
group.load_task_default_loadout(CAS)
|
||||
|
||||
def generate_cas_escort(self, attackers: typing.Dict[PlaneType, int], airport: Airport = None):
|
||||
def generate_cas_escort(self, attackers: db.PlaneDict, clients: db.PlaneDict, airport: Airport = None):
|
||||
self._generate_escort(
|
||||
units=attackers,
|
||||
clients=clients,
|
||||
airport=airport,
|
||||
side=self.conflict.attackers_side,
|
||||
location=airport is None and self._group_point(self.conflict.air_attackers_location) or None
|
||||
)
|
||||
|
||||
def generate_transport_escort(self, escort: typing.Dict[PlaneType, int], airport: Airport = None):
|
||||
def generate_transport_escort(self, escort: db.PlaneDict, clients: db.PlaneDict, airport: Airport = None):
|
||||
self._generate_escort(
|
||||
units=escort,
|
||||
clients=clients,
|
||||
airport=airport,
|
||||
side=self.conflict.defenders_side,
|
||||
location=airport is None and self._group_point(self.conflict.air_defenders_location) or None
|
||||
)
|
||||
|
||||
def generate_defense(self, defenders: typing.Dict[PlaneType, int], airport: Airport = None):
|
||||
def generate_defense(self, defenders: db.PlaneDict, clients: db.PlaneDict, airport: Airport = None):
|
||||
for type, count in defenders.items():
|
||||
group = self._generate_group(
|
||||
name=namegen.next_intercept_group_name(),
|
||||
side=self.conflict.defenders_side,
|
||||
unit=type,
|
||||
count=count,
|
||||
client_count=clients.get(type, 0),
|
||||
at=airport is None and self._group_point(self.conflict.air_defenders_location) or None,
|
||||
airport=airport)
|
||||
|
||||
@@ -140,7 +151,7 @@ class AircraftConflictGenerator:
|
||||
wayp.tasks.append(dcs.task.EngageTargets(max_distance=self.conflict.size * INTERCEPT_MAX_DISTANCE_FACTOR))
|
||||
wayp.tasks.append(dcs.task.OrbitAction())
|
||||
|
||||
def generate_transport(self, transport: typing.Dict[PlaneType, int], destination: Airport):
|
||||
def generate_transport(self, transport: db.PlaneDict, destination: Airport):
|
||||
assert len(self.escort_targets) == 0
|
||||
|
||||
for type, count in transport.items():
|
||||
@@ -149,6 +160,7 @@ class AircraftConflictGenerator:
|
||||
side=self.conflict.defenders_side,
|
||||
unit=type,
|
||||
count=count,
|
||||
client_count=0,
|
||||
at=self._group_point(self.conflict.air_defenders_location),
|
||||
airport=None
|
||||
)
|
||||
@@ -158,13 +170,14 @@ class AircraftConflictGenerator:
|
||||
self.escort_targets.append(group)
|
||||
group.land_at(destination)
|
||||
|
||||
def generate_interception(self, interceptors: typing.Dict[PlaneType, int], airport: Airport = None):
|
||||
def generate_interception(self, interceptors: db.PlaneDict, clients: db.PlaneDict, airport: Airport = None):
|
||||
for type, count in interceptors.items():
|
||||
group = self._generate_group(
|
||||
name=namegen.next_intercept_group_name(),
|
||||
side=self.conflict.attackers_side,
|
||||
unit=type,
|
||||
count=count,
|
||||
client_count=clients.get(type, 0),
|
||||
at=airport is None and self._group_point(self.conflict.air_attackers_location) or None,
|
||||
airport=airport
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ from random import randint
|
||||
|
||||
import globals
|
||||
|
||||
from shop import db
|
||||
from .conflictgen import *
|
||||
from .naming import *
|
||||
|
||||
@@ -21,6 +22,7 @@ from dcs.country import *
|
||||
SPREAD_DISTANCE_FACTOR = 0.1, 0.3
|
||||
SPREAD_DISTANCE_SIZE_FACTOR = 0.1
|
||||
|
||||
|
||||
class ArmorConflictGenerator:
|
||||
def __init__(self, mission: Mission, conflict: Conflict):
|
||||
self.m = mission
|
||||
@@ -34,7 +36,7 @@ class ArmorConflictGenerator:
|
||||
|
||||
return point.random_point_within(distance, self.conflict.size * SPREAD_DISTANCE_SIZE_FACTOR)
|
||||
|
||||
def _generate_group(self, side: Country, unit: UnitType, count: int, at: Point):
|
||||
def _generate_group(self, side: Country, unit: VehicleType, count: int, at: Point):
|
||||
for c in range(count):
|
||||
group = self.m.vehicle_group(
|
||||
side,
|
||||
@@ -46,7 +48,7 @@ class ArmorConflictGenerator:
|
||||
wayp = group.add_waypoint(self.conflict.position)
|
||||
wayp.tasks = []
|
||||
|
||||
def generate(self, attackers: typing.Dict[UnitType, int], defenders: typing.Dict[UnitType, int]):
|
||||
def generate(self, attackers: db.ArmorDict, defenders: db.ArmorDict):
|
||||
for type, count in attackers.items():
|
||||
self._generate_group(
|
||||
side=self.conflict.attackers_side,
|
||||
|
||||
@@ -39,7 +39,7 @@ class Conflict:
|
||||
air_defenders_location = None # type: Point
|
||||
|
||||
@classmethod
|
||||
def capture_conflict(self, attacker: Country, attack_heading: int, defender: Country, defense_heading: int, position: Point, size: int, radials: typing.List[int]):
|
||||
def capture_conflict(self, attacker: Country, attack_heading: int, defender: Country, defense_heading: int, position: Point, size: int, radials: typing.Collection[int]):
|
||||
instance = self()
|
||||
instance.attackers_side = attacker
|
||||
instance.defenders_side = defender
|
||||
|
||||
Reference in New Issue
Block a user