Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

RMMV - Parameter-based success chance

MesmerSign

Villager
Xy$
0.00
Hi there, you beautiful people!

I hope this hasn't been asked yet and I just missed it.
I'd like to make happen the following;

If X<Y; success

X = random number between 0-99
Y = (A/(A+B)) * 100
A = relevant Parameter (ATT, DEF, MAT, etc...) of the character as #1 in the formation
B = the difficulty value of the act

For example, if a character with DEF 50 would be trying to make a DEF-check against the difficulty of 100;
Y = (50/(50+100)) * 100 = (50/150) * 100 = 33.33333... ergo
if X<34, success

My question is, how should I go about making that?
I'm already tracking the ID of the character in #1 as a part of my system managing outfit graphic updates.
Also, how do I ensure numbers like 1/3 are rounded to full numbers when presenting them to the player? I'm thinking the whole shebang is probably best to build using the Script... -event command, but I'm a bit lacking in my Programmer skill tree.

Thanks yous!
 

Run

Towns Guard
Xy$
0.00
I covered something similar on the forum today, thread's called "Probability of Success with Events", sure you can find it easy enough.

As for rounding, I believe variables are rounded down by default.

Getting the stats of the first character in the party would work best setting it with a script.
event->control variables->choose variable->set->script->$gameActors.actor($gameParty._actors[0]).def

def at the end can be switched out with any of the following to get the desired parameter:
agi, atk, cev, cnt, cri, def, eva, exr, fdr, grd, hit, hp, hrg, level, luk, mat, mcr, mdf, mdr, mev, mhp, mmp, mp, mrf, mrg, pdr, pha, rec, tcr, tgr, tp, trg

I think I'll play around with writing a plugin for this now...
 

MesmerSign

Villager
Xy$
0.00
Thank you so much, Run. The $gameParty._actors[0] will definitely prove useful to know.
I think I got what I wanted working now. It's not necessarily the most beautiful piece of work, but at this point it doesn't really need to be, anyway.
Good luck with the plugin; looking forward to it ;)
 

MesmerSign

Villager
Xy$
0.00
This is awesome!

It seems like that if I store a difficulty into a variable, this does exactly what I need with just

tmp_check 1 def*100/(def+var1) p1

def 50
var1 100

5000/150 = 33.3333...

and much, much more.
I'll definitely give it a good look-see tomorrow.
You are awesome.
 
  • Like
Reactions: Run
Top