diff --git a/src/combatsystem.py b/src/combatsystem.py index 9f84863..76aff13 100644 --- a/src/combatsystem.py +++ b/src/combatsystem.py @@ -109,12 +109,7 @@ def check_projectile_collision(self): stun_ev = events.EntityStunned(collider_ID, attack.stun) self.event_manager.post(stun_ev) else: - #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) + self.remove_enemy_projectiles(collider_ID) #Enemy dies ev_die = events.EntityDies(collider_ID) self.event_manager.post(ev_die) @@ -135,11 +130,24 @@ 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: + self.remove_enemy_projectiles(entity_ID) self.world.destroy_entity(entity_ID) if entity_ID == self.world.player: self.reset_the_world = True self.world.to_remove = list() + + def remove_enemy_projectiles(self, enemy_ID): + for attack in self.world.attacks[enemy_ID]: + for projectile in attack.particles: + projectile.life = -1 + ev_die = events.EntityDies(projectile.entity_ID) + self.event_manager.post(ev_die) + + + def execute_attack(self, entity_ID, attack_Nr, spawn_attack_pos=None, attack_dir=None): """Entity executes one of its possible attacks if cooldown is ready. @@ -204,4 +212,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