A Skill The Does Random Number of Hits?

I'm trying to make a skill that does a random number of hits, rather than a fixed amount like the database has. I know there's a plugin for MV to do this, but couldn't find one for MZ. I don't want to display the animation over and over again, so doing "force action" probably won't work unless I'm missing something. Anyone know?
Could just make different copies of the skill, 1 for each number of hits and then randomly distribute one of those each turn in combat via a random variable roll (also make sure to forget the version of the skill that was learned in the previous turn so only 1 version of the skill can be seen at any time).
That's not quite the effect I was hoping for, but I guess it'll do the trick in a pinch. I was trying to have the skill itself do several hits in a row, like it would if I set the "repeat" to a higher number than 1, I just wanted it to be a variable amount. The way your suggestion worked (at least the way I ended up setting it up) there's a pause and the enemy clearly does another skill that causes a hit, it's just not that obvious what's going on b/c there's no text or anything, but he does flash each time. Unless someone else has a better suggestion, I'll just stick with this for now. Thanks.
This is pretty doable. Paste this into a new .js file and add it to your project through the plugin manager:
JavaScript:
const Art_Game_Action_numRepeats = Game_Action.prototype.numRepeats;
Game_Action.prototype.numRepeats = function() {
    if (!this.item().meta.repeat || !this.item().meta.repeat.match(/(\d+)\s*-\s*(\d+)/)) {
        return Art_Game_Action_numRepeats.call(this);
    }

    const min = Math.min(Number(RegExp.$1), Number(RegExp.$2));
    const max = Math.max(Number(RegExp.$1), Number(RegExp.$2));
    let repeats = Math.randomInt(max - min + 1) + min;
    if (this.isAttack()) {
        repeats += this.subject().attackTimesAdd();
    }
    return Math.floor(repeats);
};

Then, you can use this tag in the note box of your skill: <repeat: min - max>. So, for example, if I want my skill to randomly repeat between 1 and 4 times, my note tag would look like this:

Code:
<repeat: 1 - 4>

You can add/omit spaces if you wish, so this is fine too:
Code:
<repeat:1-4>

You can do any range you want. If the note tag is present, then it will ignore the number of repeats that you've set in the "Repeat" box in the database. If the note tag is not present, then it will adhere to the number of repeats that you've set in the "Repeat" box in the database.

*edit* Made the code a little more resilient, just in case you try to input the range backwards for some reason.
Oh wow awesome! thank you so much!

[edit: Actually, I just tried using it and it's not working. Also the plugin manager says it might not work with MZ.]
[edit: Actually, I just tried using it and it's not working. Also the plugin manager says it might not work with MZ.]
It's working fine for me. What is it doing when you try to use it?
It's only doing one hit. I've tried it four times and it still only does one hit.

[edit: I put this in the note box for the skill:

<repeat: 1 - 6> ]
Can you show me a screenshot of the skill, as well as a screenshot of your plugin manager?
Sure, here ya go:
That's weird. I don't believe that any of those plugins should be interfering. The only explanation I can think of is that maybe the code somehow got corrupted when you were creating the plugin. Just to be on the safe side, I'll go ahead and attach it as a proper plugin file. Try to use mine instead, and see if that helps somehow.

If that doesn't work, then if you wanna upload your project file somewhere and send me the link, I can try to figure out what's going on.

*edit* Also, make sure that you're using "New Game", and not "Continue" when you're testing this.
Actually, just realized the problem: I was using the troop battle test to test it out and apparently that doesn't work with plugins? Very strange, but I just tossed the battle into a map and tried it and it works now. Thanks again and sorry for the headache! XD
No problem. Glad you got it working.
Actually, just realized the problem: I was using the troop battle test to test it out and apparently that doesn't work with plugins?
This isn't true for every plugin, but to save yourself headaches when testing things, just do a playtest and start a new game.
That's not quite the effect I was hoping for, but I guess it'll do the trick in a pinch. I was trying to have the skill itself do several hits in a row, like it would if I set the "repeat" to a higher number than 1, I just wanted it to be a variable amount. The way your suggestion worked (at least the way I ended up setting it up) there's a pause and the enemy clearly does another skill that causes a hit, it's just not that obvious what's going on b/c there's no text or anything, but he does flash each time. Unless someone else has a better suggestion, I'll just stick with this for now. Thanks.

You can do exactly that with the method I described. You just make different versions of the skill, one for each number of repeat hits, and then select to learn one at random each turn and unlearn the previous version. But if you already found another way to do it, I guess it doesn't matter.
OK now I get what you meant! At first I wasn't sure what "randomly distribute them per turn" meant. Yes, that would in fact work, thanks!
This is pretty doable. Paste this into a new .js file and add it to your project through the plugin manager:
JavaScript:
const Art_Game_Action_numRepeats = Game_Action.prototype.numRepeats;
Game_Action.prototype.numRepeats = function() {
    if (!this.item().meta.repeat || !this.item().meta.repeat.match(/(\d+)\s*-\s*(\d+)/)) {
        return Art_Game_Action_numRepeats.call(this);
    }

    const min = Math.min(Number(RegExp.$1), Number(RegExp.$2));
    const max = Math.max(Number(RegExp.$1), Number(RegExp.$2));
    let repeats = Math.randomInt(max - min + 1) + min;
    if (this.isAttack()) {
        repeats += this.subject().attackTimesAdd();
    }
    return Math.floor(repeats);
};

Then, you can use this tag in the note box of your skill: <repeat: min - max>. So, for example, if I want my skill to randomly repeat between 1 and 4 times, my note tag would look like this:

Code:
<repeat: 1 - 4>

You can add/omit spaces if you wish, so this is fine too:
Code:
<repeat:1-4>

You can do any range you want. If the note tag is present, then it will ignore the number of repeats that you've set in the "Repeat" box in the database. If the note tag is not present, then it will adhere to the number of repeats that you've set in the "Repeat" box in the database.

*edit* Made the code a little more resilient, just in case you try to input the range backwards for some reason.

First of all, thank you @Arthran for this. It's a nifty plugin because each repeat is subject to accuracy check, which I think is great and it is definitely how it's meant to be.

But I think there could be an issue with it? Unless I'm wrong, it only plays the animation 2 times, even if repeat values are higher. Is that an engine limitation?

I'm also not sure if it messes us battlers animations, as I've seen that if there is even one miss, the battler displays the "miss" animation rather than the hit one. Then again, the hits were for 0 damage so that could be why.
So, I took the liberty of making some script changes but I think I made a mess

JavaScript:
const Art_Game_Action_numRepeats = Game_Action.prototype.numRepeats;
Game_Action.prototype.numRepeats = function() {
    const item = this.item();
    if (!item.meta.repeat || !(item.meta.repeat.match(/(\d+)\s*-\s*(\d+)/))) {
        return Art_Game_Action_numRepeats.call(this);
    }
    
    const [min, max] = [Number(RegExp.$1), Number(RegExp.$2)].sort((a, b) => a - b);
    let repeats = Math.randomInt(max - min + 1) + min;
    repeats += this.isAttack() ? this.subject().attackTimesAdd() : 0;
    return Math.floor(repeats);
};

More importantly, this didn't help with my issue so I went back to the original code, in an empty project and, guess what, animations do play more than once (maybe even too many). So, this is a Visustella compatiblity issue with one of the Core plugins (as I tried it in the sample project). Any help would be greatly appreciated.
@Dark_Ansem

My plugin doesn't change anything regarding animations. It simply makes it so that if the note tag is present, the engine will grab the number of repeats from the note tag instead of from the "Repeat" box in the database. Everything else is untouched and still handled by the engine.

I would guess that VisuStella Battle Core is what's causing your problem, since Battle Core completely overwrites almost everything regarding actions. If you want to continue using Battle Core, then your best bet would probably be to drop my plugin and implement the skill using a Custom Action Sequence instead.
I would guess that VisuStella Battle Core is what's causing your problem, since Battle Core completely overwrites almost everything regarding actions.
That is kind of what I said in the message me above?

then your best bet would probably be to drop my plugin and implement the skill using a Custom Action Sequence instead.
I cannot avoid using Battle Core so i suppose you are right. I know very little of action sequences sadly, and your solution is quite efficient and elegant.
I would guess that VisuStella Battle Core is what's causing your problem, since Battle Core completely overwrites almost everything regarding actions.
I think that, rather than this, it's the notetag that is actively the same. Let me try to change it and see if it makes a difference.

Original thread: https://forums.rpgmakerweb.com/threads/a-skill-the-does-random-number-of-hits.149830/