From 64fc57e6d231676d0c0ecccbc2e53309a5375ec4 Mon Sep 17 00:00:00 2001 From: givehub99 <71454921+givehub99@users.noreply.github.com> Date: Mon, 26 Oct 2020 11:28:44 -0700 Subject: [PATCH] Helicopter Gunship uniques (#3294) * Preparation for Helicopter unit -"All tiles costs 1" unique makes every tile cost 1. Used by Helicopter in CIV 5. -"Can pass through impassable tiles" unique allows unit to pass through any tile. Used by Helicopter in CIV 5. Does not let units cross ocean if they couldn't already, just terrain that is considered "impassable" -Mountains now do 50 damage to units that end turn on it. In civ 5 and its expansion this is what happens to any unit that is able to pass mountains. This is "hard coded" for now. Also added the notification text to template.properties * mountains do not give sight bonus when on them * Revert "mountains do not give sight bonus when on them" This reverts commit 83ad3df5d422ad0688f2eea9a0011341508a0032. --- .../jsons/translations/template.properties | 2 ++ core/src/com/unciv/logic/map/MapUnit.kt | 19 +++++++++++++++++++ .../unciv/logic/map/UnitMovementAlgorithms.kt | 7 +++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index 5372409f2b..8e900cb5a6 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -448,6 +448,8 @@ Clearing a [forest] has created [amount] Production for [cityName] = [civName] assigned you a new quest: [questName]. = [civName] rewarded you with [influence] influence for completing the [questName] quest. = The resistance in [cityName] has ended! = +Our [name] took [tileDamage] tile damage and was destroyed = +Our [name] took [tileDamage] tile damage = # World Screen UI diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index fb45e7050c..09e3ce833b 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -31,6 +31,8 @@ class MapUnit { // a major component of getDistanceToTilesWithinTurn, // which in turn is a component of getShortestPath and canReach @Transient var ignoresTerrainCost = false + @Transient var allTilesCosts1 = false + @Transient var canPassThroughImpassableTiles = false @Transient var roughTerrainPenalty = false @Transient var doubleMovementInCoast = false @Transient var doubleMovementInForestAndJungle = false @@ -121,6 +123,8 @@ class MapUnit { tempUniques = uniques + allTilesCosts1 = hasUnique("All tiles costs 1") + canPassThroughImpassableTiles = hasUnique("Can pass through impassable tiles") ignoresTerrainCost = hasUnique("Ignores terrain cost") roughTerrainPenalty = hasUnique("Rough terrain penalty") doubleMovementInCoast = hasUnique("Double movement in coast") @@ -439,6 +443,7 @@ class MapUnit { } getCitadelDamage() + getTerrainDamage() } fun startTurn() { @@ -657,6 +662,20 @@ class MapUnit { .sumBy { it.params[0].toInt() } } + private fun getTerrainDamage() { + // hard coded mountain damage for now + if (getTile().baseTerrain == Constants.mountain) { + val tileDamage = 50 + health -= tileDamage + + if (health <= 0) { + civInfo.addNotification("Our [$name] took [$tileDamage] tile damage and was destroyed", currentTile.position, Color.RED) + destroy() + } else civInfo.addNotification("Our [$name] took [$tileDamage] tile damage", currentTile.position, Color.RED) + } + + } + private fun getCitadelDamage() { // Check for Citadel damage val applyCitadelDamage = currentTile.neighbors diff --git a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt index 6769d5ab95..d517f147c5 100644 --- a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt +++ b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt @@ -8,6 +8,8 @@ class UnitMovementAlgorithms(val unit:MapUnit) { // This function is called ALL THE TIME and should be as time-optimal as possible! fun getMovementCostBetweenAdjacentTiles(from: TileInfo, to: TileInfo, civInfo: CivilizationInfo): Float { + if (unit.allTilesCosts1) + return 1f if ((from.isLand != to.isLand) && !unit.civInfo.nation.embarkDisembarkCosts1 && unit.type.isLandUnit()) return 100f // this is embarkment or disembarkment, and will take the entire turn @@ -330,8 +332,9 @@ class UnitMovementAlgorithms(val unit:MapUnit) { // because optimization on this function results in massive benefits! fun canPassThrough(tile: TileInfo): Boolean { if (tile.isImpassible()){ - // special exception - ice tiles are technically impassible, but somme units can move through them anyway - if (!(tile.terrainFeature == Constants.ice && unit.canEnterIceTiles)) + // special exception - ice tiles are technically impassible, but some units can move through them anyway + // helicopters can pass through impassable tiles like mountains + if (!(tile.terrainFeature == Constants.ice && unit.canEnterIceTiles) && !unit.canPassThroughImpassableTiles) return false } if (tile.isLand