MV Change the damage formula directly in the JS file...

... so that instead of taking just the damage formula (as per defined in the skill tab), it does:

Max(regular damage formula, a random number between 5-10)

Thanks in advance for any help!
Just so I understand what's being asked here... Is there any particular reason why you do not want to do this simply by typing it in the damage formula for each skill?
Spoiler: plugin code
JavaScript:
/*:
 * @target MV MZ
 * @plugindesc Minimum action damage is 5~10 (random).
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/161247/
 * @help Free to use and/or modify for any project, no credit required.
 */
void (function(alias) {
  Game_Action.prototype.evalDamageFormula = function(target) {
    return Math.max(alias.apply(this, arguments), 5 + Math.randomInt(6));
  };
})(Game_Action.prototype.evalDamageFormula);
(randomInt(6) returns a uniformly-random integer in the range 0~5.)
For a random nr between 5 and 10, I do it like this:

Math.random() * 5 + 5

Math.random() will choose random between 0 and 1.

Times 5 makes it random berween 0 and 5

Plus 5 will make it between 5 and 10, with 5 as minimum and 10 as maximum
You have to define the dam formula in the skill tab. That said, you can make it reference js code in a custom plugin. To do this, try something like:
JavaScript:
b.defaultAttack(a, b)
Then, in your plugin code, have a function:
JavaScript:
Game_Battler.prototype.defaultAttack = function(a, b)
And put whatever alterations you need in there.
You do need it to return a number and must be careful of the code in there, but this is an easy way to lengthen and customize the damage formula.

Hope this helps.
Spoiler: plugin code
JavaScript:
/*:
 * @target MV MZ
 * @plugindesc Minimum action damage is 5~10 (random).
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/161247/
 * @help Free to use and/or modify for any project, no credit required.
 */
void (function(alias) {
  Game_Action.prototype.evalDamageFormula = function(target) {
    return Math.max(alias.apply(this, arguments), 5 + Math.randomInt(6));
  };
})(Game_Action.prototype.evalDamageFormula);
(randomInt(6) returns a uniformly-random integer in the range 0~5.)

I think this worked, thank you.
Great! If you do run into problems with it, let me know~ 👋

@Maliki79's suggestion is good if you use similar formulae in many places and want to keep them consistent. Helps to have everything in one place if/when you want to change the formula, too.

Math.random() * 5 + 5
RMMV's core scripts round the final formula result to the nearest integer, rather than floor it. That's relevant because Math.random() returns a value in the range [0, 1) (i.e. excluding 1), so:
  • Math.round(Math.random() * 5) -> 0, 1, 2, 3, 4, 5, but 0 and 5 are half as likely as the others.
  • Math.floor(Math.random() * 5) -> 0, 1, 2, 3, 4, all equally likely.
Math.randomInt(n) is an RMMV/Z shorthand for Math.floor(Math.random() * n).
RMMV's core scripts round the final formula result to the nearest integer, rather than floor it. That's relevant because Math.random() returns a value in the range [0, 1) (i.e. excluding 1), so:
  • Math.round(Math.random() * 5) -> 0, 1, 2, 3, 4, 5, but 0 and 5 are half as likely as the others.
  • Math.floor(Math.random() * 5) -> 0, 1, 2, 3, 4, all equally likely.
Math.randomInt(n) is an RMMV/Z shorthand for Math.floor(Math.random() * n).
Oh wow... I knew how Math.random works (take any value between 0 and 1, with unlimited decimals), but I never actually realized that 0 can only be reached by rounding down and the top number only by rounding up, while all numbers in between ban be reached by rounding up and rounding down.

So I guess I did it wrong all this time. 😛

Thanks for the explanation.
@caethyril I have to report a glitch with:

Code:
void (function(alias) {
  Game_Action.prototype.evalDamageFormula = function(target) {
    return Math.max(alias.apply(this, arguments), 5 + Math.randomInt(6));
  };
})(Game_Action.prototype.evalDamageFormula);

It seems to work fine with HP Damage, but if you put HP Recover, well it will still pick 5 + Math.randomInt(6)) over the recovery formula (considered a negative value I suppose), so will damage the target instead of recovering it.
@caethyril I have to report a glitch with:

Code:
void (function(alias) {
  Game_Action.prototype.evalDamageFormula = function(target) {
    return Math.max(alias.apply(this, arguments), 5 + Math.randomInt(6));
  };
})(Game_Action.prototype.evalDamageFormula);

It seems to work fine with HP Damage, but if you put HP Recover, well it will still pick 5 + Math.randomInt(6)) over the recovery formula (considered a negative value I suppose), so will damage the target instead of recovering it.
The problem with computers is that they never do what you want them to do, and instead do exactly what you tell them to do. It's not really a glitch, the damage formula has been modified exactly in the way you asked it to be 😉

Of course this can be changed so that negative values are not affected:
JavaScript:
void (function(alias) {
  Game_Action.prototype.evalDamageFormula = function(target) {
    let normalValue = alias.apply(this, arguments);
    if(normalValue >= 0) return Math.max(normalValue, 5 + Math.randomInt(6));
    else return normalValue;
  };
})(Game_Action.prototype.evalDamageFormula)
Oops! Yep, Mac's edit should fix that. 😊

Original thread: https://forums.rpgmakerweb.com/threads/change-the-damage-formula-directly-in-the-js-file.161247/