• 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.
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...
 

thepsynergist

Rookie
Member
Joined
Mar 20, 2018
Posts
5
It doesn't appear this script is compatible with EBS, as the game crashes on a Pokemon fainting.
 

Cilerba

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

Maker of Many and Finisher of Few
Member
Joined
Jul 21, 2018
Posts
124
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
185
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

Maker of Many and Finisher of Few
Member
Joined
Jul 21, 2018
Posts
124
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
21
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?
 
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
20
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.
 

MakerBlack

Trainer
Member
Joined
Nov 23, 2020
Posts
88
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
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)
 

MakerBlack

Trainer
Member
Joined
Nov 23, 2020
Posts
88
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?
 

NikDie

Elite Trainer
Member
Joined
Dec 21, 2020
Posts
422
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.
 

mikozori69

Rookie
Member
Joined
Jun 23, 2022
Posts
2
i like your work it's amazing but pls can you make your awsome project work with v20.1
 
Back
Top