mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-01 10:25:57 +07:00
Actually fix AI from pillaging neutral roads (#8137)
This commit is contained in:
parent
f244c36b57
commit
8b4aafe941
@ -352,7 +352,9 @@ object UnitAutomation {
|
|||||||
val unitDistanceToTiles = unit.movement.getDistanceToTiles()
|
val unitDistanceToTiles = unit.movement.getDistanceToTiles()
|
||||||
val tilesThatCanWalkToAndThenPillage = unitDistanceToTiles
|
val tilesThatCanWalkToAndThenPillage = unitDistanceToTiles
|
||||||
.filter { it.value.totalDistance < unit.currentMovement }.keys
|
.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
|
if (tilesThatCanWalkToAndThenPillage.isEmpty()) return false
|
||||||
val tileToPillage = tilesThatCanWalkToAndThenPillage.maxByOrNull { it.getDefensiveBonus() }!!
|
val tileToPillage = tilesThatCanWalkToAndThenPillage.maxByOrNull { it.getDefensiveBonus() }!!
|
||||||
|
@ -886,10 +886,7 @@ object UnitActions {
|
|||||||
if (!tile.canPillageTile()) return false
|
if (!tile.canPillageTile()) return false
|
||||||
val tileOwner = tile.getOwner()
|
val tileOwner = tile.getOwner()
|
||||||
// Can't pillage friendly tiles, just like you can't attack them - it's an 'act of war' thing
|
// Can't pillage friendly tiles, just like you can't attack them - it's an 'act of war' thing
|
||||||
return if (tileOwner != null)
|
return tileOwner == null || unit.civInfo.isAtWarWith(tileOwner)
|
||||||
unit.civInfo.isAtWarWith(tileOwner)
|
|
||||||
else if (tile.canPillageTile()) true
|
|
||||||
else (tile.canPillageRoad() && tile.roadOwner != "" && unit.civInfo.isAtWarWith(tile.getRoadOwner()!!))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addGiftAction(unit: MapUnit, actionList: ArrayList<UnitAction>, tile: TileInfo) {
|
private fun addGiftAction(unit: MapUnit, actionList: ArrayList<UnitAction>, tile: TileInfo) {
|
||||||
|
Loading…
Reference in New Issue
Block a user