From 8602087edcb35654caa4c5be5db91e2f63d41dd1 Mon Sep 17 00:00:00 2001 From: YueR Date: Sun, 29 Sep 2019 02:17:08 +0800 Subject: [PATCH] update --- .../com/unciv/logic/battle/BattleDamage.kt | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/core/src/com/unciv/logic/battle/BattleDamage.kt b/core/src/com/unciv/logic/battle/BattleDamage.kt index df543a01..6c7e2be8 100644 --- a/core/src/com/unciv/logic/battle/BattleDamage.kt +++ b/core/src/com/unciv/logic/battle/BattleDamage.kt @@ -4,7 +4,9 @@ import com.unciv.Constants import com.unciv.logic.map.MapUnit import com.unciv.logic.map.TileInfo import com.unciv.models.gamebasics.unit.UnitType +import java.util.Random import kotlin.math.max +import kotlin.math.pow class BattleDamageModifier(val vs:String,val modificationAmount:Float){ fun getText(): String = "vs $vs" @@ -194,10 +196,12 @@ class BattleDamage{ } private fun getHealthDependantDamageRatio(combatant: ICombatant): Float { - if (combatant.getUnitType() == UnitType.City - || combatant.getCivInfo().nation.unique == "Units fight as though they were at full strength even when damaged") - return 1f - return 1/2f + combatant.getHealth()/200f // Each point of health reduces damage dealt by 0.5% + 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()!=UnitType.Fighter + && combatant.getUnitType()!=UnitType.Bomber) + 1f + else 1 - (100 - combatant.getHealth()) / 300f// Each 3 points of health reduces damage dealt by 1% like original game } @@ -222,12 +226,14 @@ class BattleDamage{ fun calculateDamageToAttacker(attacker: ICombatant, defender: ICombatant): Int { if(attacker.isRanged()) return 0 if(defender.getUnitType().isCivilian()) return 0 - val ratio = getDefendingStrength(attacker,defender) / getAttackingStrength(attacker,defender) - return (ratio * 30 * getHealthDependantDamageRatio(defender)).toInt() + val ratio = getAttackingStrength(attacker,defender) / getDefendingStrength(attacker,defender) + val i = if (ratio < 1) -1 else 1 + return ((24 + 12 * Random().nextFloat()) * ((ratio.pow(i) + 3).pow(4) / 512 + 0.5).pow(i) * getHealthDependantDamageRatio(defender)).toInt() } fun calculateDamageToDefender(attacker: ICombatant, defender: ICombatant): Int { val ratio = getAttackingStrength(attacker,defender) / getDefendingStrength(attacker,defender) - return (ratio * 30 * getHealthDependantDamageRatio(attacker)).toInt() + val i = if (ratio < 1) -1 else 1 + return ((24 + 12 * Random().nextFloat()) * ((ratio.pow(i) + 3).pow(4) / 512 + 0.5).pow(i) * getHealthDependantDamageRatio(attacker)).toInt() } }