• 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!
  • Our weekly protagonist poll is now up! Vote for your favorite Trading Card Game 2 protagonist in the poll by clicking here.
  • 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.

Pokemon dropping items after battle

  • 8
    Posts
    13
    Years
    • Seen Dec 28, 2016
    I made this simple script to make wild pokemon drop the items they held.
    HankMan and Nickalooose first discussed this subject in an old topic (I still can't post the link to the topic, but if you search for "Pokemon essentials dropping items" on Google you will find it) .

    If a wild pokemon is holding an item when he is defeated, there is a 50% chance that he will drop it. The item is dropped right after the Exp Gain, as suggested by Nickalooose.
    It won't work against another trainer (if you want to do so, you have to delete "!@opponent" in the function definition).

    First, I added the highlited part at the end of PokeBattle_Battle:

    Code:
        @scene.pbEndBattle(@decision)
        for i in @battlers
          i.pbResetForm
        end
        for i in $Trainer.party
          i.item=i.itemInitial
          i.itemInitial=i.itemRecycle=0
        end
        return @decision
      end
      
    [S-HIGHLIGHT]### Wild pokemon drops item if defeated
      def pbDropItem (i)
        if rand(100)>50 && @battlers[i].item!=0 && !@opponent
          $PokemonBag.pbStoreItem(@battlers[i].item)
          pbDisplay(_INTL("{1} picked up {2} from the pokemon!", $Trainer.name, PBItems.getName(@battlers[i].item)))
          end
      end   [/S-HIGHLIGHT]
    end
    Then I put the function after the exp gain at the end of pbGainExp, but before the battler's data are deleted ("@battlers.participants=[]"). It's in the PokeBattle_Battle section, around line 1799.

    Code:
                        # Finding all moves learned at this level
                        movelist=thispoke.getMoveList
                        for k in movelist
                          if k[0]==thispoke.level   # Learned a new move
                            pbLearnMove(j,k[1])
                          end
                        end
                      end
                    end
                  end
                end
              end
            end
            [S-HIGHLIGHT]pbDropItem (i)[/S-HIGHLIGHT]
            # Now clear the participants array
            @battlers[i].participants=[]
          end
        end
      end
     
    Awesome script, such a neat idea!
    One question, rather than "Player picked up Item from the pokemon!" wouldn't it be better to say "Player picked up Item from the PokemonName"?
    I've tried doing this myself but pokemon.name doesn't seem to work because I assume the Pokemon no longer exists because it has fainted.
     
    This way it should work:
    [S-HIGHLIGHT]pbDisplayPaused(_INTL("{1} picked up {2} from {3}!",$Trainer.name,PBItems.getName(@battlers.item),@battlers.name))[/S-HIGHLIGHT]

    "@battlers.name" should get you the species of the pokemon.
     
    I made this simple script to make wild pokemon drop the items they held.
    HankMan and Nickalooose first discussed this subject in an old topic (I still can't post the link to the topic, but if you search for "Pokemon essentials dropping items" on Google you will find it) .

    If a wild pokemon is holding an item when he is defeated, there is a 50% chance that he will drop it. The item is dropped right after the Exp Gain, as suggested by Nickalooose.
    It won't work against another trainer (if you want to do so, you have to delete "!@opponent" in the function definition).

    First, I added the highlited part at the end of PokeBattle_Battle:

    Code:
        @scene.pbEndBattle(@decision)
        for i in @battlers
          i.pbResetForm
        end
        for i in $Trainer.party
          i.item=i.itemInitial
          i.itemInitial=i.itemRecycle=0
        end
        return @decision
      end
      
    [S-HIGHLIGHT]### Wild pokemon drops item if defeated
      def pbDropItem (i)
        if rand(100)>50 && @battlers[i].item!=0 && !@opponent
          $PokemonBag.pbStoreItem(@battlers[i].item)
          pbDisplay(_INTL("{1} picked up {2} from the pokemon!", $Trainer.name, PBItems.getName(@battlers[i].item)))
          end
      end   [/S-HIGHLIGHT]
    end
    Then I put the function after the exp gain at the end of pbGainExp, but before the battler's data are deleted ("@battlers.participants=[]"). It's in the PokeBattle_Battle section, around line 1799.

    Code:
                        # Finding all moves learned at this level
                        movelist=thispoke.getMoveList
                        for k in movelist
                          if k[0]==thispoke.level   # Learned a new move
                            pbLearnMove(j,k[1])
                          end
                        end
                      end
                    end
                  end
                end
              end
            end
            [S-HIGHLIGHT]pbDropItem (i)[/S-HIGHLIGHT]
            # Now clear the participants array
            @battlers[i].participants=[]
          end
        end
      end

    Hei Aramant i tried your script in v16 but i never got the items, do you have a solution?
     
    Back
    Top