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,624
Reaction score
898
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
521
Reaction score
202
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
521
Reaction score
202
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
521
Reaction score
202
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

"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

Forum statistics

Threads
104,579
Messages
1,007,310
Members
136,063
Latest member
Saydas
Top