• 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!
  • It's time to vote for your favorite Pokémon Battle Revolution protagonist in our new weekly protagonist poll! Click here to cast your vote and let us know which PBR protagonist you like most.
  • 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] Give wild Pokémon held items to the Player after battle

  • 3
    Posts
    5
    Years
    • Seen Dec 14, 2020
    I found a script last year that will give items held by wild Pokemon to the player if they win the battle, but it doesn't seem to be working anymore. My guess is that "genwildpoke" no longer properly refers to the wild Pokemon you just fought and it has a different name now (when I altered the code to give a specific item to the player after battle if they win, regardless of what the wild Pokemon was holding, i.e. a green apricorn, it worked fine) but tbh I don't know enough about Ruby to be sure. I tried fixing the code myself and I can't get it to work.

    Quote of the post in question:

    Spoiler:
     
    You're correct that "genwildpoke" no longer exists inside "pbWildBattle". What "pbWildBattle" does now is pass the species of the wild Pokemon to "pbWildBattleCore", and that method actually creates the wild Pokemon, which is where you can reference it. I would suggest using the following code at the very end of "pbWildBattleCore" (just before the line "return decision"):
    Code:
    if decision == 1
      for i in foeParty
        pbReceiveItem(i.item) if i.hasItem?
      end
    end
    # Add code above
    return decision # Find this
    This method also gives items for double or triple wild battles, so if you want to limit it to only single wild battles you would need to check if "foeParty.length == 1" as an extra condition.
     
    You're correct that "genwildpoke" no longer exists inside "pbWildBattle". What "pbWildBattle" does now is pass the species of the wild Pokemon to "pbWildBattleCore", and that method actually creates the wild Pokemon, which is where you can reference it. I would suggest using the following code at the very end of "pbWildBattleCore" (just before the line "return decision"):
    Code:
    if decision == 1
      for i in foeParty
        pbReceiveItem(i.item) if i.hasItem?
      end
    end
    # Add code above
    return decision # Find this
    This method also gives items for double or triple wild battles, so if you want to limit it to only single wild battles you would need to check if "foeParty.length == 1" as an extra condition.

    This works perfectly! Thank you so much!
     
    Back
    Top