ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,837
Reaction score
6,646
First Language
English
Primarily Uses
RMMV
Custom Hit Formula 1.0
ATT_Turan

Introduction
As far as I know, there's still no plugin written with the ability to provide a custom hit formula in MZ, and I got tired of telling people that :wink:

(apparently caethyril actually had one and I didn't know about it! Well, now you can try both and tell us who you like better. It should be me.)

So I wrote this to allow for custom hit formulae globally and/or per skill.

I tested the basic functions, please let me know if you run into any errors. Because it was necessary to modify code in the middle of the Game_Action.apply() function, this may cause conflicts with other plugins that modify the same function.

I will consider making compatibility patches if the other plugin is free to use and unobfuscated. Otherwise, other authors are free to modify this code to make it compatible with theirs so long as I am still credited.

You may use this plugin to bypass MZ's default hit formula (a percentile check against the attacker's hit rate). You can redefine one universal formula to supplant it, modify it at the skill level, and decide whether evasion is checked separately.

The default behavior of the engine is to determine a hit and then check for evasion or magic evasion, depending on the skill type. You can choose to bypass this behavior in order to incorporate the eva/mev parameters into your formula (or to disregard them).

The hit formula notetags and plugin parameter function identically; the notetags will always override the plugin parameter, and the parameter is set to MZ's built-in calculation by default. So this plugin is as plug-and-play as the user desires, with the ability to change the hit calculations on just one or few skills if that's all that's required.

Use the following notetag in the notebox of your skills:

<hitformula: your_formula_here>

The formula can be any valid JavaScript expression. An evaluation of "true" means the skill will hit, whereas "false" is a miss.

The below example is fashioned after the D20 system, adding d20 + level and comparing it to the target's Defense:
<hitformula: Math.randomInt(20)+1+a.level >= b.def>

Included variables are the same as those listed in MZ's damage formula.

Terms and Credits
Free for non-commercial and commercial use. Credit ATT_Turan.
 

Attachments

  • TUR_HitFormula.js
    4.3 KB · Views: 28
Last edited:

Arthran

Veteran
Veteran
Joined
Jun 25, 2021
Messages
951
Reaction score
1,262
First Language
English
Primarily Uses
RMMZ
For anyone who wants to use this with VisuStella Battle Core, it should be compatible as long as you place this plugin somewhere above Battle Core in your plugin manager.
 

murilloc

Veteran
Veteran
Joined
Feb 16, 2023
Messages
34
Reaction score
20
First Language
ENGLISH
Primarily Uses
RMMZ
This is so incredible i'm beyond words!
It's simple, effective and give us plenty of possibilities.
Thank you so much @ATT_Turan

Just a quick question tho.
This formula already takes the evade parameters in consideration or i need to add it?

<hitformula: Math.randomInt(20)+1+a.level >= b.def>
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
8,837
Reaction score
6,646
First Language
English
Primarily Uses
RMMV
This formula already takes the evade parameters in consideration or i need to add it?
That depends on how you configured the plugin parameters.

As I described in the instructions, checking evade is normally a second check unrelated to the hit formula.

So if you left that option on, then the engine will check evade as it always does.

If you turned it off, then no, there's nothing in your formula that references it.
 

Latest Threads

Latest Profile Posts

Creating the mood, coloring, and lighting for this gonna need a big brain moment.1685936069202.png
Someone in a facebook group just corrected something I said, by saying exactly what I said. The mind boggles.
Less than 20 tiles remain in Inside_B that I need some kind of analogue of in my in custom Inside_B, and a whole 39 tiles that I didn't use and can thus make my own custom tiles or my own flavors of from other tile sheets.


Chapters advancing demonstration.
Main character roey will be revived after chapter 7, so the animations will be different after it
The title of the main characters will be ascended to celestial as well as wings and rings.
Next Up. The 2nd floor of the Western Academy!

Base:
Map012.png

With a little parallax magic *:



WestAcademyFl2.png


Anything you'd add?

Forum statistics

Threads
131,643
Messages
1,221,840
Members
173,385
Latest member
VoidKass1
Top