mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Added a new setting: "Maximum frontline length (km)"
It replaces the FRONTLINE_LENGTH constant, which was used previously. The default setting for the frontline length has been set to match the FRONTLINE_LENGTH value (80 km), but I feel the default should be a bit shorter. Discussion on the topic would be welcome.
This commit is contained in:
@@ -90,7 +90,7 @@ class DrawingsGenerator:
|
||||
heading,
|
||||
distance,
|
||||
) = FrontLineConflictDescription.frontline_vector(
|
||||
front_line, self.game.theater
|
||||
front_line, self.game.theater, self.game.settings
|
||||
)
|
||||
|
||||
end_point = plane_start.point_from_heading(heading.degrees, distance)
|
||||
|
||||
@@ -97,11 +97,11 @@ class FlotGenerator:
|
||||
|
||||
def generate(self) -> None:
|
||||
position = FrontLineConflictDescription.frontline_position(
|
||||
self.conflict.front_line, self.game.theater
|
||||
self.conflict.front_line, self.game.theater, self.game.settings
|
||||
)
|
||||
|
||||
frontline_vector = FrontLineConflictDescription.frontline_vector(
|
||||
self.conflict.front_line, self.game.theater
|
||||
self.conflict.front_line, self.game.theater, self.game.settings
|
||||
)
|
||||
|
||||
# Create player groups at random position
|
||||
|
||||
@@ -7,14 +7,12 @@ from dcs.country import Country
|
||||
from dcs.mapping import Point
|
||||
from shapely.geometry import LineString, Point as ShapelyPoint
|
||||
|
||||
from game.settings import Settings
|
||||
from game.theater.conflicttheater import ConflictTheater, FrontLine
|
||||
from game.theater.controlpoint import ControlPoint
|
||||
from game.utils import Heading
|
||||
|
||||
|
||||
FRONTLINE_LENGTH = 80000
|
||||
|
||||
|
||||
class FrontLineConflictDescription:
|
||||
def __init__(
|
||||
self,
|
||||
@@ -54,12 +52,12 @@ class FrontLineConflictDescription:
|
||||
|
||||
@classmethod
|
||||
def frontline_position(
|
||||
cls, frontline: FrontLine, theater: ConflictTheater
|
||||
cls, frontline: FrontLine, theater: ConflictTheater, settings: Settings
|
||||
) -> Tuple[Point, Heading]:
|
||||
attack_heading = frontline.attack_heading
|
||||
position = cls.find_ground_position(
|
||||
frontline.position,
|
||||
FRONTLINE_LENGTH,
|
||||
settings.max_frontline_length * 1000,
|
||||
attack_heading.right,
|
||||
theater,
|
||||
)
|
||||
@@ -69,19 +67,25 @@ class FrontLineConflictDescription:
|
||||
|
||||
@classmethod
|
||||
def frontline_vector(
|
||||
cls, front_line: FrontLine, theater: ConflictTheater
|
||||
cls, front_line: FrontLine, theater: ConflictTheater, settings: Settings
|
||||
) -> Tuple[Point, Heading, int]:
|
||||
"""
|
||||
Returns a vector for a valid frontline location avoiding exclusion zones.
|
||||
"""
|
||||
center_position, heading = cls.frontline_position(front_line, theater)
|
||||
center_position, heading = cls.frontline_position(front_line, theater, settings)
|
||||
left_heading = heading.left
|
||||
right_heading = heading.right
|
||||
left_position = cls.extend_ground_position(
|
||||
center_position, int(FRONTLINE_LENGTH / 2), left_heading, theater
|
||||
center_position,
|
||||
int(settings.max_frontline_length * 1000 / 2),
|
||||
left_heading,
|
||||
theater,
|
||||
)
|
||||
right_position = cls.extend_ground_position(
|
||||
center_position, int(FRONTLINE_LENGTH / 2), right_heading, theater
|
||||
center_position,
|
||||
int(settings.max_frontline_length * 1000 / 2),
|
||||
right_heading,
|
||||
theater,
|
||||
)
|
||||
distance = int(left_position.distance_to_point(right_position))
|
||||
return left_position, right_heading, distance
|
||||
@@ -95,9 +99,12 @@ class FrontLineConflictDescription:
|
||||
defender: Country,
|
||||
front_line: FrontLine,
|
||||
theater: ConflictTheater,
|
||||
settings: Settings,
|
||||
) -> FrontLineConflictDescription:
|
||||
assert cls.has_frontline_between(front_line.blue_cp, front_line.red_cp)
|
||||
position, heading, distance = cls.frontline_vector(front_line, theater)
|
||||
position, heading, distance = cls.frontline_vector(
|
||||
front_line, theater, settings
|
||||
)
|
||||
conflict = cls(
|
||||
position=position,
|
||||
heading=heading,
|
||||
|
||||
@@ -202,6 +202,7 @@ class MissionGenerator:
|
||||
self.mission.country(self.game.red.country_name),
|
||||
front_line,
|
||||
self.game.theater,
|
||||
self.game.settings,
|
||||
)
|
||||
# Generate frontline ops
|
||||
player_gp = self.game.ground_planners[player_cp.id].units_per_cp[
|
||||
|
||||
@@ -84,7 +84,7 @@ class VisualsGenerator:
|
||||
heading,
|
||||
distance,
|
||||
) = FrontLineConflictDescription.frontline_vector(
|
||||
front_line, self.game.theater
|
||||
front_line, self.game.theater, self.game.settings
|
||||
)
|
||||
if not plane_start:
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user