New pathfinding that avoids most of the mobs getting stuck, closes #35
This commit is contained in:
@ -43,11 +43,14 @@ class Monster(FightingEntity):
|
||||
# If they can't move and they are already close to the player,
|
||||
# They hit.
|
||||
if target and (self.y, self.x) in target.paths:
|
||||
# Move to target player
|
||||
next_y, next_x = target.paths[(self.y, self.x)]
|
||||
moved = self.check_move(next_y, next_x, True)
|
||||
if not moved and self.distance_squared(target) <= 1:
|
||||
self.map.logs.add_message(self.hit(target))
|
||||
# Move to target player by choosing the best avaliable path
|
||||
for next_y, next_x in target.paths[(self.y, self.x)]:
|
||||
moved = self.check_move(next_y, next_x, True)
|
||||
if moved:
|
||||
break
|
||||
if self.distance_squared(target) <= 1:
|
||||
self.map.logs.add_message(self.hit(target))
|
||||
break
|
||||
else:
|
||||
# Move in a random direction
|
||||
# If the direction is not available, try another one
|
||||
|
Reference in New Issue
Block a user