Replaced hardcoded embarked sight with configurable

"Normal vision when embarked" replaced by "[+1] Sight <for [Embarked] units>"
This commit is contained in:
Yair Morgenstern 2023-04-19 11:12:21 +03:00
parent 26a155351e
commit 2f25ed3053
8 changed files with 29 additions and 17 deletions

View File

@ -6,7 +6,8 @@
"[-50]% [Production] [in all cities] <when below [-10] Happiness>",
"[-33]% Strength <for [All] units> <when below [-10] Happiness>",
"Cannot build [Settler] units <when below [-10] Happiness>",
"Rebel units may spawn <when below [-20] Happiness>"
"Rebel units may spawn <when below [-20] Happiness>",
"[-1] Sight <for [Embarked] units>"
// TODO: Implement the uniques below
// "[+20]% [Culture] [in all cities] <during a golden age>",

View File

@ -538,7 +538,9 @@
"innerColor": [255,255,75],
"favoredReligion": "Christianity",
"uniqueName": "Wayfinding",
"uniques": ["Enables embarkation for land units <starting from the [Ancient era]>", "Enables [All] units to enter ocean tiles <starting from the [Ancient era]>", "Normal vision when embarked <for [All] units>", "[+10]% Strength <within [2] tiles of a [Moai]>"],
"uniques": ["Enables embarkation for land units <starting from the [Ancient era]>",
"Enables [All] units to enter ocean tiles <starting from the [Ancient era]>",
"[+1] Sight <for [Embarked] units>", "[+10]% Strength <within [2] tiles of a [Moai]>"],
"cities": ["Honolulu","Samoa","Tonga","Nuku Hiva","Raiatea","Aotearoa","Tahiti","Hilo","Te Wai Pounamu","Rapa Nui",
"Tuamotu","Rarotonga","Tuvalu","Tubuai","Mangareva","Oahu","Kiritimati","Ontong Java","Niue","Rekohu",
"Rakahanga","Bora Bora","Kailua","Uvea","Futuna","Rotuma","Tokelau","Lahaina","Bellona","Mungava","Tikopia",

View File

@ -1309,7 +1309,7 @@
"cost": 400,
"requiredTech": "Pharmaceuticals",
"promotions": ["Amphibious"],
"uniques": ["Normal vision when embarked", "Defense bonus when embarked"],
"uniques": ["[+1] Sight <when [Embarked]>", "Defense bonus when embarked"],
"attackSound": "shot"
},
{

View File

@ -6,7 +6,8 @@
"[-50]% [Production] [in all cities] <when below [-10] Happiness>",
"[-33]% Strength <for [All] units> <when below [-10] Happiness>",
"Cannot build [Settler] units <when below [-10] Happiness>",
"Rebel units may spawn <when below [-20] Happiness>"
"Rebel units may spawn <when below [-20] Happiness>",
"[-1] Sight <for [Embarked] units>"
// TODO: Implement the uniques below
// "[+20]% [Culture] [in all cities] <during a golden age>",
@ -22,4 +23,4 @@
// "[+20]% [Production] [in cities connected via railroad]"
// something something unit supply
]
}
}

View File

@ -499,7 +499,10 @@
"outerColor": [217,89,0],
"innerColor": [255,255,75],
"uniqueName": "Wayfinding",
"uniques": ["Enables embarkation for land units <starting from the [Ancient era]>", "Enables [All] units to enter ocean tiles <starting from the [Ancient era]>", "Normal vision when embarked <for [All] units>", "[+10]% Strength <within [2] tiles of a [Moai]>"],
"uniques": ["Enables embarkation for land units <starting from the [Ancient era]>",
"Enables [All] units to enter ocean tiles <starting from the [Ancient era]>",
"[+1] Sight <for [Embarked] units>",
"[+10]% Strength <within [2] tiles of a [Moai]>"],
"cities": ["Honolulu","Samoa","Tonga","Nuku Hiva","Raiatea","Aotearoa","Tahiti","Hilo","Te Wai Pounamu","Rapa Nui",
"Tuamotu","Rarotonga","Tuvalu","Tubuai","Mangareva","Oahu","Kiritimati","Ontong Java","Niue","Rekohu",
"Rakahanga","Bora Bora","Kailua","Uvea","Futuna","Rotuma","Tokelau","Lahaina","Bellona","Mungava","Tikopia",

View File

@ -278,15 +278,14 @@ class MapUnit : IsPartOfGameInfoSerialization {
val conditionalState = StateForConditionals(civInfo = civ, unit = this)
val relevantUniques = getMatchingUniques(UniqueType.Sight, conditionalState, checkCivInfoUniques = true) +
getTile().getMatchingUniques(UniqueType.Sight, conditionalState)
if (isEmbarked() && !hasUnique(UniqueType.NormalVisionWhenEmbarked, conditionalState, checkCivInfoUniques = true)) {
return 1
visibilityRange += relevantUniques
.filter { it.conditionals.any { it.type == UniqueType.ConditionalOurUnit && it.params[0] == Constants.embarked } }
.sumOf { it.params[0].toInt() }
}
visibilityRange += getMatchingUniques(UniqueType.Sight, conditionalState, checkCivInfoUniques = true)
.sumOf { it.params[0].toInt() }
visibilityRange += getTile().getMatchingUniques(UniqueType.Sight, conditionalState)
.sumOf { it.params[0].toInt() }
else visibilityRange += relevantUniques.sumOf { it.params[0].toInt() }
if (visibilityRange < 1) visibilityRange = 1
@ -799,15 +798,14 @@ class MapUnit : IsPartOfGameInfoSerialization {
return filter.filterAndLogic { matchesFilter(it) } // multiple types at once - AND logic. Looks like:"{Military} {Land}"
?: when (filter) {
// todo: unit filters should be adjectives, fitting "[filterType] units"
// This means converting "wounded units" to "Wounded", "Barbarians" to "Barbarian"
"Wounded", "wounded units" -> health < 100
Constants.wounded, "wounded units" -> health < 100
Constants.barbarians, "Barbarian" -> civ.isBarbarian()
"City-State" -> civ.isCityState()
"Embarked" -> isEmbarked()
Constants.embarked -> isEmbarked()
"Non-City" -> true
else -> {
if (baseUnit.matchesFilter(filter)) return true
if (civ.nation.matchesFilter(filter)) return true
if (tempUniquesMap.containsKey(filter)) return true
return false
}

View File

@ -441,6 +441,8 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
HealAdjacentUnits("All adjacent units heal [amount] HP when healing", UniqueTarget.Unit),
// Vision
@Deprecated("as of 4.6.4", ReplaceWith("[+1] Sight <for [Embarked] units>\" OR \"[+1] Sight <when [Embarked]>"))
NormalVisionWhenEmbarked("Normal vision when embarked", UniqueTarget.Unit, UniqueTarget.Global),
DefenceBonusWhenEmbarked("Defense bonus when embarked", UniqueTarget.Unit, UniqueTarget.Global),
NoSight("No Sight", UniqueTarget.Unit),

View File

@ -1840,6 +1840,11 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
Applicable to: Conditional
??? example "&lt;when [mapUnitFilter]&gt;"
Example: "&lt;when [Wounded]&gt;"
Applicable to: Conditional
??? example "&lt;for units with [promotion]&gt;"
Example: "&lt;for units with [Shock I]&gt;"