Animebryan

And like a Phoenix, I raise from my ashes!
Veteran
Joined
Jul 31, 2012
Messages
534
Reaction score
339
First Language
English
Primarily Uses
RMMZ
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
Veteran
Joined
Jan 26, 2017
Messages
608
Reaction score
1,438
First Language
English
Primarily Uses
RMMZ
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
Global Mod
Joined
Jul 2, 2014
Messages
14,289
Reaction score
15,405
First Language
English
Primarily Uses
RMVXA
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!
Veteran
Joined
Jul 31, 2012
Messages
534
Reaction score
339
First Language
English
Primarily Uses
RMMZ
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:

Animebryan

And like a Phoenix, I raise from my ashes!
Veteran
Joined
Jul 31, 2012
Messages
534
Reaction score
339
First Language
English
Primarily Uses
RMMZ
bumping for help
 

Animebryan

And like a Phoenix, I raise from my ashes!
Veteran
Joined
Jul 31, 2012
Messages
534
Reaction score
339
First Language
English
Primarily Uses
RMMZ
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
Veteran
Joined
Mar 7, 2014
Messages
35
Reaction score
26
First Language
English
Primarily Uses
RMMV
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
Veteran
Joined
Aug 3, 2012
Messages
22,846
Reaction score
12,374
First Language
English
Primarily Uses
RMMZ
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.
 

Animebryan

And like a Phoenix, I raise from my ashes!
Veteran
Joined
Jul 31, 2012
Messages
534
Reaction score
339
First Language
English
Primarily Uses
RMMZ
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! :kaojoy:
But does defense still get taken into account on normal hits? Because I noticed that normal hits were doing increased damage.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
14,289
Reaction score
15,405
First Language
English
Primarily Uses
RMVXA
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!
Veteran
Joined
Jul 31, 2012
Messages
534
Reaction score
339
First Language
English
Primarily Uses
RMMZ
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
Global Mod
Joined
Jul 2, 2014
Messages
14,289
Reaction score
15,405
First Language
English
Primarily Uses
RMVXA
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!
Veteran
Joined
Jul 31, 2012
Messages
534
Reaction score
339
First Language
English
Primarily Uses
RMMZ
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
Global Mod
Joined
Jul 2, 2014
Messages
14,289
Reaction score
15,405
First Language
English
Primarily Uses
RMVXA
That's what I meant, yes. How does that work in testing?
 

Animebryan

And like a Phoenix, I raise from my ashes!
Veteran
Joined
Jul 31, 2012
Messages
534
Reaction score
339
First Language
English
Primarily Uses
RMMZ
That's what I meant, yes. How does that work in testing?
See for yourself:
Battle Test (My Stats vs Metal Slime Stats).png
Massive Damage with no Critical.png
(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
Global Mod
Joined
Jul 2, 2014
Messages
14,289
Reaction score
15,405
First Language
English
Primarily Uses
RMVXA
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!
Veteran
Joined
Jul 31, 2012
Messages
534
Reaction score
339
First Language
English
Primarily Uses
RMMZ
Here's the 'Attack' skill page:
Attack Skill.png
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
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,164
First Language
English
Primarily Uses
RMMV
(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.

Instead, reverse the syntax as bgillisp already suggested.
 

Animebryan

And like a Phoenix, I raise from my ashes!
Veteran
Joined
Jul 31, 2012
Messages
534
Reaction score
339
First Language
English
Primarily Uses
RMMZ
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.

Instead, reverse the syntax as bgillisp already suggested.
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 Threads

Latest Profile Posts

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.
LzSHByh.jpg
I don’t believe in astrology. I’m a Sagittarius and we’re skeptical.
senary_concept_art.png
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.

Forum statistics

Threads
124,375
Messages
1,163,179
Members
163,167
Latest member
ADude
Top