Guaranteed drop

Hi All,

I am looking for a script that helps me handle enemy drops in a specific way:

We have 3 drops/enemy and I want to make sure that 1 out of the 3 passible items will drop for 100%.

I know I can set the individual drop rated for items, but even if I set one item's drop to 33,3% it won't guarantee that at least 1 item will drop.

Can someone help me with this?

Let me know if something is not clear.

Thanks a bunch!
Hey ♫

Here you are!

Just save as GaranteedDrop.js and follow the instructions in the help section

Spoiler
/*=======================================GuaranteedDrop.js======================================= /*: * @plugindesc Guaranteed Drop * @author Kaimonkey * @param True for all enemies? * @desc Setting to true will mean that this plugin affects enemies without the <onedrop> tag * @default false * * @help * ============================================================================ * Terms and Conditions * ============================================================================ * The plug in may only be used for NONCOMMERCIAL projects. If you wish to * use this plug in in a commercial product, please contact Kaimonkey for a * licience * * While reasonable effort will be made to fix any faults in the product, the * product comes "as is", and Kaimonkey is under no legal obligation to do so. * ============================================================================ * Intro * ============================================================================ * This script will mean that any enemy with the <onedrop> tag will always * drop exactly one item. The higher the % chance of drop on the item * the more likely to be selected it is. For example if you have * APPLE 1/1 * BANANA 1/3 * CHERRY 1/4 * Then the apple would have a 12/19 chance of being selected, the banana would have a * 4/19 chance, and the cherry would have a 3/19 chance. * */(function() { //Start Plugin var parameters = PluginManager.parameters('GuaranteedDrop'); var all_enemies = String(parameters["True for all enemies?"]) !== "false"; Game_Enemy.prototype.is_onedrop = function(){ return all_enemies || this.enemy().note.includes("<onedrop>"); }; var _km_makeDrop = Game_Enemy.prototype.makeDropItems; Game_Enemy.prototype.makeDropItems = function() { if(this.is_onedrop()){ var items = []; var drops = this.enemy().dropItems; if(drops.length == 0) return []; var totalWeight = drops.reduce(function(t, di){ if(di.denominator!=0) return t + (1.0/di.denominator); else return t; },0); var index = Math.random()*totalWeight; var i = 0; var drop = false; drops.forEach(function(di){ if(!drop){ i += (1.0/di.denominator); if(index < i){ drop = [this.itemObject(di.kind, di.dataId)]; } } },this); if(drop) return drop; return []; } return _km_makeDrop.call(this); };})(); //Close Plugin
Let me know if you have any trouble,

/Kai
Thanks Kai!

I will try it out immediately. 🙂
Works perfectly.

Thanks again! 🙂

Topic can be closed.
Arxur, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.


I will close this for you now, but please note (forum rules are linked in the lower right corner of every page) that the way to ask for a thread to be closed is to report the first post and put the request in the report.

Original thread: https://forums.rpgmakerweb.com/threads/guaranteed-drop.51254/