MV Have A Skill Selection/Action queue multiple different skills

I've been working on a game for awhile now and I've gotten into the JS guts and done all sorts of stuff but I've been having trouble with the best way to implement the following. I want to have a skill queue itself as an action as normal, but also queue another separate related action (and skill) with its own timing.

I originally wanted this functionality so I could have something like "Defensive Attack" that in one (immediate, super high initiative) action puts a self-targeted defensive state on the Actor and in the second action has a slower normal attack.

I don't need anyone to write a plugin for me or anything, I'm just hoping someone with more familiarity with the RPG Maker MV code can point me in the right direction.

edit: at the risk of overexplaining, to reiterate; I know an actor can have multiple actions through traits, but what I want is for a skill to be able to queue multiple actions on its own: itself and then other skills that I specify in a note-tag.
I think your original thought process (actually queuing/executing two skills) is a harder path than you might need. That would take, I think, a fair amount of messing with how the battle system handles actions and battler turns.

However, it would be much easier to put a little chunk of code into Window_BattleSkill.processOk() that would check for and run an eval() on a notetag that you put into the skill being selected.

So you might just give your Defensive Action
Code:
<Select Effect>
user.addState(X);
</Select Effect>

And doing that would only take a few lines of code, to my thinking.
I think your original thought process (actually queuing/executing two skills) is a harder path than you might need. That would take, I think, a fair amount of messing with how the battle system handles actions and battler turns.

However, it would be much easier to put a little chunk of code into Window_BattleSkill.processOk() that would check for and run an eval() on a notetag that you put into the skill being selected.

So you might just give your Defensive Action
Code:
<Select Effect>
user.addState(X);
</Select Effect>

And doing that would only take a few lines of code, to my thinking.
That's actually great and was my original line of thinking (without knowing about processOk or how to do it), I just became enamored with the idea of being able have an action queue multiple different skills which seemed like a cool idea to play with 🙂

But that's very useful as well and I'll keep that in mind.
Actually, it needs to get pushed back a bit further, just doing it from the BattleSkill window will make the code execute when you select the skill, not after you select the target and actually queue the action.

Try pasting this into a text editor, saving it as a *.js, and including it as a plugin.

Code:
Window_BattleActor.prototype.select = function(index) {
    if (BattleManager.inputtingAction().item().meta.selecteffect)
    {
        let user=BattleManager._subject;
        let target=this.actor();
        eval(BattleManager.inputtingAction().item().meta.selecteffect);
    }
    Window_BattleStatus.prototype.select.call(this, index);
    $gameParty.select(this.actor());
};

Window_BattleEnemy.prototype.select = function(index) {
    if (BattleManager.inputtingAction().item().meta.selecteffect)
    {
        let user=BattleManager._subject;
        let target=this.enemy();
        eval(BattleManager.inputtingAction().item().meta.selecteffect);
    }
    Window_Selectable.prototype.select.call(this, index);
    $gameTroop.select(this.enemy());
};

That should execute code when you confirm a skill's target and set it as your action for the turn.

The format of the notetag would be:
Code:
<selecteffect: code here>
you can have it do as much as you want, you just need to remove line breaks so it's one line of code.

It provides user and target variables for you to use.

Let me know how that works, it's untested mind-poop between jobs.
I'll dig back into it when I have time but the immediate issues are:

1) You can't do the conditional that way because it crashes on null, you have to do:
if (BattleManager.inputtingAction() && BattleManager.inputtingAction().item().meta.selecteffect)

2) Attaching it to select causes the code to evaluate every time a target is selected, so essentially as you click up and down the player list (for something that targets friendly) it pops every time you *select* a new target, not confirm the selection.

3) However it's done it needs to be done such that you can't activate the effect by just messing around in the interface because you could for example click the ability, move onto the next character, then back up, have the actor select a different ability, and keep the buff.
1) You can't do the conditional that way because it crashes on null, you have to do:
if (BattleManager.inputtingAction() && BattleManager.inputtingAction().item().meta.selecteffect)
That shouldn't be true, I don't know how you could be selecting anything in the battleactor or battleenemy window without having already started to input an action. But if you're encountering that case...add it in.

2) Attaching it to select causes the code to evaluate every time a target is selected, so essentially as you click up and down the player list (for something that targets friendly) it pops every time you *select* a new target, not confirm the selection.
You're correct there, I did pull out the wrong method from the code.

Go back to what I said in the first place about creating a processOk() for these two window types.
That shouldn't be true, I don't know how you could be selecting anything in the battleactor or battleenemy window without having already started to input an action. But if you're encountering that case...add it in.
When Window_BattleActor initializes it calls this.hide(), and this.hide() calls this.select(null), so you get a crash immediately as soon as the battle starts.
Okay, so add the additional check.

As I said, it was an untested snippet I tossed out while working since you originally said you just needed a point in the direction.

If it's not helpful or wanted, disregard it and you do you.

Original thread: https://forums.rpgmakerweb.com/threads/have-a-skill-selection-action-queue-multiple-different-skills.157443/