Combat Mechanics: Difference between revisions
From Ymirheim Wiki
(Combat mechanics stuff moved to the appropriate page.) |
(small formatting to the hyper link) |
||
(11 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
<translate> | |||
<!--T:1--> | |||
This page describes various combat mechanics and their calculation. | This page describes various combat mechanics and their calculation. | ||
== The Hit | == The Hit Chance Formula == <!--T:2--> | ||
The hit | <!--T:3--> | ||
The hit chance formula is <code>85% + (AttackerAccuracy - TargetEvasion)</code> | |||
Hit chance is capped at 2% (meaning that your attacks now have only 2% chance to miss even if your Accuracy is way higher that the target’s Evasion) and at 95% (meaning that your attacks now have 5% chance to hit the target regardless of the target’s Evasion). | |||
== The Cast Time Formula == | == The Cast Time Formula == <!--T:4--> | ||
The cast time formula is BaseCastTime / (1 + (CastSpeed / 100)) | |||
<!--T:5--> | |||
The cast time formula is <code>BaseCastTime / (1 + (CastSpeed / 100))</code> | |||
</translate> | |||
== Damage Calculation == | |||
=== Skill attack value === | |||
Damage calculation for any combat skill (including normal weapon skill, aka auto attack) starts with calculating the attack value: | |||
# Depending on the type of the attack (melee/ranged/magic), the maximum attack value is taken from the corresponding attack attribute (for example, for the melee attacks, the MeleeAttack attribute total value is taken).<br/><code>maxAttack = MeleeAttackAttribute.Total</code> | |||
# To determine the minimal attack value, balance factor is applied to the maximum attack value (using the result of the [[Combat_Calculation_Functions#line-172|MinAttackModifierPerBalance]] function). For example, if your balance is 60%, your minimal attack value is 60% of your maximum attack.<br/><code>minAttack = (int)(maxAttack * MinAttackModifierPerBalance(MeleeBalanceAttribute.Total))</code> | |||
# The same two steps are done to determine the minimal and maximum weapon attack (using the values of the `WeaponMeleeAttack`/`WeaponRangedAttack`/`WeaponMagicalPower` attributes:<br/><code>maxWeaponAttack = WeaponMeleeAttackAttribute.Total</code><br/><code>minWeaponAttack = (int)(maxWeaponAttack * MinAttackModifierPerBalance(MeleeBalanceAttribute.Total))</code> | |||
# If the attack is critical, the resulting attack is always the maximum attack value multiplied by the critical attack value (140% by default). This applies only to the character's attack, not to the weapon attack values. If the attack is not critical, the resulting attack value is a random value in between the minimal and maximum attack.<br/><code>attack = EffectKind == Critical ? (int)(maxAttack * (1.0 + (MeleeCriticalAttackAttribute.Total / 1000.0))) : Random.Next(minAttack, maxAttack + 1)</code> | |||
# Then attack power multiplier is applied to the resulting value. This can come from skills that say, for example, "200% Attack Power".<br/><code>attack = (int)(attack * (1f + AttackPowerAttribute.Modifier)) + AttackPowerAttribute.Bonus</code> | |||
# If the resulting value is lower than 1, it gets brought up to 1.<br/><code>attack = Math.Max(attack, 1);</code> | |||
# Then the weapon attack (which is random between the minimal and maximum weapon attack) is added to the resulting value.<br/><code>attack = attack + Random.Next(minWeaponAttack, maxWeaponAttack + 1)</code> | |||
# Finally, in case of an offensive skill attack, any attack modifiers based on the target type, and then on the target size, are applied if suitable. For example, if the attacker has +20% attack against the Fish type enemies and the target is Fish, the resulting attack will be multiplied by 20%. This is considered final skill attack value, for example: <br/><code>attackModifier = 1.0f + (FishAttackAttribute.Total / 1000.0f)</code><br/><code>attack = (int)Math.Max(attack * attackModifier, 1)</code> | |||
=== Damage reduction === | |||
After the final attack value is calculated, it can be reduced by the target's defenses: | |||
# The defense value is first taken from the target's defense attribute that corresponds to the type of the attack: `MeleeDefense`/`RangedDefense`/`MagicResistance` | |||
# Attacker's defense penetration then gets subtracted from the defense value, which gets taken from the attacker's `MeleeDefensePenetration`/`RangedDefensePenetration`/`MagicPenetration` attributes depending on the type of the attack. But the resulting value cannot go below 0.<br/><code>var defense = Math.Max(target.MagicResistanceAttribute.Total - attacker.MagicPenetrationAttribute.Total, 0)</code> | |||
# The damage is then calculated from the attack value multiplied by the value from the [[Combat_Calculation_Functions#line-127|DamageReductionFactorPerDefense]] and then [[Combat_Calculation_Functions#line-121|DamageReductionPerDefense]] gets subtracted as well: <code>var damage = (int)Math.Max((attack * DamageReductionFactorPerDefense(defense)) - DamageReductionPerDefense(defense), 1);</code> | |||
# After that, any additional elemental, size, type defenses are getting applied as well, in the same order. These defenses don't have any flat damage reduction, they only have the factors, and are calculated using [[Combat_Calculation_Functions#line-133|DamageReductionFactorPerElementalDefense]] like this: <br/><code>damage = (int)Math.Max(damage * DamageReductionFactorPerElementalDefense(elementalDefense), 1);</code> | |||
# The resulting damage cannot be lower than 1. |
Latest revision as of 11:40, 23 July 2025
This page describes various combat mechanics and their calculation.
The Hit Chance Formula
The hit chance formula is 85% + (AttackerAccuracy - TargetEvasion)
Hit chance is capped at 2% (meaning that your attacks now have only 2% chance to miss even if your Accuracy is way higher that the target’s Evasion) and at 95% (meaning that your attacks now have 5% chance to hit the target regardless of the target’s Evasion).
The Cast Time Formula
The cast time formula is BaseCastTime / (1 + (CastSpeed / 100))
Damage Calculation
Skill attack value
Damage calculation for any combat skill (including normal weapon skill, aka auto attack) starts with calculating the attack value:
- Depending on the type of the attack (melee/ranged/magic), the maximum attack value is taken from the corresponding attack attribute (for example, for the melee attacks, the MeleeAttack attribute total value is taken).
maxAttack = MeleeAttackAttribute.Total
- To determine the minimal attack value, balance factor is applied to the maximum attack value (using the result of the MinAttackModifierPerBalance function). For example, if your balance is 60%, your minimal attack value is 60% of your maximum attack.
minAttack = (int)(maxAttack * MinAttackModifierPerBalance(MeleeBalanceAttribute.Total))
- The same two steps are done to determine the minimal and maximum weapon attack (using the values of the `WeaponMeleeAttack`/`WeaponRangedAttack`/`WeaponMagicalPower` attributes:
maxWeaponAttack = WeaponMeleeAttackAttribute.Total
minWeaponAttack = (int)(maxWeaponAttack * MinAttackModifierPerBalance(MeleeBalanceAttribute.Total))
- If the attack is critical, the resulting attack is always the maximum attack value multiplied by the critical attack value (140% by default). This applies only to the character's attack, not to the weapon attack values. If the attack is not critical, the resulting attack value is a random value in between the minimal and maximum attack.
attack = EffectKind == Critical ? (int)(maxAttack * (1.0 + (MeleeCriticalAttackAttribute.Total / 1000.0))) : Random.Next(minAttack, maxAttack + 1)
- Then attack power multiplier is applied to the resulting value. This can come from skills that say, for example, "200% Attack Power".
attack = (int)(attack * (1f + AttackPowerAttribute.Modifier)) + AttackPowerAttribute.Bonus
- If the resulting value is lower than 1, it gets brought up to 1.
attack = Math.Max(attack, 1);
- Then the weapon attack (which is random between the minimal and maximum weapon attack) is added to the resulting value.
attack = attack + Random.Next(minWeaponAttack, maxWeaponAttack + 1)
- Finally, in case of an offensive skill attack, any attack modifiers based on the target type, and then on the target size, are applied if suitable. For example, if the attacker has +20% attack against the Fish type enemies and the target is Fish, the resulting attack will be multiplied by 20%. This is considered final skill attack value, for example:
attackModifier = 1.0f + (FishAttackAttribute.Total / 1000.0f)
attack = (int)Math.Max(attack * attackModifier, 1)
Damage reduction
After the final attack value is calculated, it can be reduced by the target's defenses:
- The defense value is first taken from the target's defense attribute that corresponds to the type of the attack: `MeleeDefense`/`RangedDefense`/`MagicResistance`
- Attacker's defense penetration then gets subtracted from the defense value, which gets taken from the attacker's `MeleeDefensePenetration`/`RangedDefensePenetration`/`MagicPenetration` attributes depending on the type of the attack. But the resulting value cannot go below 0.
var defense = Math.Max(target.MagicResistanceAttribute.Total - attacker.MagicPenetrationAttribute.Total, 0)
- The damage is then calculated from the attack value multiplied by the value from the DamageReductionFactorPerDefense and then DamageReductionPerDefense gets subtracted as well:
var damage = (int)Math.Max((attack * DamageReductionFactorPerDefense(defense)) - DamageReductionPerDefense(defense), 1);
- After that, any additional elemental, size, type defenses are getting applied as well, in the same order. These defenses don't have any flat damage reduction, they only have the factors, and are calculated using DamageReductionFactorPerElementalDefense like this:
damage = (int)Math.Max(damage * DamageReductionFactorPerElementalDefense(elementalDefense), 1);
- The resulting damage cannot be lower than 1.