Dice Rolls ('rand') In Damage Formulas [RMMV]

Hey, so if I designed RPG Maker MV you'd be able to put die rolls into the damage formula box for skills like 3d6 + atk or 3d20 - def or whatever, but as I didn't, is it possible (w/o plugins, although if there's a plugin that does this I'll take it) to include random expressions, i.e. rand(6) (or w/e, I don't actually know javascript but I do know that returning a random number up to x is one of the most basic commands in any scripting language) or w/e the correct call is in JS?

If you wanted to include a lot of dice, idk like, 12d6, would you have to put like rand(6) + rand(6) + rand(6) + rand(6) etc. 12 times?

Thank you very much!
-The Gentleman Loser-

(Happy new years, I guess, and certainly good riddance 2020 you wretched miserable abomination of a year.)
Math.ceil(math.random( [insert die size+1 here] ) works for a single die. You always want to add that last 1 in because math.random(x) produces a number between 0 and (x-1), since 0 counts as a number. The function math.ceil() prevents rolling a "0" by boosting the random number to its next-highest integer value. It's not -perfect-, but it's close enough that nobody will notice.

If you're doing multiple dice, take the minimum roll minus one, add it as an integer, and randomize the remainder plus one. For example, 3d12 would be random(35)+2. No matter the pool of dice, no matter if you're using multiple "die sizes", this is the most efficient manner to perform the task. 2d6 + 2d10?
(Math.ceil(math.random(30)+3)

You could also split things up to make it feel more "real". The totals wouldn't change, but doing things thisaway instead would allow for separate RNG per pool. 2d6 + 2d10, for example:
c = (math.ceil(math.random(12)+1))+(math.ceil(math.random(20)+1))

Or, even better, the "fancy" way, "rolling" each die separately. This is -probably- the most useful way to manage a dice-based system, as typing all that mess over and over and over and over gets tedious. Pre-define your variables in a script - there are plenty of ways to accomplish this.
var diceroll2 = (math.ceil(math.random(3);
var diceroll4 = (math.ceil(math.random(5);
var diceroll6 = (math.ceil(math.random(7);
var diceroll8 = (math.ceil(math.random(9);
var diceroll10 = (math.ceil(math.random(11);
var diceroll12 = (math.ceil(math.random(13);
var diceroll20 = (math.ceil(math.random(21);
var diceroll100 = (math.ceil(math.random(101);
var dicepool = 0;

And then for your damage formulas, just set it up somewhat like so, remembering to zero out your "dice pool" at the end (using the same 2d6+2d10 example):
dicepool = 2;
for (var i = 0; i < dicepool; i++) {
c+= diceroll6
};
dicepool = 2;
for (var i = 0; i < dicepool; i++) {
c+= diceroll10
};
dicepool = 0;

... If I'm off base anywhere, someone, anyone, please jump in and rectify my error. I'm half asleep and a moderate novice at js myself.
[edit: changed some ":" to ";" in a few cases of somnolent typographic error]
Moved to: MV Support

Game Mechanics Design is for discussion of mechanics, but the Support forum (or plugin request/support) is where to go for help to implement.
oh, thanks! sorry! there a LOT of subfora here. I'll try to do better in future.

@w4ffu1z that is awesome! you are awesome! thank you!

If you're doing multiple dice, take the minimum roll minus one, add it as an integer, and randomize the remainder plus one. For example, 3d12 would be random(35)+2. No matter the pool of dice, no matter if you're using multiple "die sizes", this is the most efficient manner to perform the task. 2d6 + 2d10?

You're right, and I feel like a complete idiot now, but in the best possible way (I'll probably need some more help to implement the variables in a script, as I am really far from fluent in JS, sadly; I was just starting to feel semi-competent at the basics of RGSS3 when the Tsukuru franchise swerved sharply away from Ruby). I'm glad this will be doable!

Original thread: https://forums.rpgmakerweb.com/threads/dice-rolls-rand-in-damage-formulas-rmmv.131681/