Is it possible to make a status effect that makes attack repeated be defaulted to 1 when the state is applied ?

I've been thinking of making a skill that inflicts a status effect that locks the enemy's skill repeat number to 1 and I'm asking if it's possible to do that (if it's possible to do with yanfly's battle core or any other plugin feel free to tell me)
(And no I'm not going to manually make a mirrored skill for each one where a version had it's normal repeat number and one doesn't that's too tedious and counterproductive)
I can't think of a way to do it with existing plugins without ignoring the repeat number in the database and programming it into an action sequence.

But you can copy and paste the below into a text editor, save as a *.js file and include it as a plugin:
Code:
Game_Action.prototype.numRepeats = function() {
    if (this.subject().isStateAffected(42)) return 1;
    var repeats = this.item().repeats;
    if (this.isAttack()) {
        repeats += this.subject().attackTimesAdd();
    }
    return Math.floor(repeats);
};

Replace 42 with the ID of your state that limits them.
I can't think of a way to do it with existing plugins without ignoring the repeat number in the database and programming it into an action sequence.

But you can copy and paste the below into a text editor, save as a *.js file and include it as a plugin:
Code:
Game_Action.prototype.numRepeats = function() {
    if (this.subject().isStateAffected(42)) return 1;
    var repeats = this.item().repeats;
    if (this.isAttack()) {
        repeats += this.subject().attackTimesAdd();
    }
    return Math.floor(repeats);
};

Replace 42 with the ID of your state that limits them.
i tested this in a new rpg mv project and it worked but for some reason i tried it on my current project and it seems to be not working in there
i tested this in a new rpg mv project and it worked but for some reason i tried it on my current project and it seems to be not working in there
Plugin conflict, perhaps? What plugins are in your current project?
then it sounds like you have a plugin loaded afterwards that also changes that function. I dont know what you have installed pluginwise and i cant check what the base function looks like atm, but try this and place it near the bottom of your list

Code:
var _NumRepeats = Game_Action.prototype.numRepeats;
Game_Action.prototype.numRepeats = function() {
    if (this.subject().isStateAffected(42)) return 1;
    else return _NumRepeats.call(this);
};
Plugin conflict,
bandicam 2024-04-28 21-25-33-638.jpg
perhaps? What plugins are in your current project?
bandicam 2024-04-28 21-25-28-462.jpg
bandicam 2024-04-28 21-25-19-932.jpg
here's some standalone plugins someone made for me specifically that could be related to the issue
1 - You should go through and rename your plugins. MV is a Web-based game, and expects filenames to adhere to HTTP file naming standards. Having spaces in there could cause the game on some other people's computers when you've deployed the project.

2 - None of those could have anything to do with the code I and @Robro33 gave you. The only way plugins can conflict with each other is if they - A - overwrite the same function, and the modification Robro made ensures it's not overwriting anything. or B - change the code to circumvent that function entirely, and it looks like Yanfly's Battle Engine Core does that.

The problem is that the Battle Engine converts all skills into action sequences in the DataManager, as the game is first loading. That means it's not looking at the repeats field at all while the skill is actually executing during gameplay.

I think the easiest thing for you to do is to take any skills that currently have a repeat value and program them manually using action sequences. Then you can simply use action sequence commands to check whether the attacker has this state and stop after the first hit.
coming back to this - i just tried mine with the alias in my main project with all the plugins i usually run. That includes Yanfly's BEC and Action sequences. it works just fine in mine, and the only yanfly battle plugin he uses that i do not is the animation speed one. I then tried Turan's and it also worked. a quick peek into the DevTools shows that none of them overwrites the numRepeats function, and the function *is* being used in the repeat count.

@sanemorality
Speculating here - Some plugin other than the yanfly ones overwrites it (FRSH_SaneRepeats looks the part, but neither I nor google knows what that plugin is 😛) in which case you cant put turans plugin above it if you wanted it to work, but also cant put it below that one if you wanted that one to work. Then either didnt try mine or did and also put it above that one
coming back to this - i just tried mine with the alias in my main project with all the plugins i usually run. That includes Yanfly's BEC and Action sequences. it works just fine in mine, and the only yanfly battle plugin he uses that i do not is the animation speed one. I then tried Turan's and it also worked. a quick peek into the DevTools shows that none of them overwrites the numRepeats function, and the function *is* being used in the repeat count.
Good to know! I guess I misread that portion of the Battle Engine.
coming back to this - i just tried mine with the alias in my main project with all the plugins i usually run. That includes Yanfly's BEC and Action sequences. it works just fine in mine, and the only yanfly battle plugin he uses that i do not is the animation speed one. I then tried Turan's and it also worked. a quick peek into the DevTools shows that none of them overwrites the numRepeats function, and the function *is* being used in the repeat count.

@sanemorality
Speculating here - Some plugin other than the yanfly ones overwrites it (FRSH_SaneRepeats looks the part, but neither I nor google knows what that plugin is 😛) in which case you cant put turans plugin above it if you wanted it to work, but also cant put it below that one if you wanted that one to work. Then either didnt try mine or did and also put it above that one
thank you for pointing that out that actually is an old plugin made by a friend that tried to do the idea i was suggesting in this post in the first place
after removing that and trying both plugin scripts that have been provided here it seems both are not working, if what your saying about the battle engine core not overriting the scripts is true then it means there's another plugin i'm not looking at
okay so i turned off my battle core engine plugin and it worked but when i turn it back on it doesn't work anymore
here's the battle core engine i'm using
It's against Yanfly's terms of use to redistribute any of their plugins.

It's sufficient for you to reference the version number.
oop my bad

anyways after looking through a thing my current version of battle core engine the reason why the state doesn't work is because the battle core itself messes with the way repeats work so essentioally i either have to give up on the plugin or give up on the idea lol
Oh, I see now. at the start for testing i changed the function to return 5 if the state was active to just see if it was impacted because it was easier to set up and observe in my project. what i didnt notice was that it did the default engine's repeat instead of the action sequence.

I looked a bit closer at the plugin. the battle engine does convert repeats into additional action effects / death breaks and sets the repeats to 1, but it doesnt do anything to the engine to stop it from using numRepeats to calculate the regular repeat count.

So that function can still be used to make a skill repeat, but because everything normally has it return a 1 anyways, it can only increase the repeat count - which is how i tested it. I should have tried making an already repeating skill hit less times than seeing if it would make skills hit more, but that gives me a few ideas...

That brings us back to this point though:
I think the easiest thing for you to do is to take any skills that currently have a repeat value and program them manually using action sequences. Then you can simply use action sequence commands to check whether the attacker has this state and stop after the first hit.
i either have to give up on the plugin or give up on the idea lol

It sounds like this is your next best realistic option. have you attempted it?
Thanks, @Robro33...I now have no idea whether I was right or wrong. 😛

I'm gonna try to put some tiles on a map...
I would have noticed it faster and it would have saved you a gaslighting if i looked for "repeats" in the BEC before i looked for "numRepeats", but its about the journey, right? 🤣

Original thread: https://forums.rpgmakerweb.com/threads/is-it-possible-to-make-a-status-effect-that-makes-attack-repeated-be-defaulted-to-1-when-the-state-is-applied.168142/