From 60edd73fc2593b7a48fd9b1a06cd19e724351c99 Mon Sep 17 00:00:00 2001 From: Zukero Date: Mon, 2 Oct 2017 16:32:31 +0200 Subject: [PATCH 1/3] Removed unnecessary warnings about replace area requirement-related properties. Added code to clear the "isApplied" flag on a replace area when another replace area is applied later and intersects with the first one. --- .../com/gpl/rpg/AndorsTrail/controller/MapController.java | 7 +++++++ .../gpl/rpg/AndorsTrail/model/map/TMXMapTranslator.java | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MapController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MapController.java index 2dcf06894..acced11b8 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MapController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MapController.java @@ -186,6 +186,13 @@ public final class MapController { if (!satisfiesCondition(replacement)) continue; else ConversationController.requirementFulfilled(world, replacement.requirement); tileMap.applyReplacement(replacement); + for (ReplaceableMapSection impactedReplacement : tileMap.replacements) { + if (impactedReplacement.isApplied && impactedReplacement.replacementArea.intersects(replacement.replacementArea)) { + //The applied replacement has overwritten changes made by a previously applied replacement. + //This previous replacement must now be considered as unapplied to let it be reapplied later eventually. + impactedReplacement.isApplied = false; + } + } hasUpdated = true; } } diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapTranslator.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapTranslator.java index c85491380..aed27b394 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapTranslator.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/model/map/TMXMapTranslator.java @@ -288,7 +288,8 @@ public final class TMXMapTranslator { else if (prop.name.equalsIgnoreCase(LAYERNAME_ABOVE)) layerNames.aboveLayersName = prop.value; else if (prop.name.equalsIgnoreCase(LAYERNAME_WALKABLE)) layerNames.walkableLayersName = prop.value; else if (AndorsTrailApplication.DEVELOPMENT_VALIDATEDATA) { - L.log("OPTIMIZE: Map " + map.name + " contains replace area with unknown property \"" + prop.name + "\"."); + if (!requirementPropertiesNames.contains(prop.name)) + L.log("OPTIMIZE: Map " + map.name + " contains replace area with unknown property \"" + prop.name + "\"."); } } MapSection replacementSection = transformMapSection(map, tileCache, position, layersPerLayerName, usedTileIDs, layerNames); From afadac0f2f41428d2a77c77c672c5dd87259d89d Mon Sep 17 00:00:00 2001 From: Zukero Date: Mon, 2 Oct 2017 18:24:05 +0200 Subject: [PATCH 2/3] NPCs don't need to be aggressive to "pathfind" the player anymore. --- .../rpg/AndorsTrail/controller/MonsterMovementController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java index f31fd7c62..145a4aca4 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java @@ -108,7 +108,7 @@ public final class MonsterMovementController implements EvaluateWalkable { } private void determineMonsterNextPosition(Monster m, MonsterSpawnArea area, Coord playerPosition) { - if (m.isAgressive()) { +// if (m.isAgressive()) { boolean searchForPath = false; if (m.getMovementAggressionType() == MonsterType.AggressionType.protectSpawn) { if (area.area.contains(playerPosition)) searchForPath = true; @@ -118,7 +118,7 @@ public final class MonsterMovementController implements EvaluateWalkable { if (searchForPath) { if (findPathFor(m, playerPosition)) return; } - } +// } // Monster is moving in a straight line. m.nextPosition.topLeft.set( From 716b96b6245d065ee55d956272ea9bbf2422073e Mon Sep 17 00:00:00 2001 From: Zukero Date: Mon, 2 Oct 2017 19:04:27 +0200 Subject: [PATCH 3/3] Even a NPC with a 1x1 spawn area can track a player down. --- AndorsTrail/res/raw/monsterlist_debug.json | 2 ++ .../controller/MonsterMovementController.java | 22 ++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/AndorsTrail/res/raw/monsterlist_debug.json b/AndorsTrail/res/raw/monsterlist_debug.json index 81dcb97d8..bfad50ac0 100644 --- a/AndorsTrail/res/raw/monsterlist_debug.json +++ b/AndorsTrail/res/raw/monsterlist_debug.json @@ -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 diff --git a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java index 145a4aca4..2759de0bb 100644 --- a/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java +++ b/AndorsTrail/src/com/gpl/rpg/AndorsTrail/controller/MonsterMovementController.java @@ -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)