mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-09 10:29:02 +07: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
|
||||
|
||||
// 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))
|
||||
modifiers["Boarding"] = -50
|
||||
// Naval Unit Melee attacking to Land (not City) unit
|
||||
if (attacker.unit.type.isWaterUnit() && attacker.isMelee() && !defender.getTile().isWater
|
||||
// Melee Unit on water attacking to Land (not City) unit
|
||||
if (!attacker.unit.type.isAirUnit() && attacker.isMelee() && attacker.getTile().isWater && !defender.getTile().isWater
|
||||
&& !attacker.unit.hasUnique(UniqueType.AttackAcrossCoast) && !defender.isCity())
|
||||
modifiers["Landing"] = -50
|
||||
// Air unit attacking with Air Sweep
|
||||
|
@ -378,6 +378,7 @@ class MapUnit : IsPartOfGameInfoSerialization {
|
||||
|
||||
fun isEmbarked(): Boolean {
|
||||
if (!baseUnit.isLandUnit()) return false
|
||||
if (cache.canMoveOnWater) return false
|
||||
return currentTile.isWater
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,9 @@ class MapUnitCache(private val mapUnit: MapUnit) {
|
||||
var allTilesCosts1 = false
|
||||
private set
|
||||
|
||||
var canMoveOnWater = false
|
||||
private set
|
||||
|
||||
var canPassThroughImpassableTiles = false
|
||||
private set
|
||||
|
||||
@ -75,6 +78,7 @@ class MapUnitCache(private val mapUnit: MapUnit) {
|
||||
ignoresZoneOfControl = mapUnit.hasUnique(UniqueType.IgnoresZOC)
|
||||
roughTerrainPenalty = mapUnit.hasUnique(UniqueType.RoughTerrainPenalty)
|
||||
cannotMove = mapUnit.hasUnique(UniqueType.CannotMove) || mapUnit.baseUnit.movement == 0
|
||||
canMoveOnWater = mapUnit.hasUnique(UniqueType.CanMoveOnWater)
|
||||
|
||||
doubleMovementInTerrain.clear()
|
||||
for (unique in mapUnit.getMatchingUniques(UniqueType.DoubleMovementOnTerrain, stateForConditionals = StateForConditionals.IgnoreConditionals)) {
|
||||
|
@ -37,7 +37,7 @@ class UnitMovement(val unit: MapUnit) {
|
||||
): Float {
|
||||
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
|
||||
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),
|
||||
DoubleMovementOnTerrain("Double movement in [terrainFilter]", 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),
|
||||
IgnoresTerrainCost("Ignores terrain cost", UniqueTarget.Unit),
|
||||
IgnoresZOC("Ignores Zone of Control", UniqueTarget.Unit),
|
||||
|
Loading…
Reference in New Issue
Block a user