Added Stealth tech and Stealth Bombers (#4271)

* Changed some interception-related uniques

- "Can not be intercepted" -> "Cannot be intercepted"
  This really irked me, and the new version is also how it is written
  in the wiki.
- "Reduces damage taken from interception by 50%" ->
  "Damage taken from interception reduced by [50]%"

* Added "Cannot be carried by [unitFilter] units" unique

* Added an icon for Stealth

* Added Stealth technology and the Stealth Bomber

* Possibly fixed incorrect rounding for interception damage bonus

* Various code style changes

* Made Stealth Bomber interceptable, but with 100% damage reduction
This commit is contained in:
Arthur van der Staaij 2021-06-27 07:57:11 +02:00 committed by GitHub
parent 401c10c132
commit 0f0abad5ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 430 additions and 401 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1010 KiB

After

Width:  |  Height:  |  Size: 1017 KiB

View File

@ -621,8 +621,14 @@
{
"name": "Nanotechnology",
"row": 7,
"prerequisites": ["Robotics","Lasers"],
"prerequisites": ["Robotics"],
"quote": "'The impact of nanotechnology is expected to exceed the impact that the electronics revolution has had on our lives.' - Richard Schwartz"
},
{
"name": "Stealth",
"row": 8,
"prerequisites": ["Robotics", "Lasers"],
"quote": "'Be extremely subtle, even to the point of formlessness, be extremely mysterious, even to the point of soundlessness. Thereby you can be the director of the opponent' state.' Sun Tzu"
}
]
},
@ -636,7 +642,7 @@
{
"name": "Future Tech",
"row": 5,
"prerequisites": ["Particle Physics", "Nuclear Fusion", "Nanotechnology"],
"prerequisites": ["Particle Physics", "Nuclear Fusion", "Nanotechnology", "Stealth"],
"uniques": ["Who knows what the future holds?", "Can be continually researched"],
"quote": "'I think we agree, the past is over.' - George W. Bush"
}

View File

@ -287,7 +287,7 @@
{
"name": "Evasion",
"prerequisites": ["Siege II", "Bombardment II"],
"effect": "Reduces damage taken from interception by 50%",
"effect": "Damage taken from interception reduced by [50]%",
"unitTypes": ["Bomber"]
},

View File

@ -1134,7 +1134,7 @@
"cost": 375,
"requiredTech": "Radar",
"requiredResource": "Oil",
//"upgradesTo": "Stealth Bomber",
"upgradesTo": "Stealth Bomber",
"attackSound": "shot"
},
{
@ -1150,7 +1150,7 @@
"requiredTech": "Radar",
"requiredResource": "Oil",
"promotions": ["Evasion", "Siege I"],
//"upgradesTo": "Stealth Bomber",
"upgradesTo": "Stealth Bomber",
"attackSound": "shot"
},
{
@ -1350,22 +1350,19 @@
"requiredResource": "Uranium",
"uniques": ["Can move after attacking", "No defensive terrain bonus"]
},
/*
{
"name": "Stealth Bomber",
"unitType": "Bomber",
"movement": 2,
"strength": 85,
"rangedStrength": 65,
"rangedStrength": 85,
"range": 20,
"cost": 425,
"requiredTech": "Stealth",
"requiredResource": "Aluminum",
"uniques": ["Evasion", "6 tiles in every direction always visible"],
"uniques": ["Damage taken from interception reduced by [100]%", "Cannot be carried by [Carrier] units", "6 tiles in every direction always visible"],
"attackSound": "shot"
// cannot be based on carrier
},
*/
/* Great people */

View File

@ -579,13 +579,19 @@ object Battle {
private fun tryInterceptAirAttack(attacker: MapUnitCombatant, defender: ICombatant) {
if (attacker.unit.hasUnique("Cannot be intercepted")) return
// Deprecated since 3.15.6
if (attacker.unit.hasUnique("Can not be intercepted")) return
// End deprecation
val attackedTile = defender.getTile()
for (interceptor in defender.getCivInfo().getCivUnits().filter { it.canIntercept(attackedTile) }) {
if (Random().nextFloat() > 100f / interceptor.interceptChance()) continue
var damage = BattleDamage.calculateDamageToDefender(MapUnitCombatant(interceptor), null, attacker)
damage += damage * interceptor.interceptDamagePercentBonus() / 100
if (attacker.unit.hasUnique("Reduces damage taken from interception by 50%")) damage /= 2
var damageFactor = 1f + interceptor.interceptDamagePercentBonus().toFloat() / 100f
damageFactor *= attacker.unit.receivedInterceptDamageFactor()
damage = (damage.toFloat() * damageFactor).toInt()
attacker.takeDamage(damage)
interceptor.attacksThisTurn++

View File

@ -14,6 +14,7 @@ import com.unciv.models.ruleset.tile.TileImprovement
import com.unciv.models.ruleset.unit.BaseUnit
import com.unciv.models.ruleset.unit.UnitType
import java.text.DecimalFormat
import kotlin.math.pow
import kotlin.random.Random
/**
@ -835,6 +836,7 @@ class MapUnit {
fun canTransport(unit: MapUnit): Boolean {
if (owner != unit.owner) return false
if (!isTransportTypeOf(unit)) return false
if (unit.getMatchingUniques("Cannot be carried by [] units").any{matchesFilter(it.params[0])}) return false
if (currentTile.airUnits.count { it.isTransported } >= carryCapacity(unit)) return false
return true
}
@ -844,6 +846,16 @@ class MapUnit {
.sumBy { it.params[0].toInt() }
}
fun receivedInterceptDamageFactor(): Float {
var damageFactor = 1f
for (unique in getMatchingUniques("Damage taken from interception reduced by []%"))
damageFactor *= 1f - unique.params[0].toFloat() / 100f
// Deprecated since 3.15.6
damageFactor *= 0.5f.pow(getUniques().count{it.text == "Reduces damage taken from interception by 50%"})
// End deprecation
return damageFactor
}
private fun getTerrainDamage() {
// hard coded mountain damage for now
if (getTile().baseTerrain == Constants.mountain) {

View File

@ -472,6 +472,7 @@ Unless otherwise specified, all the following are from [the Noun Project](https:
* [Atom](https://thenounproject.com/term/atom/1586852/) By Kelsey Armstrong for Particle Physics
* [Thermonuclear fusion](https://thenounproject.com/search/?q=fusion&i=3292735) by Olena Panasovska, UA for Nuclear Fusion
* [telecommunications](https://thenounproject.com/search/?q=telecommunications&i=3191260) by Wichai Wi for Telcommunications
* [Radar](https://thenounproject.com/term/radar/1546196/) By CINDYFLA, ID for Stealth
* [Information Technology](https://thenounproject.com/term/information-technology/1927668/) By Vectors Markeet for Future Tech
## Terrain