Any way to get an item to increase a random stat in battle?

Came across a similar question that went unanswered in an RPG Maker VX Ace thread.

Basically, I'm looking for a way to have an item to increase a random stat for a certain number of turns during battle. Is there any way to do this?
not directly.

you increase stats like you want by applying state, but all states are fixed.

so what you have to do is make multiple states for all possible values, then have the item call a common event and in that event you'll use control variable and conditional branches to randomly select one of those states to be applied.
Andars 'solution' is somewhat overly elaborate...

Code:
a.buff(Math.round(Math.random() * 8));
Use that as part of the skill formula..

The `Math.round(Math.random() * 8)` gets a random stat id between 0-7. the .buff() triggers a buff for that given stat id, and the a. reffers to the attacker using the skill/item.

Happy gaming :*

Edit:

There are other functions which might be more suitable..
Code:
a.increaseBuff(id);
a.overwriteBuffTurns(id, turnCount);
increaseBuff takes into account if the max buff is already applied (where buff() wouldnt) and overwriteBuffTurns() takes a second argument for the number of turns the buff should last..

for an easy way to create incredibly complex skill formulas, see this post! :*

Edit edit: after double checking, the .buff() call just returns the level of the current buff for that id. so i'd recommend using the increaseBuff function after all lol, and also the overwrite function if you need to set the turn count 😛
Andars 'solution' is somewhat overly elaborate...

Code:
a.buff(Math.round(Math.random() * 8));
Use that as part of the skill formula..

The `Math.round(Math.random() * 8)` gets a random stat id between 0-7. the .buff() triggers a buff for that given stat id, and the a. reffers to the attacker using the skill/item.

Happy gaming :*

Edit:

There are other functions which might be more suitable..
Code:
a.increaseBuff(id);
a.overwriteBuffTurns(id, turnCount);
increaseBuff takes into account if the max buff is already applied (where buff() wouldnt) and overwriteBuffTurns() takes a second argument for the number of turns the buff should last..

for an easy way to create incredibly complex skill formulas, see this post! :*

Edit edit: after double checking, the .buff() call just returns the level of the current buff for that id. so i'd recommend using the increaseBuff function after all lol, and also the overwrite function if you need to set the turn count 😛
@?????? Right, so.... how do I apply these codes? I know as formulas, but what do I categorize them as? HP recover, or something else?
The skill categorization should have no major impact tbh. That only affects how hp is handled when the 'damage' is applied. 🙂
You can use something like this in the damage formula:
JavaScript:
var p = [0,1,2,3,4,5,6,7]; b.addBuff(p[Math.randomInt(p.length)], 3); 0
This says:
  • Store a list of numbers in a temporary variable called p.
    These represent base parameter IDs, as follows:
    Code:
     0    1    2    3    4    5    6    7
    mhp  mmp  atk  def  mat  mdf  agi  luk

  • Get a random value from the list p, then add a 3-turn buff of that base param to the target.
  • Return a result of 0 (damage, healing, whatever).

Edit: if you prefer to add a state instead of using the built-in buff system, you can use addState in a similar way, e.g.
JavaScript:
var p = [10,11,12,20,21,22]; b.addState(p[Math.randomInt(p.length)]); 0
You can use something like this in the damage formula:
JavaScript:
var p = [0,1,2,3,4,5,6,7]; b.addBuff(p[Math.randomInt(p.length)], 3); 0
This says:
  • Store a list of numbers in a temporary variable called p.
    These represent base parameter IDs, as follows:
    Code:
     0    1    2    3    4    5    6    7
    mhp  mmp  atk  def  mat  mdf  agi  luk

  • Get a random value from the list p, then add a 3-turn buff of that base param to the target.
  • Return a result of 0 (damage, healing, whatever).

Edit: if you prefer to add a state instead of using the built-in buff system, you can use addState in a similar way, e.g.
JavaScript:
var p = [10,11,12,20,21,22]; b.addState(p[Math.randomInt(p.length)]); 0
This worked! Thank you so much. 😀

Original thread: https://forums.rpgmakerweb.com/threads/any-way-to-get-an-item-to-increase-a-random-stat-in-battle.130794/