Nukes don't require line of sight to hit target tile (#13618)

* can nuke in range without visibility

* can not nuke unexplored tiles

* remove redundant check

* getTilesInDistance instead of aerialDistanceTo

* revert suggested change
This commit is contained in:
metablaster 2025-07-15 10:52:42 +02:00 committed by GitHub
parent 8138a0b9c5
commit e0040588a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 7 deletions

View File

@ -29,12 +29,15 @@ object Nuke {
* Both [BattleTable.simulateNuke] and [AirUnitAutomation.automateNukes] check range, so that check is omitted here.
*/
fun mayUseNuke(nuke: MapUnitCombatant, targetTile: Tile): Boolean {
if (nuke.getTile() == targetTile) return false
// Can only nuke visible Tiles
if (!targetTile.isVisible(nuke.getCivInfo())) return false
val attackerCiv = nuke.getCivInfo()
val launchTile = nuke.getTile()
if (launchTile == targetTile) return false
if (!targetTile.isExplored(attackerCiv)) return false
// Can only nuke in unit's range, visibility (line of sight) doesn't matter
if (launchTile.aerialDistanceTo(targetTile) > nuke.unit.getRange()) return false
var canNuke = true
val attackerCiv = nuke.getCivInfo()
fun checkDefenderCiv(defenderCiv: Civilization?) {
if (defenderCiv == null) return
// Allow nuking yourself! (Civ5 source: CvUnit::isNukeVictim)

View File

@ -343,9 +343,7 @@ class BattleTable(val worldScreen: WorldScreen) : Table() {
val attackButton = "NUKE".toTextButton().apply { color = Color.RED }
val canReach = attacker.unit.currentTile.getTilesInDistance(attacker.unit.getRange()).contains(targetTile)
if (!worldScreen.isPlayersTurn || !attacker.canAttack() || !canReach || !canNuke) {
if (!worldScreen.isPlayersTurn || !attacker.canAttack() || !canNuke) {
attackButton.disable()
attackButton.label.color = Color.GRAY
}