Checking Party Members Stats

Hi,

I have a problem with something I thought would be rather easy, but I searched for some time now without finding a solution.

I want to create a Conditional Branch that checks if a party members parameter, like atk or agi is higher or equal to a constant. It is important to me that it is a party member, instead of a specific actor, since the players can choose between a lot of different actors for their party.

So for example, if the player wants to move a rock, the game should check if any of the party members atk (what would be replaced with strenght or something) is higher than 30, before the rock can be moved.

If there is a way to accomplish this, without using scripts, I was not able to find it yet. Using scripts I thought of two solutions:

1. Just creating a usual Conditional Branch with a Script for a condition that checks for the first party members atk is high enough and if not checks for the second and so on.

2. Setting a variable according to the parameter first and then letting the game check the variable rather than the parameter directly.

Since I am new to scripting all I could do was using fragments from similar questions and fuse them together, but I failed miserably ...

That's why I am asking the people who actually understand what they are doing 😀

I would appreciate any kind of help, like an explanation how to do these things in general, an alternative way to do this or a premade script.

My first tries looked like this:

Conditional Branch
If:
(Script) $gameParty.members(0).atk >= 30



Or the other one:

var actor = $gameParty.members(0); $gameVariables.setValue(1, actor.atk)
Proper way to use these are:

$gameParty.members()[memberIndex].stat

or

$gameActors.actor(id).stat

because

$gameActors.actor(id) uses info directly from DataActors.json

and $gameParty.members()[id] refers to current party in play

TIP:
$gameParty.members()[0] is current Party leader and you can use
$gameParty.leader() to refer directly for party leader.
If you're going to keep checking until you either find one that meets the requirements or run out of party members, then you can skip the process of checking individuals, and just ask for ANY party member that meets the requirements.

Conditional Branch: Script: $gameParty.members().some(function(actor) {return actor.atk >= 30})

If you run this on the map and you only want to check the active battlers and not the reserve members, use battleMembers() instead of members()
Worked!
Thank you both so much, also for your additional tips. This will be very useful 🙂

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/checking-party-members-stats.133421/