mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Cleanup the killed map objects recognition
removed the extra array to track killed_map_objects and reuse the existing killed_ground_units routine to remove duplicate code and possible confusion
This commit is contained in:
parent
2d07ef717c
commit
4139258508
@ -96,12 +96,9 @@ class StateData:
|
|||||||
#: Names of aircraft units that were killed during the mission.
|
#: Names of aircraft units that were killed during the mission.
|
||||||
killed_aircraft: List[str]
|
killed_aircraft: List[str]
|
||||||
|
|
||||||
#: Names of vehicle (and ship) units that were killed during the mission.
|
#: Names of vehicles, ships or buildings that were killed during the mission.
|
||||||
killed_ground_units: List[str]
|
killed_ground_units: List[str]
|
||||||
|
|
||||||
#: Names of map objects that were killed during the mission.
|
|
||||||
killed_map_objects: list[str]
|
|
||||||
|
|
||||||
#: List of descriptions of destroyed statics. Format of each element is a mapping of
|
#: List of descriptions of destroyed statics. Format of each element is a mapping of
|
||||||
#: the coordinate type ("x", "y", "z", "type", "orientation") to the value.
|
#: the coordinate type ("x", "y", "z", "type", "orientation") to the value.
|
||||||
destroyed_statics: List[dict[str, Union[float, str]]]
|
destroyed_statics: List[dict[str, Union[float, str]]]
|
||||||
@ -120,7 +117,6 @@ class StateData:
|
|||||||
# Also normalize dead map objects (which are ints) to strings. The unit map
|
# Also normalize dead map objects (which are ints) to strings. The unit map
|
||||||
# only stores strings.
|
# only stores strings.
|
||||||
killed_ground_units=list({str(u) for u in data["killed_ground_units"]}),
|
killed_ground_units=list({str(u) for u in data["killed_ground_units"]}),
|
||||||
killed_map_objects=data["killed_map_objects"],
|
|
||||||
destroyed_statics=data["destroyed_objects_positions"],
|
destroyed_statics=data["destroyed_objects_positions"],
|
||||||
base_capture_events=data["base_capture_events"],
|
base_capture_events=data["base_capture_events"],
|
||||||
)
|
)
|
||||||
@ -322,16 +318,6 @@ class Debriefing:
|
|||||||
losses.enemy_airlifts.append(airlift_unit)
|
losses.enemy_airlifts.append(airlift_unit)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Find killed map objects and mark them as loss
|
|
||||||
for map_object in self.state_data.killed_map_objects:
|
|
||||||
building = self.unit_map.building_or_fortification(map_object)
|
|
||||||
if building is not None:
|
|
||||||
if building.ground_object.control_point.captured:
|
|
||||||
losses.player_buildings.append(building)
|
|
||||||
else:
|
|
||||||
losses.enemy_buildings.append(building)
|
|
||||||
continue
|
|
||||||
|
|
||||||
return losses
|
return losses
|
||||||
|
|
||||||
def base_capture_events(self) -> List[BaseCaptureEvent]:
|
def base_capture_events(self) -> List[BaseCaptureEvent]:
|
||||||
|
|||||||
@ -342,7 +342,7 @@ class SceneryGenerator(BuildingSiteGenerator):
|
|||||||
t = TriggerOnce(Event.NoEvent, f"MapObjectIsDead Trigger {trigger_zone.id}")
|
t = TriggerOnce(Event.NoEvent, f"MapObjectIsDead Trigger {trigger_zone.id}")
|
||||||
t.add_condition(MapObjectIsDead(trigger_zone.id))
|
t.add_condition(MapObjectIsDead(trigger_zone.id))
|
||||||
script_string = String(
|
script_string = String(
|
||||||
f'killed_map_objects[#killed_map_objects + 1] = "{trigger_zone.name}"'
|
f'killed_ground_units[#killed_ground_units + 1] = "{trigger_zone.name}"'
|
||||||
)
|
)
|
||||||
t.actions.append(DoScript(script_string))
|
t.actions.append(DoScript(script_string))
|
||||||
self.m.triggerrules.triggers.append(t)
|
self.m.triggerrules.triggers.append(t)
|
||||||
|
|||||||
@ -8,7 +8,6 @@ killed_aircrafts = {} -- killed aircraft will be added via S_EVENT_CRASH event
|
|||||||
killed_ground_units = {} -- killed units will be added via S_EVENT_DEAD event
|
killed_ground_units = {} -- killed units will be added via S_EVENT_DEAD event
|
||||||
base_capture_events = {}
|
base_capture_events = {}
|
||||||
destroyed_objects_positions = {} -- will be added via S_EVENT_DEAD event
|
destroyed_objects_positions = {} -- will be added via S_EVENT_DEAD event
|
||||||
killed_map_objects = {} -- killed map objects will be added via TriggerRules
|
|
||||||
mission_ended = false
|
mission_ended = false
|
||||||
|
|
||||||
local function ends_with(str, ending)
|
local function ends_with(str, ending)
|
||||||
@ -36,7 +35,6 @@ function write_state()
|
|||||||
["base_capture_events"] = base_capture_events,
|
["base_capture_events"] = base_capture_events,
|
||||||
["mission_ended"] = mission_ended,
|
["mission_ended"] = mission_ended,
|
||||||
["destroyed_objects_positions"] = destroyed_objects_positions,
|
["destroyed_objects_positions"] = destroyed_objects_positions,
|
||||||
["killed_map_objects"] = killed_map_objects,
|
|
||||||
}
|
}
|
||||||
if not json then
|
if not json then
|
||||||
local message = string.format("Unable to save DCS Liberation state to %s, JSON library is not loaded !", _debriefing_file_location)
|
local message = string.format("Unable to save DCS Liberation state to %s, JSON library is not loaded !", _debriefing_file_location)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user