mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 23:40:01 +07:00
Added mod constants for the distance between two cities (#6211)
This commit is contained in:
@ -151,6 +151,7 @@ object SpecificUnitAutomation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun automateSettlerActions(unit: MapUnit) {
|
fun automateSettlerActions(unit: MapUnit) {
|
||||||
|
val modConstants = unit.civInfo.gameInfo.ruleSet.modOptions.constants
|
||||||
if (unit.getTile().militaryUnit == null // Don't move until you're accompanied by a military unit
|
if (unit.getTile().militaryUnit == null // Don't move until you're accompanied by a military unit
|
||||||
&& !unit.civInfo.isCityState() // ..unless you're a city state that was unable to settle its city on turn 1
|
&& !unit.civInfo.isCityState() // ..unless you're a city state that was unable to settle its city on turn 1
|
||||||
&& unit.getDamageFromTerrain() < unit.health) return // Also make sure we won't die waiting
|
&& unit.getDamageFromTerrain() < unit.health) return // Also make sure we won't die waiting
|
||||||
@ -159,17 +160,18 @@ object SpecificUnitAutomation {
|
|||||||
for (city in unit.civInfo.gameInfo.getCities()) {
|
for (city in unit.civInfo.gameInfo.getCities()) {
|
||||||
val center = city.getCenterTile()
|
val center = city.getCenterTile()
|
||||||
if (unit.civInfo.knows(city.civInfo) &&
|
if (unit.civInfo.knows(city.civInfo) &&
|
||||||
// If the CITY OWNER knows that the UNIT OWNER agreed not to settle near them
|
// If the CITY OWNER knows that the UNIT OWNER agreed not to settle near them
|
||||||
city.civInfo.getDiplomacyManager(unit.civInfo).hasFlag(DiplomacyFlags.AgreedToNotSettleNearUs)
|
city.civInfo.getDiplomacyManager(unit.civInfo).hasFlag(DiplomacyFlags.AgreedToNotSettleNearUs)
|
||||||
) {
|
) {
|
||||||
yieldAll(center.getTilesInDistance(6))
|
yieldAll(center.getTilesInDistance(6))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for (tile in center.getTilesAtDistance(3)) {
|
yieldAll(center.getTilesInDistance(modConstants.minimalCityDistance)
|
||||||
if (tile.getContinent() == center.getContinent())
|
.filter { it.getContinent() == center.getContinent() }
|
||||||
yield(tile)
|
)
|
||||||
}
|
yieldAll(center.getTilesInDistance(modConstants.minimalCityDistanceOnDifferentContinents)
|
||||||
yieldAll(center.getTilesInDistance(2))
|
.filter { it.getContinent() != center.getContinent() }
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}.toSet()
|
}.toSet()
|
||||||
|
|
||||||
|
@ -637,11 +637,16 @@ open class TileInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun canBeSettled(): Boolean {
|
fun canBeSettled(): Boolean {
|
||||||
|
val modConstants = tileMap.gameInfo.ruleSet.modOptions.constants
|
||||||
if (isWater || isImpassible())
|
if (isWater || isImpassible())
|
||||||
return false
|
return false
|
||||||
if (getTilesInDistance(2).any { it.isCityCenter() } ||
|
if (getTilesInDistance(modConstants.minimalCityDistanceOnDifferentContinents)
|
||||||
getTilesAtDistance(3).any { it.isCityCenter() && it.getContinent() == getContinent() })
|
.any { it.isCityCenter() && it.getContinent() != getContinent() }
|
||||||
return false
|
|| getTilesInDistance(modConstants.minimalCityDistance)
|
||||||
|
.any { it.isCityCenter() && it.getContinent() == getContinent() }
|
||||||
|
) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,4 +25,11 @@ class ModConstants {
|
|||||||
// unitSupplyBase and unitSupplyPerCity can be found in difficulties.json
|
// unitSupplyBase and unitSupplyPerCity can be found in difficulties.json
|
||||||
// unitSupplyBase, unitSupplyPerCity and unitSupplyPerPopulation can also be increased through uniques
|
// unitSupplyBase, unitSupplyPerCity and unitSupplyPerPopulation can also be increased through uniques
|
||||||
val unitSupplyPerPopulation = 0.5
|
val unitSupplyPerPopulation = 0.5
|
||||||
|
|
||||||
|
// The minimal distance that must be between any two cities, not counting the tiles cities are on
|
||||||
|
// The number is the amount of tiles between two cities, not counting the tiles the cities are on.
|
||||||
|
// e.g. "C__C", where "C" is a tile with a city and "_" is a tile without a city, has a distance of 2.
|
||||||
|
// First constant is for cities on the same landmass, the second is for cities on different continents.
|
||||||
|
val minimalCityDistance = 3
|
||||||
|
val minimalCityDistanceOnDifferentContinents = 2
|
||||||
}
|
}
|
Reference in New Issue
Block a user