NPCHandler.java
find this:
underneath it add:Code:if (player.absX == npcs[i].absX && player.absY == npcs[i].absY) { stepAway(i); npcs[i].randomWalk = false; npcs[i].facePlayer(player.getIndex()); }
then add this somewhere:Code:if ((player.absX == npcs[i].absX-1 && player.absY == npcs[i].absY+1) || (player.absX == npcs[i].absX-1 && player.absY == npcs[i].absY-1) || (player.absX == npcs[i].absX+1 && player.absY == npcs[i].absY-1) || (player.absX == npcs[i].absX+1 && player.absY == npcs[i].absY+1)){ stepAway2(player,i); npcs[i].randomWalk = false; npcs[i].facePlayer(player.getIndex()); }
Code:public void stepAway2(Player player, int i) { int[][] points = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } }; for (int[] k : points) { int dir = NPCClipping.getDirection(k[0], k[1]); if (NPCDumbPathFinder.canMoveTo(npcs[i], dir)) { NPCDumbPathFinder.walkTowards(npcs[i], npcs[i].absX > player.absX ? player.absX-1 : player.absX+1 ,npcs[i].absY > player.absY ? player.absY+1 : player.absY-1); break; } } }




