Wild Item Drops

Resource Wild Item Drops

Cilerba

relic artist!
Relic Artist
Joined
Nov 15, 2014
Posts
14
Age
24
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:
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...
 

Cilerba

relic artist!
Relic Artist
Joined
Nov 15, 2014
Posts
14
Age
24
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!
 

Droid779

Weeb
Member
Joined
Mar 15, 2018
Posts
46
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:

Elle

Trainer
Member
Joined
Jul 21, 2018
Posts
95
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!
 

Mr. Gela

Discord: theo#7722
Member
Joined
Jul 19, 2015
Posts
214
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.
 

Elle

Trainer
Member
Joined
Jul 21, 2018
Posts
95
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. :)
 

EpiQ

Novice
Member
Joined
Mar 1, 2018
Posts
22
Can you help me pls? I have this error:
Code:
---------------------------
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?
 

TechSkylander1518

Wiki Dweeb
Member
Joined
Mar 24, 2017
Posts
656
Solved the issue of player drops! Just change the conditional to

if @opponent==false && @pokemon.item >0 && showMessage && @battle.pbIsOpposing?(@index)

(Unrelated to player, but I switched it to @opponent==false because I was still getting trainer drops, for some reason)
 

Skyflyer

Seeking for knowledge
Member
Joined
Jun 23, 2019
Posts
9
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.
 

messi3d

Trainer
Member
Joined
Nov 23, 2020
Posts
64
Age
18
The trainer Pokémon drop also, I just want the wild ones, can someone help me?
 
Last edited by a moderator:

TungstenBasilisk

Rookie
Member
Joined
Dec 29, 2020
Posts
3
Age
22
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:
def pbWildBAttleSuccess

and replace that entire method with this:
Ruby:
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)
 

messi3d

Trainer
Member
Joined
Nov 23, 2020
Posts
64
Age
18
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:
def pbWildBAttleSuccess

and replace that entire method with this:
Ruby:
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?
 

NikDie

Rookie
Member
Joined
Dec 21, 2020
Posts
8
Age
27
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.
 
Top