mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 05:46:43 -04:00
Fix Polynesia's Wayfinding (#6238)
* Fix Polynesia's Wayfinding * Fix mod option to use other unit filters with UnitsMayEnterOcean
This commit is contained in:
parent
f360eda047
commit
651dcff581
@ -488,7 +488,7 @@
|
|||||||
"innerColor": [255,255,78],
|
"innerColor": [255,255,78],
|
||||||
"favoredReligion": "Christianity",
|
"favoredReligion": "Christianity",
|
||||||
"uniqueName": "Wayfinding",
|
"uniqueName": "Wayfinding",
|
||||||
"uniques": ["Enables embarkation for land units <starting from the [Ancient era]>", "Enables embarked units to enter ocean tiles <starting from the [Ancient era]>", "Normal vision when embarked <for [All] units>", "+[10]% Strength if 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]>", "Normal vision when embarked <for [All] units>", "+[10]% Strength if within [2] tiles of a [Moai]"],
|
||||||
"cities": ["Honolulu","Samoa","Tonga","Nuku Hiva","Raiatea","Aotearoa","Tahiti","Hilo","Te Wai Pounamu","Rapa Nui",
|
"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",
|
"Tuamotu","Rarotonga","Tuvalu","Tubuai","Mangareva","Oahu","Kiritimati","Ontong Java","Niue","Rekohu",
|
||||||
"Rakahanga","Bora Bora","Kailua","Uvea","Futuna","Rotuma","Tokelau","Lahaina","Bellona","Mungava","Tikopia",
|
"Rakahanga","Bora Bora","Kailua","Uvea","Futuna","Rotuma","Tokelau","Lahaina","Bellona","Mungava","Tikopia",
|
||||||
|
@ -266,7 +266,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Astronomy",
|
"name": "Astronomy",
|
||||||
"row": 2,
|
"row": 2,
|
||||||
"uniques": ["[+1] Movement <for [Embarked] units>","Enables embarked units to enter ocean tiles"],
|
"uniques": ["[+1] Movement <for [Embarked] units>","Enables [Embarked] units to enter ocean tiles"],
|
||||||
"prerequisites": ["Compass","Education"],
|
"prerequisites": ["Compass","Education"],
|
||||||
"quote": "'Joyfully to the breeze royal Odysseus spread his sail, and with his rudder skillfully he steered.' - Homer"
|
"quote": "'Joyfully to the breeze royal Odysseus spread his sail, and with his rudder skillfully he steered.' - Homer"
|
||||||
},
|
},
|
||||||
|
@ -468,7 +468,7 @@
|
|||||||
"outerColor": [225,105,0],
|
"outerColor": [225,105,0],
|
||||||
"innerColor": [255,255,78],
|
"innerColor": [255,255,78],
|
||||||
"uniqueName": "Wayfinding",
|
"uniqueName": "Wayfinding",
|
||||||
"uniques": ["Enables embarkation for land units <starting from the [Ancient era]>", "Enables embarked units to enter ocean tiles <starting from the [Ancient era]>", "Normal vision when embarked <for [All] units>", "+[10]% Strength if 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]>", "Normal vision when embarked <for [All] units>", "+[10]% Strength if within [2] tiles of a [Moai]"],
|
||||||
"cities": ["Honolulu","Samoa","Tonga","Nuku Hiva","Raiatea","Aotearoa","Tahiti","Hilo","Te Wai Pounamu","Rapa Nui",
|
"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",
|
"Tuamotu","Rarotonga","Tuvalu","Tubuai","Mangareva","Oahu","Kiritimati","Ontong Java","Niue","Rekohu",
|
||||||
"Rakahanga","Bora Bora","Kailua","Uvea","Futuna","Rotuma","Tokelau","Lahaina","Bellona","Mungava","Tikopia",
|
"Rakahanga","Bora Bora","Kailua","Uvea","Futuna","Rotuma","Tokelau","Lahaina","Bellona","Mungava","Tikopia",
|
||||||
|
@ -246,7 +246,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Astronomy",
|
"name": "Astronomy",
|
||||||
"row": 2,
|
"row": 2,
|
||||||
"uniques": ["[+1] Movement <for [Embarked] units>","Enables embarked units to enter ocean tiles"],
|
"uniques": ["[+1] Movement <for [Embarked] units>","Enables [Embarked] units to enter ocean tiles"],
|
||||||
"prerequisites": ["Compass","Education"],
|
"prerequisites": ["Compass","Education"],
|
||||||
"quote": "'Joyfully to the breeze royal Odysseus spread his sail, and with his rudder skillfully he steered.' - Homer"
|
"quote": "'Joyfully to the breeze royal Odysseus spread his sail, and with his rudder skillfully he steered.' - Homer"
|
||||||
},
|
},
|
||||||
|
@ -3,7 +3,6 @@ package com.unciv.logic.civilization
|
|||||||
import com.unciv.logic.city.CityInfo
|
import com.unciv.logic.city.CityInfo
|
||||||
import com.unciv.logic.map.MapSize
|
import com.unciv.logic.map.MapSize
|
||||||
import com.unciv.logic.map.RoadStatus
|
import com.unciv.logic.map.RoadStatus
|
||||||
import com.unciv.logic.map.TileInfo
|
|
||||||
import com.unciv.models.ruleset.Era
|
import com.unciv.models.ruleset.Era
|
||||||
import com.unciv.models.ruleset.unique.UniqueMap
|
import com.unciv.models.ruleset.unique.UniqueMap
|
||||||
import com.unciv.models.ruleset.unique.UniqueTriggerActivation
|
import com.unciv.models.ruleset.unique.UniqueTriggerActivation
|
||||||
@ -34,11 +33,13 @@ class TechManager {
|
|||||||
|
|
||||||
// MapUnit.canPassThrough is the most called function in the game, and having these extremely specific booleans is one way of improving the time cost
|
// MapUnit.canPassThrough is the most called function in the game, and having these extremely specific booleans is one way of improving the time cost
|
||||||
@Transient
|
@Transient
|
||||||
var wayfinding = false
|
|
||||||
@Transient
|
|
||||||
var unitsCanEmbark = false
|
var unitsCanEmbark = false
|
||||||
@Transient
|
@Transient
|
||||||
var embarkedUnitsCanEnterOcean = false
|
var embarkedUnitsCanEnterOcean = false
|
||||||
|
@Transient
|
||||||
|
var allUnitsCanEnterOcean = false
|
||||||
|
@Transient
|
||||||
|
var specificUnitsCanEnterOcean = false
|
||||||
|
|
||||||
// UnitMovementAlgorithms.getMovementCostBetweenAdjacentTiles is a close second =)
|
// UnitMovementAlgorithms.getMovementCostBetweenAdjacentTiles is a close second =)
|
||||||
@Transient
|
@Transient
|
||||||
@ -373,15 +374,22 @@ class TechManager {
|
|||||||
fun setTransients() {
|
fun setTransients() {
|
||||||
researchedTechnologies.addAll(techsResearched.map { getRuleset().technologies[it]!! })
|
researchedTechnologies.addAll(techsResearched.map { getRuleset().technologies[it]!! })
|
||||||
researchedTechnologies.forEach { addTechToTransients(it) }
|
researchedTechnologies.forEach { addTechToTransients(it) }
|
||||||
|
updateEra() // before updateTransientBooleans so era-based conditionals can work
|
||||||
updateTransientBooleans()
|
updateTransientBooleans()
|
||||||
updateEra()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTransientBooleans() {
|
private fun updateTransientBooleans() {
|
||||||
wayfinding = civInfo.hasUnique(UniqueType.EmbarkAndEnterOcean)
|
val wayfinding = civInfo.hasUnique(UniqueType.EmbarkAndEnterOcean)
|
||||||
unitsCanEmbark = wayfinding || civInfo.hasUnique(UniqueType.LandUnitEmbarkation)
|
unitsCanEmbark = wayfinding ||
|
||||||
|
civInfo.hasUnique(UniqueType.LandUnitEmbarkation)
|
||||||
|
val enterOceanUniques = civInfo.getMatchingUniques(UniqueType.UnitsMayEnterOcean)
|
||||||
|
allUnitsCanEnterOcean = enterOceanUniques.any { it.params[0] == "All" }
|
||||||
|
embarkedUnitsCanEnterOcean = wayfinding ||
|
||||||
|
allUnitsCanEnterOcean ||
|
||||||
|
enterOceanUniques.any { it.params[0] == "Embarked" } ||
|
||||||
|
civInfo.hasUnique(UniqueType.EmbarkedUnitsMayEnterOcean)
|
||||||
|
specificUnitsCanEnterOcean = enterOceanUniques.any { it.params[0] != "All" && it.params[0] != "Embarked" }
|
||||||
|
|
||||||
embarkedUnitsCanEnterOcean = wayfinding || civInfo.hasUnique(UniqueType.EmbarkedUnitsMayEnterOcean)
|
|
||||||
movementSpeedOnRoads = if (civInfo.hasUnique(UniqueType.RoadMovementSpeed))
|
movementSpeedOnRoads = if (civInfo.hasUnique(UniqueType.RoadMovementSpeed))
|
||||||
RoadStatus.Road.movementImproved else RoadStatus.Road.movement
|
RoadStatus.Road.movementImproved else RoadStatus.Road.movement
|
||||||
roadsConnectAcrossRivers = civInfo.hasUnique(UniqueType.RoadsConnectAcrossRivers)
|
roadsConnectAcrossRivers = civInfo.hasUnique(UniqueType.RoadsConnectAcrossRivers)
|
||||||
|
@ -610,14 +610,18 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
|||||||
&& !tile.isCityCenter())
|
&& !tile.isCityCenter())
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
val unitSpecificAllowOcean: Boolean by lazy {
|
||||||
|
unit.civInfo.tech.specificUnitsCanEnterOcean &&
|
||||||
|
unit.civInfo.getMatchingUniques(UniqueType.UnitsMayEnterOcean)
|
||||||
|
.any { unit.matchesFilter(it.params[0]) }
|
||||||
|
}
|
||||||
if (tile.isWater && unit.baseUnit.isLandUnit()) {
|
if (tile.isWater && unit.baseUnit.isLandUnit()) {
|
||||||
if (!unit.civInfo.tech.unitsCanEmbark) return false
|
if (!unit.civInfo.tech.unitsCanEmbark) return false
|
||||||
if (tile.isOcean && !unit.civInfo.tech.embarkedUnitsCanEnterOcean)
|
if (tile.isOcean && !unit.civInfo.tech.embarkedUnitsCanEnterOcean && !unitSpecificAllowOcean)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (tile.isOcean && !unit.civInfo.tech.wayfinding) { // Apparently all Polynesian naval units can enter oceans
|
if (tile.isOcean && !unit.civInfo.tech.allUnitsCanEnterOcean) { // Apparently all Polynesian naval units can enter oceans
|
||||||
if (unit.cannotEnterOceanTiles) return false
|
if (!unitSpecificAllowOcean && unit.cannotEnterOceanTiles) return false
|
||||||
}
|
}
|
||||||
if (tile.naturalWonder != null) return false
|
if (tile.naturalWonder != null) return false
|
||||||
|
|
||||||
|
@ -289,8 +289,10 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
|||||||
UnitStartingActions("[baseUnitFilter] units built [cityFilter] can [action] [amount] extra times", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
UnitStartingActions("[baseUnitFilter] units built [cityFilter] can [action] [amount] extra times", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||||
// ToDo: make per unit and use unit filters?
|
// ToDo: make per unit and use unit filters?
|
||||||
LandUnitEmbarkation("Enables embarkation for land units", UniqueTarget.Global),
|
LandUnitEmbarkation("Enables embarkation for land units", UniqueTarget.Global),
|
||||||
|
UnitsMayEnterOcean("Enables [mapUnitFilter] units to enter ocean tiles", UniqueTarget.Global),
|
||||||
|
@Deprecated("as of 3.19.13", ReplaceWith("Enables [Embarked] units to enter ocean tiles <starting from the [Ancient era]>"))
|
||||||
EmbarkedUnitsMayEnterOcean("Enables embarked units to enter ocean tiles", UniqueTarget.Global),
|
EmbarkedUnitsMayEnterOcean("Enables embarked units to enter ocean tiles", UniqueTarget.Global),
|
||||||
@Deprecated("as of 3.19.9", ReplaceWith("Enables embarkation for land units <starting from the [Ancient era]>\", \"Enables embarked units to enter ocean tiles <starting from the [Ancient era]>"))
|
@Deprecated("as of 3.19.9", ReplaceWith("Enables embarkation for land units <starting from the [Ancient era]>\", \"Enables [All] units to enter ocean tiles <starting from the [Ancient era]>"))
|
||||||
EmbarkAndEnterOcean("Can embark and move over Coasts and Oceans immediately", UniqueTarget.Global),
|
EmbarkAndEnterOcean("Can embark and move over Coasts and Oceans immediately", UniqueTarget.Global),
|
||||||
|
|
||||||
PopulationLossFromNukes("Population loss from nuclear attacks [amount]% [cityFilter]", UniqueTarget.Global),
|
PopulationLossFromNukes("Population loss from nuclear attacks [amount]% [cityFilter]", UniqueTarget.Global),
|
||||||
|
@ -551,7 +551,9 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
|
|||||||
??? example "Enables embarkation for land units"
|
??? example "Enables embarkation for land units"
|
||||||
Applicable to: Global
|
Applicable to: Global
|
||||||
|
|
||||||
??? example "Enables embarked units to enter ocean tiles"
|
??? example "Enables [mapUnitFilter] units to enter ocean tiles"
|
||||||
|
Example: "Enables [Wounded] units to enter ocean tiles"
|
||||||
|
|
||||||
Applicable to: Global
|
Applicable to: Global
|
||||||
|
|
||||||
??? example "Population loss from nuclear attacks [amount]% [cityFilter]"
|
??? example "Population loss from nuclear attacks [amount]% [cityFilter]"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user