Script Call - current troop "addParam is not a function"

Howdy!

I've decided to convert my RPG VX Ace to MZ and having to learn JS, and have run into an issue

I'm trying to change the current troop's parameters.
The following is one of those lines:

$gameTroop.members().addParam(2,$gameVariables.value(84))

but I keep getting:
1713407371886.png


If I dive into the Script Call Reference spreadsheets, it's true, I don't see that syntax anywhere,
but there is one for $gameParty.members().

Am I just doing this incorrectly or does this function for $gameTroop.members() not exist?
$gameTroop.members() returns an array of enemies and addParam() is a method for battlers. if you want to use the addParam method on the entire troop, you can use the forEach function on the members array to run addParam on each enemy
@Robro33 is correct. To be more specific, if you want to add the parameter to the entire troop, you would do as follows:

JavaScript:
$gameTroop.members().forEach(function(member) {
    member.addParam(2, $gameVariables.value(84));
});

...and, if just want to add it to the first member of the troop:

JavaScript:
$gameParty.members()[0].addParam(2, 10);

...where [0] is the first member of the array, [1] would be the second, and so on. The Script Call reference spreadsheet does this for its example of "Give the party leader a permanent +10 ATK bonus", if you realize.
Thank you for responding @Robro33 and @Ultra_K

Ok, so I started out with .forEach but was still experimenting. Looks like I drove off the road when I was on the right path to begin with. However, I had no idea how to lay it out, so thank you so much for that @Ultra_K !

@Ultra_K Any chance you know how to do the same to EXP and G given at the end of a Battle?

I'm trying to add a multiplier to the EXP and Gold like I did with the $gameTroop parameters. I did this in RPG Maker VX Ace, but I can't figure out where or how I did it.

at its very basics I'm trying to do something like:
$gameTroop.members().expTotal() *= $gameVariables.value(85)

I realize this is missing a step since the .expTotal() is merely getting total XP.

Essentially, what I've done is made the Enemies scale to the main character. In essence, all the enemies have the same parameters. Depending on the level of the main character and progression into the game determines the strength and rewards for defeating the troop.

I've now got the Params in place but still need to figure out how to alter the EXP and Gold received for defeating them.
@Brigg Hmm, that may be more difficult to do. Keep in mind, I don't really know much about JS and how MV/MZ works internally. But I do know that the EXP and Gold aren't defined in the same way as the parameters, because they are designed to be static values defined in your database, whereas the parameters change "easily" to begin with. Somebody correct me if I'm wrong, but I don't think there is a function that would do what you want. 🙁

There may be some plugin that helps, however. This forum thread asks about doing custom EXP tables, it may be close? If the posts are anything to go by, the first plugin they talk about has some peculiarity listed in its Itch.io comments, and the second one by Hime is for MV but it seems like it works in MZ? This reddit post also talks about it in more detail.

If they don't serve you well, maybe you could give more EXP and Gold by calling common events at the end of every battle, but I recon, that would be less "elegant" because the battle end messages won't give the more "accurate" values.

Good luck in any case, I hope you find something that works.
Yeah, I wasn't able to it in RPG Maker VX Ace either. I had to go into the actual system files and make it actually multiply against the player level - but it worked!

I have no idea how to do that here or even find where I made the change in Ace.

My first attempt was using XP Tables, but I wasn't a big fan. It was such a mess. When I scaled it, it made everything so much more smoother. And I didn't have to pre-play the game to figure out the progression.
$gameTroop.members().expTotal() *= $gameVariables.value(85)
Perhaps try the following?
$dataEnemies[x].exp *= $gameVariables.value(85);
I realize this is missing a step since the .expTotal() is merely getting total XP.
then you know what to change. Doing
Code:
Game_Troop.prototype.expTotal = function() {
    return this.deadMembers().reduce(function(r, enemy) {
        return r + enemy.exp();
    }, 0) * $gameVariables.value(85);
};
or
Code:
Game_Enemy.prototype.exp = function() {
    return this.enemy().exp * $gameVariables.value(85);
};
as a plugin would cause what you want. youd just have to make sure that that variable always has a value greater than 0
@Robro33
That worked like a charm!
Thank you SO much! You guys are absolute legends.

Original thread: https://forums.rpgmakerweb.com/threads/script-call-current-troop-addparam-is-not-a-function.167840/