mirror of
https://github.com/yairm210/Unciv.git
synced 2025-10-02 16:31:15 -04:00
Clean up some differences between units that can move on water and other units (#9841)
* Clean up some differences between units that can move on water, water units, and land units * Strangely no evidence this actually comes up? * refernce the cache in more places * Decided to change this back to match expected results * Remove unnecessary parenthesis
This commit is contained in:
parent
b838d8ec5a
commit
203ee77c8b
@ -121,8 +121,8 @@ object BattleHelper {
|
|||||||
if (tileCombatant is CityCombatant && tileCombatant.city.hasJustBeenConquered) return false
|
if (tileCombatant is CityCombatant && tileCombatant.city.hasJustBeenConquered) return false
|
||||||
if (!combatant.getCivInfo().isAtWarWith(tileCombatant.getCivInfo())) return false
|
if (!combatant.getCivInfo().isAtWarWith(tileCombatant.getCivInfo())) return false
|
||||||
|
|
||||||
if (combatant is MapUnitCombatant && combatant.isLandUnit() && combatant.isMelee() &&
|
if (combatant is MapUnitCombatant && combatant.isLandUnit() && combatant.isMelee() && tile.isWater &&
|
||||||
!combatant.hasUnique(UniqueType.LandUnitEmbarkation) && tile.isWater
|
!combatant.getCivInfo().tech.unitsCanEmbark && !combatant.unit.cache.canMoveOnWater
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ object BattleDamage {
|
|||||||
val modifiers = getGeneralModifiers(attacker, defender, CombatAction.Attack, tileToAttackFrom)
|
val modifiers = getGeneralModifiers(attacker, defender, CombatAction.Attack, tileToAttackFrom)
|
||||||
|
|
||||||
if (attacker is MapUnitCombatant) {
|
if (attacker is MapUnitCombatant) {
|
||||||
if (attacker.unit.isEmbarked()
|
if (attacker.unit.isEmbarked() && defender.getTile().isLand
|
||||||
&& !attacker.unit.hasUnique(UniqueType.AttackAcrossCoast))
|
&& !attacker.unit.hasUnique(UniqueType.AttackAcrossCoast))
|
||||||
modifiers["Landing"] = -50
|
modifiers["Landing"] = -50
|
||||||
|
|
||||||
|
@ -513,7 +513,7 @@ class TileMap(initialCapacity: Int = 10) : IsPartOfGameInfoSerialization {
|
|||||||
var potentialCandidates = getPassableNeighbours(currentTile)
|
var potentialCandidates = getPassableNeighbours(currentTile)
|
||||||
while (unitToPlaceTile == null && tryCount++ < 10) {
|
while (unitToPlaceTile == null && tryCount++ < 10) {
|
||||||
unitToPlaceTile = potentialCandidates
|
unitToPlaceTile = potentialCandidates
|
||||||
.sortedByDescending { if (unit.baseUnit.isLandUnit()) it.isLand else true } // Land units should prefer to go into land tiles
|
.sortedByDescending { if (unit.baseUnit.isLandUnit() && !unit.cache.canMoveOnWater) it.isLand else true } // Land units should prefer to go into land tiles
|
||||||
.firstOrNull { unit.movement.canMoveTo(it) }
|
.firstOrNull { unit.movement.canMoveTo(it) }
|
||||||
if (unitToPlaceTile != null) continue
|
if (unitToPlaceTile != null) continue
|
||||||
// if it's not found yet, let's check their neighbours
|
// if it's not found yet, let's check their neighbours
|
||||||
|
@ -509,6 +509,7 @@ class MapUnit : IsPartOfGameInfoSerialization {
|
|||||||
var healing = when {
|
var healing = when {
|
||||||
tile.isCityCenter() -> 25
|
tile.isCityCenter() -> 25
|
||||||
tile.isWater && isFriendlyTerritory && (baseUnit.isWaterUnit() || isTransported) -> 20 // Water unit on friendly water
|
tile.isWater && isFriendlyTerritory && (baseUnit.isWaterUnit() || isTransported) -> 20 // Water unit on friendly water
|
||||||
|
tile.isWater && isFriendlyTerritory && cache.canMoveOnWater -> 20 // Treated as a water unit on friendly water
|
||||||
tile.isWater -> 0 // All other water cases
|
tile.isWater -> 0 // All other water cases
|
||||||
isFriendlyTerritory -> 20 // Allied territory
|
isFriendlyTerritory -> 20 // Allied territory
|
||||||
tile.getOwner() == null -> 10 // Neutral territory
|
tile.getOwner() == null -> 10 // Neutral territory
|
||||||
|
@ -769,7 +769,7 @@ class UnitMovement(val unit: MapUnit) {
|
|||||||
unit.civ.getMatchingUniques(UniqueType.UnitsMayEnterOcean)
|
unit.civ.getMatchingUniques(UniqueType.UnitsMayEnterOcean)
|
||||||
.any { unit.matchesFilter(it.params[0]) }
|
.any { unit.matchesFilter(it.params[0]) }
|
||||||
}
|
}
|
||||||
if (tile.isWater && unit.baseUnit.isLandUnit()) {
|
if (tile.isWater && unit.baseUnit.isLandUnit() && !unit.cache.canMoveOnWater) {
|
||||||
if (!unit.civ.tech.unitsCanEmbark) return false
|
if (!unit.civ.tech.unitsCanEmbark) return false
|
||||||
if (tile.isOcean && !unit.civ.tech.embarkedUnitsCanEnterOcean && !unitSpecificAllowOcean)
|
if (tile.isOcean && !unit.civ.tech.embarkedUnitsCanEnterOcean && !unitSpecificAllowOcean)
|
||||||
return false
|
return false
|
||||||
@ -791,7 +791,7 @@ class UnitMovement(val unit: MapUnit) {
|
|||||||
if (firstUnit != null && unit.civ != firstUnit.civ) {
|
if (firstUnit != null && unit.civ != firstUnit.civ) {
|
||||||
// Allow movement through unguarded, at-war Civilian Unit. Capture on the way
|
// Allow movement through unguarded, at-war Civilian Unit. Capture on the way
|
||||||
// But not for Embarked Units capturing on Water
|
// But not for Embarked Units capturing on Water
|
||||||
if (!(unit.baseUnit.isLandUnit() && tile.isWater)
|
if (!(unit.baseUnit.isLandUnit() && tile.isWater && !unit.cache.canMoveOnWater)
|
||||||
&& firstUnit.isCivilian() && unit.civ.isAtWarWith(firstUnit.civ))
|
&& firstUnit.isCivilian() && unit.civ.isAtWarWith(firstUnit.civ))
|
||||||
return true
|
return true
|
||||||
// Cannot enter hostile tile with any unit in there
|
// Cannot enter hostile tile with any unit in there
|
||||||
|
Loading…
x
Reference in New Issue
Block a user