RMMV Randomized State - Yanfly State Core

MerlinCross

Veteran
Veteran
Joined
Jun 8, 2015
Messages
208
Reaction score
88
First Language
English
Primarily Uses
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){
target.addState(34);//state ID
}
if(rr==1){
target.addState(35);
}
if(rr==2){
target.addState(36);
}
</Pre-Damage Eval>

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

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
2,587
Reaction score
880
First Language
Dutch
Primarily Uses
RMMV
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
Veteran
Joined
Dec 5, 2017
Messages
509
Reaction score
196
First Language
english
Primarily Uses
RMMV
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
Veteran
Joined
Jun 8, 2015
Messages
208
Reaction score
88
First Language
English
Primarily Uses
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
Veteran
Joined
Jun 8, 2015
Messages
208
Reaction score
88
First Language
English
Primarily Uses
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){
target.addState(34);//state ID
}
if(rr==1){
target.addState(35);
}
if(rr==2){
target.addState(36);
}
</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
Veteran
Joined
Dec 5, 2017
Messages
509
Reaction score
196
First Language
english
Primarily Uses
RMMV
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
Veteran
Joined
Jun 8, 2015
Messages
208
Reaction score
88
First Language
English
Primarily Uses
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
Veteran
Joined
Jun 8, 2015
Messages
208
Reaction score
88
First Language
English
Primarily Uses
Randomized skill.png
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
Veteran
Joined
Dec 5, 2017
Messages
509
Reaction score
196
First Language
english
Primarily Uses
RMMV
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
Veteran
Joined
Jun 8, 2015
Messages
208
Reaction score
88
First Language
English
Primarily Uses
I could try. Message you back later about it.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

I always told my DA fans how much I hate slot machines. They're fine in games as a risk-and-reward system. But when you're spending REAL MONEY in a Vegas casino to try and hit the jackpot (which very, very few people will), it can really hurt your budget. Gambling is a bad habit, and I don't like wasting my money on a slim chance. Go to Vegas for the experience, not the jackpot.
Took the kids to a corn maze. They gave us a map and had lights at certain points in the maze. Not overwhelming... or underwhelming... just... whelming.
Okay, vacuuming fruit flies out of the air is surprisingly effective.
Finally finished my menu redesign after like a month of coding! I hate designing menus... Good news though - I thought of a complete redesign for it now, so yay...
Still no scam calls all day... also I got a quick gig designing a mascot drawing for a small business, so I might actually make some green of my own after all. That would be a perfect job for me, since I love art and digital design.

Forum statistics

Threads
104,390
Messages
1,006,035
Members
135,919
Latest member
SuitonKoton
Top