MV Battle item target reserve party

Hello, everyone!

I'm using the default battle system (RMMV) but with just one party member fighting with this code:
Code:
Game_Party.prototype.maxBattleMembers = function() {
    return 1;
};

With this, my party can have any size but just the first one wil enter the battle.
But when i try to use an item on someone, just the one in battle can be targered, so, how can i make the item target the reserve party? They don't even appear on the target list.

I'll be able to change the fighter, that's why i need to be able to heal/revive someone else.
I'm not using any plugin.
I've searched and found this topic with the same question but without answer: https://forums.rpgmakerweb.com/index.php?threads/battle-item-to-target-reserve-party.120108/

Thank you!
The default battle system only looks at actors that are within $gameParty.battleMembers(). You would need to rewrite parts of the battle system, or request a plugin to, at bare minimum:
  1. Allow battle actors to target actors with skills who are outside of $gameParty.battleMembers()
  2. Add a window to display every potential actor's status and select them with skills
I'm not sure if such a plugin exists.
You could try something like this maybe:
Spoiler
Code:
// ==========================================================================
/*:
* @author Another Fen
* @plugindesc Allows friendly actions to target reserve members.
* @help Likely incompatible with plugins that alter possible action
* target scopes or the battle UI.
*/
// ==========================================================================

(function() {
    Window_BattleActor.prototype.maxItems = function() {
        return $gameParty.allMembers().length;
    };

    Window_BattleActor.prototype.drawItem = function(index) {
        var actor = $gameParty.allMembers()[index];
        this.changePaintOpacity(actor.isBattleMember());
        this.drawBasicArea(this.basicAreaRect(index), actor);
        this.drawGaugeArea(this.gaugeAreaRect(index), actor);
        this.changePaintOpacity(true);
    };

    Window_BattleActor.prototype.actor = function() {
        return $gameParty.allMembers()[this.index()];
    };

    // ---

    Game_Action.prototype.allowReserveTargets = function() {
        return this.isForFriend() && this.friendsUnit() === $gameParty;
    };

    Game_Action.prototype.targetsForFriends = function() {
        if (this.isForUser()) {
            return [this.subject()];
        } else {
            var unit = this.friendsUnit();
            var includeReserve = this.allowReserveTargets();
            var targets = (includeReserve ? unit.allMembers() : unit.members());
            var validTargets = targets.filter(target => this.testApply(target));
            if (this.isForAll()) {
                return validTargets;
            } else if (this._targetIndex < 0) {
                return [this.pickRandomTarget(validTargets)];
            } else {
                var main = targets[this._targetIndex];
                return [(main && this.testApply(main)) ? main : validTargets[0]];
            }       
        }
    };

    Game_Action.prototype.pickRandomTarget = function(targets) {
        var tgrSumFunction = (sum, target) => sum + target.tgr;
        var tgrSum = targets.reduce(tgrSumFunction, 0);
        var tgrTarget = Math.random() * tgrSum;
        return targets.find(target => (tgrTarget -= target.tgr) < 0);
    };
   
})();
There is probably a better way to solve this, as this is probably incompatible with most plugins that alter the possible target scopes or the target selection UI and would have to be adjusted.


I'm not using any plugin.
If it isn't already, your code to limit battle members would work great as a plugin rather than a script command (This way battle party size would not reset each time the application is started).

@Kenen​

The default battle system only looks at actors that are within $gameParty.battleMembers(). You would need to rewrite parts of the battle system, or request a plugin to, at bare minimum:
  1. Allow battle actors to target actors with skills who are outside of $gameParty.battleMembers()
  2. Add a window to display every potential actor's status and select them with skills
I'm not sure if such a plugin exists.
I've tryed to find something but with no sucess. Thanks for the answer!


@Another Fen​

Thank you, that's what i need!
There is probably a better way to solve this, as this is probably incompatible with most plugins that alter the possible target scopes or the target selection UI and would have to be adjusted.
By now i'm not planning to use something witch change the scope, so it will work fine.

If it isn't already, your code to limit battle members would work great as a plugin rather than a script command (This way battle party size would not reset each time the application is started).
I'll use it as a plugin with some more modifications, thanks.

Original thread: https://forums.rpgmakerweb.com/threads/battle-item-target-reserve-party.133452/