Adds prevention from passive monsters being "dodgy"
When player gets close to passive monsters they will stop moving now. This should prevent annoying behaviour when trying to line up a strike.
This commit is contained in:
parent
83a36db574
commit
c8386ee719
|
@ -152,6 +152,13 @@ map_move_monsters(Map *map, RoomMatrix *rm)
|
||||||
continue;
|
continue;
|
||||||
if (!position_in_room(&monster->sprite->pos, &map->currentRoom))
|
if (!position_in_room(&monster->sprite->pos, &map->currentRoom))
|
||||||
continue;
|
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);
|
allDone = allDone && monster_move(monster, rm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include "position.h"
|
#include "position.h"
|
||||||
#include "defines.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;
|
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
|
bool
|
||||||
position_in_room(Position *pos, Position *roomPos)
|
position_in_room(Position *pos, Position *roomPos)
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,6 +38,9 @@ position_in_room(Position *pos, Position *roomPos);
|
||||||
bool
|
bool
|
||||||
position_equals(const Position*, const Position*);
|
position_equals(const Position*, const Position*);
|
||||||
|
|
||||||
|
bool
|
||||||
|
position_proximity(unsigned int distance, const Position*, const Position*);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
position_in_roommatrix(const Position*);
|
position_in_roommatrix(const Position*);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue