Script call question.

Hello all I have a quick question I'm hoping someone can help me with. I am trying add stat point rewards at the end of a battle. I am able to do that just fine but the problem is using the change parameter option to add the stat also adds it to the reserve party members not just the active ones. I know I could set up a system to check against every character but I have so many I am hoping to find a script call if there is one to add the stat to just the active members.

I use something similar $gameActors.actor(x).isBattleMember() for checking a different aspect but was hoping there was something similar to just add the stat point the active group rather than setting up a different $gameActors.actor(x).isBattleMember() for each playable character.

Thank you for taking the time to have a look here and I hope someone can help.
$gameParty.battleMembers().forEach(function(actor) { actor.<command to add stat here> })

Note - that will include both dead and alive members in the battle party. If you only want alive members, do this:

$gameParty.battleMembers().forEach(function(actor) { if actor.isAlive() { actor.<command to add stat here> }})
$gameParty.battleMembers().forEach(function(actor) { actor.<command to add stat here> })

Note - that will include both dead and alive members in the battle party. If you only want alive members, do this:

$gameParty.battleMembers().forEach(function(actor) { if actor.isAlive() { actor.<command to add stat here> }})


Thank you very much for the script it looks like just what I need. Embarrassingly though I am having a problem. At the part that has
{ actor.<command to add stat here> }})
I am not sure what to add. I tried a bunch of different variations that I thought would work but no luck. If say I wanted the script to add
5 to the attack stat how would I type that? I tried atk * 10 Attack + 10 and a few other variations but no luck. Sorry for my ignorance here
but thank you for the quick reply.
You'd have to find the event command that would do this, then look at the Game_Interpreter script (in rpg_objects.js) and see what it does behind the scenes to do the same thing, and then you'd do that.

For instance, to change attack, you would use the Change Parameter command. So in rpg_objects.js, search for Change Parameter. This is what the function does:
Code:
// Change Parameter
Game_Interpreter.prototype.command317 = function() {
    var value = this.operateValue(this._params[3], this._params[4], this._params[5]);
    this.iterateActorEx(this._params[0], this._params[1], function(actor) {
        actor.addParam(this._params[2], value);
    }.bind(this));
    return true;
};

The command you're interested in is actor.addParam(...) so then you need to work out what the arguments are. The first one is what parameter is being changed. You can see this in the drop-down list for Parameter in the Change Parameter command - Max HP is element 0, Max MP is 1, Attack is 2. So the first argument will be 2 for Attack. The second is how much you want to change it by. So if you want to increase it by 5, the command will be actor.addParam(2, 5);

If you want to change other parameters, or do something different to the actor, you'll need to figure out what the correct command will be.
Hmm I was on the right track had been trying almost exactly what you wrote but with the proper command I'm still getting an error.
I believe now it should look like this
$gameParty.battleMembers().forEach(function(actor) { if actor.isAlive() { actor.addParam(2, 5); }}) or
$gameParty.battleMembers().forEach(function(actor) { if actor.isAlive() { actor.<.addParam(2, 5);> }})
however neither seems to be working for me am I overlooking something here?

And again thank you very much for your time it is very appreciated.
You don't put < and > in a formula. I put that in my first script call to say "you need to replace this with something".

Try putting ( and ) around actor.isAlive()

$gameParty.battleMembers().forEach(function(actor) { if (actor.isAlive()) { actor.addParam(2, 5); }})

And if it gives you an error, say what the error message is.
You are amazing 😀 Thank you so much just needed those parentheses and now its working great that little command will save so much space. You're the best thank you thank you thank you.

Original thread: https://forums.rpgmakerweb.com/threads/script-call-question.78067/