A Skill The Does Random Number of Hits?

Sorry, to bump but is there a way to add conditions to this scriptlet? For example, if the user's state is state 21, it changes the range of repeats?

Could be useful.
Sorry, to bump but is there a way to add conditions to this scriptlet? For example, if the user's state is state 21, it changes the range of repeats?

Could be useful.
I could try?
I could try?
Looking forward that, too~!And not to mean request but if there will be a 20% or 30% percentage in certain hits will be coolest.

By the way,I use Visu battle core with the plugin is fine, just make sure this plugin is above of it.
I would guess that VisuStella Battle Core is what's causing your problem, since Battle Core completely overwrites almost everything regarding actions.
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.
They seemed pretty cool with helping me out with a compatibility issue (see below thread), so perhaps you could just drop them a support ticket?

so perhaps you could just drop them a support ticket?
I can try, I've asked even simpler things on discord and they've gone completely ignored.

Looking forward that, too~!And not to mean request but if there will be a 20% or 30% percentage in certain hits will be coolest.
Please rephrase your question?

Sorry, to bump but is there a way to add conditions to this scriptlet? For example, if the user's state is state 21, it changes the range of repeats?

Could be useful.
JavaScript:
/*:
 * @target MZ
 * @plugindesc Custom Repeat Range for Skills and Items
 * @author Original plugin by Artharn, edits by Dark_Ansem
 *
 * @help This plugin allows you to specify a custom range of possible repeat values for skills and items in RPG Maker MZ.
 *
 * To use this plugin, add the following meta tag to a skill or item's note field:
 *
 * <repeat:x-y>
 *
 * where x is the minimum number of repeats and y is the maximum number of repeats.
 *
 * You can also specify a custom repeat range for specific states by using the following meta tag:
 *
 * <repeatStateId:x-y>
 *
 * where StateId is the ID of the state and x and y are the minimum and maximum number of repeats, respectively.
 *
 * For example, to specify that a skill should repeat 2-4 times normally, but 3-5 times if the user is affected by state 5, you would use the following meta tags:
 *
 * <repeat:2-4>
 * <repeat5:3-5>
 */

const Art_Game_Action_numRepeats = Game_Action.prototype.numRepeats;
Game_Action.prototype.numRepeats = function() {
    const repeatRange = this.getRepeatRange();
    if (!repeatRange) {
        return Art_Game_Action_numRepeats.call(this);
    }

    const [min, max] = repeatRange;
    let repeats = Math.randomInt(max - min + 1) + min;

    if (this.isAttack()) {
        repeats += subject.attackTimesAdd();
    }

    return Math.floor(repeats);
};

Game_Action.prototype.getRepeatRange = function() {
    const item = this.item();
    const subject = this.subject();
    let repeatMeta = item.meta.repeat;

    if (!repeatMeta || !repeatMeta.match(/(\d+)\s*-\s*(\d+)/)) {
        return null;
    }

    // Check each state affecting the subject
    subject.states().forEach(state => {
        // If there's a specific repeat range for this state, use it
        const stateRepeatMeta = item.meta[`repeat${state.id}`];
        if (stateRepeatMeta && stateRepeatMeta.match(/(\d+)\s*-\s*(\d+)/)) {
            repeatMeta = stateRepeatMeta;
        }
    });

    // Safety check: If repeatMeta is still not defined, use the default repeat
    if (!repeatMeta.match(/(\d+)\s*-\s*(\d+)/)) {
        repeatMeta = item.meta.repeat;
    }

    const [min, max] = [Number(RegExp.$1), Number(RegExp.$2)].sort((a, b) => a - b);
    return [min, max];
}
I can try, I've asked even simpler things on discord and they've gone completely ignored.
I imagine they are in no obligation to help, of course, but I posted a support request complete with upload of stripped down project illustrating the problem and got a response within a week. Was a pleasant surprise.
I can try, I've asked even simpler things on discord and they've gone completely ignored.


Please rephrase your question?


JavaScript:
/*:
 * @target MZ
 * @plugindesc Custom Repeat Range for Skills and Items
 * @author Original plugin by Artharn, edits by Dark_Ansem
 *
 * @help This plugin allows you to specify a custom range of possible repeat values for skills and items in RPG Maker MZ.
 *
 * To use this plugin, add the following meta tag to a skill or item's note field:
 *
 * <repeat:x-y>
 *
 * where x is the minimum number of repeats and y is the maximum number of repeats.
 *
 * You can also specify a custom repeat range for specific states by using the following meta tag:
 *
 * <repeatStateId:x-y>
 *
 * where StateId is the ID of the state and x and y are the minimum and maximum number of repeats, respectively.
 *
 * For example, to specify that a skill should repeat 2-4 times normally, but 3-5 times if the user is affected by state 5, you would use the following meta tags:
 *
 * <repeat:2-4>
 * <repeat5:3-5>
 */

const Art_Game_Action_numRepeats = Game_Action.prototype.numRepeats;
Game_Action.prototype.numRepeats = function() {
    const repeatRange = this.getRepeatRange();
    if (!repeatRange) {
        return Art_Game_Action_numRepeats.call(this);
    }

    const [min, max] = repeatRange;
    let repeats = Math.randomInt(max - min + 1) + min;

    if (this.isAttack()) {
        repeats += subject.attackTimesAdd();
    }

    return Math.floor(repeats);
};

Game_Action.prototype.getRepeatRange = function() {
    const item = this.item();
    const subject = this.subject();
    let repeatMeta = item.meta.repeat;

    if (!repeatMeta || !repeatMeta.match(/(\d+)\s*-\s*(\d+)/)) {
        return null;
    }

    // Check each state affecting the subject
    subject.states().forEach(state => {
        // If there's a specific repeat range for this state, use it
        const stateRepeatMeta = item.meta[`repeat${state.id}`];
        if (stateRepeatMeta && stateRepeatMeta.match(/(\d+)\s*-\s*(\d+)/)) {
            repeatMeta = stateRepeatMeta;
        }
    });

    // Safety check: If repeatMeta is still not defined, use the default repeat
    if (!repeatMeta.match(/(\d+)\s*-\s*(\d+)/)) {
        repeatMeta = item.meta.repeat;
    }

    const [min, max] = [Number(RegExp.$1), Number(RegExp.$2)].sort((a, b) => a - b);
    return [min, max];
}
Awesome, thanks!

I’ll test!
I imagine they are in no obligation to help, of course, but I posted a support request complete with upload of stripped down project illustrating the problem and got a response within a week. Was a pleasant surprise.
I'll be level with you, if they help me fix the issues I have I'd be more than happy to have my scripts integrated in their FREE plugins. with mention of course.
heyo, sorry to bump this thread, But I recently stumbled here after trying to find a plug in to let me do just this
I wanted to make a skill that hit a group of enemies randomly 5-10 times.
And while this Plugin DOES work for me, I can't make the random aspect work properly. I've tried setting it up in the database to hit 1 random enemy, but whenever the skill repeats it just... hits that same enemy over and over LOL
I've also tried different things like, making it hit 2 random enemies and repeating 2-5 times, or to hit 4 random enemies and repeat 1-2 times. But no matter what I try, there's barely almost any variance to it. Does anyone know of a solution here so that the random aspect can work, or is this a lost cause oof--
(Sorry if this question doesn't belong in this thread btw. it's been awhile since i've interacted on here oop--)

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