mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
calculate heading to center of conflict for sams
This commit is contained in:
parent
1094085872
commit
dd50ee92a9
@ -27,6 +27,7 @@ Saves from 4.0.0 are compatible with 4.1.0.
|
||||
* **[Campaign]** Air defense sites now generate a fixed number of launchers per type.
|
||||
* **[Campaign]** Added support for Mariana Islands map.
|
||||
* **[Mission Generation]** Improvements for better support of the Skynet Plugin and long range SAMs are now acting as EWR
|
||||
* **[Mission Generation]** SAM sites are now headed towards the center of the conflict
|
||||
* **[Plugins]** Increased time JTAC Autolase messages stay visible on the UI.
|
||||
* **[UI]** Added ability to take notes and have those notes appear as a kneeboard page.
|
||||
* **[UI]** Hovering over the weather information now dispalys the cloud base (meters and feet).
|
||||
|
||||
@ -48,6 +48,7 @@ class AirDefenseGroupGenerator(VehicleGroupGenerator[SamGroundObject], ABC):
|
||||
|
||||
self.vg.name = self.group_name_for_role(self.vg.id, self.primary_group_role())
|
||||
self.auxiliary_groups: List[VehicleGroup] = []
|
||||
self.heading = self.heading_to_conflict()
|
||||
|
||||
def add_auxiliary_group(self, role: SkynetRole) -> VehicleGroup:
|
||||
gid = self.game.next_group_id()
|
||||
|
||||
@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import math
|
||||
import operator
|
||||
import random
|
||||
from collections import Iterable
|
||||
from typing import TYPE_CHECKING, Type, TypeVar, Generic, Any
|
||||
@ -15,6 +16,7 @@ from dcs.unittype import VehicleType, UnitType, ShipType
|
||||
|
||||
from game.dcs.groundunittype import GroundUnitType
|
||||
from game.factions.faction import Faction
|
||||
from game.theater import MissionTarget
|
||||
from game.theater.theatergroundobject import TheaterGroundObject, NavalGroundObject
|
||||
from game.utils import Heading
|
||||
|
||||
@ -70,6 +72,27 @@ class GroupGenerator(Generic[GroupT, UnitT, UnitTypeT, TgoT]):
|
||||
) -> UnitT:
|
||||
raise NotImplementedError
|
||||
|
||||
def heading_to_conflict(self) -> int:
|
||||
# Heading for a Group to the enemy.
|
||||
# Should be the point between the nearest and the most distant conflict
|
||||
conflicts: dict[MissionTarget, float] = {}
|
||||
|
||||
for conflict in self.game.theater.conflicts():
|
||||
conflicts[conflict] = conflict.distance_to(self.go)
|
||||
|
||||
if len(conflicts) == 0:
|
||||
return self.heading
|
||||
|
||||
closest_conflict = min(conflicts.items(), key=operator.itemgetter(1))[0]
|
||||
most_distant_conflict = max(conflicts.items(), key=operator.itemgetter(1))[0]
|
||||
|
||||
conflict_center = Point(
|
||||
(closest_conflict.position.x + most_distant_conflict.position.x) / 2,
|
||||
(closest_conflict.position.y + most_distant_conflict.position.y) / 2,
|
||||
)
|
||||
|
||||
return int(self.go.position.heading_between_point(conflict_center))
|
||||
|
||||
|
||||
class VehicleGroupGenerator(
|
||||
Generic[TgoT], GroupGenerator[VehicleGroup, Vehicle, Type[VehicleType], TgoT]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user