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.
Could be useful.
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.
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?
forums.rpgmakerweb.com
I can try, I've asked even simpler things on discord and they've gone completely ignored.
Please rephrase your question?
/*:
* @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 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.
Original thread: https://forums.rpgmakerweb.com/threads/a-skill-the-does-random-number-of-hits.149830/