mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Ground objects are always generated and destroyable, even when it's not the current mission objective.
Fix : SAM site destruction status is saved correctly. Added most SAM site to generator.
This commit is contained in:
@@ -1018,8 +1018,7 @@ def unit_task(unit: UnitType) -> Task:
|
||||
return unit_task(SAM_CONVERT[unit])
|
||||
|
||||
print(unit.name + " cause issue")
|
||||
assert False
|
||||
|
||||
return None
|
||||
|
||||
def find_unittype(for_task: Task, country_name: str) -> typing.List[UnitType]:
|
||||
return [x for x in UNIT_BY_TASK[for_task] if x in FACTIONS[country_name]["units"]]
|
||||
|
||||
@@ -15,6 +15,8 @@ from game.db import assigned_units_from, unitdict_from
|
||||
from userdata.debriefing import Debriefing
|
||||
from userdata import persistency
|
||||
|
||||
import game.db as db
|
||||
|
||||
DIFFICULTY_LOG_BASE = 1.1
|
||||
EVENT_DEPARTURE_MAX_DISTANCE = 340000
|
||||
|
||||
@@ -127,6 +129,23 @@ class Event:
|
||||
self.operation.current_mission.save(persistency.mission_path_for("liberation_nextturn_quick.miz"))
|
||||
|
||||
def commit(self, debriefing: Debriefing):
|
||||
|
||||
for destroyed_unit_name in debriefing.dead_units_name:
|
||||
|
||||
for cp in self.game.theater.controlpoints:
|
||||
|
||||
for i, ground_object in enumerate(cp.ground_objects):
|
||||
if ground_object.dcs_identifier == "AA":
|
||||
for g in ground_object.groups:
|
||||
for u in g.units:
|
||||
if u.name == destroyed_unit_name:
|
||||
g.units.remove(u)
|
||||
ucount = sum([len(g.units) for g in ground_object.groups])
|
||||
print(ucount)
|
||||
if ucount == 0:
|
||||
print("SET DEAD")
|
||||
ground_object.is_dead = True
|
||||
|
||||
for country, losses in debriefing.destroyed_units.items():
|
||||
if country == self.attacker_name:
|
||||
cp = self.departure_cp
|
||||
|
||||
16
game/game.py
16
game/game.py
@@ -96,6 +96,9 @@ class Game:
|
||||
turn = 0
|
||||
game_stats: GameStats = None
|
||||
|
||||
current_unit_id = 0
|
||||
current_group_id = 0
|
||||
|
||||
def __init__(self, player_name: str, enemy_name: str, theater: ConflictTheater, start_date: datetime):
|
||||
self.settings = Settings()
|
||||
self.events = []
|
||||
@@ -315,3 +318,16 @@ class Game:
|
||||
def current_day(self):
|
||||
return self.date + timedelta(days=self.turn//4)
|
||||
|
||||
def next_unit_id(self):
|
||||
"""
|
||||
Next unit id for pre-generated units
|
||||
"""
|
||||
self.current_unit_id += 1
|
||||
return self.current_unit_id
|
||||
|
||||
def next_group_id(self):
|
||||
"""
|
||||
Next unit id for pre-generated units
|
||||
"""
|
||||
self.current_group_id += 1
|
||||
return self.current_group_id
|
||||
|
||||
@@ -86,7 +86,9 @@ class Operation:
|
||||
options_dict = loads(f.read())["options"]
|
||||
|
||||
dcs.Mission.aaa_vehicle_group = aaa.aaa_vehicle_group
|
||||
|
||||
self.current_mission = dcs.Mission(terrain)
|
||||
|
||||
if is_quick:
|
||||
self.quick_mission = self.current_mission
|
||||
else:
|
||||
@@ -117,6 +119,10 @@ class Operation:
|
||||
self.defenders_starting_position = ship
|
||||
|
||||
def generate(self):
|
||||
|
||||
# Generate ground object first
|
||||
self.groundobjectgen.generate()
|
||||
|
||||
# air support
|
||||
self.airsupportgen.generate(self.is_awacs_enabled)
|
||||
for i, tanker_type in enumerate(self.airsupportgen.generated_tankers):
|
||||
@@ -132,8 +138,6 @@ class Operation:
|
||||
else:
|
||||
self.current_mission.groundControl.red_tactical_commander = self.ca_slots
|
||||
|
||||
# ground infrastructure
|
||||
self.groundobjectgen.generate()
|
||||
self.extra_aagen.generate()
|
||||
|
||||
# triggers
|
||||
|
||||
Reference in New Issue
Block a user