Advertisement
Jragyn

[MV] J_DropItem

Dec 12th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* -------------------------------------------------------------------------- */
  2. // J_DropItem
  3. // V: 1.0
  4. //
  5.  
  6. /*:@plugindesc Modifies the database drop functionality to be a percent instead of 1/N.
  7. @author J
  8.  
  9. @help The plugin makes it so that the number you enter into the database is now the
  10.         percentage chance of the item dropping instead of 1/N chance, where N is the
  11.         number you entered in the database.
  12.  
  13.         Additionally, to accommodate the possibility of decimals, you can change the
  14.         setting so that it reflects off of either 100 or 1000 point scale. 100 scale
  15.         is as you know it: enter 54, and it will be 54% chance of drop. 1000 point
  16.         means that if you enter 54, it will be 5.4% chance of drop, 547 will instead
  17.         be 54.7% chance of drop. Default will be 1000, but you can change it to 100
  18.         if you want.
  19.  
  20.         NOTE: obviously, you can change the scale to whatever you want, but be sure to
  21.         take a look at the math in the function if you do to make sure you understand
  22.         what you are doing to the numbers!
  23.  
  24. @param dropScale
  25. @desc 100 or 1000 depending on if you don't or do need decimal chance drop rates.
  26. @default 1000
  27.  
  28. */
  29. var Imported = Imported || {};
  30. Imported.J_DropItems = true;
  31.  
  32. J.AddOns = J.AddOns || {};
  33. J.AddOns.DropItems = J.AddOns.DropItems || {};
  34. J.AddOns.DropItems.pluginParams = PluginManager.parameters('J_AddOns');
  35. J.AddOns.DropItems.dropScale = Number(J.AddOns.DropItems.pluginParams['dropScale']) || 100;
  36.  
  37. // OVERWRITES [Game_Enemy.makeDropItems]
  38. // Also to incorporate percentage drop, and additional notetag drops.
  39. Game_Enemy.prototype.makeDropItems = function() {
  40.     var dropList = this.enemy().dropItems.concat(this.enemy().extraDrops);
  41.     var itemsFound = [];
  42.     for (var i = 0; i < dropList.length; i++) {
  43.       var di = dropList[i];
  44.       var dropRate = di.denominator;
  45.       if (Imported.J_Difficulty) {
  46.         window.console.log("diff exists!");
  47.         dropRate = di.denominator * (J.AddOns.Difficulty.convertBparams(10) / 100);        
  48.       }
  49.       if (di.kind > 0) {
  50.         var rand = Math.random() * J.AddOns.DropItems.dropScale;
  51.         if (rand < dropRate) {
  52.           itemsFound.push(this.itemObject(di.kind, di.dataId));
  53.         }
  54.       }
  55.     }
  56.     return itemsFound;
  57. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement