• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
  • The Eevee Expo Game Jam has concluded! 🎉 Head on over to the game jam forum to play through the games.
    Don't forget to come back September 21st to vote for your favorites!
  • Reminder: AI-generated content is not allowed on the forums per the Rules and Regulations. Please contact us if you have any questions!
Wild Item Drops

Resource Wild Item Drops 1.0

Cilerba

relic artist!
Relic Artist
Joined
Nov 15, 2014
Posts
12
Cilerba submitted a new resource:

Wild Item Drops - Obtain dropped items after a wild Pokémon faints.

I made a script that allows wild Pokémon to drop their hold items when fainted.
Copy and paste wherever.

Code:
Expand Collapse Copy
class PokeBattle_Battler
	def pbFaint(showMessage=true)
	unless fainted?
	  PBDebug.log("!!!***Can't faint with HP greater than 0")
	  return true
	end
	if @fainted
#	  PBDebug.log("!!!***Can't faint if already fainted")
	  return true
	end
	@battle.scene.pbFainted(self)
	pbInitEffects(false)
	# Reset status
	self.status=0
	self.statusCount=0
	if @pokemon && @battle.internalbattle...

Read more about this resource...
 
It doesn't appear this script is compatible with EBS, as the game crashes on a Pokemon fainting.
 
Thanks for pointing out the error. I should have a fix within a few days along with a way to separate drop items from hold items!
 
I noticed a bug where my Pokémon “drops” its item when it faints, but the Pokémon still have the item and it duplicates that item into my bag.
 
Last edited:
Is there any way to increase the chances of the item being dropped? Also, does it only drop the Common item or is there a chance it will drop it's uncommon / rare item? I've tested about a dozen battles and so far only common drops but that could be just bad luck on my part.

That being said, really awesome script!
 
Is there any way to increase the chances of the item being dropped? Also, does it only drop the Common item or is there a chance it will drop it's uncommon / rare item? I've tested about a dozen battles and so far only common drops but that could be just bad luck on my part.

That being said, really awesome script!
For scripted events such as Snorlax/a legendary, you can manually give the Pokémon an item before the fight by editing it. For all wild encounters you can just edit their PBS entry, which has about 3 different item slots (or you can use the same item all 3 times for close to 100% chance of finding them equipped with it). I can't check right now but check the default PBS files. The values are called something like WildItemCommon, WildItemUncommon WildItemRare, but I might be wrong.
 
For scripted events such as Snorlax/a legendary, you can manually give the Pokémon an item before the fight by editing it. For all wild encounters you can just edit their PBS entry, which has about 3 different item slots (or you can use the same item all 3 times for close to 100% chance of finding them equipped with it). I can't check right now but check the default PBS files. The values are called something like WildItemCommon, WildItemUncommon WildItemRare, but I might be wrong.

Alright, thanks for the help. :)
 
Can you help me pls? I have this error:
Code:
Expand Collapse Copy
---------------------------
Pokemon
---------------------------
[Pokémon Essentials version 17.1]

Exception: NoMethodError

Message: undefined method `fainted?' for #<PokeBattle_Battler:0x945d0e8>

Wild Drop:3:in `pbFaint'

PokeBattle_Battler:3170:in `pbProcessMoveAgainstTarget'

PokeBattle_Battler:3473:in `pbUseMove'

PokeBattle_Battler:3453:in `loop'

PokeBattle_Battler:3476:in `pbUseMove'

PokeBattle_Battler:3674:in `pbProcessTurn'

PokeBattle_Battler:3673:in `logonerr'

PokeBattle_Battler:3673:in `pbProcessTurn'

PokeBattle_Battle:2907:in `pbAttackPhase'

PokeBattle_Battle:2904:in `each'

Thank you!
PS: Is it already separate hold items with drop items? Or will be in the future?
 
Is there any way to differenciate if the rival is a wild pokémon or a trainer? The script works even if I defeat a trainer's pokémon, and I don't want that to happend, I want this to happend just against wild pokémon.
 
The trainer Pokémon drop also, I just want the wild ones, can someone help me?
 
Last edited by a moderator:
For anyone using this script in v18.1, I've got it working properly. Just find this bit of code in 006_Pokebattle_Scene:
Ruby:
Expand Collapse Copy
def pbWildBAttleSuccess

and replace that entire method with this:
Ruby:
Expand Collapse Copy
def pbWildBattleSuccess
    if @battle.battlers[1].pokemon.hasItem?
     qty=rand(3)+1
     if $PokemonBag.pbStoreItem(@battle.battlers[1].pokemon.item,qty)
     itemname=PBItems.getName(@battle.battlers[1].pokemon.item)
     pocket=pbGetPocket(@battle.battlers[1].pokemon.item)
     @battle.pbDisplayPaused(_INTL("The wild {1} dropped\n{2} <icon=bagPocket#{pocket}> x{3}!",@battle.battlers[1].pbThis,itemname,qty))
     end
    end
    @battleEnd = true
    pbBGMPlay(pbGetWildVictoryME)
  end

this will fix drops happening when your own pokemon faints and when a trainer pokemon holding an item faints :3 btw this is a replacement to the code in the OP by Cilerba, you won't need the code they wrote at all. Idk what would happen if you had both scripts installed lol also, this version of the script randomizes the number of items dropped by the pokemon (between 1 and 3) you can remove that if you wish

(Thanks to GolisopodUser for pointing me in the right direction for this, and Screedle for pointing out the errors I originally made)
 
For anyone using this script in v18.1, I've got it working properly. Just find this bit of code in 006_Pokebattle_Scene:
Ruby:
Expand Collapse Copy
def pbWildBAttleSuccess

and replace that entire method with this:
Ruby:
Expand Collapse Copy
def pbWildBattleSuccess
    if @battle.battlers[1].pokemon.hasItem?
     qty=rand(3)+1
     if $PokemonBag.pbStoreItem(@battle.battlers[1].pokemon.item,qty)
     itemname=PBItems.getName(@battle.battlers[1].pokemon.item)
     pocket=pbGetPocket(@battle.battlers[1].pokemon.item)
     @battle.pbDisplayPaused(_INTL("The wild {1} dropped\n{2} <icon=bagPocket#{pocket}> x{3}!",@battle.battlers[1].pbThis,itemname,qty))
     end
    end
    @battleEnd = true
    pbBGMPlay(pbGetWildVictoryME)
  end

this will fix drops happening when your own pokemon faints and when a trainer pokemon holding an item faints :3 btw this is a replacement to the code in the OP by Cilerba, you won't need the code they wrote at all. Idk what would happen if you had both scripts installed lol also, this version of the script randomizes the number of items dropped by the pokemon (between 1 and 3) you can remove that if you wish

(Thanks to GolisopodUser for pointing me in the right direction for this, and Screedle for pointing out the errors I originally made)
thanks for that, you are amazing! Would you know how to add more items that the wild Pokémon can handle? We know you have common items, unusual items and rare items according to PBS. How do I add another item tab? And could you tell me how to make certain items to drop in random quantity? and other items drop by unit?
 
I found a Bug, if you catch a Pokémon which is helding an Item, you will get the held Item after the Battle but the Pokémon is still holding this Item as well.
So you basically doubled the Item.
 
i like your work it's amazing but pls can you make your awsome project work with v20.1
 
Back
Top