• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Scottie, Todd, Serena, Kris - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Equipping Items

  • 132
    Posts
    10
    Years
    I'm looking for a way to turn an item on/off, much like how you can turn the ExpShare on/off. This is so the player can "equip" the item from his bag, whereupon a switch would run from there until the item is no longer equipped.

    For reference, here's the script that (somehow) defines the effect of the ExpShare in PItem_ItemEffects:
    Code:
    ItemHandlers::UseFromBag.add(:EXPALL,proc{|item|
       $PokemonBag.pbChangeItem(:EXPALL,:EXPALLOFF)
       Kernel.pbMessage(_INTL("The Exp Share was turned off."))
       next 1 # Continue
    })
    
    ItemHandlers::UseFromBag.add(:EXPALLOFF,proc{|item|
       $PokemonBag.pbChangeItem(:EXPALLOFF,:EXPALL)
       Kernel.pbMessage(_INTL("The Exp Share was turned on."))
       next 1 # Continue
    })

    Thanks
     
    So, if I understand, you want an Item that will turn a switch on and off? Okay.
    Code:
    ItemHandlers::UseFromBag.add(:ITEMON,proc{|item|
       $PokemonBag.pbChangeItem(:ITEMON,:ITEMOFF)
       $game_switches[varnum] = true
       Kernel.pbMessage(_INTL("The Item was unequiped."))
       next 1 # Continue
    })
    
    ItemHandlers::UseFromBag.add(:ITEMOFF,proc{|item|
       $PokemonBag.pbChangeItem(:ITEMOFF,:ITEMON)
       $game_switches[varnum] = false
       Kernel.pbMessage(_INTL("The Item was equiped."))
       next 1 # Continue
    })
    Replace varnum with the switch you want to change. This will turn the switch numbered varnum on and off.

    Is that what you want?

    EDIT: I feel that what you meant was an explanation. The EXPALL is almost a dummy item, the game just checks if you have it in your bag. $PokemonBag.pbChangeItem replaces all of the first item with the second one.
     
    So, if I understand, you want an Item that will turn a switch on and off? Okay.
    Code:
    ItemHandlers::UseFromBag.add(:ITEMON,proc{|item|
       $PokemonBag.pbChangeItem(:ITEMON,:ITEMOFF)
       $game_switches[varnum] = true
       Kernel.pbMessage(_INTL("The Item was unequiped."))
       next 1 # Continue
    })
    
    ItemHandlers::UseFromBag.add(:ITEMOFF,proc{|item|
       $PokemonBag.pbChangeItem(:ITEMOFF,:ITEMON)
       $game_switches[varnum] = false
       Kernel.pbMessage(_INTL("The Item was equiped."))
       next 1 # Continue
    })
    Replace varnum with the switch you want to change. This will turn the switch numbered varnum on and off.

    Is that what you want?

    EDIT: I feel that what you meant was an explanation. The EXPALL is almost a dummy item, the game just checks if you have it in your bag. $PokemonBag.pbChangeItem replaces all of the first item with the second one.

    I see. But, how do you plug a specific item into that script? Simply by replacing the "ITEM" in "ITEMON" with the name of the item?
     
    :ITEMON, and :ITEMOFF are the Internal names of the item.
    See this is the first item in item.txt, a repel
    Code:
    1,[COLOR="Red"]REPEL[/COLOR],Repel,Repels,1,350,"An item that prevents weak wild Pokémon from appearing for 100 steps after its use.",2,0,0,
    See that red section, all in capital, that's the internal name. You would have the internal name of the item there instead of ITEMON/ITEMOFF.
    Defining an item
    Item Effects
     
    Ah, one step closer. Thanks for the help.

    I'm able to get it to say "This item was equipped," but using it again does not undo it. It says the item is equipped over and over, plus the switch doesn't seem to activate. I may just be misunderstanding what you're saying though. To me, it seems like all ITEMON/OFFs would be entirely replaced by one item's internal name with no distinctive ON or OFF suffix. Like this, where I use REPEL as the item:

    Code:
    ItemHandlers::UseFromBag.add(:REPEL,proc{|item|
       $PokemonBag.pbChangeItem(:REPEL,:REPEL)
       $game_switches[varnum] = false
       Kernel.pbMessage(_INTL("The Item was equipped."))
       next 1 # Continue
    })

    That's what I'm getting. Seems like there should be a little more to it than that, especially since I can't un-equip the item.

    EDIT: Never mind, I got it. Easy-peasy. Thanks again!
     
    Last edited:
    Back
    Top