• 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.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll here!
  • Red, Hilda, Paxton, or Kellyn - 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.

[Scripting Question] Restore held items after battle

  • 6
    Posts
    4
    Years
    • she/her
    • Seen Feb 3, 2024
    I'm making a game with more of a focus on competitive-style battles, and I want the player to be able to use items like focus sashes and weakness policies without worrying about permanently losing the item. I found this script: https://www.pokecommunity.com/showthread.php?t=429026 that says it achieves the effect I'm looking for, but upon getting into a battle with the script enabled, the game crashes with the following error:
    Code:
    [Pokémon Essentials version 18.1]
    Exception: ArgumentError
    Message: wrong number of arguments(0 for 1)
    
    Backtrace:
    Battle_StartAndEnd:258:in `pbStartBattleCore'
    Battle_StartAndEnd:258:in `pbStartBattle'
    PField_Battles:421:in `pbTrainerBattleCore'
    PField_Battles:420:in `pbSceneStandby'
    PField_Battles:422:in `pbTrainerBattleCore'
    PField_Battles:419:in `pbBattleAnimation'
    PField_Battles:419:in `pbTrainerBattleCore'
    PField_Battles:487:in `pbTrainerBattle'
    Debug_Menu:369:in `pbDebugMenuActions'
    Debug_Menu:857:in `pbDebugMenu'
    Is there a way to get this script to work, or if not, is there an alternate way to restore the player's held items after a battle?
     
    Not tested, but if you look at the function:
    Code:
      def pbRemoveItem(permanent=true)
    comment the line that deletes the item:
    Code:
      def pbRemoveItem(permanent=true)
        @effects[PBEffects::ChoiceBand] = -1
        @effects[PBEffects::Unburden]   = true if @item>0
        setInitialItem(0) if self.initialItem==@item && permanent # Comment this
        self.item = 0
      end
     
    Thank you! This worked for most things; for other people seeking the same effect, search out other instances of setInitialItem and comment them as well.
     
    Back
    Top