diff --git a/carball/json_parser/actor/car.py b/carball/json_parser/actor/car.py index d0cb2e74..706900ca 100644 --- a/carball/json_parser/actor/car.py +++ b/carball/json_parser/actor/car.py @@ -48,10 +48,34 @@ def update(self, actor: dict, frame_number: int, time: float, delta: float) -> N } def add_demo(self, actor, frame_number): - if 'TAGame.Car_TA:ReplicatedDemolish' in actor: + if 'TAGame.Car_TA:ReplicatedDemolishGoalExplosion' in actor: + demo_data = actor['TAGame.Car_TA:ReplicatedDemolishGoalExplosion'] + # add attacker and victim player ids + attacker_car_id = demo_data['attacker'] + + victim_car_id = demo_data['victim'] + if attacker_car_id != -1 and victim_car_id != -1 and attacker_car_id < 1e9 and victim_car_id < 1e9: + # Filter out weird stuff where it's not a demo + # frame 1 of 0732D41D4AF83D610AE2A988ACBC977A (rlcs season 4 eu) + attacker_player_id = self.parser.car_player_ids[attacker_car_id] + victim_player_id = self.parser.car_player_ids[victim_car_id] + if attacker_player_id != -1 and victim_player_id != -1: + demo_data['attacker_player_id'] = attacker_player_id + demo_data['victim_player_id'] = victim_player_id + # add frame_number + demo_data['frame_number'] = frame_number + self.parser.demos_data.append(demo_data) + logger.debug('ReplicatedDemolish: Att: %s, Def: %s' % + (attacker_player_id, victim_player_id)) + logger.debug('RepDemo Names: Att: %s. Def: %s' % + (self.parser.player_dicts[attacker_player_id]['name'], + self.parser.player_dicts[victim_player_id]['name'])) + actor.pop('TAGame.Car_TA:ReplicatedDemolishGoalExplosion') + elif 'TAGame.Car_TA:ReplicatedDemolish' in actor: demo_data = actor['TAGame.Car_TA:ReplicatedDemolish'] # add attacker and victim player ids attacker_car_id = demo_data['attacker'] + victim_car_id = demo_data['victim'] if attacker_car_id != -1 and victim_car_id != -1 and attacker_car_id < 1e9 and victim_car_id < 1e9: # Filter out weird stuff where it's not a demo diff --git a/carball/json_parser/frame_parser.py b/carball/json_parser/frame_parser.py index eeab6bc0..82563f89 100644 --- a/carball/json_parser/frame_parser.py +++ b/carball/json_parser/frame_parser.py @@ -153,6 +153,7 @@ def parse_frames(self): for new_actor in frame['new_actors']: actor_id = new_actor['actor_id'] object_name = self.objects[new_actor['object_id']] + self.actors[actor_id] = { 'Id': actor_id, 'TypeName': object_name,