mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
naval intercept operation; package refactoring
This commit is contained in:
@@ -1,2 +1,11 @@
|
||||
import dcs
|
||||
from .aaa import *
|
||||
from .aircraft import *
|
||||
from .armor import *
|
||||
from .awacsgen import *
|
||||
from .conflictgen import *
|
||||
from .shipgen import *
|
||||
from .visualgen import *
|
||||
from .settingsgen import *
|
||||
|
||||
from . import naming
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from game import db
|
||||
from game import *
|
||||
|
||||
from theater.conflicttheater import ConflictTheater
|
||||
from .conflictgen import *
|
||||
|
||||
@@ -176,7 +176,7 @@ class AircraftConflictGenerator:
|
||||
groups.append(group)
|
||||
return groups
|
||||
|
||||
def generate_cas(self, attackers: db.PlaneDict, clients: db.PlaneDict, at: db.StartingPosition = None):
|
||||
def generate_cas_strikegroup(self, attackers: db.PlaneDict, clients: db.PlaneDict, at: db.StartingPosition = None):
|
||||
assert len(self.escort_targets) == 0
|
||||
|
||||
for flying_type, count, client_count in self._split_to_groups(attackers, clients):
|
||||
@@ -195,7 +195,26 @@ class AircraftConflictGenerator:
|
||||
|
||||
group.add_waypoint(self.conflict.from_cp.position, RTB_ALTITUDE)
|
||||
|
||||
def generate_cas_escort(self, attackers: db.PlaneDict, clients: db.PlaneDict, at: db.StartingPosition = None):
|
||||
def generate_ship_strikegroup(self, attackers: db.PlaneDict, clients: db.PlaneDict, at: db.StartingPosition = None):
|
||||
assert len(self.escort_targets) == 0
|
||||
|
||||
for flying_type, count, client_count in self._split_to_groups(attackers, clients):
|
||||
group = self._generate_group(
|
||||
name=namegen.next_cas_group_name(),
|
||||
side=self.conflict.attackers_side,
|
||||
unit_type=flying_type,
|
||||
count=count,
|
||||
client_count=client_count,
|
||||
at=at and at or self._group_point(self.conflict.air_attackers_location))
|
||||
self.escort_targets.append(group)
|
||||
|
||||
group.add_waypoint(self.conflict.position, CAS_ALTITUDE, WARM_START_AIRSPEED)
|
||||
group.task = AntishipStrike.name
|
||||
self._setup_group(group, AntishipStrike, clients)
|
||||
|
||||
group.add_waypoint(self.conflict.from_cp.position, RTB_ALTITUDE)
|
||||
|
||||
def generate_strikegroup_escort(self, attackers: db.PlaneDict, clients: db.PlaneDict, at: db.StartingPosition = None):
|
||||
for g in self._generate_escort(
|
||||
side=self.conflict.attackers_side,
|
||||
units=attackers,
|
||||
|
||||
@@ -14,6 +14,9 @@ from dcs.point import *
|
||||
from dcs.task import *
|
||||
from dcs.country import *
|
||||
|
||||
from theater import *
|
||||
|
||||
|
||||
GROUND_DISTANCE_FACTOR = 0.8
|
||||
GROUNDINTERCEPT_DISTANCE_FACTOR = 3
|
||||
AIR_DISTANCE = 32000
|
||||
@@ -25,6 +28,9 @@ INTERCEPT_DEFENDERS_DISTANCE = 30000
|
||||
INTERCEPT_MAX_DISTANCE = 80000
|
||||
INTERCEPT_MIN_DISTANCE = 45000
|
||||
|
||||
NAVAL_INTERCEPT_DISTANCE_FACTOR = 1.3
|
||||
NAVAL_INTERCEPT_STEP = 3000
|
||||
|
||||
|
||||
def _opposite_heading(h):
|
||||
return h+180
|
||||
@@ -119,3 +125,31 @@ class Conflict:
|
||||
instance.ground_defenders_location = instance.position.point_from_heading(random.choice(to_cp.radials), instance.size * GROUNDINTERCEPT_DISTANCE_FACTOR)
|
||||
|
||||
return instance
|
||||
|
||||
@classmethod
|
||||
def naval_intercept_conflict(cls, attacker: Country, defender: Country, theater: ConflictTheater, from_cp: ControlPoint, to_cp: ControlPoint):
|
||||
radial = random.choice(to_cp.sea_radials)
|
||||
|
||||
initial_distance = int(from_cp.position.distance_to_point(to_cp.position) * NAVAL_INTERCEPT_DISTANCE_FACTOR)
|
||||
position = to_cp.position.point_from_heading(radial, initial_distance)
|
||||
for offset in range(0, initial_distance, NAVAL_INTERCEPT_STEP):
|
||||
if theater.is_on_land(position):
|
||||
break
|
||||
else:
|
||||
position = to_cp.position.point_from_heading(radial, offset)
|
||||
|
||||
instance = cls()
|
||||
instance.from_cp = from_cp
|
||||
instance.to_cp = to_cp
|
||||
instance.attackers_side = attacker
|
||||
instance.defenders_side = defender
|
||||
|
||||
instance.position = position
|
||||
instance.size = SIZE_REGULAR
|
||||
instance.radials = to_cp.radials
|
||||
|
||||
attacker_heading = from_cp.position.heading_between_point(to_cp.position)
|
||||
instance.air_attackers_location = instance.position.point_from_heading(attacker_heading, AIR_DISTANCE)
|
||||
instance.air_defenders_location = instance.position.point_from_heading(_opposite_heading(attacker_heading), AIR_DISTANCE)
|
||||
|
||||
return instance
|
||||
|
||||
@@ -9,8 +9,8 @@ from dcs.action import *
|
||||
from dcs.unit import Skill
|
||||
|
||||
from game import db
|
||||
from theater.weatherforecast import WeatherForecast
|
||||
from theater.conflicttheater import Conflict
|
||||
from theater import *
|
||||
from gen import *
|
||||
|
||||
ACTIVATION_TRIGGER_SIZE = 40000
|
||||
ACTIVATION_TRIGGER_MIN_DISTANCE = 5000
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from game import db
|
||||
from .conflictgen import *
|
||||
from .naming import *
|
||||
|
||||
@@ -5,15 +6,33 @@ from dcs.mission import *
|
||||
from dcs.unitgroup import *
|
||||
from dcs.task import *
|
||||
|
||||
SHIP_RANDOM_SPREAD = 300
|
||||
|
||||
|
||||
class ShipGenerator:
|
||||
def __init__(self, mission: Mission, conflict: Conflict):
|
||||
self.m = mission
|
||||
self.conflict = conflict
|
||||
|
||||
def generate(self, type: ShipType, country: str, at: Point) -> ShipGroup:
|
||||
def generate_carrier(self, type: ShipType, country: str, at: Point) -> ShipGroup:
|
||||
return self.m.ship_group(
|
||||
country=self.m.country(country),
|
||||
name=namegen.next_transport_group_name(),
|
||||
_type=type,
|
||||
position=at)
|
||||
|
||||
def generate_cargo(self, units: db.ShipDict) -> typing.Collection[ShipGroup]:
|
||||
groups = []
|
||||
for unit_type, unit_count in units.items():
|
||||
group = self.m.ship_group(
|
||||
country=self.conflict.defenders_side,
|
||||
name=namegen.next_transport_group_name(),
|
||||
_type=unit_type,
|
||||
position=self.conflict.position.random_point_within(SHIP_RANDOM_SPREAD, SHIP_RANDOM_SPREAD),
|
||||
group_size=unit_count,
|
||||
)
|
||||
|
||||
group.add_waypoint(self.conflict.to_cp.position)
|
||||
groups.append(group)
|
||||
|
||||
return groups
|
||||
|
||||
@@ -6,7 +6,8 @@ from dcs.mission import Mission
|
||||
from dcs.statics import *
|
||||
from dcs.unit import Static
|
||||
|
||||
from theater.conflicttheater import Conflict
|
||||
from theater import *
|
||||
from .conflictgen import *
|
||||
#from game.game import Game
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user