From ada3564713e212dbef6576e02d5e395bd4af15d1 Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Sun, 17 May 2020 01:02:07 +0200 Subject: [PATCH] Fixed issue with targets forwards to player --- src/entities/Entity.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/entities/Entity.py b/src/entities/Entity.py index 8b8ecf0..10514bc 100644 --- a/src/entities/Entity.py +++ b/src/entities/Entity.py @@ -218,14 +218,17 @@ class Entity(pygame.sprite.Sprite): self.movementTarget = target from src.AI.AutomaticMovement import aStar self.movesList = aStar(self, self.movementTarget, map) - if not self.movesList: - self.movementTarget = None def updateEntityCoords(self): """ Called each frame. Will consume moves from the moveList, if there are any. """ + # Special case, where the selected entitiy was directly forwards the player + if self.movementTarget is not None and not self.movesList: + self.movementTarget.on_interaction(self) + self.movementTarget = None + if self.movementTarget is not None and self.movesList: nextMove = self.movesList[0] if self.move(nextMove):