Custom Hit Formula MZ

@imcatman This doesn't make sense.

The point of a hit formula is to determine whether an attack hits or misses - there's no such thing as an action result or the missed or evaded properties until well after that notetag's code has been run.

I think you're looking to do something with a skill notetag or during an action sequence. My Eval Tags plugin provides notetags that occur during skill resolution, or if you're using VisuStella plugins their Battle Core does.

Also, just mentioning based on your profile - this is an MZ plugin. It's entirely possible that this portion of the code is the same for MV so it might work, but I didn't test it in that engine at all.
@ATT_Turan Thank you for your reply.

Oh, my profile says RMMV, but I recently started using MZ, so this question is about MZ. I'll update my profile later.

I was trying to use a skill's notetag to check the enemy's evasion condition. In MV's Battle Engine Core (YEP), I was able to use target.result().missed or target.result().evaded within a notetag to check for evasion conditions, but I can't seem to do that with VisuStella's Battle Core.

That’s why I was wondering if it might be possible to achieve this using a hit formula.I'll keep exploring other methods to see if there’s a way to achieve what I’m aiming for. Thank you!
@imcatman Yanfly's Battle Engine Core doesn't provide any notetags to do anything by itself, but that's not really your point.

You absolutely can do it with VisuStella's Battle Core - there's a whole section of notetags that execute code at different times during a skill or turn.

But if you're having a hard time figuring out what to do there, you'd need to make a new thread asking your specific question - it wouldn't have anything to do with this plugin.

Good luck.
Hey, here's a question: is it possible to use the Custom Parameters from VisuStella's Core Engine with this?
Hey, here's a question: is it possible to use the Custom Parameters from VisuStella's Core Engine with this?
The formula is just JavaScript, so you can use anything you can express in JavaScript.

I'm not versed with that plugin, but I assume the documentation gives you some way to reference the custom parameters.
The formula is just JavaScript, so you can use anything you can express in JavaScript.

I'm not versed with that plugin, but I assume the documentation gives you some way to reference the custom parameters.
Hey, I have the same question as the person above. As far as i can see in your code, these lines load the involved actor's skills from $dataSkills and put them into an array
1749223254478.png
1749223323421.png

VisuStella's parameters seem to be from Game_Battlerbase and not $dataSkills
1749223312445.png
1749223318428.png


I'm kind of new to RPG Maker and not the most versed in JS, do you have an idea on how i would impliment the custom parameters? I understand somewhat how you do the original, but i don't really know any of the syntax
Hey, I have the same question as the person above.
I don't really see why you're rooting around in code or looking at skills.

You define how to access custom parameters right in the Core Engine plugin parameters:

1749238053552.png


If you had the entry above, you would reference the attacker's Strength in a hit formula by simply using a.str, exactly like it says in the screenshot you provided from the documentation.
I don't really see why you're rooting around in code or looking at skills.

You define how to access custom parameters right in the Core Engine plugin parameters:

View attachment 342335

If you had the entry above, you would reference the attacker's Strength in a hit formula by simply using a.str, exactly like it says in the screenshot you provided from the documentation.
It's possible I'm wrong, but as far as I can tell, using custom parameters as is results in an error. Calling them in a formula as per

v[1] = b.str

(formula involving v[1] in some way)

results in an error (automatic miss)

And using them directly in a formula

a.str > b.def

Makes the attack automatically hit.

What I was trying to say is that I think they SHOULD be pulled up, but your plugin finds the values of skills from $dataSkills, but visustella custom parameters values are from Game_Battlerbase, so it results in an error when used in the plugin. So my theory is that if code is added to your plugin to either take skill values from battlerbase or just add on the visuatella ones to your array, they'll be compatible.

I could be wrong, but if I'm not, I would love help implementing this. Thanks for your reply
And using them directly in a formula

a.str > b.def

Makes the attack automatically hit.
That would not happen if the custom parameter were being somehow ignored. If you reference a nonexistent property in a formula, it will have a value of undefined - that will never evaluate to being greater than anything. That means the attacks would always automatically fail, not hit.

What I was trying to say is that I think they SHOULD be pulled up, but your plugin finds the values of skills from $dataSkills, but visustella custom parameters values are from Game_Battlerbase, so it results in an error when used in the plugin.
You are confusing yourself by trying to read the code - that's not how any of it works.

The variable a - defined in the appropriate function of my plugin as this.subject() - and b - passed in as an argument to that function - are both going to be of types either Game_Actor or Game_Enemy, both of which inherit from Game_BattlerBase.

If my code didn't have correct references to the attacker and target, none of it would work.

So my theory is that if code is added to your plugin to either take skill values from battlerbase
There's no such thing as "skill values from battlerbase".

or just add on the visuatella ones to your array
There's no such thing, I don't make an array of anything.

I could be wrong, but if I'm not, I would love help implementing this.
You would have to post screenshots of how your custom parameters are defined in your plugin parameters and the exact formulae you're trying to use.

Then press F8 and go to the Console tab while the game is running so you can see whether it produces any errors and post a screenshot of that window.
That would not happen if the custom parameter were being somehow ignored. If you reference a nonexistent property in a formula, it will have a value of undefined - that will never evaluate to being greater than anything. That means the attacks would always automatically fail, not hit.


You are confusing yourself by trying to read the code - that's not how any of it works.

The variable a - defined in the appropriate function of my plugin as this.subject() - and b - passed in as an argument to that function - are both going to be of types either Game_Actor or Game_Enemy, both of which inherit from Game_BattlerBase.

If my code didn't have correct references to the attacker and target, none of it would work.


There's no such thing as "skill values from battlerbase".


There's no such thing, I don't make an array of anything.


You would have to post screenshots of how your custom parameters are defined in your plugin parameters and the exact formulae you're trying to use.

Then press F8 and go to the Console tab while the game is running so you can see whether it produces any errors and post a screenshot of that window.
Ok, fair enough, seems like I've confused myself.

I'm not with my PC right now, but I'll do some testing and return. It's possible there's weird errors resulting from me using a combination of visustella and eli parameters. Thanks for the help.
v[1] = b.str
As a side note, make sure you've read the documentation and plugin parameters for everything else you're using.

There are VisuStella plugins (perhaps even the Core Engine) which reserve variables for specific purposes. If you're trying to use variable 1 in your formula and it's reserved by a plugin parameter, that would yield unexpected results.
oh my god it was a single } LMAOOOOOOOOOOOOOOOOOOOOOOOO IM SO SORRY, THANK YOU SO MUCH

(also the variable 1 thing was screwing with things so that helped a lot)

Original thread: https://forums.rpgmakerweb.com/threads/custom-hit-formula-mz.156236/