mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
We were setting up all the correct *target* waypoints but the AI doesn't use the target waypoints; they use the targets property of the ingress waypoint. This meant that the flight plan looked correct in the UI and was correct for players but the tasks were set up incorrectly for the AI because building TGOs are aggravatingly multiple TGOs with the same name in the implementation. Mission targets now enumerate their own strike targets so that this mistake is harder to make in the future. This won't be perfect, the AI is still not able to parallelize tasks and since buildings aren't groups they can only attack one structure at a time, but they'll now at least switch to the next target after hitting the first one. As a bonus, stop bombing the dead buildings. Fixes https://github.com/dcs-liberation/dcs_liberation/issues/235 Fixes https://github.com/dcs-liberation/dcs_liberation/issues/244
50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Iterator, TYPE_CHECKING, List, Union
|
|
|
|
from dcs.mapping import Point
|
|
from dcs.unit import Unit
|
|
|
|
if TYPE_CHECKING:
|
|
from gen.flights.flight import FlightType
|
|
|
|
|
|
class MissionTarget:
|
|
def __init__(self, name: str, position: Point) -> None:
|
|
"""Initializes a mission target.
|
|
|
|
Args:
|
|
name: The name of the mission target.
|
|
position: The location of the mission target.
|
|
"""
|
|
self.name = name
|
|
self.position = position
|
|
|
|
def distance_to(self, other: MissionTarget) -> int:
|
|
"""Computes the distance to the given mission target."""
|
|
return self.position.distance_to_point(other.position)
|
|
|
|
def is_friendly(self, to_player: bool) -> bool:
|
|
"""Returns True if the objective is in friendly territory."""
|
|
raise NotImplementedError
|
|
|
|
def mission_types(self, for_player: bool) -> Iterator[FlightType]:
|
|
from gen.flights.flight import FlightType
|
|
|
|
if self.is_friendly(for_player):
|
|
yield FlightType.BARCAP
|
|
else:
|
|
yield from [
|
|
FlightType.ESCORT,
|
|
FlightType.TARCAP,
|
|
FlightType.SEAD,
|
|
FlightType.SWEEP,
|
|
# TODO: FlightType.ELINT,
|
|
# TODO: FlightType.EWAR,
|
|
# TODO: FlightType.RECON,
|
|
]
|
|
|
|
@property
|
|
def strike_targets(self) -> List[Union[MissionTarget, Unit]]:
|
|
raise NotImplementedError
|