Actually fix AI from pillaging neutral roads (#8137)

This commit is contained in:
itanasi 2022-12-14 21:20:32 -08:00 committed by GitHub
parent f244c36b57
commit 8b4aafe941
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

@ -352,7 +352,9 @@ object UnitAutomation {
val unitDistanceToTiles = unit.movement.getDistanceToTiles()
val tilesThatCanWalkToAndThenPillage = unitDistanceToTiles
.filter { it.value.totalDistance < unit.currentMovement }.keys
.filter { unit.movement.canMoveTo(it) && UnitActions.canPillage(unit, it) }
.filter { unit.movement.canMoveTo(it) && UnitActions.canPillage(unit, it)
&& (it.canPillageTileImprovement()
|| (it.canPillageRoad() && it.roadOwner != "" && unit.civInfo.isAtWarWith(it.getRoadOwner()!!)))}
if (tilesThatCanWalkToAndThenPillage.isEmpty()) return false
val tileToPillage = tilesThatCanWalkToAndThenPillage.maxByOrNull { it.getDefensiveBonus() }!!

View File

@ -886,10 +886,7 @@ object UnitActions {
if (!tile.canPillageTile()) return false
val tileOwner = tile.getOwner()
// Can't pillage friendly tiles, just like you can't attack them - it's an 'act of war' thing
return if (tileOwner != null)
unit.civInfo.isAtWarWith(tileOwner)
else if (tile.canPillageTile()) true
else (tile.canPillageRoad() && tile.roadOwner != "" && unit.civInfo.isAtWarWith(tile.getRoadOwner()!!))
return tileOwner == null || unit.civInfo.isAtWarWith(tileOwner)
}
private fun addGiftAction(unit: MapUnit, actionList: ArrayList<UnitAction>, tile: TileInfo) {