mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 21:35:14 -04:00
Resolved #4629 - atomic bomb interception works as intended
This commit is contained in:
parent
b62c56d175
commit
775f42aa0d
@ -44,7 +44,7 @@ object Battle {
|
|||||||
val attackedTile = defender.getTile()
|
val attackedTile = defender.getTile()
|
||||||
|
|
||||||
if (attacker is MapUnitCombatant && attacker.getUnitType().isAirUnit()) {
|
if (attacker is MapUnitCombatant && attacker.getUnitType().isAirUnit()) {
|
||||||
tryInterceptAirAttack(attacker, defender)
|
tryInterceptAirAttack(attacker, attackedTile, defender.getCivInfo())
|
||||||
if (attacker.isDefeated()) return
|
if (attacker.isDefeated()) return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,10 +505,10 @@ object Battle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Declare war on all potentially hit units. They'll try to intercept the nuke before it drops
|
// Declare war on all potentially hit units. They'll try to intercept the nuke before it drops
|
||||||
for (hitUnit in hitTiles.map { it.getUnits() }.flatten()) {
|
for(civWhoseUnitWasAttacked in hitTiles.flatMap { it.getUnits() }.map { it.civInfo }.distinct()) {
|
||||||
tryDeclareWar(hitUnit.civInfo)
|
tryDeclareWar(civWhoseUnitWasAttacked)
|
||||||
if (attacker.getUnitType().isAirUnit() && !attacker.isDefeated()) {
|
if (attacker.getUnitType().isAirUnit() && !attacker.isDefeated()) {
|
||||||
tryInterceptAirAttack(attacker, MapUnitCombatant(hitUnit))
|
tryInterceptAirAttack(attacker, targetTile, civWhoseUnitWasAttacked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (attacker.isDefeated()) return
|
if (attacker.isDefeated()) return
|
||||||
@ -668,10 +668,9 @@ object Battle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryInterceptAirAttack(attacker: MapUnitCombatant, defender: ICombatant) {
|
private fun tryInterceptAirAttack(attacker: MapUnitCombatant, attackedTile:TileInfo, interceptingCiv:CivilizationInfo) {
|
||||||
if (attacker.unit.hasUnique("Cannot be intercepted")) return
|
if (attacker.unit.hasUnique("Cannot be intercepted")) return
|
||||||
val attackedTile = defender.getTile()
|
for (interceptor in interceptingCiv.getCivUnits().filter { it.canIntercept(attackedTile) }) {
|
||||||
for (interceptor in defender.getCivInfo().getCivUnits().filter { it.canIntercept(attackedTile) }) {
|
|
||||||
if (Random().nextFloat() > 100f / interceptor.interceptChance()) continue
|
if (Random().nextFloat() > 100f / interceptor.interceptChance()) continue
|
||||||
|
|
||||||
var damage = BattleDamage.calculateDamageToDefender(MapUnitCombatant(interceptor), null, attacker)
|
var damage = BattleDamage.calculateDamageToDefender(MapUnitCombatant(interceptor), null, attacker)
|
||||||
@ -692,14 +691,14 @@ object Battle {
|
|||||||
attacker.getCivInfo()
|
attacker.getCivInfo()
|
||||||
.addNotification("Our [$attackerName] was destroyed by an intercepting [$interceptorName]",
|
.addNotification("Our [$attackerName] was destroyed by an intercepting [$interceptorName]",
|
||||||
interceptor.currentTile.position, attackerName, NotificationIcon.War, interceptorName)
|
interceptor.currentTile.position, attackerName, NotificationIcon.War, interceptorName)
|
||||||
defender.getCivInfo()
|
interceptingCiv
|
||||||
.addNotification("Our [$interceptorName] intercepted and destroyed an enemy [$attackerName]",
|
.addNotification("Our [$interceptorName] intercepted and destroyed an enemy [$attackerName]",
|
||||||
locations, interceptorName, NotificationIcon.War, attackerName)
|
locations, interceptorName, NotificationIcon.War, attackerName)
|
||||||
} else {
|
} else {
|
||||||
attacker.getCivInfo()
|
attacker.getCivInfo()
|
||||||
.addNotification("Our [$attackerName] was attacked by an intercepting [$interceptorName]",
|
.addNotification("Our [$attackerName] was attacked by an intercepting [$interceptorName]",
|
||||||
interceptor.currentTile.position, attackerName, NotificationIcon.War, interceptorName)
|
interceptor.currentTile.position, attackerName, NotificationIcon.War, interceptorName)
|
||||||
defender.getCivInfo()
|
interceptingCiv
|
||||||
.addNotification("Our [$interceptorName] intercepted and attacked an enemy [$attackerName]",
|
.addNotification("Our [$interceptorName] intercepted and attacked an enemy [$attackerName]",
|
||||||
locations, interceptorName, NotificationIcon.War, attackerName)
|
locations, interceptorName, NotificationIcon.War, attackerName)
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ class CityInfo {
|
|||||||
if (startingEra in ruleset.eras) {
|
if (startingEra in ruleset.eras) {
|
||||||
for (building in ruleset.eras[startingEra]!!.settlerBuildings) {
|
for (building in ruleset.eras[startingEra]!!.settlerBuildings) {
|
||||||
if (ruleset.buildings[building]!!.isBuildable(cityConstructions)) {
|
if (ruleset.buildings[building]!!.isBuildable(cityConstructions)) {
|
||||||
cityConstructions.addBuilding(civInfo.getEquivalentBuilding(building).name)
|
try cityConstructions.addBuilding(civInfo.getEquivalentBuilding(building).name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user