mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Fix campaigns without frontline.
* Missions will now generate without a frontline conflict * Bulls is now defined as the nearest opposing airfield for each side
This commit is contained in:
parent
c501c45c52
commit
292ac42003
@ -86,6 +86,25 @@ class Operation:
|
||||
cls.game.enemy_country,
|
||||
frontline.position
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def air_conflict(cls) -> Conflict:
|
||||
assert cls.game
|
||||
player_cp, enemy_cp = cls.game.theater.closest_opposing_control_points()
|
||||
mid_point = player_cp.position.point_from_heading(
|
||||
player_cp.position.heading_between_point(enemy_cp.position),
|
||||
player_cp.position.distance_to_point(enemy_cp.position) / 2
|
||||
)
|
||||
return Conflict(
|
||||
cls.game.theater,
|
||||
player_cp,
|
||||
enemy_cp,
|
||||
cls.game.player_name,
|
||||
cls.game.enemy_name,
|
||||
cls.game.player_country,
|
||||
cls.game.enemy_country,
|
||||
mid_point
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _set_mission(cls, mission: Mission) -> None:
|
||||
@ -287,11 +306,8 @@ class Operation:
|
||||
cls.airsupportgen.air_support)
|
||||
cls._generate_ground_conflicts()
|
||||
|
||||
# TODO: This is silly, once Bulls position is defined without Conflict this should be removed.
|
||||
default_conflict = [i for i in cls.conflicts()][0]
|
||||
# Triggers
|
||||
triggersgen = TriggersGenerator(cls.current_mission, default_conflict,
|
||||
cls.game)
|
||||
triggersgen = TriggersGenerator(cls.current_mission, cls.game)
|
||||
triggersgen.generate()
|
||||
|
||||
# Setup combined arms parameters
|
||||
@ -334,13 +350,11 @@ class Operation:
|
||||
@classmethod
|
||||
def _generate_air_units(cls) -> None:
|
||||
"""Generate the air units for the Operation"""
|
||||
# TODO: this is silly, once AirSupportConflictGenerator doesn't require Conflict this can be removed.
|
||||
default_conflict = [i for i in cls.conflicts()][0]
|
||||
|
||||
# Air Support (Tanker & Awacs)
|
||||
assert cls.radio_registry and cls.tacan_registry
|
||||
cls.airsupportgen = AirSupportConflictGenerator(
|
||||
cls.current_mission, default_conflict, cls.game, cls.radio_registry,
|
||||
cls.current_mission, cls.air_conflict(), cls.game, cls.radio_registry,
|
||||
cls.tacan_registry)
|
||||
cls.airsupportgen.generate()
|
||||
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from dcs.action import MarkToAll
|
||||
from dcs.condition import TimeAfter
|
||||
from dcs.mission import Mission
|
||||
@ -12,6 +14,9 @@ from game.theater import Airfield
|
||||
from dcs.unitgroup import FlyingGroup
|
||||
from .conflictgen import Conflict
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from game.game import Game
|
||||
|
||||
PUSH_TRIGGER_SIZE = 3000
|
||||
PUSH_TRIGGER_ACTIVATION_AGL = 25
|
||||
|
||||
@ -34,9 +39,8 @@ class Silence(Option):
|
||||
|
||||
|
||||
class TriggersGenerator:
|
||||
def __init__(self, mission: Mission, conflict: Conflict, game):
|
||||
def __init__(self, mission: Mission, game: Game):
|
||||
self.mission = mission
|
||||
self.conflict = conflict # TODO: Move conflict out of this class. Only needed for bullseye position
|
||||
self.game = game
|
||||
|
||||
def _set_allegiances(self, player_coalition: str, enemy_coalition: str):
|
||||
@ -111,10 +115,11 @@ class TriggersGenerator:
|
||||
player_coalition = "blue"
|
||||
enemy_coalition = "red"
|
||||
|
||||
self.mission.coalition["blue"].bullseye = {"x": self.conflict.position.x,
|
||||
"y": self.conflict.position.y}
|
||||
self.mission.coalition["red"].bullseye = {"x": self.conflict.position.x,
|
||||
"y": self.conflict.position.y}
|
||||
player_cp, enemy_cp = self.game.theater.closest_opposing_control_points()
|
||||
self.mission.coalition["blue"].bullseye = {"x": enemy_cp.position.x,
|
||||
"y": enemy_cp.position.y}
|
||||
self.mission.coalition["red"].bullseye = {"x": player_cp.position.x,
|
||||
"y": player_cp.position.y}
|
||||
|
||||
self._set_skill(player_coalition, enemy_coalition)
|
||||
self._set_allegiances(player_coalition, enemy_coalition)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user