# Need plugin for Critical Hits to ignore defense

#### Animebryan

##### And like a Phoenix, I raise from my ashes!
I need a plugin for making critical hits ignore defense. I've had people mention that it might be possible to do with the damage formula but I have yet to come across a way to do that. Any help would be appreciated.

#### Llareian

##### Jack of All Trades, Master of None
In your damage formula, you need to use the following:
(b.result().critical ? x : y)
This says that if the result is critical, the value is x, and if the result is not critical, the value is y.

On the default damage formula, which reads
a.atk * 4 - b.def * 2
you would instead change it to
a.atk * 4 - (b.result().critical ? 0 : b.def * 2)

Adapt this to however your damage formula uses defense to effectively ignore defense.

#### bgillisp

##### Global Moderators
Incidentally, for anyone to be able to write this plug-in, you'll have to share your damage formula. The reason is the damage formula is eval'd as one entire expression, and javascript cannot just ignore one part of one line. That's just not how code works. So you'll have to share your formula, then call a custom function in the damage box to pass the key parameters to the function the writer writes, then it can check for critical hit or not, and call which formula it needs to.

Either way, you'll have to post your damage formula for this to even be possible.

#### Animebryan

##### And like a Phoenix, I raise from my ashes!
Here's the damage formula I'm using: (a.atk - b.def / 2) / 2
However, I'm going back & forth between / 2 & / 3 at the end, because the original formula randomly shifts between / 2 & / 4, but currently I'm using / 2 for the time being.

Edit: I just tried the formula like this: (a.atk - (b.result().critical ? 0 : b.def / 2) / 2)
Its now completely ignoring defense, even for normal hits. Either the formula suggested is wrong or I did it wrong.

Last edited:

bumping for help

#### Animebryan

##### And like a Phoenix, I raise from my ashes!
I'm seriously begging for help here. I need either a plugin to make this work or a damage formula, I just need something to make this work.

#### scanime

##### Will Make RPGs For Fun
I tried the formula in a brand new game, and it seemed to work for me. To test it, I edited the Minotaur enemy and gave him 300 DEF. Then I made a copy of Harold (his twin brother Horald) and gave him a new trait: Ex-Paramter Critical Rate +1000%. With that, he is pretty much guaranteed to land a critical hit every time.

When I did a test battle, Harold would hit but never did any damage because of the Minotaur's defense. But his twin Horald would land a critical hit and do damage.

#### Kes

##### Veteran
This can be done just using the damage formula. I know the syntax in Ruby, but not in JS, so sadly I can't give you the fully worked out formula, but here is the Ruby formula in case you can translate it (or a passing reader might do it for you).

if b.result.critical; a.atk * 4; end; a.atk * 4 - b.def * 2

What is happening here is that it is checking if the hit is critical. If it is, it is applying the damage without any defense being taken into account. If it isn't, then it is the usual damage.

Guesswork on my part. It might be
if b.resultCritical;
and then the rest the same.

#### caethyril

##### ^_^
a.atk * 4 - (b.result().critical ? 0 : b.def * 2)
This formula works for me. I learned something new and useful here!

#### Animebryan

##### And like a Phoenix, I raise from my ashes!
I tried the formula in a brand new game, and it seemed to work for me. To test it, I edited the Minotaur enemy and gave him 300 DEF. Then I made a copy of Harold (his twin brother Horald) and gave him a new trait: Ex-Paramter Critical Rate +1000%. With that, he is pretty much guaranteed to land a critical hit every time.

When I did a test battle, Harold would hit but never did any damage because of the Minotaur's defense. But his twin Horald would land a critical hit and do damage.
Strange. But when I tested it, it constantly ignored defense even with normal attacks. I should also mention that I'm using Mr. Trivel's Minimum Damage plugin (https://github.com/Trivel/RMMV/blob/master/MrTS_MinimumDamage.js), although I don't know if that would change anything.
I guess I'll test it again tonight & record it then upload it to YouTube so you guys can see the results in action.

This formula works for me. I learned something new and useful here!
But does defense still get taken into account on normal hits? Because I noticed that normal hits were doing increased damage.

#### bgillisp

##### Global Moderators
That's because if you copy exactly what they have it might not match your damage formula, so damage might change. You'll have to edit it to match your damage formula as well.

#### Animebryan

##### And like a Phoenix, I raise from my ashes!
That's because if you copy exactly what they have it might not match your damage formula, so damage might change. You'll have to edit it to match your damage formula as well.
What do you mean 'copy what they have'? They said that they using the same formula that I posted, so there shouldn't be any difference.

#### bgillisp

##### Global Moderators
Actually most of the posters posted examples using the default formula, not yours, as none of those posted results above used your formula.

Also make sure you set your variance to something reasonable (the default of 20 means 20% increase or decrease to damage, which can cause some wild swings in damage results), else just due to RNG it can appear you are getting more damage.

Edit: I looked at yours above, and I think you reversed the syntax, it is using DEF on critical hits and ignoring it for normal. I can't get it to copy/paste your formula without double posting on myself though. But switch the 0 and the b.def/2 around, and post what it looks like that way.

#### Animebryan

##### And like a Phoenix, I raise from my ashes!
Actually most of the posters posted examples using the default formula, not yours, as none of those posted results above used your formula.

Also make sure you set your variance to something reasonable (the default of 20 means 20% increase or decrease to damage, which can cause some wild swings in damage results), else just due to RNG it can appear you are getting more damage.

Edit: I looked at yours above, and I think you reversed the syntax, it is using DEF on critical hits and ignoring it for normal. I can't get it to copy/paste your formula without double posting on myself though. But switch the 0 and the b.def/2 around, and post what it looks like that way.
Like this: (a.atk - (b.result().critical ? b.def / 2 : 0) / 2)

#### bgillisp

##### Global Moderators
That's what I meant, yes. How does that work in testing?

#### Animebryan

##### And like a Phoenix, I raise from my ashes!
That's what I meant, yes. How does that work in testing?
See for yourself:

(That's a normal hit, not critical)

This is what I got after inserting the stats into the formula:
(72 - 250 / 2) / 2)
(72 - 125) / 2
-53 / 2
-26.5 + (20% Variance)

(-20%) (+20%)
-21.2 ~ -31.8

Last edited:

#### bgillisp

##### Global Moderators
Can you post a screenshot of your skill too? That way someone who knows more in JavaScript than me can figure out why it isn't working (at least I assume you mean it isn't working by that post).

#### Animebryan

##### And like a Phoenix, I raise from my ashes!
Here's the 'Attack' skill page:

You can't see the full formula in the box so here it is again: (a.atk - (b.result().critical ? b.def / 2 : 0) / 2)

#### Aloe Guvner

##### Walrus
(a.atk - (b.result().critical ? b.def / 2 : 0) / 2)
Your formula is saying to subtract damage equal to b.def / 2 if there is a critical hit and subtract zero damage if there is not a critical hit.

#### Animebryan

##### And like a Phoenix, I raise from my ashes!
Your formula is saying to subtract damage equal to b.def / 2 if there is a critical hit and subtract zero damage if there is not a critical hit.

I actually had it right the 1st time. He was the one who suggested the backwards version. I've changed it back since then. While it does ignore DEF on criticals, but for some strange reason its also increasing the base damage. My normal hits should only be doing 1 damage (thanks to Mr. Trivel's Minimum Damage Plugin), but when using the new formula, my normal hits are now doing 10 damage, which shouldn't be possible. I just don't understand why its increasing overall (even the Crit. Damage is increased).

### Latest Profile Posts

Surprise Surprise.
If you are a fan of TRPGs like Fire Emblem, take a moment to help me by filling out this:

Camping inside a hidden cave.
I don’t believe in astrology. I’m a Sagittarius and we’re skeptical.

The concept art for the sprite of Senary, a major character in my upcoming (as-of-yet-unnamed) project. She is known as the Timelord because she can "stop time" by making eye contact with a person; Paralyzing them for a short period of time through a type of hypnosis. Tell me what you think about her. I'm thinking of changing the color of her coat.