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,860
Reaction score
2,196
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,276
Reaction score
1,228
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 Posts

Latest Profile Posts

Redesigning characters after such a long time feels great. Makes me excited to work on an old game again.
Phone menu to replace main menu WIP:
It's been that long since I wrote a plugin, it took me 4 attempts to realize it's != rather than #. In a 40-line plugin, 20 of those lines being documentation!
Disk Check Plugin - Running on Linux:
RMMV-Game-Mint.png
workin on some graphics for my game. was originally planning on doing a cartoony style for the town but I might stick with this instead

Forum statistics

Threads
116,095
Messages
1,095,709
Members
151,469
Latest member
will-o-wistful
Top