How do I check if all ALIVE party members have a state?

Discussion in 'Javascript/Plugin Support' started by Nectar, Sep 26, 2019.

  1. Nectar

    Nectar Fried Ore0s Veteran

    Messages:
    110
    Likes Received:
    16
    First Language:
    English
    Primarily Uses:
    RMMV
    Via conditional branch.

    Just want to check if all live members are affected by a certain state
     
    #1
  2. Oddball

    Oddball Veteran Veteran

    Messages:
    1,667
    Likes Received:
    445
    First Language:
    English
    Primarily Uses:
    N/A
    Conditinal branches within conditinal branches. Sense you want to check for all, it doesn't matter who you check for first. You also don't need an else branch, and you can check for a state in one of the conditinal branch pages

    Edit, you can also check if there HP is above 0. First use conditinal branches checking for party members HP above 0 for each party member, those you might need to use else branches. Then for each alive member, check if they have the state. It might look like a mess when your done, but im sure it will work
     
    #2
  3. NinjaKittyProductions

    NinjaKittyProductions Professional Murder Hobos Veteran

    Messages:
    367
    Likes Received:
    305
    First Language:
    English
    Primarily Uses:
    RMMV
    Code:
    var allState = true;
    var party = $gameParty.aliveMembers();
    for (i = 0; i < party.length; i++) {
          //x = state ID
           if (!party[i].isStateAffected(x)) {
               allState = false;
           }
    }
    
    // y = switch ID... such as 18
    $gameSwitches.setValue(y, allState)
    
    You can run this in a troop event.
    Capture.PNG

    You can also run this in a Common Event as well but it won't run correctly in combat if it is a Common Event.
     
    #3
    caethyril and Nectar like this.
  4. Oddball

    Oddball Veteran Veteran

    Messages:
    1,667
    Likes Received:
    445
    First Language:
    English
    Primarily Uses:
    N/A
    And they will be protected by Allstate. Are you in good hands? :p
     
    #4
  5. Nectar

    Nectar Fried Ore0s Veteran

    Messages:
    110
    Likes Received:
    16
    First Language:
    English
    Primarily Uses:
    RMMV
    Yay it works, thanks guys
     
    #5
  6. caethyril

    caethyril ^_^ Veteran

    Messages:
    1,318
    Likes Received:
    820
    Location:
    UK
    First Language:
    English
    Primarily Uses:
    RMMV
    Another possible option is Conditional Branch > Script:
    Code:
    $gameParty.aliveMembers.every(function(m) { return m.isStateAffected(5); });
    This should be true iff all living party members are affected by state 5. In battle it'll only count members active in battle, on the map it'll include reserve members as well. :)
     
    #6
  7. Nectar

    Nectar Fried Ore0s Veteran

    Messages:
    110
    Likes Received:
    16
    First Language:
    English
    Primarily Uses:
    RMMV
    Ah both are very useful, I'll keep that in my notes, thanks guys!
     
    #7

Share This Page