Fix a few bugs related to nukes (#4324)

* Fixed bugs where nukes don't work due to capitilzation issues

* Renamed existing translations

* Fixed crash happening when nuking tiles without an owner

* Added notifications to attacker for civs that have declared war as a result of the nuke dropping
This commit is contained in:
Xander Lenstra 2021-07-01 21:18:37 +02:00 committed by GitHub
parent e80c7d2101
commit c350a3c923
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 9 deletions

View File

@ -1209,7 +1209,7 @@
"requiredTech": "Nuclear Fission",
"requiredResource": "Uranium",
"promotions" : ["Evasion"],
"uniques": ["Nuclear weapon of strength [1]", "Requires [Manhattan Project]", "Self-destructs when attacking",
"uniques": ["Nuclear weapon of Strength [1]", "Requires [Manhattan Project]", "Self-destructs when attacking",
"Blast radius [2]"],
"attackSound": "nuke"
// Plane rather than a missile - can be based in city or Carrier only.
@ -1259,7 +1259,7 @@
"range": 12,
"cost": 1000,
"requiredTech": "Advanced Ballistics",
"uniques": ["Self-destructs when attacking", "Nuclear weapon of strength [2]", "Requires [Manhattan Project]",
"uniques": ["Self-destructs when attacking", "Nuclear weapon of Strength [2]", "Requires [Manhattan Project]",
"Blast radius [2]", "Consumes [2] [Uranium]"],
"attackSound": "nuke"
},

View File

@ -3781,7 +3781,7 @@ Panzer = Panzer
Anti-Tank Gun = Panzerabwehr-Kanone
Nuclear weapon of strength [amount] = Atomwaffe der Stärke [amount]
Nuclear weapon of Strength [amount] = Atomwaffe der Stärke [amount]
Self-destructs when attacking = Selbstzerstörung beim Angriff
Blast radius [amount] = Explosionsradius [amount]

View File

@ -3784,7 +3784,7 @@ Panzer = Panzer
Anti-Tank Gun = Pansarvärnskanon
Nuclear weapon of strength [amount] = Kärnvapen av styrka [amount]
Nuclear weapon of Strength [amount] = Kärnvapen av Styrka [amount]
Self-destructs when attacking = Självdestruerar vid anfall
Blast radius [amount] = Sprängradie [amount]

View File

@ -443,6 +443,7 @@ An enemy [unit] was spotted in our territory =
[amount] enemy units were spotted near our territory =
[amount] enemy units were spotted in our territory =
A(n) [nukeType] exploded in our territory! =
After being hit by our [nukeType], [civName] has declared war on us!
The civilization of [civName] has been destroyed! =
The City-State of [name] has been destroyed! =
We have captured a barbarian encampment and recovered [goldAmount] gold! =

View File

@ -389,6 +389,7 @@ object Battle {
&& civSuffered.getDiplomacyManager(attackingCiv).diplomaticStatus != DiplomaticStatus.War
) {
attackingCiv.getDiplomacyManager(civSuffered).declareWar()
attackingCiv.addNotification("After being hit by our [${attacker.getName()}], [${civSuffered}] has declared war on us!", targetTile.position, NotificationIcon.War)
}
}
@ -397,8 +398,8 @@ object Battle {
else attacker.unit.getMatchingUniques("Blast radius []").first().params[0].toInt()
val strength = when {
(attacker.unit.hasUnique("Nuclear weapon of strength []")) ->
attacker.unit.getMatchingUniques("Nuclear weapon of strength []").first().params[0].toInt()
(attacker.unit.hasUnique("Nuclear weapon of Strength []")) ->
attacker.unit.getMatchingUniques("Nuclear weapon of Strength []").first().params[0].toInt()
// Deprecated since 3.15.3
(attacker.unit.hasUnique("Nuclear weapon")) -> 1
//
@ -409,8 +410,8 @@ object Battle {
val hitTiles = targetTile.getTilesInDistance(blastRadius)
// Declare war on the owners of all hit tiles
for (hitCiv in hitTiles.map { it.getOwner() }.distinct()) {
hitCiv!!.addNotification("A(n) [${attacker.getName()}] exploded in our territory!".tr(), targetTile.position, NotificationIcon.War)
for (hitCiv in hitTiles.mapNotNull { it.getOwner() }.distinct()) {
hitCiv.addNotification("A(n) [${attacker.getName()}] exploded in our territory!".tr(), targetTile.position, NotificationIcon.War)
tryDeclareWar(hitCiv)
}

View File

@ -263,7 +263,7 @@ class BaseUnit : INamed, IConstruction {
fun isGreatPerson() = uniqueObjects.any { it.placeholderText == "Great Person - []" }
// "Nuclear Weapon" unique deprecated since 3.15.4
fun isNuclearWeapon() = uniqueObjects.any { it.placeholderText == "Nuclear Weapon" || it.placeholderText == "Nuclear Weapon of strength []" }
fun isNuclearWeapon() = uniqueObjects.any { it.placeholderText == "Nuclear Weapon" || it.placeholderText == "Nuclear weapon of Strength []" }
fun movesLikeAirUnits() = unitType.isAirUnit() || unitType.isMissile()