mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-20 01:07:40 +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 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() }!!
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user