ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
11,113
Reaction score
9,046
First Language
English
Primarily Uses
RMMV
Custom Hit Formula 1.1
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, as well as user and target.

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

Attachments

  • TUR_HitFormula.js
    4.5 KB · Views: 19
Last edited:

Arthran

Regular
Regular
Joined
Jun 25, 2021
Messages
1,093
Reaction score
1,577
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

Regular
Regular
Joined
Feb 16, 2023
Messages
35
Reaction score
22
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
Regular
Joined
Jul 2, 2014
Messages
11,113
Reaction score
9,046
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.
 

aironneil

Indecisive Creator
Regular
Joined
Sep 7, 2013
Messages
46
Reaction score
15
First Language
English
Primarily Uses
RMMZ
Sorry, but it doesn't seem to work for me. No matter what I put in the Hit Formula it doesn't do anything. I even tried making the formula always return false and it still just kept to the default. I turned all other plugins off to see if that made a difference and it didn't.

Edit: Nevermind, I forgot about hit rate with the default formula.
 
Last edited:

bookco

Regular
Regular
Joined
May 29, 2023
Messages
161
Reaction score
155
First Language
English
Primarily Uses
RMMZ
How do I make a certain hit formula for this plugin? I have tried <hitformula: true>, but it doesn't work in all cases. Would this be a compatibility issue with another plugin in that case?

EDIT: Nevermind, I answered my own question as I was asking it. I got my issue resolved by making sure both plugins were telling the skill to always hit.
 
Last edited:

Latest Threads

Latest Profile Posts

I was wondering why Skyler's hair looked weird on their new sprite. Well I forgot adding their iconic hairband
Anyone up to give Holder, TRIDIUM, GenericFantasyDev and Black Mage the fight of their lives?
Go ahead.
"The internet made everyone way too comfortable with disrespecting each other and not getting punched in the face."
I woke up a touch early and was going to draw by the fireplace until it’s a more appropriate noise-making time, but I left my stylus AND my glasses (WHAT?!) upstairs and it’s just too cold to get out of the blanket now.
Made some simple samples with the Time Reversal Mechanic. It would be interesting to make a bigger puzzle where you could dynamically choose which elements are affected by the time reverse. But if there's much more than move routes and waits, it's starts to get too annoying for my brain :D Like even that exploding bomb was such a bother.

Forum statistics

Threads
134,871
Messages
1,251,436
Members
177,671
Latest member
Tweateur
Top