[SOLVED] Give a Random State

Discussion in 'RPG Maker MV' started by LeeAceSan, Feb 2, 2018.

  1. LeeAceSan

    LeeAceSan Veteran Veteran

    Messages:
    52
    Likes Received:
    30
    First Language:
    French
    Primarily Uses:
    RMMV
    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. :rock-left:

    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 :unsure:

    This code work to add one state :

    <Passive Condition Cases>

    TP% >= 50
    TP% <= 90

    </Passive Condition Cases>

    Someone have an idea ?

    Thanks
     
    #1
  2. lvkeai

    lvkeai test Custom Title Member

    Messages:
    16
    Likes Received:
    8
    First Language:
    Chinese
    Primarily Uses:
    RMMV
    <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.
     
    #2
    LeeAceSan likes this.
  3. LeeAceSan

    LeeAceSan Veteran Veteran

    Messages:
    52
    Likes Received:
    30
    First Language:
    French
    Primarily Uses:
    RMMV
    Thank you Ivkeai but how to give a random state to the battler ?
     
    #3
  4. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,598
    Likes Received:
    10,511
    First Language:
    English
    Primarily Uses:
    RMVXA
    @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.
     
    #4
    LeeAceSan likes this.
  5. LeeAceSan

    LeeAceSan Veteran Veteran

    Messages:
    52
    Likes Received:
    30
    First Language:
    French
    Primarily Uses:
    RMMV
    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 :cutesmile:
     
    #5
  6. LeeAceSan

    LeeAceSan Veteran Veteran

    Messages:
    52
    Likes Received:
    30
    First Language:
    French
    Primarily Uses:
    RMMV
    Bump please :D

    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>
     
    #6
  7. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,598
    Likes Received:
    10,511
    First Language:
    English
    Primarily Uses:
    RMVXA
    @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.
     
    #7
    LeeAceSan likes this.
  8. LeeAceSan

    LeeAceSan Veteran Veteran

    Messages:
    52
    Likes Received:
    30
    First Language:
    French
    Primarily Uses:
    RMMV
    Works perfectly ! :D:thumbsup-right:

    Thank you so much to both of you !
     
    #8

Share This Page