Thursday, March 14, 2019

Critical Hits. The consequence of the defense formula.

So, after giving some thoughts, came to my attention that the Critical Hits in some games are also kind of affected by the Defense formula, I've talked about in a post I've made some time ago, but the diference between the defense formula for normal damage and critical damage is very perceptible, and sometimes fatal, on the gameplay.

The formula of critical hits generally uses:
Damage * CriticalRate - Defense
Ps:. Do notice that I didn't made use of parenthesis between Damage * CriticalRate, because since It's a multiplication before the subtraction of Defense, the multiplication should be done first, so would be redundant to add it.

The problem with such formula is that the Defense status may be useless depending on how high the Damage value is, meaning that if a game uses high numbers for Damage value, the Critical hit can be very deadly.

Let's say for an example: My character have 1000 of Damage, the creature it is attacking have 250 Defense, the damage dealt to health will be:
1000 - 250 = 750
Everything normal here, now let's try with the critical rate of 2 times.
1000 * 2 - 250 = 1750
Do you see the problem? You actually is dealing more damage than the defense can handle, and that could be fatal during gameplay, even more if the player is actually the one who receives the critical hit, It could lead to an instant defeat.

The way of solving that, would be if did kind of the same thing from Defense calculation on the Attack VS Dps thread:
(Damage - Defense) * CriticalRate
Ps:. In this case, the Parenthesis was necessary, because I want the subtractions to happen first, and then the multiplication happen. If you're actually bad at math, take note of this fact when building a formula or solving problems.

That way, the Critical rate is actually the resulting damage after the defense has been calculated, but wait!
The critical rate actually makes the user deal higher damage value, right? So that means the first formula is actually correct? Well, Yes. But actually, you decide which one you're going to use, either use the ideal, Damage * CriticalRate - Defense, or the forgiving one, (Damage - Defense) * CriticalRate.

Just beware of the fact that as stated above, depending on how high the numbers are in your project, the Critical Hit may mean insta defeat to the one inflicted with it, so beware when implementing the system on your project, and try not to do like a certain mmo I've met which relied on Critical Hits to actually inflict damage to creatures, that was very deplorable.

Well, that's all, folks!
Today's post wasn't related to the project, but I hope this help in case someone of you guys decides to build a game someday.

No comments:

Post a Comment