mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-22 19:08:48 -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.
|
* Both [BattleTable.simulateNuke] and [AirUnitAutomation.automateNukes] check range, so that check is omitted here.
|
||||||
*/
|
*/
|
||||||
fun mayUseNuke(nuke: MapUnitCombatant, targetTile: Tile): Boolean {
|
fun mayUseNuke(nuke: MapUnitCombatant, targetTile: Tile): Boolean {
|
||||||
if (nuke.getTile() == targetTile) return false
|
val attackerCiv = nuke.getCivInfo()
|
||||||
// Can only nuke visible Tiles
|
val launchTile = nuke.getTile()
|
||||||
if (!targetTile.isVisible(nuke.getCivInfo())) return false
|
|
||||||
|
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
|
var canNuke = true
|
||||||
val attackerCiv = nuke.getCivInfo()
|
|
||||||
fun checkDefenderCiv(defenderCiv: Civilization?) {
|
fun checkDefenderCiv(defenderCiv: Civilization?) {
|
||||||
if (defenderCiv == null) return
|
if (defenderCiv == null) return
|
||||||
// Allow nuking yourself! (Civ5 source: CvUnit::isNukeVictim)
|
// 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 attackButton = "NUKE".toTextButton().apply { color = Color.RED }
|
||||||
|
|
||||||
val canReach = attacker.unit.currentTile.getTilesInDistance(attacker.unit.getRange()).contains(targetTile)
|
if (!worldScreen.isPlayersTurn || !attacker.canAttack() || !canNuke) {
|
||||||
|
|
||||||
if (!worldScreen.isPlayersTurn || !attacker.canAttack() || !canReach || !canNuke) {
|
|
||||||
attackButton.disable()
|
attackButton.disable()
|
||||||
attackButton.label.color = Color.GRAY
|
attackButton.label.color = Color.GRAY
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user