diff --git a/src/combatsystem.py b/src/combatsystem.py index 9f84863..3ba347d 100644 --- a/src/combatsystem.py +++ b/src/combatsystem.py @@ -109,13 +109,13 @@ def check_projectile_collision(self): stun_ev = events.EntityStunned(collider_ID, attack.stun) self.event_manager.post(stun_ev) else: + #Enemy dies #Remove all projectiles of enemy for attack in self.world.attacks[collider_ID]: for projectile in attack.particles: projectile.life = -1 ev_die = events.EntityDies(projectile.entity_ID) self.event_manager.post(ev_die) - #Enemy dies ev_die = events.EntityDies(collider_ID) self.event_manager.post(ev_die) if not collider_ID == attacks_ID: @@ -135,6 +135,13 @@ def check_projectile_collision(self): def remove_dead_entities(self): for entity_ID in self.world.to_remove: + #make sure no ownerless projectile stays on the screen + if entity_ID in self.world.attacks: + for attack in self.world.attacks[entity_ID]: + for projectile in attack.particles: + projectile.life = -1 + ev_die = events.EntityDies(projectile.entity_ID) + self.event_manager.post(ev_die) self.world.destroy_entity(entity_ID) if entity_ID == self.world.player: self.reset_the_world = True @@ -204,4 +211,4 @@ def execute_attack(self, entity_ID, attack_Nr, spawn_attack_pos=None, attack_dir self.world.appearance[effect_ID].play_animation = True # def handle_collision(self, collider_ID, collidee_ID): -# pass \ No newline at end of file +# pass