mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Fixing issues after using actual Country in Faction
This commit is contained in:
parent
cca45d3729
commit
da109146c9
@ -19,7 +19,6 @@ from game.ato.flightstate import Completed
|
||||
from game.ato.flighttype import FlightType
|
||||
from game.ato.package import Package
|
||||
from game.ato.starttype import StartType
|
||||
from game.factions.faction import Faction
|
||||
from game.missiongenerator.lasercoderegistry import LaserCodeRegistry
|
||||
from game.missiongenerator.missiondata import MissionData
|
||||
from game.radio.radios import RadioRegistry
|
||||
@ -159,14 +158,12 @@ class AircraftGenerator:
|
||||
|
||||
for squadron in control_point.squadrons:
|
||||
try:
|
||||
self._spawn_unused_for(squadron, country, faction)
|
||||
self._spawn_unused_for(squadron, country)
|
||||
except NoParkingSlotError:
|
||||
# If we run out of parking, stop spawning aircraft at this base.
|
||||
break
|
||||
|
||||
def _spawn_unused_for(
|
||||
self, squadron: Squadron, country: Country, faction: Faction
|
||||
) -> None:
|
||||
def _spawn_unused_for(self, squadron: Squadron, country: Country) -> None:
|
||||
assert isinstance(squadron.location, Airfield)
|
||||
for _ in range(squadron.untasked_aircraft):
|
||||
# Creating a flight even those this isn't a fragged mission lets us
|
||||
|
||||
@ -30,8 +30,12 @@ class CargoShipGenerator:
|
||||
|
||||
def generate_cargo_ship(self, ship: CargoShip) -> ShipGroup:
|
||||
waypoints = ship.route
|
||||
|
||||
country = self.game.coalition_for(ship.player_owned).faction.country
|
||||
country = self.mission.country(country.name)
|
||||
|
||||
group = self.mission.ship_group(
|
||||
self.game.coalition_for(ship.player_owned).faction.country,
|
||||
country,
|
||||
ship.name,
|
||||
HandyWind,
|
||||
position=waypoints[0],
|
||||
|
||||
@ -76,9 +76,10 @@ class ConvoyGenerator:
|
||||
main_unit_type, main_unit_count = unit_types[0]
|
||||
|
||||
faction = self.game.coalition_for(for_player).faction
|
||||
country = self.mission.country(faction.country.name)
|
||||
|
||||
group = self.mission.vehicle_group(
|
||||
faction.country,
|
||||
country,
|
||||
name,
|
||||
main_unit_type.dcs_unit_type,
|
||||
position=position,
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import math
|
||||
import random
|
||||
from datetime import timedelta
|
||||
@ -159,8 +158,9 @@ class FlotGenerator:
|
||||
if utype is None:
|
||||
utype = AircraftType.named("MQ-9 Reaper")
|
||||
|
||||
country = self.mission.country(self.game.blue.faction.country.name)
|
||||
jtac = self.mission.flight_group(
|
||||
country=self.game.blue.faction.country,
|
||||
country=country,
|
||||
name=namegen.next_jtac_name(),
|
||||
aircraft_type=utype.dcs_unit_type,
|
||||
position=position[0],
|
||||
@ -753,6 +753,7 @@ class FlotGenerator:
|
||||
self.conflict.heading.left if is_player else self.conflict.heading.right
|
||||
)
|
||||
country = self.game.coalition_for(is_player).faction.country
|
||||
country = self.mission.country(country.name)
|
||||
for group in groups:
|
||||
if group.role == CombatGroupRole.ARTILLERY:
|
||||
distance_from_frontline = (
|
||||
|
||||
@ -43,13 +43,6 @@ if TYPE_CHECKING:
|
||||
from game import Game
|
||||
|
||||
|
||||
def country_id_from_name(name: str) -> int:
|
||||
for k, v in country_dict.items():
|
||||
if v.name == name:
|
||||
return k
|
||||
return -1
|
||||
|
||||
|
||||
class MissionGenerator:
|
||||
def __init__(self, game: Game, time: datetime) -> None:
|
||||
self.game = game
|
||||
@ -65,6 +58,9 @@ class MissionGenerator:
|
||||
|
||||
self.generation_started = False
|
||||
|
||||
self.p_country = country_dict[self.game.blue.faction.country.id]()
|
||||
self.e_country = country_dict[self.game.red.faction.country.id]()
|
||||
|
||||
with open("resources/default_options.lua", "r", encoding="utf-8") as f:
|
||||
options = dcs.lua.loads(f.read())["options"]
|
||||
ext_view = game.settings.external_views_allowed
|
||||
@ -133,15 +129,13 @@ class MissionGenerator:
|
||||
"neutrals", bullseye=Bullseye(Point(0, 0, self.mission.terrain)).to_pydcs()
|
||||
)
|
||||
|
||||
p_country = self.game.blue.faction.country
|
||||
e_country = self.game.red.faction.country
|
||||
self.mission.coalition["blue"].add_country(p_country)
|
||||
self.mission.coalition["red"].add_country(e_country)
|
||||
self.mission.coalition["blue"].add_country(self.p_country)
|
||||
self.mission.coalition["red"].add_country(self.e_country)
|
||||
|
||||
belligerents = {p_country, e_country}
|
||||
for country in country_dict.keys():
|
||||
if country not in belligerents:
|
||||
self.mission.coalition["neutrals"].add_country(country_dict[country]())
|
||||
belligerents = {self.p_country.id, self.e_country.id}
|
||||
for country_id in country_dict.keys():
|
||||
if country_id not in belligerents:
|
||||
self.mission.coalition["neutrals"].add_country(country_dict[country_id]())
|
||||
|
||||
def add_airfields_to_unit_map(self) -> None:
|
||||
for control_point in self.game.theater.controlpoints:
|
||||
@ -236,19 +230,19 @@ class MissionGenerator:
|
||||
aircraft_generator.clear_parking_slots()
|
||||
|
||||
aircraft_generator.generate_flights(
|
||||
self.game.blue.faction.country,
|
||||
self.p_country,
|
||||
self.game.blue.ato,
|
||||
tgo_generator.runways,
|
||||
)
|
||||
aircraft_generator.generate_flights(
|
||||
self.game.red.faction.country,
|
||||
self.e_country,
|
||||
self.game.red.ato,
|
||||
tgo_generator.runways,
|
||||
)
|
||||
if not self.game.settings.perf_disable_idle_aircraft:
|
||||
aircraft_generator.spawn_unused_aircraft(
|
||||
self.game.blue.faction.country,
|
||||
self.game.red.faction.country,
|
||||
self.p_country,
|
||||
self.e_country,
|
||||
)
|
||||
|
||||
self.mission_data.flights = aircraft_generator.flights
|
||||
@ -278,7 +272,7 @@ class MissionGenerator:
|
||||
pos = Point(cast(float, d["x"]), cast(float, d["z"]), self.mission.terrain)
|
||||
if utype is not None and not self.game.position_culled(pos):
|
||||
self.mission.static_group(
|
||||
country=self.game.blue.faction.country,
|
||||
country=self.p_country,
|
||||
name="",
|
||||
_type=utype,
|
||||
hidden=True,
|
||||
|
||||
@ -687,7 +687,7 @@ class TgoGenerator:
|
||||
|
||||
def generate(self) -> None:
|
||||
for cp in self.game.theater.controlpoints:
|
||||
country = self.game.coalition_for(cp.captured).faction.country
|
||||
country = self.m.country(cp.coalition.faction.country.name)
|
||||
|
||||
# Generate helipads
|
||||
helipad_gen = HelipadGenerator(
|
||||
|
||||
@ -73,6 +73,7 @@ class VisualsGenerator:
|
||||
self.game = game
|
||||
|
||||
def _generate_frontline_smokes(self) -> None:
|
||||
country = self.mission.country(self.game.red.faction.country.name)
|
||||
for front_line in self.game.theater.conflicts():
|
||||
from_cp = front_line.blue_cp
|
||||
to_cp = front_line.red_cp
|
||||
@ -99,7 +100,7 @@ class VisualsGenerator:
|
||||
break
|
||||
|
||||
self.mission.static_group(
|
||||
self.game.red.faction.country,
|
||||
country,
|
||||
"",
|
||||
_type=v,
|
||||
position=pos,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user