Certain items only usable when switch is turned on

● ARCHIVED · READ-ONLY
Started by GummyHelix 4 posts View original ↗
  1. Hello there!


    Basically what I'm looking for is the ability to turn a switch on, and a certain set of items are usable then and only then. When the switch is turned off, they're now again unusable. It's like how some items are only usable in battle and others only on the field, except more in depth. Also, it'd be nice if I could use more than one switch for different sets items.


    Main reason I'm asking is I'm making Common Event-based battle systems. It's gonna have Undertale mechanics! :D  (If you don't know what Undertale is and want to see an example of what I'm going to do...)


    Would anybody be able to do something like this? Thank you in advance!
  2. Here you go:

    Code:
    #============================================================================
    # Conditional Item Use
    # by Shaz
    #----------------------------------------------------------------------------
    # Add <enable:x> to an item's note box, and replace x with a switch number
    # (no leading zeros) to make the item usable only when that switch is turned
    # on:
    # <enable:15> will allow the item to only be used when switch 15 is on.
    # Don't forget to give the switch a name so you don't accidentally use it
    # for something else!
    #============================================================================
    
    
    class Game_Party < Game_Unit
      alias shaz_conditional_usable? usable?
      #--------------------------------------------------------------------------
      # * Determine Skill/Item Usability
      #--------------------------------------------------------------------------
      def usable?(item)
        if item.is_a?(RPG::Item) && item.note =~ /<enable:(\d+)>/i
          return false if !$game_switches[$1.to_i]
        end
        return shaz_conditional_usable?(item)
      end
    end
  3. @Shaz Oh my goodness, thank you so much!!! I'll put it to good use!! :D
  4. This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.