Fix seige units finding targets bug.
This commit is contained in:
parent
0e5c1843fe
commit
0f1221e033
3 changed files with 7 additions and 3 deletions
|
@ -146,6 +146,7 @@ class UnitAutomation{
|
|||
val tilesWithEnemies = unit.civInfo.viewableTiles
|
||||
.filter { containsAttackableEnemy(it, MapUnitCombatant(unit)) }
|
||||
|
||||
val minMovBeforeSetup = if (unit.hasUnique("Must set up to ranged attack") && unit.action != "Set Up" ) minMovementBeforeAttack+1.0f else minMovementBeforeAttack
|
||||
val rangeOfAttack = unit.getRange()
|
||||
|
||||
val attackableTiles = ArrayList<AttackableTile>()
|
||||
|
@ -155,7 +156,7 @@ class UnitAutomation{
|
|||
// So the poor unit thought it could attack from the tile, but when it comes to do so it has no movement points!
|
||||
// Silly floats, basically
|
||||
val tilesToAttackFrom = unitDistanceToTiles.asSequence()
|
||||
.filter { unit.currentMovement - it.value >= minMovementBeforeAttack }
|
||||
.filter { unit.currentMovement - it.value >= minMovBeforeSetup }
|
||||
.map { it.key }
|
||||
.filter { unit.canMoveTo(it) || it==unit.getTile() }
|
||||
|
||||
|
@ -534,4 +535,4 @@ class SpecificUnitAutomation{
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,7 +185,6 @@ class MapUnit {
|
|||
if(currentMovement==0f) return false
|
||||
if(attacksThisTurn>0 && !hasUnique("1 additional attack per turn")) return false
|
||||
if(attacksThisTurn>1) return false
|
||||
if(hasUnique("Must set up to ranged attack") && action != "Set Up") return false
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -153,6 +153,10 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
|||
attackButton.onClick {
|
||||
if (attacker is MapUnitCombatant) {
|
||||
attacker.unit.moveToTile(attackableEnemy!!.tileToAttackFrom)
|
||||
if (attacker.unit.hasUnique("Must set up to ranged attack") && attacker.unit.action != "Set Up") {
|
||||
attacker.unit.action = "Set Up"
|
||||
attacker.unit.useMovementPoints(1f)
|
||||
}
|
||||
}
|
||||
battle.attack(attacker, defender)
|
||||
worldScreen.shouldUpdate=true
|
||||
|
|
Loading…
Reference in a new issue