Advertisement
Maliki79

Mal_DMII_RandomParams

Jan 30th, 2025 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Maliki's DM_Independent Items Extension - Random Parameters
  3. // Mal_DMII_RandomParams.js
  4. // version 1.0 MZ
  5. //=============================================================================
  6. /*:
  7.  * @target MZ
  8.  *  
  9.  * @plugindesc ver1.0 MZ - Allows users of DM's Independent Items to set random params to weapons and Armor Equips.
  10.  * @author Maliki79
  11.  *
  12.  * @help You need three steps to use this plugin:
  13.  * 1: Make sure DM_IndependentItems is added to your project properly.
  14.  * 2: Make sure desired weapons and armors are tagged to be Independent Items.
  15.  * 3: Tag Weapon/Items with <maliiRandomParams: x, y> with x being the param number and y being the max range.
  16.  *
  17.  * Param numbers are as followed: 0 = MaxHP, 1 = MaxMP, 2 = Atk, 3 = Def,
  18.  *                                4 = MAT, 5 = MDF, 6 = AGI, 7 = Luk
  19.  *
  20.  * You may use as many of this tag as needed and the plugin will add all the same params together to get the max range of randomness.
  21.  *
  22.  * So for example, if you use the tag <maliiRandomParams: 2, 20> on a weapon or armor with 70 atk,
  23.  * The plugin will randomly give the equip an atk value between 50 and 90. (70 +-20)
  24.  * The value can potentially go into the negative.
  25.  */
  26.  
  27. var MalDMIIDatabaseLoad = DataManager.isDatabaseLoaded;
  28. DataManager.isDatabaseLoaded = function() {
  29.   if (!MalDMIIDatabaseLoad.call(this)) return false;
  30.   if (!DataManager._MalDMII_DatabaseLoaded) {
  31.     this.processDMIINotetags($dataWeapons);
  32.     this.processDMIINotetags($dataArmors);
  33.     DataManager._MalDMII_DatabaseLoaded = true;
  34.   }
  35.   return true;
  36. };
  37.  
  38. DataManager.processDMIINotetags = function(group) {
  39.     for (var n = 1; n < group.length; n++) {
  40.         var obj = group[n];
  41.         obj.instanceParams = [0,0,0,0,0,0,0,0];
  42.         this.createIIrandomParams(obj);
  43.     }
  44. };
  45.  
  46. DataManager.createIIrandomParams = function(obj) {
  47. var noteread = obj.note;
  48. while(noteread.indexOf("maliiRandomParams") > -1)
  49. {
  50.     var notereg = noteread.split("<maliiRandomParams: ");
  51.     var match = notereg[1].split(">");
  52.     match = match[0].split(", ");
  53.     obj.instanceParams[parseInt(match[0])] += parseInt(match[1]);
  54.     noteread = noteread.replace("<maliiRandomParams: ", " ");
  55. }
  56. };
  57.  
  58. var DMIIgainItem = Game_Party.prototype.gainItem;
  59. Game_Party.prototype.gainItem = function(item, amount, includeEquip) { 
  60.     DMIIgainItem.call(this, item, amount, includeEquip);
  61.     if(item && item.meta.independentItem) $gameParty.applyRandomStats(item);
  62. };
  63.  
  64. Game_Party.prototype.applyRandomStats = function(item) {
  65.     for (var i=0; i < 8; i++) {
  66.         if(item.instanceParams[i] != 0) {
  67.                 var numb = Math.randomInt(item.instanceParams[i]+1);
  68.                 if (Math.randomInt(2) == 1) numb *= -1;
  69.                 item.params[i] += numb;
  70.         };
  71.            
  72.     };
  73. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement