mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -04:00
Move on water (#9622)
* Add in Move on water unique * Small fixes * Remove redundant check
This commit is contained in:
parent
47e93a86bf
commit
f78fd7e665
@ -119,11 +119,11 @@ object BattleDamage {
|
|||||||
modifiers["Landing"] = -50
|
modifiers["Landing"] = -50
|
||||||
|
|
||||||
// Land Melee Unit attacking to Water
|
// Land Melee Unit attacking to Water
|
||||||
if (attacker.unit.type.isLandUnit() && !attacker.unit.isEmbarked() && attacker.isMelee() && defender.getTile().isWater
|
if (attacker.unit.type.isLandUnit() && !attacker.getTile().isWater && attacker.isMelee() && defender.getTile().isWater
|
||||||
&& !attacker.unit.hasUnique(UniqueType.AttackAcrossCoast))
|
&& !attacker.unit.hasUnique(UniqueType.AttackAcrossCoast))
|
||||||
modifiers["Boarding"] = -50
|
modifiers["Boarding"] = -50
|
||||||
// Naval Unit Melee attacking to Land (not City) unit
|
// Melee Unit on water attacking to Land (not City) unit
|
||||||
if (attacker.unit.type.isWaterUnit() && attacker.isMelee() && !defender.getTile().isWater
|
if (!attacker.unit.type.isAirUnit() && attacker.isMelee() && attacker.getTile().isWater && !defender.getTile().isWater
|
||||||
&& !attacker.unit.hasUnique(UniqueType.AttackAcrossCoast) && !defender.isCity())
|
&& !attacker.unit.hasUnique(UniqueType.AttackAcrossCoast) && !defender.isCity())
|
||||||
modifiers["Landing"] = -50
|
modifiers["Landing"] = -50
|
||||||
// Air unit attacking with Air Sweep
|
// Air unit attacking with Air Sweep
|
||||||
|
@ -378,6 +378,7 @@ class MapUnit : IsPartOfGameInfoSerialization {
|
|||||||
|
|
||||||
fun isEmbarked(): Boolean {
|
fun isEmbarked(): Boolean {
|
||||||
if (!baseUnit.isLandUnit()) return false
|
if (!baseUnit.isLandUnit()) return false
|
||||||
|
if (cache.canMoveOnWater) return false
|
||||||
return currentTile.isWater
|
return currentTile.isWater
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,9 @@ class MapUnitCache(private val mapUnit: MapUnit) {
|
|||||||
var allTilesCosts1 = false
|
var allTilesCosts1 = false
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
var canMoveOnWater = false
|
||||||
|
private set
|
||||||
|
|
||||||
var canPassThroughImpassableTiles = false
|
var canPassThroughImpassableTiles = false
|
||||||
private set
|
private set
|
||||||
|
|
||||||
@ -75,6 +78,7 @@ class MapUnitCache(private val mapUnit: MapUnit) {
|
|||||||
ignoresZoneOfControl = mapUnit.hasUnique(UniqueType.IgnoresZOC)
|
ignoresZoneOfControl = mapUnit.hasUnique(UniqueType.IgnoresZOC)
|
||||||
roughTerrainPenalty = mapUnit.hasUnique(UniqueType.RoughTerrainPenalty)
|
roughTerrainPenalty = mapUnit.hasUnique(UniqueType.RoughTerrainPenalty)
|
||||||
cannotMove = mapUnit.hasUnique(UniqueType.CannotMove) || mapUnit.baseUnit.movement == 0
|
cannotMove = mapUnit.hasUnique(UniqueType.CannotMove) || mapUnit.baseUnit.movement == 0
|
||||||
|
canMoveOnWater = mapUnit.hasUnique(UniqueType.CanMoveOnWater)
|
||||||
|
|
||||||
doubleMovementInTerrain.clear()
|
doubleMovementInTerrain.clear()
|
||||||
for (unique in mapUnit.getMatchingUniques(UniqueType.DoubleMovementOnTerrain, stateForConditionals = StateForConditionals.IgnoreConditionals)) {
|
for (unique in mapUnit.getMatchingUniques(UniqueType.DoubleMovementOnTerrain, stateForConditionals = StateForConditionals.IgnoreConditionals)) {
|
||||||
|
@ -37,7 +37,7 @@ class UnitMovement(val unit: MapUnit) {
|
|||||||
): Float {
|
): Float {
|
||||||
if (unit.cache.cannotMove) return 100f
|
if (unit.cache.cannotMove) return 100f
|
||||||
|
|
||||||
if (from.isLand != to.isLand && unit.baseUnit.isLandUnit())
|
if (from.isLand != to.isLand && unit.baseUnit.isLandUnit() && !unit.cache.canMoveOnWater)
|
||||||
return if (from.isWater && to.isLand) unit.cache.costToDisembark ?: 100f
|
return if (from.isWater && to.isLand) unit.cache.costToDisembark ?: 100f
|
||||||
else unit.cache.costToEmbark ?: 100f
|
else unit.cache.costToEmbark ?: 100f
|
||||||
|
|
||||||
|
@ -506,6 +506,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
|||||||
CannotMove("Cannot move", UniqueTarget.Unit),
|
CannotMove("Cannot move", UniqueTarget.Unit),
|
||||||
DoubleMovementOnTerrain("Double movement in [terrainFilter]", UniqueTarget.Unit),
|
DoubleMovementOnTerrain("Double movement in [terrainFilter]", UniqueTarget.Unit),
|
||||||
AllTilesCost1Move("All tiles cost 1 movement", UniqueTarget.Unit),
|
AllTilesCost1Move("All tiles cost 1 movement", UniqueTarget.Unit),
|
||||||
|
CanMoveOnWater("May travel on Water tiles without embarking", UniqueTarget.Unit),
|
||||||
CanPassImpassable("Can pass through impassable tiles", UniqueTarget.Unit),
|
CanPassImpassable("Can pass through impassable tiles", UniqueTarget.Unit),
|
||||||
IgnoresTerrainCost("Ignores terrain cost", UniqueTarget.Unit),
|
IgnoresTerrainCost("Ignores terrain cost", UniqueTarget.Unit),
|
||||||
IgnoresZOC("Ignores Zone of Control", UniqueTarget.Unit),
|
IgnoresZOC("Ignores Zone of Control", UniqueTarget.Unit),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user