Made mobs check if they can see the player

This commit is contained in:
Nicolas Margulies
2021-01-08 17:26:56 +01:00
parent 4a80dc36ad
commit 46a5dc6931
2 changed files with 16 additions and 3 deletions

View File

@ -42,7 +42,9 @@ class Monster(FightingEntity):
# that targets the player.
# If they can not move and are already close to the player,
# they hit.
if target and (self.y, self.x) in target.paths:
if target and (self.y, self.x) in target.paths and \
self.map.is_visible_from(self.y, self.x,
target.y, target.x, 5):
# Moves to target player by choosing the best available path
for next_y, next_x in target.paths[(self.y, self.x)]:
moved = self.check_move(next_y, next_x, True)