MZ Remove Skill from other actors once its selected in battle menu?

Hello!

So what I'm trying to do its a bit tricky and is most likely going to require a base code modification/plugin of some sort to execute properly. I have a condition within every battle that once a specific variable is at a set number, it gives a specific attack skill to actors who have another skill. Think of it like a combo meter: once a certain amount of combo is reached, actors who have the combo skill receive a finisher move. The problem is, I want the finisher move to be executed by any actor who has the skill, but once its selected, it cant be selected again by a separate actor. If I allow multiple actors to select the finisher, they can execute a very powerful move up to four times, which I don't want.

The key to this is removing it from the other actors once its selected by another actor, not used. Like I said, I believe this is going to have to override rpgmaker mz's base java code.

Any help or advice would be appreciated. Thank you all!
Hmmm, are you using plugins, like if you have VS, I think you can use the JS hide/show skill notetags and check for your battle members that if they've put that action in their actions like for each battle members if their actions length is bigger than 0:

_actions[0].item().id !== X

If they can take multiple actions I guess you have to check the whole array then.

EDIT: Oh yeah, check if the item isSkill too.
Hmmm, are you using plugins, like if you have VS, I think you can use the JS hide/show skill notetags and check for your battle members that if they've put that action in their actions like for each battle members if their actions length is bigger than 0:

_actions[0].item().id !== X

If they can take multiple actions I guess you have to check the whole array then.

EDIT: Oh yeah, check if the item isSkill too.

Thank you for the reply!

Unfortunately, I am not using any VisuStella plugins. I tried setting them up but its a bit much for my liking.

I think I just need to know where in the games code it sets the attack chosen for an actor.

1748994542894.png


I think it may be within the rmmz_scenes file, but I would really want some confirmation before diving into 6000+ lines of code lol.
Ok so after consulting with my script smitch for a couple hours I got this plugin:

(() => {
const restrictedSkillIds = [49, 51];
const selectedSkills = new Set();
let lastSelectedSkillId = null;

const _Scene_Battle_selectNextCommand = Scene_Battle.prototype.selectNextCommand;
Scene_Battle.prototype.selectNextCommand = function() {
const actor = BattleManager.actor();
if (actor) {
const action = actor.inputtingAction();
if (action && action.item() && restrictedSkillIds.includes(action.item().id)) {
lastSelectedSkillId = action.item().id;
selectedSkills.add(lastSelectedSkillId);
} else {
lastSelectedSkillId = null;
}
}
_Scene_Battle_selectNextCommand.call(this);
};

const _Scene_Battle_commandCancel = Scene_Battle.prototype.commandCancel;
Scene_Battle.prototype.commandCancel = function() {
const actor = BattleManager.actor();
if (actor && lastSelectedSkillId && selectedSkills.has(lastSelectedSkillId)) {
selectedSkills.delete(lastSelectedSkillId);
lastSelectedSkillId = null;
if (this._skillWindow) {
this._skillWindow.refresh(); // update UI immediately
}
}
_Scene_Battle_commandCancel.call(this);
};

const _BattleManager_endTurn = BattleManager.endTurn;
BattleManager.endTurn = function() {
selectedSkills.clear();
lastSelectedSkillId = null;
_BattleManager_endTurn.call(this);
};

const _Window_BattleSkill_isEnabled = Window_BattleSkill.prototype.isEnabled;
Window_BattleSkill.prototype.isEnabled = function(skill) {
if (restrictedSkillIds.includes(skill.id) && selectedSkills.has(skill.id)) {
return false;
}
return _Window_BattleSkill_isEnabled.call(this, skill);
};
})();

Just swap the skill ID's at the top with the ones you want and It should work.

Original thread: https://forums.rpgmakerweb.com/threads/remove-skill-from-other-actors-once-its-selected-in-battle-menu.178116/