mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-09 15:29:32 +07:00
Automated Civilians don't multi-turn path through Enemy Territory (#9038)
This commit is contained in:
@ -237,6 +237,7 @@ class UnitMovement(val unit: MapUnit) {
|
|||||||
val newTilesToCheck = ArrayList<Tile>()
|
val newTilesToCheck = ArrayList<Tile>()
|
||||||
var considerZoneOfControl = true // only for first distance!
|
var considerZoneOfControl = true // only for first distance!
|
||||||
val visitedTiles: HashSet<Tile> = hashSetOf(currentTile)
|
val visitedTiles: HashSet<Tile> = hashSetOf(currentTile)
|
||||||
|
val civilization = unit.civ
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if (distance == 2) { // only set this once after distance > 1
|
if (distance == 2) { // only set this once after distance > 1
|
||||||
@ -261,6 +262,9 @@ class UnitMovement(val unit: MapUnit) {
|
|||||||
// Avoid damaging terrain on first pass
|
// Avoid damaging terrain on first pass
|
||||||
if (avoidDamagingTerrain && unit.getDamageFromTerrain(reachableTile) > 0)
|
if (avoidDamagingTerrain && unit.getDamageFromTerrain(reachableTile) > 0)
|
||||||
continue
|
continue
|
||||||
|
// Avoid Enemy Territory if Civilian and Automated. For multi-turn pathing
|
||||||
|
if (unit.isCivilian() && unit.isAutomated() && reachableTile.isEnemyTerritory(civilization))
|
||||||
|
continue
|
||||||
if (reachableTile == destination) {
|
if (reachableTile == destination) {
|
||||||
val path = mutableListOf(destination)
|
val path = mutableListOf(destination)
|
||||||
// Traverse the tree upwards to get the list of tiles leading to the destination
|
// Traverse the tree upwards to get the list of tiles leading to the destination
|
||||||
|
Reference in New Issue
Block a user