From 1edaa1f74e9c71d8f53a5a78a6923315d6e01ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Czeka=C5=84ski?= Date: Sun, 26 Apr 2020 14:41:22 +0200 Subject: [PATCH] If A* destination is entity - disable stepping on it Player shouldn't step on berry or rabbit, etc... --- src/AI/AutomaticMovement.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/AI/AutomaticMovement.py b/src/AI/AutomaticMovement.py index 8f958c9..63cb7c3 100644 --- a/src/AI/AutomaticMovement.py +++ b/src/AI/AutomaticMovement.py @@ -72,6 +72,11 @@ class AutomaticMovement: if self.goalTest(elem.state): movesList = [] + + coordsWithUiOffset = [elem.state[0] + self.leftUiWidth, elem.state[0]] + if self.map.getEntityOnCoord(coordsWithUiOffset) is not None: # If goal was some entity - omit one forward movement, because player shouldn't step on entity. + elem = elem.parent + while elem.action is not None: movesList.append(elem.action) elem = elem.parent