From ba33e2266d873029174884d5f5e8664ca324e3f9 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sat, 26 Oct 2019 21:18:17 +0300 Subject: [PATCH] Resolved #1230 - sleeping units wake up if there's an enemy nearby --- core/src/com/unciv/logic/map/MapUnit.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index 9593f4a952..02e2b823fb 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -384,6 +384,13 @@ class MapUnit { currentMovement = getMaxMovement().toFloat() attacksThisTurn=0 due = true + + // Wake sleeping units if there's an enemy nearby + if(action==Constants.unitActionSleep && currentTile.getTilesInDistance(2).any { + it.militaryUnit!=null && it.militaryUnit!!.civInfo.isAtWarWith(civInfo) + }) + action=null + val tileOwner = getTile().getOwner() if(tileOwner!=null && !civInfo.canEnterTiles(tileOwner) && !tileOwner.isCityState()) // if an enemy city expanded onto this tile while I was in it movement.teleportToClosestMoveableTile()