From c2bd0724e821b2876aab815f9c66f6bc52aa136c Mon Sep 17 00:00:00 2001 From: YueR Date: Wed, 2 Oct 2019 23:21:23 +0800 Subject: [PATCH] update --- core/src/com/unciv/logic/battle/BattleDamage.kt | 7 +++---- core/src/com/unciv/logic/battle/CityCombatant.kt | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/core/src/com/unciv/logic/battle/BattleDamage.kt b/core/src/com/unciv/logic/battle/BattleDamage.kt index db29033383..a7ef5e6cf1 100644 --- a/core/src/com/unciv/logic/battle/BattleDamage.kt +++ b/core/src/com/unciv/logic/battle/BattleDamage.kt @@ -199,8 +199,7 @@ class BattleDamage{ } private fun getHealthDependantDamageRatio(combatant: ICombatant): Float { - return if (combatant.getUnitType() == UnitType.City) 0.75f - else if(combatant.getCivInfo().nation.unique == "Units fight as though they were at full strength even when damaged" && !combatant.getUnitType().isAirUnit()) + return if(combatant.getCivInfo().nation.unique == "Units fight as though they were at full strength even when damaged" && !combatant.getUnitType().isAirUnit()) 1f else 1 - (100 - combatant.getHealth()) / 300f// Each 3 points of health reduces damage dealt by 1% like original game } @@ -228,12 +227,12 @@ class BattleDamage{ if(attacker.isRanged()) return 0 if(defender.getUnitType().isCivilian()) return 0 val ratio = getAttackingStrength(attacker,defender) / getDefendingStrength(attacker,defender) - return (damageModifier(ratio, true) * getHealthDependantDamageRatio(defender)).toInt() + return (damageModifier(ratio, true) * (if(defender.getUnitType() == UnitType.City) 1.00f else getHealthDependantDamageRatio(defender))).toInt() } fun calculateDamageToDefender(attacker: ICombatant, defender: ICombatant): Int { val ratio = getAttackingStrength(attacker,defender) / getDefendingStrength(attacker,defender) - return (damageModifier(ratio,false) * getHealthDependantDamageRatio(attacker)).toInt() + return (damageModifier(ratio,false) * (if(attacker.getUnitType() == UnitType.City) 0.75f else getHealthDependantDamageRatio(attacker))).toInt() } fun damageModifier(attackerToDefenderRatio:Float, damageToAttacker:Boolean): Float { diff --git a/core/src/com/unciv/logic/battle/CityCombatant.kt b/core/src/com/unciv/logic/battle/CityCombatant.kt index b7678ad12f..17583b81a8 100644 --- a/core/src/com/unciv/logic/battle/CityCombatant.kt +++ b/core/src/com/unciv/logic/battle/CityCombatant.kt @@ -26,7 +26,7 @@ class CityCombatant(val city: CityInfo) : ICombatant { } override fun getUnitType(): UnitType = UnitType.City - override fun getAttackingStrength(): Int = getCityStrength()*2/5 // I remember reading this but I don't recall where + override fun getAttackingStrength(): Int = getCityStrength() //If we don't need to multiply by a modifier number (0.75) in Damage Calculations, getCityStrength() should multiply by 1/1.54488 (about 2/3 not 2/5), i use another mathod, because in original game the city only has strength attribute (in other words, City's AttackingStrength() = getCityStrength() in original game). override fun getDefendingStrength(): Int{ if(isDefeated()) return 1 return getCityStrength()