MZ Add a BUFF out of battle?

What's the script line again that does that?

actor.addBuff(paramId, turns)
Here's an example from the MV / MZ Script Call List:

// Add a 3-turn ATK buff to the party leader $gameParty.leader().addBuff(2, 3);
So if I want to pick actor 3 (regardless of who's the leader), how do I use this? v

actor.addBuff(paramId, turns)

Where does the 3 go?

Also, is there a command to add it to all party members?
  1. Give buff to actor ID 3:

    $gameActors.actor(3).addBuff(paramId, turns);

  2. Give buff to party member 3 (index 2):

    $gameParty.members()[2].addBuff(paramId, turns);
    Technically the party leader is member index 0, i.e. $gameParty.members()[0]. Maybe I should replace the leader() examples with that, to avoid confusion.

  3. Give buff to all party members:

    for (const actor of $gameParty.members()) { actor.addBuff(paramId, turns); }
    I.e. loop through all party members and do the same thing for each of them. (If used in battle, this will only affect members currently in battle.)
Spoiler: technical
For points 1 & 2: the Script Call List I linked earlier does document it, but in 2 parts: examples in the "Actors & Enemies" section, e.g. "Actor (by Index)", tell you that they get a Game_Actor, which is a kind of Game_Battler (that could probably be made clearer). That's then valid for use in the "Add Buff" call.

For point 3: for loops are handy whenever you want to do something "for all X". JavaScript has various kinds of loop, but often you'll only need basic for or for...of:
👋

Original thread: https://forums.rpgmakerweb.com/threads/add-a-buff-out-of-battle.151865/