What's the script line again that does that?
MZ Add a BUFF out of battle?
Javascript/Plugin Supportactor.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?
actor.addBuff(paramId, turns)
Where does the 3 go?
Also, is there a command to add it to all party members?
- Give buff to actor ID 3:
$gameActors.actor(3).addBuff(paramId, turns);
- 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 theleader()examples with that, to avoid confusion.
- 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.)
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
For point 3:
developer.mozilla.org
developer.mozilla.org
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:for - JavaScript | MDN
The for statement creates a loop that consists of three optional expressions, enclosed in parentheses and separated by semicolons, followed by a statement (usually a block statement) to be executed in the loop.
for...of - JavaScript | MDN
The for...of statement executes a loop that operates on a sequence of values sourced from an iterable object. Iterable objects include instances of built-ins such as Array, String, TypedArray, Map, Set, NodeList (and other DOM collections), as well as the arguments object, generators produced by...
Original thread: https://forums.rpgmakerweb.com/threads/add-a-buff-out-of-battle.151865/