Consolidated Generic Tile Bonus Uniques (including Friendly Land, Foreign Land) (#3232)

* Redid things with help from HadeanLake:

-"+[]% combat bonus in []" Unit Unique
-"+[]% combat bonus for units fighting in []" Nation Unique
-Both of these can check for terrain or Friendly Land or Foreign Land
-Function to add stacking modifiers
-Himeji Castle and Foreign Legion had uniques changed to fit this syntax
-Old way still works for now, but deprecated

* fixed comments about deprecation and the new syntax
This commit is contained in:
givehub99
2020-10-06 00:52:30 -07:00
committed by GitHub
parent f9ebc8aa0f
commit 9ffa0bee54
4 changed files with 24 additions and 8 deletions

View File

@ -676,7 +676,7 @@
"isWonder": true,
"greatPersonPoints": {"production": 2},
"providesFreeBuilding": "Castle",
"uniques": ["+15% combat strength for units fighting in friendly territory"],
"uniques": ["+[15]% combat bonus for units fighting in [Friendly Land]"],
"requiredTech": "Gunpowder",
"quote": "'Bushido is realized in the presence of death. This means choosing death whenever there is a choice between life and death. There is no other reasoning.' - Yamamoto Tsunetomo"
},

View File

@ -1149,7 +1149,7 @@
"requiredTech": "Replaceable Parts",
"upgradesTo": "Infantry",
"obsoleteTech": "Plastics",
"uniques": ["+20% bonus outside friendly territory"],
"uniques": ["+[20]% combat bonus in [Foreign Land]"],
"attackSound": "shot"
},
/*

View File

@ -859,6 +859,7 @@ WaterAircraftCarrier =
Composite Bowman =
Foreign Land =
Friendly Land =
Marine =
Mobile SAM =
Paratrooper =

View File

@ -206,12 +206,31 @@ object BattleDamage {
return modifiers
}
private fun addStackingModifier(modifiers : HashMap<String,Float>, text : String, modificationAmount : Float) {
if (modifiers.containsKey(text)) modifiers[text] = modifiers[text]!! + modificationAmount
else modifiers[text] = modificationAmount
}
private fun getTileSpecificModifiers(unit: MapUnitCombatant, tile: TileInfo): HashMap<String,Float> {
val modifiers = HashMap<String,Float>()
// As of 3.11.0 This is to be deprecated and converted to "+[15]% combat bonus for units fighting in [Friendly Land]" - keeping it here to that mods with this can still work for now
// Civ 5 does not use "Himeji Castle"
if(tile.isFriendlyTerritory(unit.getCivInfo()) && unit.getCivInfo().hasUnique("+15% combat strength for units fighting in friendly territory"))
modifiers["Himeji Castle"] = 0.15f
addStackingModifier(modifiers, "Friendly Land", 0.15f)
// As of 3.11.0 This is to be deprecated and converted to "+[20]% combat bonus in [Foreign Land]" - keeping it here to that mods with this can still work for now
if(!tile.isFriendlyTerritory(unit.getCivInfo()) && unit.unit.hasUnique("+20% bonus outside friendly territory"))
modifiers["Foreign Land"] = 0.2f
addStackingModifier(modifiers, "Foreign Land", 0.2f)
for (unique in unit.unit.getMatchingUniques("+[]% combat bonus in []")
+ unit.getCivInfo().getMatchingUniques("+[]% combat bonus for units fighting in []")) {
val filter = unique.params[1]
if (filter == tile.getLastTerrain().name
|| filter == "Foreign Land" && !tile.isFriendlyTerritory(unit.getCivInfo())
|| filter == "Friendly Land" && tile.isFriendlyTerritory(unit.getCivInfo()))
addStackingModifier(modifiers, filter, unique.params[0].toFloat() / 100)
}
// As of 3.10.6 This is to be deprecated and converted to "+[]% combat bonus in []" - keeping it here to that mods with this can still work for now
if (unit.unit.hasUnique("+25% bonus in Snow, Tundra and Hills") &&
@ -237,10 +256,6 @@ object BattleDamage {
&& (tile.terrainFeature== Constants.forest || tile.terrainFeature==Constants.jungle))
modifiers[tile.terrainFeature!!]=0.33f
for (unique in unit.unit.getUniques().filter { it.placeholderText == "+[]% combat bonus in []" })
if (tile.getLastTerrain().name == unique.params[1])
modifiers[unique.params[1]] = unique.params[0].toFloat() / 100
val isRoughTerrain = tile.isRoughTerrain()
for (BDM in getBattleDamageModifiersOfUnit(unit.unit)) {
val text = BDM.getText()