mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
naval intercept operation; package refactoring
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user