mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-23 11:34:54 -04:00
Forest chopping moddability (#13072)
* Update ModConstants.kt * Update UniqueType.kt * Update TileImprovementFunctions.kt * Update Terrains.json * Update Terrains.json * Update TileImprovementFunctions.kt * Update TileImprovementFunctions.kt * Update TileImprovementFunctions.kt * Update Terrains.json * Update Terrains.json * Update UniqueType.kt * Update TileImprovementFunctions.kt * Update TileImprovementFunctions.kt * Update TileImprovementFunctions.kt * Update TileImprovementFunctions.kt * Update TileImprovementFunctions.kt * Update TileImprovementFunctions.kt * Game speed modifier * Add meta modifier (WIP) * Update * Update UniqueType.kt * Rename * Float * Revert modifier * Update Unique.kt * Update TileImprovementFunctions.kt * Update TileImprovementFunctions.kt
This commit is contained in:
parent
c3e44daa4c
commit
1c03133fdc
@ -188,7 +188,7 @@
|
||||
"defenceBonus": 0.25,
|
||||
"occursOn": ["Tundra","Plains","Grassland","Hill"],
|
||||
"uniques": ["Rough terrain", "Vegetation",
|
||||
"Provides a one-time Production bonus to the closest city when cut down",
|
||||
"Provides a one-time bonus of [+30 Production] to the closest city when cut down <(modified by game speed)>",
|
||||
"Blocks line-of-sight from tiles at same elevation",
|
||||
"[25]% Chance to be destroyed by nukes",
|
||||
"A Region is formed with at least [30]% [Forest] tiles, with priority [3]",
|
||||
|
@ -188,7 +188,7 @@
|
||||
"occursOn": ["Tundra","Plains","Grassland","Hill"],
|
||||
"uniques": [
|
||||
"Rough terrain", "Vegetation",
|
||||
"Provides a one-time Production bonus to the closest city when cut down",
|
||||
"Provides a one-time bonus of [+30 Production] to the closest city when cut down <(modified by game speed)>",
|
||||
"Blocks line-of-sight from tiles at same elevation",
|
||||
"[25]% Chance to be destroyed by nukes",
|
||||
"A Region is formed with at least [30]% [Forest] tiles, with priority [3]",
|
||||
|
@ -10,6 +10,7 @@ import com.unciv.models.ruleset.tile.TileImprovement
|
||||
import com.unciv.models.ruleset.unique.StateForConditionals
|
||||
import com.unciv.models.ruleset.unique.UniqueTriggerActivation
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.models.stats.Stats
|
||||
|
||||
|
||||
/** Reason why an Improvement cannot be built by a given civ */
|
||||
@ -312,20 +313,26 @@ class TileImprovementFunctions(val tile: Tile) {
|
||||
val closestCity = civ.cities.minByOrNull { it.getCenterTile().aerialDistanceTo(tile) }
|
||||
?: return
|
||||
val distance = closestCity.getCenterTile().aerialDistanceTo(tile)
|
||||
var productionPointsToAdd = if (distance == 1) 20 else 20 - (distance - 2) * 5
|
||||
if (tile.owningCity == null || tile.owningCity!!.civ != civ) productionPointsToAdd =
|
||||
productionPointsToAdd * 2 / 3
|
||||
if (productionPointsToAdd > 0) {
|
||||
closestCity.cityConstructions.addProductionPoints(productionPointsToAdd)
|
||||
if (distance > 5) return
|
||||
var stats = Stats()
|
||||
for (unique in tile.getTerrainMatchingUniques(UniqueType.ProductionBonusWhenRemoved)) {
|
||||
if (unique.isModifiedByGameSpeed())
|
||||
stats.add(unique.stats * civ.gameInfo.speed.modifier)
|
||||
else stats.add(unique.stats)
|
||||
}
|
||||
if (stats.isEmpty()) return
|
||||
if (distance != 1) stats *= (6 - distance) / 4f
|
||||
if (tile.owningCity == null || tile.owningCity!!.civ != civ) stats *= 2 / 3f
|
||||
for ((stat, value) in stats) {
|
||||
closestCity.addStat(stat, value.toInt())
|
||||
val locations = LocationAction(tile.position, closestCity.location)
|
||||
civ.addNotification(
|
||||
"Clearing a [$removedTerrainFeature] has created [$productionPointsToAdd] Production for [${closestCity.name}]",
|
||||
"Clearing a [$removedTerrainFeature] has created [${stats.toStringForNotifications()}] for [${closestCity.name}]",
|
||||
locations, NotificationCategory.Production, NotificationIcon.Construction
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Marks tile as target tile for a building with a [UniqueType.CreatesOneImprovement] unique */
|
||||
fun markForCreatesOneImprovement(improvement: String) {
|
||||
tile.stopWorkingOnImprovement()
|
||||
|
@ -562,7 +562,7 @@ enum class UniqueType(
|
||||
DamagesContainingUnits("Units ending their turn on this terrain take [amount] damage", UniqueTarget.Terrain),
|
||||
TerrainGrantsPromotion("Grants [promotion] ([comment]) to adjacent [mapUnitFilter] units for the rest of the game", UniqueTarget.Terrain),
|
||||
GrantsCityStrength("[amount] Strength for cities built on this terrain", UniqueTarget.Terrain),
|
||||
ProductionBonusWhenRemoved("Provides a one-time Production bonus to the closest city when cut down", UniqueTarget.Terrain),
|
||||
ProductionBonusWhenRemoved("Provides a one-time bonus of [stats] to the closest city when cut down", UniqueTarget.Terrain, flags = setOf(UniqueFlag.AcceptsSpeedModifier)),
|
||||
Vegetation("Vegetation", UniqueTarget.Terrain, UniqueTarget.Improvement, flags = UniqueFlag.setOfHiddenToUsers), // Improvement included because use as tileFilter works
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user