This commit is contained in:
YueR 2019-10-02 23:21:23 +08:00
parent 4afb23d093
commit c2bd0724e8
2 changed files with 4 additions and 5 deletions

View File

@ -199,8 +199,7 @@ class BattleDamage{
} }
private fun getHealthDependantDamageRatio(combatant: ICombatant): Float { private fun getHealthDependantDamageRatio(combatant: ICombatant): Float {
return if (combatant.getUnitType() == UnitType.City) 0.75f return if(combatant.getCivInfo().nation.unique == "Units fight as though they were at full strength even when damaged" && !combatant.getUnitType().isAirUnit())
else if(combatant.getCivInfo().nation.unique == "Units fight as though they were at full strength even when damaged" && !combatant.getUnitType().isAirUnit())
1f 1f
else 1 - (100 - combatant.getHealth()) / 300f// Each 3 points of health reduces damage dealt by 1% like original game 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(attacker.isRanged()) return 0
if(defender.getUnitType().isCivilian()) return 0 if(defender.getUnitType().isCivilian()) return 0
val ratio = getAttackingStrength(attacker,defender) / getDefendingStrength(attacker,defender) 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 { fun calculateDamageToDefender(attacker: ICombatant, defender: ICombatant): Int {
val ratio = getAttackingStrength(attacker,defender) / getDefendingStrength(attacker,defender) 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 { fun damageModifier(attackerToDefenderRatio:Float, damageToAttacker:Boolean): Float {

View File

@ -26,7 +26,7 @@ class CityCombatant(val city: CityInfo) : ICombatant {
} }
override fun getUnitType(): UnitType = UnitType.City 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{ override fun getDefendingStrength(): Int{
if(isDefeated()) return 1 if(isDefeated()) return 1
return getCityStrength() return getCityStrength()