mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-15 10:18:26 +07:00
Civ no longer attempts to intercept his own nukes - #4629
This commit is contained in:
@ -118,7 +118,7 @@ object Battle {
|
|||||||
if (civUnit is MapUnitCombatant) {
|
if (civUnit is MapUnitCombatant) {
|
||||||
bonusUniques.addAll(civUnit.unit.getMatchingUniques(bonusUniquePlaceholderText))
|
bonusUniques.addAll(civUnit.unit.getMatchingUniques(bonusUniquePlaceholderText))
|
||||||
}
|
}
|
||||||
|
|
||||||
bonusUniquePlaceholderText = "Earn []% of [] unit's [] as [] when killed within 4 tiles of a city following this religion"
|
bonusUniquePlaceholderText = "Earn []% of [] unit's [] as [] when killed within 4 tiles of a city following this religion"
|
||||||
val cityWithReligion =
|
val cityWithReligion =
|
||||||
civUnit.getTile().getTilesInDistance(4).firstOrNull {
|
civUnit.getTile().getTilesInDistance(4).firstOrNull {
|
||||||
@ -224,7 +224,7 @@ object Battle {
|
|||||||
plunderedGoods.add(stat, percentage / 100f * damageDealt)
|
plunderedGoods.add(stat, percentage / 100f * damageDealt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val civ = plunderingUnit.getCivInfo()
|
val civ = plunderingUnit.getCivInfo()
|
||||||
plunderedGoods.toHashMap().filterNot { it.value == 0f }.forEach {
|
plunderedGoods.toHashMap().filterNot { it.value == 0f }.forEach {
|
||||||
val plunderedAmount = it.value.toInt()
|
val plunderedAmount = it.value.toInt()
|
||||||
@ -505,7 +505,8 @@ 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(civWhoseUnitWasAttacked in hitTiles.flatMap { it.getUnits() }.map { it.civInfo }.distinct()) {
|
for(civWhoseUnitWasAttacked in hitTiles.flatMap { it.getUnits() }.map { it.civInfo }.distinct()
|
||||||
|
.filter{it != attackingCiv}) {
|
||||||
tryDeclareWar(civWhoseUnitWasAttacked)
|
tryDeclareWar(civWhoseUnitWasAttacked)
|
||||||
if (attacker.getUnitType().isAirUnit() && !attacker.isDefeated()) {
|
if (attacker.getUnitType().isAirUnit() && !attacker.isDefeated()) {
|
||||||
tryInterceptAirAttack(attacker, targetTile, civWhoseUnitWasAttacked)
|
tryInterceptAirAttack(attacker, targetTile, civWhoseUnitWasAttacked)
|
||||||
@ -543,7 +544,7 @@ object Battle {
|
|||||||
// todo: reduce extreme code duplication, parameterize probabilities where an unique already used
|
// todo: reduce extreme code duplication, parameterize probabilities where an unique already used
|
||||||
private fun nukeStrength1Effect(attacker: MapUnitCombatant, tile: TileInfo) {
|
private fun nukeStrength1Effect(attacker: MapUnitCombatant, tile: TileInfo) {
|
||||||
// https://forums.civfanatics.com/resources/unit-guide-modern-future-units-g-k.25628/
|
// https://forums.civfanatics.com/resources/unit-guide-modern-future-units-g-k.25628/
|
||||||
// https://www.carlsguides.com/strategy/civilization5/units/aircraft-nukes.php
|
// https://www.carlsguides.com/strategy/civilization5/units/aircraft-nukes.ph
|
||||||
// Testing done by Ravignir
|
// Testing done by Ravignir
|
||||||
var damageModifierFromMissingResource = 1f
|
var damageModifierFromMissingResource = 1f
|
||||||
val civResources = attacker.getCivInfo().getCivResourcesByName()
|
val civResources = attacker.getCivInfo().getCivResourcesByName()
|
||||||
@ -670,10 +671,15 @@ object Battle {
|
|||||||
|
|
||||||
private fun tryInterceptAirAttack(attacker: MapUnitCombatant, attackedTile:TileInfo, interceptingCiv:CivilizationInfo) {
|
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
|
||||||
for (interceptor in interceptingCiv.getCivUnits().filter { it.canIntercept(attackedTile) }) {
|
for (interceptor in interceptingCiv.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
|
||||||
|
)
|
||||||
|
|
||||||
var damageFactor = 1f + interceptor.interceptDamagePercentBonus().toFloat() / 100f
|
var damageFactor = 1f + interceptor.interceptDamagePercentBonus().toFloat() / 100f
|
||||||
damageFactor *= attacker.unit.receivedInterceptDamageFactor()
|
damageFactor *= attacker.unit.receivedInterceptDamageFactor()
|
||||||
@ -685,22 +691,37 @@ object Battle {
|
|||||||
|
|
||||||
val attackerName = attacker.getName()
|
val attackerName = attacker.getName()
|
||||||
val interceptorName = interceptor.name
|
val interceptorName = interceptor.name
|
||||||
val locations = LocationAction(listOf(interceptor.currentTile.position, attacker.unit.currentTile.position))
|
val locations = LocationAction(
|
||||||
|
listOf(
|
||||||
|
interceptor.currentTile.position,
|
||||||
|
attacker.unit.currentTile.position
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
if (attacker.isDefeated()) {
|
if (attacker.isDefeated()) {
|
||||||
attacker.getCivInfo()
|
attacker.getCivInfo()
|
||||||
.addNotification("Our [$attackerName] was destroyed by an intercepting [$interceptorName]",
|
.addNotification(
|
||||||
interceptor.currentTile.position, attackerName, NotificationIcon.War, interceptorName)
|
"Our [$attackerName] was destroyed by an intercepting [$interceptorName]",
|
||||||
|
interceptor.currentTile.position, attackerName, NotificationIcon.War,
|
||||||
|
interceptorName
|
||||||
|
)
|
||||||
interceptingCiv
|
interceptingCiv
|
||||||
.addNotification("Our [$interceptorName] intercepted and destroyed an enemy [$attackerName]",
|
.addNotification(
|
||||||
locations, interceptorName, NotificationIcon.War, attackerName)
|
"Our [$interceptorName] intercepted and destroyed an enemy [$attackerName]",
|
||||||
|
locations, interceptorName, NotificationIcon.War, attackerName
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
attacker.getCivInfo()
|
attacker.getCivInfo()
|
||||||
.addNotification("Our [$attackerName] was attacked by an intercepting [$interceptorName]",
|
.addNotification(
|
||||||
interceptor.currentTile.position, attackerName, NotificationIcon.War, interceptorName)
|
"Our [$attackerName] was attacked by an intercepting [$interceptorName]",
|
||||||
|
interceptor.currentTile.position, attackerName,NotificationIcon.War,
|
||||||
|
interceptorName
|
||||||
|
)
|
||||||
interceptingCiv
|
interceptingCiv
|
||||||
.addNotification("Our [$interceptorName] intercepted and attacked an enemy [$attackerName]",
|
.addNotification(
|
||||||
locations, interceptorName, NotificationIcon.War, attackerName)
|
"Our [$interceptorName] intercepted and attacked an enemy [$attackerName]",
|
||||||
|
locations, interceptorName, NotificationIcon.War, attackerName
|
||||||
|
)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -763,4 +784,4 @@ object Battle {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -120,9 +120,8 @@ class CityInfo {
|
|||||||
// Add buildings and pop we get from starting in this era
|
// Add buildings and pop we get from starting in this era
|
||||||
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))
|
||||||
try cityConstructions.addBuilding(civInfo.getEquivalentBuilding(building).name)
|
cityConstructions.addBuilding(civInfo.getEquivalentBuilding(building).name)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user