Rework killed map_objects recognition

- removed the map_object_id from the TGO
- add a new TriggerRule with the MapObjectIsDead Condition which adds the map object to the killed_map_objects array in the state.json
- Use the trigger_zone_name as the unique identifier used for the unit_map to recognize the kill
This commit is contained in:
RndName
2021-12-31 17:10:23 +01:00
parent a013d27d17
commit abe76ea003
6 changed files with 40 additions and 18 deletions

View File

@@ -99,6 +99,9 @@ class StateData:
#: Names of vehicle (and ship) units that were killed during the mission.
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
#: the coordinate type ("x", "y", "z", "type", "orientation") to the value.
destroyed_statics: List[dict[str, Union[float, str]]]
@@ -117,6 +120,7 @@ class StateData:
# Also normalize dead map objects (which are ints) to strings. The unit map
# only stores strings.
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"],
base_capture_events=data["base_capture_events"],
)
@@ -318,6 +322,16 @@ class Debriefing:
losses.enemy_airlifts.append(airlift_unit)
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
def base_capture_events(self) -> List[BaseCaptureEvent]: