Skills requiring shield usage

Discussion in 'Javascript/Plugin Support' started by Zakarijah, Sep 13, 2019.

  1. Zakarijah

    Zakarijah Villager Member

    Messages:
    24
    Likes Received:
    1
    Location:
    Midwest
    First Language:
    English
    Primarily Uses:
    RMMV
    If I use this,

    <Custom Requirement>
    value = false;
    for (i = ; i < user._equips.length; i++) {
    if (user._equips._dataClass == 'armor' && user._equips._itemId == 1) value = true;
    }
    </Custom Requirement>


    Does that make the skill ONLY usable when they have that singular item equipped?

    For example, I'd like the character to only be able to use 'Shield Bash' when a shield is equipped.

    But I'm unsure of how to code that in.

    I thought I could do it using Yanfly's Skill core but i get confused on Notetags -_-
     
    #1
  2. PixelHeart

    PixelHeart The Pixel Heartist! Veteran

    Messages:
    3,725
    Likes Received:
    1,697
    First Language:
    English
    Primarily Uses:
    Other
    Well, I know this isint a coding related answer to your question, but personally I would just give the shield equipment an attribute in the database that adds the skill when equipped. When unequipped, I believe it should no longer be available. Is that like what you were going for?

    EDIT: ...assuming that you are using the default turn based battle system.
     
    #2
  3. shockra

    shockra Slightly Crazy Programmer Veteran

    Messages:
    405
    Likes Received:
    177
    Location:
    US
    First Language:
    English
    Primarily Uses:
    RMMV
    I would try this:

    <Custom Requirement>
    value = user.equips()[1].atypeId === "shield type ID"
    </Custom Requirement>

    This code assumes that the shield is equipped in the second equipment slot and that shields are considered an armor type in the Systems tab. If that's not the case, the code may need a bit of tweaking.
     
    #3
  4. Zakarijah

    Zakarijah Villager Member

    Messages:
    24
    Likes Received:
    1
    Location:
    Midwest
    First Language:
    English
    Primarily Uses:
    RMMV
    So I had multiple characters using’ shield’ but I realized the White Mage character and black Mage character equips the small shield and the main hero can equip all shields.

    I just gave the Main Hero only the Large Shields and they all add the skill now


    I did try this but it doesn’t seem to want to work, so I just used the above method.
     
    Last edited by a moderator: Sep 14, 2019
    #4
  5. Wavelength

    Wavelength Pre-Merge Boot Moderator

    Messages:
    4,391
    Likes Received:
    3,665
    Location:
    Florida, USA
    First Language:
    English
    Primarily Uses:
    RMVXA
    The way I'd do it, which is much simpler, is simply to give the shield equipment the Add Skill: Shield Bash feature in their features box. The only reason I can think of that this wouldn't fit your needs is if you want to require the player has already learned Shield Bash thru levels or skill-learn events first, in order for it to be available when shields are equip.

    If you do need that, then I'd recommend using a Custom Show Eval rather than a Custom Requirement. And while your javascript lines look close, they are definitely not correct. You have a set operator without an expression on the right-hand side when you say i = ; this needs to be i = 0; and you never use i in the evaluation - my guess is that you need to say equips[0] rather than equips in both places you use it. This might or might not get you there; checking equips is always tough and I'm much more used to the way it's handled in Ace.

    One more thing, @Zakarijah - please don't double post. If you need to quote multiple posts, there's a Multi-Quote function (click the "+ Quote" action on the posts, and then click the button that says Insert Quotes right below your post entry box). I've merged your posts together for you this time.
     
    #5
  6. shockra

    shockra Slightly Crazy Programmer Veteran

    Messages:
    405
    Likes Received:
    177
    Location:
    US
    First Language:
    English
    Primarily Uses:
    RMMV
    The code wouldn't be identical to what I typed. 'Shield Type ID' would have to be replaced by the ID of the Armor Type. So if the shield Armor Type is 2, the code would be:

    <Custom Requirement>
    value = user.equips()[1].atypeId === 2;
    </Custom Requirement>
     
    #6

Share This Page