MV Check party members stats

I want to make an event check the stats of every party member in the current party when the player activates it. There will be 8 characters you can change between throughout the game, but you can only play with 3 at a time.

Like, if a boulder is in the way, the event will check if anyone in the current party has enough strength to move it or if a book is written in a different language, the event will check if anyone in the current party has enough intellect to read it.

When the event is checking, I want it to only check the stats of the 3 characters that you’re currently playing with.

What line of code would I use to have the event check stats of the current party?
You can get the highest ATK from all current party members with:
  1. Only event commands (using Control Variables -> Game Data -> Actor):
    Spoiler: event example
    ◆Control Variables:#0017 Check = 0 ◆If:Harold is in the party ◆Control Variables:#0008 Temporary = Attack of Harold ◆If:Temporary > Check ◆Control Variables:#0017 Check = Temporary ◆ :End ◆ :End ◆If:Therese is in the party ◆Control Variables:#0008 Temporary = Attack of Therese ◆If:Temporary > Check ◆Control Variables:#0017 Check = Temporary ◆ :End ◆ :End ◆Comment:etc ◆Text:None, Window, Bottom : :Highest party ATK is \v[17].

  2. Or Control Variables -> Script:
    JavaScript:
    $gameParty.members().reduce(function(a, c) { return Math.max(a, c.atk); }, 0)
    You can then compare the value in a Conditional Branch. For a different param, replace atk with the appropriate identifier.

  3. Or Conditional Branch -> Script:
    JavaScript:
    $gameParty.members().reduce(function(a, c) { return Math.max(a, c.atk); }, 0) >= 6
    This checks if the highest ATK is at least 6.
[Edit: corrected option 2 ("Conditional Branch" -> "Control Variables") and added option 3.]
You can get the highest ATK from all current party members with:
  1. Only event commands (using Control Variables -> Game Data -> Actor):
    Spoiler: event example
    ◆Control Variables:#0017 Check = 0 ◆If:Harold is in the party ◆Control Variables:#0008 Temporary = Attack of Harold ◆If:Temporary > Check ◆Control Variables:#0017 Check = Temporary ◆ :End ◆ :End ◆If:Therese is in the party ◆Control Variables:#0008 Temporary = Attack of Therese ◆If:Temporary > Check ◆Control Variables:#0017 Check = Temporary ◆ :End ◆ :End ◆Comment:etc ◆Text:None, Window, Bottom : :Highest party ATK is \v[17].

  2. Or Conditional Branch -> Script:
    JavaScript:
    $gameParty.members().reduce(function(a, c) { return Math.max(a, c.atk); }, 0);
    For a different param, replace atk with the appropriate identifier.
Thank you so much! I’m currently working on it. I will update soon!

Update: So, I tried to use the Conditional Branch, both characters that I'm checking the atk on can push the boulder, but 1 character has an atk of 7 and the other has an atk of 5. I changed the 0 to 6 because that's where I thought I was supposed to put how much atk the character needs to have, but I must have done something wrong.
JavaScript:
$gameParty.members().reduce(function(a, c) { return Math.max(a, c.atk); }, 6);
Sorry, my mistake! I wrote "Conditional Branch", but what I wrote only gets the value, it doesn't compare it to anything. 😅

You would need to either:
  • Store that in a variable (Control Variables -> Script), then compare it in a Conditional Branch; or
  • Do the comparison in the scripted branch, e.g.
    JavaScript:
    $gameParty.members().reduce(function(a, c) { return Math.max(a, c.atk); }, 0) >= 6
I've edited my previous post for any future readers~ 😮‍💨

The number at the end is the starting value for a, so you should keep that at 0. reduce loops through all entries (party members in this case) and accumulates a single value, a (the largest ATK in this case). Details:
Sorry, my mistake! I wrote "Conditional Branch", but what I wrote only gets the value, it doesn't compare it to anything. 😅

You would need to either:
  • Store that in a variable (Control Variables -> Script), then compare it in a Conditional Branch; or
  • Do the comparison in the scripted branch, e.g.
    JavaScript:
    $gameParty.members().reduce(function(a, c) { return Math.max(a, c.atk); }, 0) >= 6
I've edited my previous post for any future readers~ 😮‍💨

The number at the end is the starting value for a, so you should keep that at 0. reduce loops through all entries (party members in this case) and accumulates a single value, a (the largest ATK in this case). Details:
Works perfectly! Thank you so much!

Original thread: https://forums.rpgmakerweb.com/threads/check-party-members-stats.163550/