Party member attack to variable issue

Discussion in 'RPG Maker MV' started by Poppie360, May 14, 2018.

  1. Poppie360

    Poppie360 chocobo wrangler Veteran

    Messages:
    120
    Likes Received:
    32
    Location:
    NH, USA
    First Language:
    English
    Primarily Uses:
    RMMV
    Hi, im having a small issue with the map based battle system i'm making. i cannot set a variable of the ATK of a party member. here's a screenshot of the section of the event and the respective error atributed to it:
    [​IMG] [​IMG]

    any help is appreciated, as i haven't been able to find a solution to this yet.
     
    #1
  2. Aloe Guvner

    Aloe Guvner Walrus Veteran

    Messages:
    1,600
    Likes Received:
    1,005
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    How many members are in the party when that error happens? My guess is that you have less than 3 party members.

    To find out, when the error happens, open the console by pressing F8.
    Type this and press enter:
    Code:
    $gameParty.members();
    Then you can check how many, and can expand the results to see more details.
     
    #2
  3. Poppie360

    Poppie360 chocobo wrangler Veteran

    Messages:
    120
    Likes Received:
    32
    Location:
    NH, USA
    First Language:
    English
    Primarily Uses:
    RMMV
    ah, that'd make sense, let me try something for a second

    EDIT: yes, that was the issue.
    [​IMG]
    do you know how to check the size of the party then? some things are dependent on how many you have in your party, i'll have to create a conditional branch
     
    #3
  4. Astfgl66

    Astfgl66 Veteran Veteran

    Messages:
    659
    Likes Received:
    504
    First Language:
    French
    You'll probably want to do that with a loop anyway, its both cleaner and more efficient and will save you party size checks.
    Something like that should work
    Code:
    var members =$gameParty.members()
    for (var i = 0; i < members.length; i++) { //loop through all members
     $gameVariables.setValue(69 + i, members[i].atk) //set variable 69 to party member 1 attack, 70 pm 2, 71 pm 3
    }
    
    You can add lines to that loop to store defense or anything else really, just change the default variable number.

    To check party size just type:
    $gameParty.members().length
     
    #4
  5. Poppie360

    Poppie360 chocobo wrangler Veteran

    Messages:
    120
    Likes Received:
    32
    Location:
    NH, USA
    First Language:
    English
    Primarily Uses:
    RMMV
    thanks, although i only need to check it once at the beginning of the event. (due to it being just an event that runs once to set up variables needed for calculations) $gameParty.members() was the correct script call needed. (not sure 100% how to mention someone) but thanks @Aloe Guvner for helping out with this as well. the thread can be closed thanks to the issue being resolved.
     
    #5
  6. Aloe Guvner

    Aloe Guvner Walrus Veteran

    Messages:
    1,600
    Likes Received:
    1,005
    Location:
    USA
    First Language:
    English
    Primarily Uses:
    RMMV
    Actually, @Astfgl66 suggestion is exactly this. You could try his/her suggestion in a Script Call Event Command, because you then you don't need to worry about how many members are in the party. It will figure that out for you.

    For example, in your screenshot, you might have 1 or 2 or 3 members in the party.

    What his/her code is doing:
    • Set Variable #69 to the first member attack
    • Set Variable #70 to the second member attack (if there is a second member!)
    • Set Variable #71 to the third member attack (if there is a third member!)

    This is exactly the same as the suggestion, just written more concisely:
    Code:
    $gameParty.members.forEach(function(actor, i){$gameVariables.setValue(69 + i, actor.atk);});
    $gameParty.members.forEach(function(actor, i){$gameVariables.setValue(73 + i, actor.def);});
    
     
    #6

Share This Page