How to check for 'no weapon equipped'

Discussion in 'RPG Maker MV' started by Animebryan, Mar 11, 2019.

  1. Animebryan

    Animebryan Feels like I'm slowly dying! Veteran

    Messages:
    335
    Likes Received:
    154
    Location:
    Marysville, CA
    First Language:
    English
    Primarily Uses:
    RMMV
    I'm running conditional branches to check for every instance of each weapon. But I also need to check for if there's no weapon equipped, but the conditional branch option for a weapon doesn't allow to check for an empty slot. Is there a script call to do this?
     
    #1
  2. Dreadshadow

    Dreadshadow Lv 38 Tech Magician Moderator

    Messages:
    3,835
    Likes Received:
    2,480
    First Language:
    Greek
    Primarily Uses:
    RMMV
    Assuming you got weapons A,B,C.
    You need to create more complex condtidional branching.
    You must nest them one inside another, using the ELSE option.
    The final else will eventually cover the no weapon case.

    Code:
    ◆If:Harold has equipped Sword
      ◆Commen:Comment:Sword
      ◆
    :Else
      ◆If:Harold has equipped Axe
        ◆Comment:Axe
        ◆
      :Else
        ◆If:Harold has equipped Cane
          ◆Comment:Cane
          ◆
        :Else
          ◆If:Harold has equipped Bow
            ◆Comment:Bow
            ◆
          :Else
            ◆Comment: THINGS TO HAPPEN IF UNARMED GOES HERE
            ◆
          :End
          ◆
        :End
        ◆
      :End
      ◆
    :End
    
    Note that the more the weapons, the more the nested conditions eventually.

    As for script command, well you can make one yourself.
    https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-mv-script-call-list.46456/

    Combine what you see in B-182 along with B-194.
     
    Last edited: Mar 12, 2019
    #2
  3. Animebryan

    Animebryan Feels like I'm slowly dying! Veteran

    Messages:
    335
    Likes Received:
    154
    Location:
    Marysville, CA
    First Language:
    English
    Primarily Uses:
    RMMV
    As for the script call option, I'm having trouble understanding how to write it out. Is the 1st actor ID 0 or 1? Do I put anything in the () after equips? Would [n] be the weapon ID & if so, would checking for ID 0 work? And do I need that 2nd line with 'return'?
     
    #3
  4. Aesica

    Aesica undefined Veteran

    Messages:
    748
    Likes Received:
    708
    Location:
    SW5GMW 4xVHk
    First Language:
    English
    Primarily Uses:
    RMMV
    Every actor has a weapon() function that returns an array of equipped weapons. If the length of this array is 0, then no weapons are equipped. It's a pretty simple snippet of code, but I can't really give a proper example without knowing which actor you're trying to check. I guess this example works:

    Code:
    If : Script : $gameParty.members()[0].weapons().length === 0
      [Stuff for no weapon equipped here]
    : End
    This branch is evaluated as true if the first party member has no weapon equipped
     
    #4
  5. Animebryan

    Animebryan Feels like I'm slowly dying! Veteran

    Messages:
    335
    Likes Received:
    154
    Location:
    Marysville, CA
    First Language:
    English
    Primarily Uses:
    RMMV
    Do I start from If or $game... when using that code?
     
    #5
  6. Aesica

    Aesica undefined Veteran

    Messages:
    748
    Likes Received:
    708
    Location:
    SW5GMW 4xVHk
    First Language:
    English
    Primarily Uses:
    RMMV
    That's meant to be an example of what an event sequence would look like on the event window. For the conditional branch, you'd go all the way to the page where you can input a script conditional, then add in $gameParty...blahblah

    But again, that only works for the first character in the party.
     
    #6

Share This Page