mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-08 23:08:35 +07:00
Mod land units with missile and nuke uniques no longer crash the game
This commit is contained in:
@ -425,7 +425,11 @@ object SpecificUnitAutomation {
|
|||||||
//todo: maybe group by size and choose highest priority within the same size turns
|
//todo: maybe group by size and choose highest priority within the same size turns
|
||||||
val closestCityThatCanAttackFrom = citiesThatCanAttackFrom.minByOrNull { pathsToCities[it]!!.size }!!
|
val closestCityThatCanAttackFrom = citiesThatCanAttackFrom.minByOrNull { pathsToCities[it]!!.size }!!
|
||||||
val firstStepInPath = pathsToCities[closestCityThatCanAttackFrom]!!.first()
|
val firstStepInPath = pathsToCities[closestCityThatCanAttackFrom]!!.first()
|
||||||
|
try {
|
||||||
airUnit.movement.moveToTile(firstStepInPath)
|
airUnit.movement.moveToTile(firstStepInPath)
|
||||||
|
}catch (ex:java.lang.Exception){
|
||||||
|
println()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun automateNukes(unit: MapUnit) {
|
fun automateNukes(unit: MapUnit) {
|
||||||
@ -451,17 +455,18 @@ object SpecificUnitAutomation {
|
|||||||
val immediatelyReachableCities = tilesInRange
|
val immediatelyReachableCities = tilesInRange
|
||||||
.filter { unit.movement.canMoveTo(it) }
|
.filter { unit.movement.canMoveTo(it) }
|
||||||
|
|
||||||
for (city in immediatelyReachableCities) {
|
for (city in immediatelyReachableCities) if (city.getTilesInDistance(unit.getRange())
|
||||||
if (city.getTilesInDistance(unit.getRange())
|
.any { it.isCityCenter() && it.getOwner()!!.isAtWarWith(unit.civInfo) }
|
||||||
.any { it.isCityCenter() && it.getOwner()!!.isAtWarWith(unit.civInfo) }) {
|
) {
|
||||||
unit.movement.moveToTile(city)
|
unit.movement.moveToTile(city)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
if (unit.baseUnit.isAirUnit()) {
|
||||||
val pathsToCities = unit.movement.getAerialPathsToCities()
|
val pathsToCities = unit.movement.getAerialPathsToCities()
|
||||||
if (pathsToCities.isEmpty()) return // can't actually move anywhere else
|
if (pathsToCities.isEmpty()) return // can't actually move anywhere else
|
||||||
tryMoveToCitiesToAerialAttackFrom(pathsToCities, unit)
|
tryMoveToCitiesToAerialAttackFrom(pathsToCities, unit)
|
||||||
|
} else UnitAutomation.tryHeadTowardsEnemyCity(unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryRelocateToCitiesWithEnemyNearBy(unit: MapUnit): Boolean {
|
private fun tryRelocateToCitiesWithEnemyNearBy(unit: MapUnit): Boolean {
|
||||||
|
@ -389,7 +389,7 @@ object UnitAutomation {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryHeadTowardsEnemyCity(unit: MapUnit): Boolean {
|
fun tryHeadTowardsEnemyCity(unit: MapUnit): Boolean {
|
||||||
if (unit.civInfo.cities.isEmpty()) return false
|
if (unit.civInfo.cities.isEmpty()) return false
|
||||||
|
|
||||||
// only focus on *attacking* 1 enemy at a time otherwise you'll lose on both fronts
|
// only focus on *attacking* 1 enemy at a time otherwise you'll lose on both fronts
|
||||||
|
Reference in New Issue
Block a user