mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-06 16:28:40 +07:00
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:
@ -676,7 +676,7 @@
|
|||||||
"isWonder": true,
|
"isWonder": true,
|
||||||
"greatPersonPoints": {"production": 2},
|
"greatPersonPoints": {"production": 2},
|
||||||
"providesFreeBuilding": "Castle",
|
"providesFreeBuilding": "Castle",
|
||||||
"uniques": ["+15% combat strength for units fighting in friendly territory"],
|
"uniques": ["+[15]% combat bonus for units fighting in [Friendly Land]"],
|
||||||
"requiredTech": "Gunpowder",
|
"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"
|
"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"
|
||||||
},
|
},
|
||||||
|
@ -1149,7 +1149,7 @@
|
|||||||
"requiredTech": "Replaceable Parts",
|
"requiredTech": "Replaceable Parts",
|
||||||
"upgradesTo": "Infantry",
|
"upgradesTo": "Infantry",
|
||||||
"obsoleteTech": "Plastics",
|
"obsoleteTech": "Plastics",
|
||||||
"uniques": ["+20% bonus outside friendly territory"],
|
"uniques": ["+[20]% combat bonus in [Foreign Land]"],
|
||||||
"attackSound": "shot"
|
"attackSound": "shot"
|
||||||
},
|
},
|
||||||
/*
|
/*
|
||||||
|
@ -859,6 +859,7 @@ WaterAircraftCarrier =
|
|||||||
|
|
||||||
Composite Bowman =
|
Composite Bowman =
|
||||||
Foreign Land =
|
Foreign Land =
|
||||||
|
Friendly Land =
|
||||||
Marine =
|
Marine =
|
||||||
Mobile SAM =
|
Mobile SAM =
|
||||||
Paratrooper =
|
Paratrooper =
|
||||||
|
@ -206,12 +206,31 @@ object BattleDamage {
|
|||||||
return modifiers
|
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> {
|
private fun getTileSpecificModifiers(unit: MapUnitCombatant, tile: TileInfo): HashMap<String,Float> {
|
||||||
val modifiers = 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"))
|
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"))
|
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
|
// 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") &&
|
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))
|
&& (tile.terrainFeature== Constants.forest || tile.terrainFeature==Constants.jungle))
|
||||||
modifiers[tile.terrainFeature!!]=0.33f
|
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()
|
val isRoughTerrain = tile.isRoughTerrain()
|
||||||
for (BDM in getBattleDamageModifiersOfUnit(unit.unit)) {
|
for (BDM in getBattleDamageModifiersOfUnit(unit.unit)) {
|
||||||
val text = BDM.getText()
|
val text = BDM.getText()
|
||||||
|
Reference in New Issue
Block a user