mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-22 10:54:19 -04:00
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:
parent
8138a0b9c5
commit
e0040588a0
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user