[SOLVED] Give a Random State

Hi guy,

Can you help me please ?

I have a system of fear with the TP bar and I want to do this :

- If the battler has his TP between 50 and 90 % : He obtain a random state. 🤘

With these Yanfly plugins : auto-passive state and passive cases, I think there is a solution in Lunatic Mode, but my level is too bad 🤔

This code work to add one state :

Spoiler: NoteTag
<Passive Condition Cases>

TP% >= 50
TP% <= 90

</Passive Condition Cases>

Someone have an idea ?

Thanks
<Custom Passive Condition>

if (user.tp>= 50&&user.tp<= 90) {

condition = true;

} else {

condition = false;

}

</Custom Passive Condition>
I haven't read your writing, and I'm using YEP_autopassivestate.
Thank you Ivkeai but how to give a random state to the battler ?
@lvkeai You posted twice in the wrong place. Here are the two pieces of code that you posted, you will need to say which is the relevant one.

First post

YEP_BuffsStatesCore.js
<Custom Turn Start Effect>
if (user.tp<=20) {
var rr = Math.floor(Math.random() * 3);
if(rr==1){
user.addState(4);
}else if(rr==2){
user.addState(5);
}else{
user.addState(6);
}
}
</Custom Turn Start Effect>
You just need this piece of code.

Second post

YEP_BuffsStatesCore.js
<Custom Turn Start Effect>
if (user.tp>=20&&user.tp<=90) {
var rr = Math.floor(Math.random() * 3);
if(rr==1){
user.addState(4);
}else if(rr==2){
user.addState(5);
}else{
user.addState(6);
}
}
</Custom Turn Start Effect>
Just this piece of code is enough.
Thank you KES ! And of course thank you lvkeai !

That's perfect, the only problem is : the state change every turn, I want to do this :

TP between 50 and 90
: Add State 1 ; 2 or 3 and keep it.
TP > 90 : Remove state 1 ; 2 or 3 & Add State 4 ; 5 or 6

Thanks again ☺️
Bump please 😀

I want to create a state who give a random state to the battler, this piece of code work but change the random state every turn.
I want the battler keep only one state between 50 and 90 TP.

How I can do that please ?

<Custom Turn Start Effect>
if (user.tp>=50&&user.tp<=90) {
var rr = Math.floor(Math.random() * 3);
if(rr==1){
user.addState(4);
}else if(rr==2){
user.addState(5);
}else{
user.addState(6);
}
}
</Custom Turn Start Effect>
@lvkeai For the third time (at least) you have posted your reply as a Report, so once again I am posting it back here. Please be more careful where you post. All you need to do is to go to the bottom of the page and the Reply box is there.

@LeeAceSan Here is the code that lvkeai suggests.

if (!user.isStateAffected(4)&&!user.isStateAffected(5)&&!user.isStateAffected(6)){
if (user.tp>=50&&user.tp<=90) {
var rr = Math.floor(Math.random() * 3);
if(rr==1){
user.addState(4);
}else if(rr==2){
user.addState(5);
}else{
user.addState(6);
}
}
}

If you already have a state, you don't trigger it.
Works perfectly ! 😀👍

Thank you so much to both of you !

Original thread: https://forums.rpgmakerweb.com/threads/solved-give-a-random-state.90759/