dcs_liberation/theater/frontline.py
Dan Albert 28e00055ab Differentiate BARCAP and TARCAP.
Previously the only difference between these was the objective type:
TARCAP was for front lines and BARCAP was for everything else.

Now BARCAP is for friendly areas and TARCAP is for enemy areas. The
practical difference between the two is that a TARCAP package is like
the old front line CAP in that it will adjust its patrol time to match
the package if it can, and it will also arrive two minutes ahead of the
rest of the package to clear the area if needed.
2020-11-16 00:32:50 -08:00

48 lines
1.7 KiB
Python

"""Battlefield front lines."""
from typing import Tuple
from dcs.mapping import Point
from . import ControlPoint, MissionTarget
# TODO: Dedup by moving everything to using this class.
FRONTLINE_MIN_CP_DISTANCE = 5000
def compute_position(control_point_a: ControlPoint,
control_point_b: ControlPoint) -> Point:
a = control_point_a.position
b = control_point_b.position
attack_heading = a.heading_between_point(b)
attack_distance = a.distance_to_point(b)
middle_point = a.point_from_heading(attack_heading, attack_distance / 2)
strength_delta = float(control_point_a.base.strength -
control_point_b.base.strength)
position = middle_point.point_from_heading(attack_heading,
strength_delta *
attack_distance / 2 -
FRONTLINE_MIN_CP_DISTANCE)
return position
class FrontLine(MissionTarget):
"""Defines a front line location between two control points.
Front lines are the area where ground combat happens.
"""
def __init__(self, control_point_a: ControlPoint,
control_point_b: ControlPoint) -> None:
super().__init__(f"Front line {control_point_a}/{control_point_b}",
compute_position(control_point_a, control_point_b))
self.control_point_a = control_point_a
self.control_point_b = control_point_b
@property
def control_points(self) -> Tuple[ControlPoint, ControlPoint]:
"""Returns a tuple of the two control points."""
return self.control_point_a, self.control_point_b
def is_friendly(self, to_player: bool) -> bool:
return False