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

bg400

AKA WriterStudios (avatar made by DrQuack64)
Member
Joined
Jun 11, 2020
Messages
25
Reaction score
6
First Language
English
Primarily Uses
RMMV
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?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,418
Reaction score
7,709
First Language
German
Primarily Uses
RMMV
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.
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,517
Reaction score
3,221
First Language
Binary
Primarily Uses
RMMZ
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 :p
 
Last edited:

bg400

AKA WriterStudios (avatar made by DrQuack64)
Member
Joined
Jun 11, 2020
Messages
25
Reaction score
6
First Language
English
Primarily Uses
RMMV
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 :p
@?????? Right, so.... how do I apply these codes? I know as formulas, but what do I categorize them as? HP recover, or something else?
 

??????

Diabolical Codemaster
Veteran
Joined
May 11, 2012
Messages
6,517
Reaction score
3,221
First Language
Binary
Primarily Uses
RMMZ
The skill categorization should have no major impact tbh. That only affects how hp is handled when the 'damage' is applied. :)
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,108
Reaction score
1,517
First Language
EN
Primarily Uses
RMMZ
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
 

bg400

AKA WriterStudios (avatar made by DrQuack64)
Member
Joined
Jun 11, 2020
Messages
25
Reaction score
6
First Language
English
Primarily Uses
RMMV
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. :D
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Frostorm wrote on Featherbrain's profile.
Hey, so what species are your raptors? Any of these?
... so here's my main characters running around inside "Headspace", a place people use as a safe place away from anxious/panic related thinking.
Stream will be live shortly! I will be doing some music tonight! Feel free to drop by!
Made transition effects for going inside or outside using zoom, pixi filter, and a shutter effect
I have gathered enough feedback from a few selected people. But it is still available if you want to sign up https://forums.rpgmakerweb.com/index.php?threads/looking-for-testers-a-closed-tech-demo.130774/

Forum statistics

Threads
105,993
Messages
1,018,200
Members
137,774
Latest member
Halop
Top