Automated Civilians don't multi-turn path through Enemy Territory (#9038)

This commit is contained in:
itanasi
2023-03-26 01:47:45 -07:00
committed by GitHub
parent 879cb5ea4a
commit e18a964a28

View File

@ -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