diff --git a/src/map.c b/src/map.c
index 06846cb..5f94edf 100644
--- a/src/map.c
+++ b/src/map.c
@@ -152,6 +152,13 @@ map_move_monsters(Map *map, RoomMatrix *rm)
continue;
if (!position_in_room(&monster->sprite->pos, &map->currentRoom))
continue;
+
+ // Prevent passive monsters from being "dodgy"
+ Position pos = position_to_matrix_coords(&monster->sprite->pos);
+ if (monster->state.current == PASSIVE
+ && position_proximity(1, &rm->playerRoomPos, &pos))
+ continue;
+
allDone = allDone && monster_move(monster, rm);
}
diff --git a/src/position.c b/src/position.c
index cd0249e..ddb8837 100644
--- a/src/position.c
+++ b/src/position.c
@@ -16,6 +16,7 @@
* along with this program. If not, see .
*/
+#include
#include "position.h"
#include "defines.h"
@@ -55,6 +56,19 @@ position_equals(const Position *p1, const Position *p2)
return p1->x == p2->x && p1->y == p2->y;
}
+bool
+position_proximity(unsigned int distance,
+ const Position *p1,
+ const Position *p2)
+{
+ unsigned int dx, dy;
+
+ dx = abs(p1->x - p2->x);
+ dy = abs(p1->y - p2->y);
+
+ return dx <= distance && dy <= distance;
+}
+
bool
position_in_room(Position *pos, Position *roomPos)
{
diff --git a/src/position.h b/src/position.h
index 4e20522..f894246 100644
--- a/src/position.h
+++ b/src/position.h
@@ -38,6 +38,9 @@ position_in_room(Position *pos, Position *roomPos);
bool
position_equals(const Position*, const Position*);
+bool
+position_proximity(unsigned int distance, const Position*, const Position*);
+
bool
position_in_roommatrix(const Position*);