Resource icon

Proper Wild Item Drops (Based on Cilerba's Wild Item Drop Resource)

Pokémon Essentials Version
v18.1 ✅
This is a Proper Wild Item Drop script. I based my script on the work of Cilerba (
I'd also like to say thank you to ThatWelshOne_, Vendily and Golisopod User for helping with parts of the script and pointing me in the right direction, respectively!

Essentially, what this does is read the pokemon.txt PBS file and generate a list of items that can be "dropped" by a wild pokemon at the end of a battle. These items are completely separate from Wild Hold Items (so a wild pokemon can both hold an item and drop completely different items at the same time if you so wish). The way the script is set up now, a pokemon will have up to 3 different drop items defined. At the end of a battle, a random number between 1-3 will be set for each item and that number of items will be "dropped" and added to the player's bag. There is a 50 percent chance to drop the common item, 20 to drop the uncommon item, and 5 to drop the rare item. These can be edited in the portion of the script "chances". There are also 2 other arrays of chances that the script will use instead, if the first pokemon in your party has the Compound Eyes ability, or the Super Luck ability, respectively.

Set up is very simple.

First, you're gonna want to define wildDropItems. In PokeBattle_Pokemon, find the section def wildHoldItems and underneath it, paste this bit of code:
# Returns the items this species can drop in the wild.
  def wildDropItems
    ret = []
    return ret

In Compiler_PBS find
# If any held item is defined for this form, clear default data for all
      # three held items.
      if (contents["WildItemCommon"] && contents["WildItemCommon"]!="") ||
         (contents["WildItemUncommon"] && contents["WildItemUncommon"]!="") ||
         (contents["WildItemRare"] && contents["WildItemRare"]!="")
        speciesData[speciesID][SpeciesWildItemCommon]   = nil
        speciesData[speciesID][SpeciesWildItemUncommon] = nil
        speciesData[speciesID][SpeciesWildItemRare]     = nil

and paste this directly below it:
if (contents["WildDropCommon"] && contents["WildDropCommon"]!="") ||
         (contents["WildDropUncommon"] && contents["WildDropUncommon"]!="") ||
         (contents["WildDropRare"] && contents["WildDropRare"]!="")
        speciesData[speciesID][SpeciesWildDropCommon]   = nil
        speciesData[speciesID][SpeciesWildDropUncommon] = nil
        speciesData[speciesID][SpeciesWildDropRare]     = nil

Now to add the proper fields to the PBS file:

in Misc_Data, scroll down to the section labeled Pokemon Data and add these to the list of things there:
SpeciesWildDropCommon = 28
SpeciesWildDropUncommon = 29
SpeciesWildDropRare = 30
(Make sure the numbers you use here are unused in your file, my next available ones were 28-30 but if you're already using those, just use the next available numbers)

then, just below, in def self.optionalValues(compilingForms = false)

"WildItemCommon"      => [SpeciesWildItemCommon,   "e", :PBItems],
      "WildItemUncommon"    => [SpeciesWildItemUncommon, "e", :PBItems],
      "WildItemRare"        => [SpeciesWildItemRare,     "e", :PBItems],

and directly underneath it, paste:
"WildDropCommon"      => [SpeciesWildDropCommon,   "e", :PBItems],
      "WildDropUncommon"    => [SpeciesWildDropUncommon, "e", :PBItems],
      "WildDropRare"        => [SpeciesWildDropRare,     "e", :PBItems],

the next step is the actual script, put this anywhere above "Main". I recommend directly above, as that is where I have it placed.

class PokeBattle_Scene

  def pbWildBattleSuccess
    @battle.battlers.each {|b|
    next if !b
    next if !b.opposes?
    pkmn = b.pokemon
    next if !pkmn
    if pkmn.wildDropItems.inject(0){|sum,x| sum + x } != 0
      wildDrop = pkmn.wildDropItems
      firstqty = rand(3)+1
      secondqty = rand(3)+1
      thirdqty = rand(3)+1
      firstPkmn = $Trainer.firstPokemon
      chances = [50,20,5]
      chances = [60,40,15] if firstPkmn && isConst?(firstPkmn.ability,PBAbilities,:COMPOUNDEYES)
      chances = [50,50,50] if firstPkmn && isConst?(firstPkmn.ability,PBAbilities,:SUPERLUCK)
      droprnd = rand(100)
      if (wildDrop[0]==wildDrop[1] && wildDrop[1]==wildDrop[2]) || droprnd<chances[0]
        if $PokemonBag.pbStoreItem(wildDrop[0],firstqty)
          itemname = PBItems.getName(wildDrop[0])
          pocket = pbGetPocket(wildDrop[0])
          @battle.pbDisplayPaused(_INTL("{1} dropped\n{2} <icon=bagPocket#{pocket}> x{3}!",b.pbThis,itemname,firstqty))
      if droprnd<chances[1]
        if $PokemonBag.pbStoreItem(wildDrop[1],secondqty)
          itemname = PBItems.getName(wildDrop[1])
          pocket = pbGetPocket(wildDrop[1])
          @battle.pbDisplayPaused(_INTL("{1} dropped\n{2} <icon=bagPocket#{pocket}> x{3}!",b.pbThis,itemname,secondqty))
      if droprnd<chances[2]
        if $PokemonBag.pbStoreItem(wildDrop[2],thirdqty)
          itemname = PBItems.getName(wildDrop[2])
          pocket = pbGetPocket(wildDrop[2])
          @battle.pbDisplayPaused(_INTL("{1} dropped\n{2} <icon=bagPocket#{pocket}> x{3}!",b.pbThis,itemname,thirdqty))
  @battleEnd = true

The very last step is adding the fields WildDropCommon/WildDropUncommon/WildDropRare to the PBS file for whichever pokemon you want and defining the item that you want to be dropped. This is an optional field, so you don't have to define one at all, and I personally recommend putting those fields underneath the POKEDEX entry (or WIldItemCommon/WildItemUncommon/WildItemRare fields, if those are defined. I'm not sure if the position is important, but why chance it?)

If you have questions or any bugs/issues to report, lemme know and I'll try my best to help. I'm still learning to code myself!
Tungesten Basilisk (Me)
  • Screenshot Wild Item Drops.png
    Screenshot Wild Item Drops.png
    52.2 KB · Views: 57
First release
Last update
5.00 star(s) 1 ratings

Latest reviews

I've implemented this resource into my own game and haven't run into any issues yet! If I do, I'll be sure to report back. Great idea, very functional, something I really appreciate having access to.
I'm glad this is something you can use for your game! And I'm glad you haven't run into any issues yet haha cx Please do let me know if there is an issue you run into!