Script Calling the Entire Troop Help

Hey Gang!


I'm trying to adjust battler's params, but I want it to adjust all of them at once.


I've tried:


$game_troop.members[index].param[id]


I was hoping "[index]" would apply to the entire troop, but alas, it is not.


It's expecting a number 0-7 for the .members[index_id]


Anyway to make this happen without writing the script call for all 8 slots individually?


Edit: Been trying to test this out, and I'm starting to think adjusting Battler params through Script Calls is not doable. Is this true?


For example, one of my Script Calls is:


$game_troop.members[0].param(0) + $game_variables[81]


In this scenario, Var:81 is the product of the Player's Level and a multiplier that will increase the Battler's MHP along with the Player's level.
It is doable, but you need a different command for that: You can use


battler.add_param( param-ID , value-you-want-to-add )


to modify a battlers parameters (as demonstrated in the Game_Interpreter script if you search for the name of the event command "Change Parameters")


If you want to do something for all entries of a list (like the entire troop) you can use a loop:


$game_troop.members.each { |member| member.add_param(0, 500) }


would run the code within {} once for each member in the troop, substituting the variable member (or whatever name you choose) by the respective enemy.


If you want to execute code for a specific range of numbers, you can go for


10.upto(20) { |number| ... }


which will in this case count from 10 up to 20, executing the code with number set to 10-20 accordingly.
Awesome, Fen!


Another question. How would that work with a Battler's gold and exp?


I've been trying variations of $game_troop.members.each { |member| member.add_exp(member.exp + value) }.


In the Game_Interpreter, I found $actor.change_exp(actor.exp + value, @params[5]) 

Original thread: https://forums.rpgmakerweb.com/threads/script-calling-the-entire-troop-help.60052/