# RMMVRandomized State - Yanfly State Core

#### MerlinCross

##### Veteran
Hi, I'm trying to figure out how to apply a random state after using a skill. That and maybe check to see what states it has and clears any possible state that could be applied by this skill(So you can't just stack it).

I looked around and found a post that kinda gave a base idea but doesn't seem to work. In part because it's probably not set up to work with mine but could someone take a look. Right now i'm just trying to apply a random state;

<Pre-Damage Eval>
var rr = Math.floor(Math.random() * 3);//Get a random number
if(rr==0){
}
if(rr==1){
}
if(rr==2){
}
</Pre-Damage Eval>

I might need to fixe the "Math.random" part but unsure of how to go about it.

##### Veteran
you might something like this:

Math.randomInt(X) return to a random integer. (from 0 to X - 1)
Math.randomInt(15) will return a number from 0 to 14
X + Math.randomInt(Y) for a range from x to y
Example would be: 2 + Math.randomInt(8) will give you a result from 2 to 9

#### Tiamat-86

##### old jrpg gamer
do you have yanfly skill core? that notetag isn't part of buff/state core its from skill core

edit: the things you would change is the * 3,
the number of if statements,
and the state numbers.

look at the * 3 as * X with X being the number of possible states the skill can inflict.
make a separate if statement for each possible state starting with if rr = 0.
and of course match the state numbers to the state IDs in your database.

since you want this skill to also clear any older states so they don't stack you should make it
<After Eval> so that the effects section of the skill can be used to cure all old states

Last edited:

#### MerlinCross

##### Veteran
do you have yanfly skill core? that notetag isn't part of buff/state core its from skill core

edit: the things you would change is the * 3,
the number of if statements,
and the state numbers.

look at the * 3 as * X with X being the number of possible states the skill can inflict.
make a separate if statement for each possible state starting with if rr = 0.
and of course match the state numbers to the state IDs in your database.

since you want this skill to also clear any older states so they don't stack you should make it
<After Eval> so that the effects section of the skill can be used to cure all old states
Thanks.

Though it's not so much "Clear all states" and more "Clear all states this ability could provide" so they don't just keep getting stacking effects.

#### MerlinCross

##### Veteran
Also when I first stumbled across this code, it was listed as Buff/state core so that might be why I'm having trouble. I DO have skill core but.

Trying

<Pre-Damage Eval>
var rr = Math.randomInt(3);//Get a random number
if(rr==0){
}
if(rr==1){
}
if(rr==2){
}
</Pre-Damage Eval>

What I think should happen; game makes a number from 0 - 2(0 counts as an integer).
It then generates a state based off which number it came up with.

Could the code be making EVERY number from 0-2? Is that the problem, that I'm getting something like 1.32434214?

#### Tiamat-86

##### old jrpg gamer
can you post a screenshot of the skill? the notetag should be working but there could be something else in the skill thats causing the problem

#### MerlinCross

##### Veteran
Ah I seemed to have found the issue. It only works if I have the damage set to HP damage(Though it probably would work for any damage types besides None).

Kinda don't want a 0 pop up of "No damage" each time they try to use the ability.

#### MerlinCross

##### Veteran

I hate to double post but it's been a week or so. And @Tiamat-86 wanted a screen shot so here you go.
Again the skill actually works now but it only works when a Damage type is applied. Probably because Yanfly Battle wants it.

Question if I should keep the convo here or make an new thread as it's more about Yanfly's Skill core it seems.

#### Tiamat-86

##### old jrpg gamer
have you tried changing it to Before Eval or After Eval instead of Pre-Damage Eval and Post-Damage Eval?
skill core plugin has a footnote about how the damage evals can effect the damage formula.
Before and After don't effect the formula.

edit: i just read headnote though stating before and after doesnt even matter if the skill hits or not.
but since the skill is "certain hit" anyways that wont be an issue for this 1 skill in particular.

#### MerlinCross

##### Veteran
I could try. Message you back later about it.

### Latest Profile Posts

"How dare you!" is probably the most overused reason to start conflict.
Another day of mostly mapping in Make a Game in RPG Maker MZ: Episode 7 starting now! We're making a mansion! Come watch live and join in on the chat!
Game=Forest, Feature=Tree. There's little worth in looking at a tree except in its relation to how it affects the feel of the forest.
Been a while, guys. Despite being in college now, I'm working on Season's Promise as often as I can.
Helping my sister make her game
I hope i can get some freckles for the generator soon