mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Reproducible unit naming
Splits infantry and other unit IDs. Resets IDs to start from zero at each press of "Takeoff" Direct access to the the `Game` class IDs is done on the `Operation` class to preserve save compat
This commit is contained in:
parent
436725b38e
commit
aa7825d4aa
@ -26,12 +26,12 @@ from gen.environmentgen import EnvironmentGenerator
|
||||
from gen.forcedoptionsgen import ForcedOptionsGenerator
|
||||
from gen.groundobjectsgen import GroundObjectsGenerator
|
||||
from gen.kneeboard import KneeboardGenerator
|
||||
from gen.naming import namegen
|
||||
from gen.radios import RadioFrequency, RadioRegistry
|
||||
from gen.tacan import TacanRegistry
|
||||
from gen.triggergen import TRIGGER_RADIUS_MEDIUM, TriggersGenerator
|
||||
|
||||
from .. import db
|
||||
from ..debriefing import Debriefing
|
||||
from ..theater import Airfield
|
||||
from ..unitmap import UnitMap
|
||||
|
||||
@ -69,6 +69,7 @@ class Operation:
|
||||
options_dict = loads(f.read())["options"]
|
||||
cls._set_mission(Mission(game.theater.terrain))
|
||||
cls.game = game
|
||||
cls.reset_naming_ids()
|
||||
cls._setup_mission_coalitions()
|
||||
cls.current_mission.options.load_from_dict(options_dict)
|
||||
|
||||
@ -86,7 +87,7 @@ class Operation:
|
||||
cls.game.enemy_country,
|
||||
frontline.position
|
||||
)
|
||||
|
||||
|
||||
@classmethod
|
||||
def air_conflict(cls) -> Conflict:
|
||||
assert cls.game
|
||||
@ -103,7 +104,7 @@ class Operation:
|
||||
cls.game.enemy_name,
|
||||
cls.game.player_country,
|
||||
cls.game.enemy_country,
|
||||
mid_point
|
||||
mid_point
|
||||
)
|
||||
|
||||
@classmethod
|
||||
@ -295,7 +296,7 @@ class Operation:
|
||||
heading=d["orientation"],
|
||||
dead=True,
|
||||
)
|
||||
|
||||
|
||||
@classmethod
|
||||
def generate(cls) -> UnitMap:
|
||||
"""Build the final Mission to be exported"""
|
||||
@ -349,7 +350,6 @@ class Operation:
|
||||
cls.jtacs,
|
||||
cls.airgen
|
||||
)
|
||||
|
||||
return cls.unit_map
|
||||
|
||||
@classmethod
|
||||
@ -411,6 +411,15 @@ class Operation:
|
||||
ground_conflict_gen.generate()
|
||||
cls.jtacs.extend(ground_conflict_gen.jtacs)
|
||||
|
||||
@classmethod
|
||||
def reset_naming_ids(cls):
|
||||
if not cls.game:
|
||||
logging.warning("Game object not initialized before resetting IDs")
|
||||
return
|
||||
cls.game.current_group_id = 0
|
||||
cls.game.current_unit_id = 0
|
||||
namegen.reset_numbers()
|
||||
|
||||
@classmethod
|
||||
def generate_lua(cls, airgen: AircraftConflictGenerator,
|
||||
airsupportgen: AirSupportConflictGenerator,
|
||||
|
||||
@ -9,6 +9,7 @@ ALPHA_MILITARY = ["Alpha","Bravo","Charlie","Delta","Echo","Foxtrot",
|
||||
|
||||
class NameGenerator:
|
||||
number = 0
|
||||
infantry_number = 0
|
||||
|
||||
ANIMALS = [
|
||||
"SHARK", "TORTOISE", "BAT", "PANGOLIN", "AARDWOLF",
|
||||
@ -45,14 +46,18 @@ class NameGenerator:
|
||||
def reset(self):
|
||||
self.number = 0
|
||||
self.ANIMALS = NameGenerator.ANIMALS.copy()
|
||||
|
||||
def reset_numbers(self):
|
||||
self.number = 0
|
||||
self.infantry_number = 0
|
||||
|
||||
def next_unit_name(self, country, parent_base_id, unit_type):
|
||||
self.number += 1
|
||||
return "unit|{}|{}|{}|{}|".format(country.id, self.number, parent_base_id, db.unit_type_name(unit_type))
|
||||
|
||||
def next_infantry_name(self, country, parent_base_id, unit_type):
|
||||
self.number += 1
|
||||
return "infantry|{}|{}|{}|{}|".format(country.id, self.number, parent_base_id, db.unit_type_name(unit_type))
|
||||
self.infantry_number += 1
|
||||
return "infantry|{}|{}|{}|{}|".format(country.id, self.infantry_number, parent_base_id, db.unit_type_name(unit_type))
|
||||
|
||||
def next_basedefense_name(self):
|
||||
return "basedefense_aa|0|0|"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user