Even a NPC with a 1x1 spawn area can track a player down.

This commit is contained in:
Zukero
2017-10-02 19:04:27 +02:00
parent afadac0f2f
commit 716b96b624
2 changed files with 14 additions and 10 deletions

View File

@@ -13,6 +13,7 @@
"attackChance": 50,
"droplistID": "debugshop1",
"phraseID": "debugshop",
"movementAggressionType":"wholeMap",
"attackDamage": {
"min": 1,
"max": 2
@@ -85,6 +86,7 @@
"attackCost": 10,
"attackChance": 50,
"droplistID": "debuglist1",
"movementAggressionType":"wholeMap",
"attackDamage": {
"min": 1,
"max": 2

View File

@@ -76,15 +76,7 @@ public final class MonsterMovementController implements EvaluateWalkable {
PredefinedMap map = world.model.currentMap;
LayeredTileMap tileMap = world.model.currentTileMap;
m.nextActionTime = System.currentTimeMillis() + getMillisecondsPerMove(m);
if (m.movementDestination == null) {
// Monster has waited and should start to move again.
m.movementDestination = new Coord(m.position);
if (Constants.rnd.nextBoolean()) {
m.movementDestination.x = area.area.topLeft.x + Constants.rnd.nextInt(area.area.size.width);
} else {
m.movementDestination.y = area.area.topLeft.y + Constants.rnd.nextInt(area.area.size.height);
}
} else if (m.position.equals(m.movementDestination)) {
if (m.movementDestination != null && m.position.equals(m.movementDestination)) {
// Monster has been moving and arrived at the destination.
cancelCurrentMonsterMovement(m);
} else {
@@ -119,7 +111,17 @@ public final class MonsterMovementController implements EvaluateWalkable {
if (findPathFor(m, playerPosition)) return;
}
// }
// Monster has waited and should start to move again.
if (m.movementDestination == null) {
m.movementDestination = new Coord(m.position);
if (Constants.rnd.nextBoolean()) {
m.movementDestination.x = area.area.topLeft.x + Constants.rnd.nextInt(area.area.size.width);
} else {
m.movementDestination.y = area.area.topLeft.y + Constants.rnd.nextInt(area.area.size.height);
}
}
// Monster is moving in a straight line.
m.nextPosition.topLeft.set(
m.position.x + sgn(m.movementDestination.x - m.position.x)