Crit chance in damage formula

Oddball

Veteran
Veteran
Joined
Sep 4, 2014
Messages
2,019
Reaction score
584
First Language
English
Primarily Uses
N/A
In rpg maker vx ace thier was a formula you could put in the damage formula bar thing that could let you add a specific crit chance to the skill. is thier something like this in MZ?

Thank you in advance
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,837
Reaction score
2,176
First Language
EN
Primarily Uses
RMMZ
Maybe something like this (untested):

let r = a.atk * 4 - b.def * 2; if (Math.random() < 0.2) { b.result().critical = true; r = this.applyCritical(r); }; r

  • Store the usual formula result, whatever it is, in a temporary variable named r;
  • Math.random() < 0.2 should be true 20% of the time;
  • b.result().critical = true triggers the crit visual effects/message;
  • r = this.applyCritical(r) applies the normal critical multiplier to r.
    • You could do something like r *= 3 here (i.e. "multiply r by 3") instead if you want.
  • Finally, return the value of r.
I think it has to be done separately like this because the crit result is passed into makeDamageValue as a fixed value, before the formula gets evaluated.
 

vietanhdang2017

Veteran
Veteran
Joined
Sep 16, 2021
Messages
31
Reaction score
14
First Language
English
Primarily Uses
RMMV
I think it's not possible. Crit had been decided before damage calculating
 

Oddball

Veteran
Veteran
Joined
Sep 4, 2014
Messages
2,019
Reaction score
584
First Language
English
Primarily Uses
N/A
Maybe something like this (untested):

let r = a.atk * 4 - b.def * 2; if (Math.random() < 0.2) { b.result().critical = true; r = this.applyCritical(r); }; r
Thanks i'll try this out

@vietanhdang2017 you could in VX Ace
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,231
Reaction score
1,195
First Language
English
Primarily Uses
RMMV
I think it's not possible. Crit had been decided before damage calculating
Just because it was decided doesn't mean it can't be changed, as caethyril did.

And since it being a critical doesn't do anything until after the damage is calculated (you can't print large text of the damage that doesn't exist yet), I suspect this will work.

However, make sure you turn Critical Hits off on the skill page in your database. You wouldn't want the engine to decide it's a critical, multiply the damage, then you multiply it again inside your formula.
 

Latest Threads

Latest Profile Posts

I just don't know why, but it's funny.
5.gif
Ugh. The one time I forget to save every hour or so is also the day my computer crashes. That's life!
Even though I spent 100's of dollars on my game already. I think I might just have to give it away for free. Since I haven't heard back from people if I could use some of their graphics. Even from a global mod here. Maybe I can make a donation thing.
you know, some days you get resentful that game dev is even considered a "fun job" and other days it's like, welp, time to roll up my sleeves and code these molotov cocktails
If you suck at playing trumpets, that is probably why.

Forum statistics

Threads
115,963
Messages
1,094,429
Members
151,232
Latest member
tamexe
Top