"Party Size" During Battles Ignores Reserve Members

Is there any easy way to get the correct party size (including reserve members) during battle events?

With 5 or 6 party members, MV returns the correct number outside battles, but only 4 during battle events. This is using the editor "Control Variables" to set a variable to give the number of party members via "Game Data", "Other" and "Party Members".

I am trying to do a "surrender" event that includes "abort battle", and I want some but not all the potential party members to suffer negative consequences. I want the reserve party members (those after the first 4) to share the grief. Because I don't know how many party members there will be during play, and who they will be, I want to check each party member and act upon the result of the check, so I use a loop which breaks when the look variable gets larger than the party size.

"$gameParty.members().length" seems to work in the same way as the editor, giving 4 in battle, the correct 5 or 6 outside battle.

Spoiler: System Info
The version of MV is 1.6.1., running on a Ubuntu laptop
Plugins used are:

YEP_CoreEngine
YEP_MessageCore
YEP_BaseTroopEvents
GALV_VisibilityRange
HIME_LargeChoice
HIME_HiddenChoiceConditions
GenderFunctions (Trihan's conversion of an Ace script from Mr. Bubbles)
RegionEncounters (again, by Trihan)

The best that I have come up with is setting a flag in the battle event, aborting the battle and having an autorun common event triggered by the flag to handle surrender aftermath. This works, but it looks a little strange. Has anyone got any better ideas?
Use
Code:
$gameParty.allMembers()
Use
Code:
$gameParty.allMembers()

Surprisingly, I needed this for exactly the same reason.
When the number of party members is 20
If I assign $gameParty.members().length to a variable, the number of party members appears properly in the field, but during the battle, only the party members participating in the battle seem to check with numbers.
So I tried to put $gameParty.allMembers() in a variable to see if it works, but it returns [object object].
It doesn't even apply in battle.
If you're just displaying the value of the variable, it will return [object object] because it's an array. You can only really manipulate it with code if you're going down that route.

The reason it returns 4 in battle is because of the way it's coded:

Code:
Game_Party.prototype.members = function() {
    return this.inBattle() ? this.battleMembers() : this.allMembers();
};

If you want to store the number of party members in a variable to actually use for a display, do

Code:
$gameParty.allMembers().length

instead.
@Trihan - Thank you! that is brilliant. Thank you so much!

Sorry I was a bit slow in replying to thank you, I was testing things out. Works a treat now! Thanks again!
If you're just displaying the value of the variable, it will return [object object] because it's an array. You can only really manipulate it with code if you're going down that route.

The reason it returns 4 in battle is because of the way it's coded:

Code:
Game_Party.prototype.members = function() {
    return this.inBattle() ? this.battleMembers() : this.allMembers();
};

If you want to store the number of party members in a variable to actually use for a display, do

Code:
$gameParty.allMembers().length

instead.

Because of that code, it is really unfortunate that even using $gameParty.members().length in combat only applies up to 4.
So how do I check the maximum number of parties during a battle?
One of the skills of my game deals damage in proportion to the total number of party members.
So there are two things I tried.

$gameParty.members().length * 0.5
Using this formula, only the number of up to 4 players participating in the battle is checked.

$gameParty.allMembers() * 0.5
Using this formula, the damage is only 0.

How can it be applied?
$gameParty.allMembers() * 0.5
Using this formula, the damage is only 0.
You need the .length too: $gameParty.allMembers().length * 0.5
You need the .length too: $gameParty.allMembers().length * 0.5

Ah, I was stupid.

You should have added .length to the one below.
Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/party-size-during-battles-ignores-reserve-members.123432/