Improve AI strike targeting.

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
This commit is contained in:
Dan Albert
2021-05-19 23:26:59 -07:00
parent 04ebe4c68a
commit 2a77f57aa4
8 changed files with 49 additions and 34 deletions

View File

@@ -1,5 +1,4 @@
from __future__ import annotations
from game.scenery_group import SceneryGroup
import heapq
import itertools
@@ -9,7 +8,7 @@ from abc import ABC, abstractmethod
from dataclasses import dataclass, field
from enum import Enum
from functools import total_ordering
from typing import Any, Dict, Iterator, List, Optional, Set, TYPE_CHECKING, Type
from typing import Any, Dict, Iterator, List, Optional, Set, TYPE_CHECKING, Type, Union
from dcs.mapping import Point
from dcs.ships import (
@@ -19,10 +18,12 @@ from dcs.ships import (
Type_071_Amphibious_Transport_Dock,
)
from dcs.terrain.terrain import Airport, ParkingSlot
from dcs.unit import Unit
from dcs.unittype import FlyingType
from game import db
from game.point_with_heading import PointWithHeading
from game.scenery_group import SceneryGroup
from gen.flights.closestairfields import ObjectiveDistanceCache
from gen.ground_forces.ai_ground_planner_db import TYPE_SHORAD
from gen.ground_forces.combat_stance import CombatStance
@@ -781,6 +782,10 @@ class ControlPoint(MissionTarget, ABC):
return self.captured != other.captured
@property
def strike_targets(self) -> List[Union[MissionTarget, Unit]]:
return []
class Airfield(ControlPoint):
def __init__(

View File

@@ -1,8 +1,9 @@
from __future__ import annotations
from typing import Iterator, TYPE_CHECKING
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
@@ -42,3 +43,7 @@ class MissionTarget:
# TODO: FlightType.EWAR,
# TODO: FlightType.RECON,
]
@property
def strike_targets(self) -> List[Union[MissionTarget, Unit]]:
raise NotImplementedError

View File

@@ -2,7 +2,7 @@ from __future__ import annotations
import itertools
import logging
from typing import Iterator, List, TYPE_CHECKING
from typing import Iterator, List, TYPE_CHECKING, Union
from dcs.mapping import Point
from dcs.triggers import TriggerZone
@@ -185,6 +185,10 @@ class TheaterGroundObject(MissionTarget):
"""True if this TGO is the group for the control point itself (CVs and FOBs)."""
return False
@property
def strike_targets(self) -> List[Union[MissionTarget, Unit]]:
return self.units
class BuildingGroundObject(TheaterGroundObject):
def __init__(
@@ -233,6 +237,15 @@ class BuildingGroundObject(TheaterGroundObject):
def kill(self) -> None:
self._dead = True
def iter_building_group(self) -> Iterator[TheaterGroundObject]:
for tgo in self.control_point.ground_objects:
if tgo.obj_name == self.obj_name and not tgo.is_dead:
yield tgo
@property
def strike_targets(self) -> List[Union[MissionTarget, Unit]]:
return list(self.iter_building_group())
class SceneryGroundObject(BuildingGroundObject):
def __init__(