Is it possible to scale skill success chance % against your stats?

Joined
Dec 7, 2022
Messages
4
Reaction score
1
First Language
English
Primarily Uses
RMMZ
Hi there! I am currently in the early stages of building an RPGMaker game. I have pretty much all of my visual assets sorted so it's time for me to think about how I can implement the core mechanics.

One thing I am struggling with right now is how restrictive the basic stats are. Primarily, that skill success seems to be a flat % based on the character and the skill itself.

What I am looking to do is have skills scale to stats, mimicking a dice-rolling system like you'd find in a tabletop game.

So for instance - say you roll two six-sided dice each time you want to use a skill, then check the total against your relevant stat. If the number rolled is lower than your stat, the skill works (for instance - you have 10 ATK and you roll a 6, so it works). 2D6 has eleven possible outcomes (2-12) so the chance of any one number would be 1 in 11.

What I would like to do is have a success formula something along the lines of:

Success% = (Skill)/11x100

So if your skill is 8, 8 rounds to 73% of 11, so you have a 73% chance of success.

Unfortunately I can't seem to set my own formula for this anywhere when making a skill. There are formulae like this for *damage* but nothing about hit chance... I have looked at the VisuStellaMZ engine plugins but I can't find anything there that lets me do this - unless I have missed something, which is entirely possible given that I am learning as I go.

The best idea I have had so far is to have a common event for each skill that rolls a random number, then checks it against the stat and uses a conditional branch to implement the consequences if it's successful. However in base RPG maker I can't seem to set a "current target" for effects like removing enemy hp, it always seems to be based on either 'all troops' or a specific slot in the battle.

If anyone has any idea of how I might implement this in RPGMakerMZ I would be greatly appreciative. Thank you!
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,101
Reaction score
4,909
First Language
English
Primarily Uses
RMMV
I haven't seen anything made for MZ to do this yet. MV had the Yanfly Hit Accuracy plugin and Victor Engine Hit Formula.

Hit Accuracy is listed as being compatible with MZ via Project FOSSIL.
 
Joined
Dec 7, 2022
Messages
4
Reaction score
1
First Language
English
Primarily Uses
RMMZ
Ah HA! Having read it through; using Victor Engine + FOSSIL is exactly what I need... just takes a little monkeying with the formula is all, which should not be too difficult considering it is just "Is random number less than STAT".

Thanks! Perfect. I will see if I can get that working.
 
Joined
Dec 7, 2022
Messages
4
Reaction score
1
First Language
English
Primarily Uses
RMMZ
So I've tinkered around with this for a while and I am struggling. It *might* be FOSSIL not working but it's difficult to tell..

I have made a custom skill called 'Test' that should deal 1 damage on a successful hit. The hit formula I've structured using VE Hit Formula is as follows:


<hit formula>
if (math.randomInt(11)+2) <= a.atk {
result = 100
} else {
result = 0
}
</hit formula>

What this should mean is that the game spits out a random number from 2-12 (simulating a roll of two six-sided dice) and if it is lower than the atk stat, it hits.

My test actor has 16 attack so it should be a 100% hit rate.
My test enemy has 0 in every stat and no extra parameters.

However, strangely, every single use is coming up with "(Enemy) evaded the attack!" every single time.

This makes me think that the plugin is doing -something- to alter the hit chance but I am unsure what since I have nothing written in the default field. Does anyone familiar with VE Hit Formula know if I'm doing something obviously wrong?

EDIT:

Seems that evade chance is just a flat 100% whenever VE Hit Formula is used on MZ, so it may not be compatible with FOSSIL.

Turns out I'm just stupid, see below comment.
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,101
Reaction score
4,909
First Language
English
Primarily Uses
RMMV
I have made a custom skill called 'Test' that should deal 1 damage on a successful hit. The hit formula I've structured using VE Hit Formula is as follows:
I don't see that plugin in the compatibility list on the FOSSIL thread. That's why I specifically mentioned that Yanfly Hit Accuracy is reported to be compatible.

What this should mean is that the game spits out a random number from 2-12 (simulating a roll of two six-sided dice) and if it is lower than the atk stat, it hits.
Technically speaking, that's not accurate. The results of 2d6 are not an even distribution from 2-12, because you have more combinations that will result in values in the middle. See here:

So if you actually want to model that, you can simply do that with the math functions:
Code:
Math.randomInt(6)+Math.randomInt(6)+2

<hit formula>
if (math.randomInt(11)+2) <= a.atk {
result = 100
} else {
result = 0
}
</hit formula>
You have the wrong syntax for your code. The entire conditional statement needs to be in parentheses, but you've closed them early. Also, the function is not math.randomInt(), it's Math.randomInt() - everything in code is case sensitive.

Also, it's not required, but it's strongly recommended to place semicolons at the end of statements - again, to help you keep track. So correct syntax for what you're trying to do (ignoring the mathematical correction I mentioned above) is:
Code:
if (Math.randomInt(11)+2<=a.atk)
    result=100;
else
    result=0;

So try it with correct code before ditching the plugin.
 
Joined
Dec 7, 2022
Messages
4
Reaction score
1
First Language
English
Primarily Uses
RMMZ
I have made a custom skill called 'Test' that should deal 1 damage on a successful hit. The hit formula I've structured using VE Hit Formula is as follows:
I don't see that plugin in the compatibility list on the FOSSIL thread. That's why I specifically mentioned that Yanfly Hit Accuracy is reported to be compatible.
See the reason I went for a crack with VE Hit Formula is that the Yanfly.moe.wiki entry for Yanfly Hit Accuracy didn't seem to list the ability to set things skill-by-skill, only change the overall formula which wasn't quite suitable for what I was aiming for.

However...

You have the wrong syntax for your code. The entire conditional statement needs to be in parentheses, but you've closed them early. Also, the function is not math.randomInt(), it's Math.randomInt() - everything in code is case sensitive.
This is why I need to use the forums more often, hah. It was pretty late when I was reading the documentation for the Math. command and that just... slipped my mind. With your actually correct syntax, things are working now. I've removed my previous comment about fossil/VE Hit Formula as I don't want to give anyone else the wrong impression.

And thank you for the tip on simulating actual dice probability, that is helpful for the fidelity of what I am trying to do.

Thanks very very much for the advice, I really appreciate it! This will make my project work a lot, lot smoother now.
 

Latest Threads

Latest Posts

Latest Profile Posts

I drew one of my chars! The man with 100 kids and a lot of love to give :kaopride:
Me: *about to stalk someone's posts*
Forum: "This member limits who may view their full profile."
Me: *bummer*
Also forum: Advanced search > Posted by ...
1B77FB7E-3802-4179-BB2D-F390021512A6.jpeg
Starting a fly by the night dev studio. Anyone want in? Excellent working conditions with onsite lodging. LOL
I finally got all the walk animations done! I mean, I gotta reskin it for the actual characters since this is a character from another project, but still! Doesn't look like a mess now! ;v;
[IMG]https://s3.gifyu.com/images/kalirr-movement-animation-showoff.gif[/IMG]

Forum statistics

Threads
128,545
Messages
1,195,330
Members
169,132
Latest member
veegsredds
Top