mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-14 12:00:12 +07:00
AI no longer nukes single units
Nuking is considered a declaration of war from the attacker, not the defender
This commit is contained in:
parent
62c42851ed
commit
96269c5c29
@ -1,5 +1,6 @@
|
||||
package com.unciv.logic.automation
|
||||
|
||||
import com.unciv.logic.battle.Battle
|
||||
import com.unciv.logic.battle.MapUnitCombatant
|
||||
import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
@ -295,16 +296,24 @@ object SpecificUnitAutomation {
|
||||
|
||||
// This really needs to be changed, to have better targetting for missiles
|
||||
fun automateMissile(unit: MapUnit) {
|
||||
if (BattleHelper.tryAttackNearbyEnemy(unit)) return
|
||||
|
||||
val tilesInRange = unit.currentTile.getTilesInDistance(unit.getRange()*2)
|
||||
|
||||
for(tile in tilesInRange) {
|
||||
// For now AI will only use nukes against cities because in all honesty that's the best use for them.
|
||||
if (tile.isCityCenter() && tile.getOwner()!!.isAtWarWith(unit.civInfo)) {
|
||||
Battle.nuke(MapUnitCombatant(unit), tile)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
val immediatelyReachableCities = tilesInRange
|
||||
.filter { unit.movement.canMoveTo(it) }
|
||||
|
||||
for (city in immediatelyReachableCities) {
|
||||
if (city.getTilesInDistance(unit.getRange())
|
||||
.any { BattleHelper.containsAttackableEnemy(it, MapUnitCombatant(unit)) }) {
|
||||
.any { it.isCityCenter() && it.getOwner()!!.isAtWarWith(unit.civInfo) }) {
|
||||
unit.movement.moveToTile(city)
|
||||
return
|
||||
}
|
||||
|
@ -387,8 +387,8 @@ object Battle {
|
||||
|
||||
fun declareWar(civSuffered: CivilizationInfo) {
|
||||
if (civSuffered != attackingCiv
|
||||
&& civSuffered.knows(attackingCiv)
|
||||
&& civSuffered.getDiplomacyManager(attackingCiv).canDeclareWar()) {
|
||||
&& attackingCiv.knows(attackingCiv)
|
||||
&& attackingCiv.getDiplomacyManager(civSuffered).canDeclareWar()) {
|
||||
civSuffered.getDiplomacyManager(attackingCiv).declareWar()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user