mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Remove unused conflictgen globals
Remove unused `Conflict` properties mypy fixes Cleanup
This commit is contained in:
parent
da17d1e5d1
commit
967574820f
@ -38,7 +38,6 @@ class Event:
|
|||||||
location = None # type: Point
|
location = None # type: Point
|
||||||
from_cp = None # type: ControlPoint
|
from_cp = None # type: ControlPoint
|
||||||
to_cp = None # type: ControlPoint
|
to_cp = None # type: ControlPoint
|
||||||
|
|
||||||
operation = Operation
|
operation = Operation
|
||||||
difficulty = 1 # type: int
|
difficulty = 1 # type: int
|
||||||
BONUS_BASE = 5
|
BONUS_BASE = 5
|
||||||
@ -63,8 +62,6 @@ class Event:
|
|||||||
return int(math.log(self.to_cp.importance + 1, DIFFICULTY_LOG_BASE) * self.BONUS_BASE)
|
return int(math.log(self.to_cp.importance + 1, DIFFICULTY_LOG_BASE) * self.BONUS_BASE)
|
||||||
|
|
||||||
def generate(self) -> UnitMap:
|
def generate(self) -> UnitMap:
|
||||||
self.operation.ca_slots = self.ca_slots
|
|
||||||
|
|
||||||
self.operation.prepare(self.game)
|
self.operation.prepare(self.game)
|
||||||
unit_map = self.operation.generate()
|
unit_map = self.operation.generate()
|
||||||
self.operation.current_mission.save(
|
self.operation.current_mission.save(
|
||||||
|
|||||||
@ -14,9 +14,7 @@ from dcs.lua.parse import loads
|
|||||||
from dcs.mapping import Point
|
from dcs.mapping import Point
|
||||||
from dcs.translation import String
|
from dcs.translation import String
|
||||||
from dcs.triggers import TriggerStart
|
from dcs.triggers import TriggerStart
|
||||||
from dcs.unittype import UnitType
|
|
||||||
from game.plugins import LuaPluginManager
|
from game.plugins import LuaPluginManager
|
||||||
from game.theater import ControlPoint
|
|
||||||
from gen import Conflict, FlightType, VisualGenerator
|
from gen import Conflict, FlightType, VisualGenerator
|
||||||
from gen.aircraft import AIRCRAFT_DATA, AircraftConflictGenerator, FlightData
|
from gen.aircraft import AIRCRAFT_DATA, AircraftConflictGenerator, FlightData
|
||||||
from gen.airfields import AIRFIELD_DATA
|
from gen.airfields import AIRFIELD_DATA
|
||||||
@ -59,8 +57,7 @@ class Operation:
|
|||||||
player_awacs_enabled = True
|
player_awacs_enabled = True
|
||||||
# TODO: #436 Generate Air Support for red
|
# TODO: #436 Generate Air Support for red
|
||||||
enemy_awacs_enabled = True
|
enemy_awacs_enabled = True
|
||||||
is_awacs_enabled = False
|
ca_slots = 1
|
||||||
ca_slots = 0
|
|
||||||
unit_map: UnitMap
|
unit_map: UnitMap
|
||||||
jtacs: List[JtacInfo] = []
|
jtacs: List[JtacInfo] = []
|
||||||
plugin_scripts: List[str] = []
|
plugin_scripts: List[str] = []
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import logging
|
|||||||
import textwrap
|
import textwrap
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List, Optional, TYPE_CHECKING
|
from typing import List, Optional, TYPE_CHECKING, Type
|
||||||
|
|
||||||
from game.settings import Settings
|
from game.settings import Settings
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ class LuaPluginWorkOrder:
|
|||||||
self.mnemonic = mnemonic
|
self.mnemonic = mnemonic
|
||||||
self.disable = disable
|
self.disable = disable
|
||||||
|
|
||||||
def work(self, operation: Operation) -> None:
|
def work(self, operation: Type[Operation]) -> None:
|
||||||
if self.disable:
|
if self.disable:
|
||||||
operation.bypass_plugin_script(self.mnemonic)
|
operation.bypass_plugin_script(self.mnemonic)
|
||||||
else:
|
else:
|
||||||
@ -144,11 +144,11 @@ class LuaPlugin(PluginSettings):
|
|||||||
for option in self.definition.options:
|
for option in self.definition.options:
|
||||||
option.set_settings(self.settings)
|
option.set_settings(self.settings)
|
||||||
|
|
||||||
def inject_scripts(self, operation: Operation) -> None:
|
def inject_scripts(self, operation: Type[Operation]) -> None:
|
||||||
for work_order in self.definition.work_orders:
|
for work_order in self.definition.work_orders:
|
||||||
work_order.work(operation)
|
work_order.work(operation)
|
||||||
|
|
||||||
def inject_configuration(self, operation: Operation) -> None:
|
def inject_configuration(self, operation: Type[Operation]) -> None:
|
||||||
# inject the plugin options
|
# inject the plugin options
|
||||||
if self.options:
|
if self.options:
|
||||||
option_decls = []
|
option_decls = []
|
||||||
|
|||||||
@ -7,7 +7,7 @@ from dataclasses import dataclass
|
|||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
from itertools import tee
|
from itertools import tee
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, Iterator, List, Optional, Tuple, Union
|
from typing import Any, Dict, Iterator, List, Optional, Tuple, Union, cast
|
||||||
|
|
||||||
from dcs import Mission
|
from dcs import Mission
|
||||||
from dcs.countries import (
|
from dcs.countries import (
|
||||||
@ -471,7 +471,7 @@ class ConflictTheater:
|
|||||||
closest_distance = distance
|
closest_distance = distance
|
||||||
return closest
|
return closest
|
||||||
|
|
||||||
def closest_opposing_control_points(self) -> Tuple[ControlPoint]:
|
def closest_opposing_control_points(self) -> Tuple[ControlPoint, ControlPoint]:
|
||||||
"""
|
"""
|
||||||
Returns a tuple of the two nearest opposing ControlPoints in theater.
|
Returns a tuple of the two nearest opposing ControlPoints in theater.
|
||||||
(player_cp, enemy_cp)
|
(player_cp, enemy_cp)
|
||||||
@ -487,17 +487,19 @@ class ConflictTheater:
|
|||||||
closest_distance = dist
|
closest_distance = dist
|
||||||
if dist < closest_distance:
|
if dist < closest_distance:
|
||||||
distances[cp.id] = dist
|
distances[cp.id] = dist
|
||||||
closest_cp = min(distances, key=distances.get)
|
closest_cp_id = min(distances, key=distances.get) # type: ignore
|
||||||
all_cp_min_distances[(control_point.id, closest_cp)] = distances[closest_cp]
|
|
||||||
|
all_cp_min_distances[(control_point.id, closest_cp_id)] = distances[closest_cp_id]
|
||||||
closest_opposing_cps = [
|
closest_opposing_cps = [
|
||||||
self.find_control_point_by_id(i)
|
self.find_control_point_by_id(i)
|
||||||
for i
|
for i
|
||||||
in min(all_cp_min_distances, key=all_cp_min_distances.get)
|
in min(all_cp_min_distances, key=all_cp_min_distances.get) # type: ignore
|
||||||
] # type: List[ControlPoint]
|
] # type: List[ControlPoint]
|
||||||
|
assert len(closest_opposing_cps) == 2
|
||||||
if closest_opposing_cps[0].captured:
|
if closest_opposing_cps[0].captured:
|
||||||
return tuple(closest_opposing_cps)
|
return cast(Tuple[ControlPoint, ControlPoint], tuple(closest_opposing_cps))
|
||||||
else:
|
else:
|
||||||
return tuple(reversed(closest_opposing_cps))
|
return cast(Tuple[ControlPoint, ControlPoint], tuple(reversed(closest_opposing_cps)))
|
||||||
|
|
||||||
def find_control_point_by_id(self, id: int) -> ControlPoint:
|
def find_control_point_by_id(self, id: int) -> ControlPoint:
|
||||||
for i in self.controlpoints:
|
for i in self.controlpoints:
|
||||||
|
|||||||
@ -14,7 +14,6 @@ from dcs.task import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from game import db
|
from game import db
|
||||||
from game.operation.operation import Operation
|
|
||||||
from .naming import namegen
|
from .naming import namegen
|
||||||
from .callsigns import callsign_for_support_unit
|
from .callsigns import callsign_for_support_unit
|
||||||
from .conflictgen import Conflict
|
from .conflictgen import Conflict
|
||||||
@ -122,9 +121,10 @@ class AirSupportConflictGenerator:
|
|||||||
|
|
||||||
self.air_support.tankers.append(TankerInfo(str(tanker_group.name), callsign, variant, freq, tacan))
|
self.air_support.tankers.append(TankerInfo(str(tanker_group.name), callsign, variant, freq, tacan))
|
||||||
|
|
||||||
try:
|
awacs_unit = db.find_unittype(AWACS, self.conflict.attackers_side)[0]
|
||||||
|
if awacs_unit:
|
||||||
freq = self.radio_registry.alloc_uhf()
|
freq = self.radio_registry.alloc_uhf()
|
||||||
awacs_unit = db.find_unittype(AWACS, self.conflict.attackers_side)[0]
|
|
||||||
awacs_flight = self.mission.awacs_flight(
|
awacs_flight = self.mission.awacs_flight(
|
||||||
country=self.mission.country(self.game.player_country),
|
country=self.mission.country(self.game.player_country),
|
||||||
name=namegen.next_awacs_name(self.mission.country(self.game.player_country)),
|
name=namegen.next_awacs_name(self.mission.country(self.game.player_country)),
|
||||||
@ -142,6 +142,5 @@ class AirSupportConflictGenerator:
|
|||||||
|
|
||||||
self.air_support.awacs.append(AwacsInfo(
|
self.air_support.awacs.append(AwacsInfo(
|
||||||
str(awacs_flight.name), callsign_for_support_unit(awacs_flight), freq))
|
str(awacs_flight.name), callsign_for_support_unit(awacs_flight), freq))
|
||||||
except:
|
else:
|
||||||
Operation.player_awacs_enabled = False
|
|
||||||
logging.warning("No AWACS for faction")
|
logging.warning("No AWACS for faction")
|
||||||
@ -8,37 +8,8 @@ from dcs.mapping import Point
|
|||||||
from game.theater.conflicttheater import ConflictTheater, FrontLine
|
from game.theater.conflicttheater import ConflictTheater, FrontLine
|
||||||
from game.theater.controlpoint import ControlPoint
|
from game.theater.controlpoint import ControlPoint
|
||||||
|
|
||||||
AIR_DISTANCE = 40000
|
|
||||||
|
|
||||||
CAPTURE_AIR_ATTACKERS_DISTANCE = 25000
|
|
||||||
CAPTURE_AIR_DEFENDERS_DISTANCE = 60000
|
|
||||||
STRIKE_AIR_ATTACKERS_DISTANCE = 45000
|
|
||||||
STRIKE_AIR_DEFENDERS_DISTANCE = 25000
|
|
||||||
|
|
||||||
CAP_CAS_DISTANCE = 10000, 120000
|
|
||||||
|
|
||||||
GROUND_INTERCEPT_SPREAD = 5000
|
|
||||||
GROUND_DISTANCE_FACTOR = 1.4
|
|
||||||
GROUND_DISTANCE = 2000
|
|
||||||
|
|
||||||
GROUND_ATTACK_DISTANCE = 25000, 13000
|
|
||||||
|
|
||||||
TRANSPORT_FRONTLINE_DIST = 1800
|
|
||||||
|
|
||||||
INTERCEPT_ATTACKERS_HEADING = -45, 45
|
|
||||||
INTERCEPT_DEFENDERS_HEADING = -10, 10
|
|
||||||
INTERCEPT_CONFLICT_DISTANCE = 50000
|
|
||||||
INTERCEPT_ATTACKERS_DISTANCE = 100000
|
|
||||||
INTERCEPT_MAX_DISTANCE = 160000
|
|
||||||
INTERCEPT_MIN_DISTANCE = 100000
|
|
||||||
|
|
||||||
NAVAL_INTERCEPT_DISTANCE_FACTOR = 1
|
|
||||||
NAVAL_INTERCEPT_DISTANCE_MAX = 40000
|
|
||||||
NAVAL_INTERCEPT_STEP = 5000
|
|
||||||
|
|
||||||
FRONTLINE_LENGTH = 80000
|
FRONTLINE_LENGTH = 80000
|
||||||
FRONTLINE_MIN_CP_DISTANCE = 5000
|
|
||||||
FRONTLINE_DISTANCE_STRENGTH_FACTOR = 0.7
|
|
||||||
|
|
||||||
|
|
||||||
def _opposite_heading(h):
|
def _opposite_heading(h):
|
||||||
@ -98,10 +69,6 @@ class Conflict:
|
|||||||
def opposite_heading(self) -> int:
|
def opposite_heading(self) -> int:
|
||||||
return _heading_sum(self.heading, 180)
|
return _heading_sum(self.heading, 180)
|
||||||
|
|
||||||
@property
|
|
||||||
def to_size(self):
|
|
||||||
return self.to_cp.size * GROUND_DISTANCE_FACTOR
|
|
||||||
|
|
||||||
def find_ground_position(self, at: Point, heading: int, max_distance: int = 40000) -> Point:
|
def find_ground_position(self, at: Point, heading: int, max_distance: int = 40000) -> Point:
|
||||||
return Conflict._find_ground_position(at, max_distance, heading, self.theater)
|
return Conflict._find_ground_position(at, max_distance, heading, self.theater)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user