Advertisement
Jragyn

[MV] J_XPGPvariance

Dec 10th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* -------------------------------------------------------------------------- */
  2. // J_XPGPvariance
  3. // V: 1.1
  4.  
  5. /*:@plugindesc Provides notetag-defined levels to give multipliers against XP/GP.
  6. @author J
  7.  
  8. @help This plugin will do nothing without some setup, but in order to gain the
  9.         bonus XP, you'll have to assign levels to enemies with notetags:
  10.             <level: xx>
  11.         Then, this plugin will math out the difference between the two, and
  12.         use a very straight-forward table to determine the multiplier to be
  13.         used for giving experience to the player.
  14.         NOTE: this is based on the leader of the party.
  15.  
  16.         In order for bonus GP to work, use notetags:
  17.                     <gpMod: yy>
  18.         Which will result in a bonus between -yy and +yy of the gold that the
  19.         enemy would give you.
  20.  
  21.        
  22.         Requires: J_Base (reads the notetags)
  23.  
  24.         v1.1: fixed issue where level differences greater than 10, or less than
  25.           -10 were not being handled.
  26. */
  27. var Imported = Imported || {};
  28. Imported.J_XPGPvariance = true;
  29.  
  30. J.AddOns = J.AddOns || {};
  31. J.AddOns.XPGPvariance =   J.AddOns.XPGPvariance || {};
  32.  
  33. /* -------------------------------------------------------------------------- */
  34. //    XP / GOLD VARIANCE [NEW!]
  35. // This does two things:
  36. //   1. Creates a variance of X amount in obtained Gold from enemies.
  37. //   2. Enables EXP multipliers based on actor vs enemy levels.
  38. /* -------------------------------------------------------------------------- */
  39. // the function for fetching a random number +/- number
  40. // between the given amount. Used in adding Gold variance to drops.
  41. J.AddOns.XPGPvariance.getGPvar = function(e) {
  42.   var bonus = 0;
  43.   if (Imported.J_Base) {
  44.     var g = e.gpvar;
  45.     var r1 = Math.floor((Math.random() * g) + 1);
  46.     var r2 = Math.floor((Math.random() * g) + 1);
  47.     bonus = ((r1 + r2) - g);
  48.   }
  49.   return bonus;
  50. };
  51.  
  52. // the main function for getting an experience multiplier based on
  53. // actor and enemy level difference.
  54. J.AddOns.XPGPvariance.doSexp = function(a, e) { // a = actor, e = enemy
  55.   var multiplier = 1.0
  56.   if (!Imported.J_Base) {
  57.     console.warn("You need J_Base to make this work!");
  58.     return multiplier;
  59.   }
  60.   if (e.level == 0) {} // if enemy level isn't set just return normal XP.
  61.   else {
  62.     multiplier = J.AddOns.XPGPvariance.getMult(a, e);
  63.   }
  64.   return multiplier;
  65. };
  66.  
  67. // The switch that handles level difference and multipliers.
  68. // Edit here if you want to change the multipliers.
  69. J.AddOns.XPGPvariance.getMult = function(a, e) { // a = actor, e = enemy
  70.   var compared = e.level - a.level;
  71.   var diff = compared;
  72.   switch (compared) {
  73.     case diff>9: return 5.0; // 10 or more levels lower than the enemy.
  74.     case 9: return 4.0;
  75.     case 8: return 3.0;
  76.     case 7: return 2.5;
  77.     case 6: return 2.0;
  78.     case 5: return 1.75; // five levels below the enemy.
  79.     case 4: return 1.5;
  80.     case 3: return 1.3;
  81.     case 2: return 1.2;
  82.     case 1: return 1.1;
  83.     case 0: return 1.0; // same level as the enemy.
  84.     case -1: return 0.9;
  85.     case -2: return 0.8;
  86.     case -3: return 0.7;
  87.     case -4: return 0.6;
  88.     case -5: return 0.5; // five levels higher than the enemy.
  89.     case -6: return 0.4;
  90.     case -7: return 0.3;
  91.     case -8: return 0.2;
  92.     case -9: return 0.1;
  93.     case (diff<-9): return 0.05; // 10 or more levels higher than the enemy.
  94.     default: return 1.0; // if no notetag is set, use only base experience.
  95.   }
  96. }
  97.  
  98. // based on difference, modifies and returns experience
  99. var _Game_Enemy_jxpgp_exp = Game_Enemy.prototype.exp;
  100. Game_Enemy.prototype.exp = function() {
  101.   var baseExp = _Game_Enemy_jxpgp_exp.call(this);
  102.   baseExp *= J.AddOns.XPGPvariance.doSexp($gameParty.leader(), this.enemy());
  103.   return Math.round(baseExp);
  104. };
  105.  
  106. // based on difference, modifies and returns Gold
  107. // also factors in the gp variance, if it exists.
  108. var _Game_Enemy_jxpgp_gold = Game_Enemy.prototype.gold;
  109. Game_Enemy.prototype.gold = function() {
  110.   var baseGold = _Game_Enemy_jxpgp_gold.call(this);
  111.   if (Imported.J_Base) baseGold += J.AddOns.XPGPvariance.getGPvar(this.enemy());
  112.   return Math.round(baseGold);
  113. };
  114. /* -------------------------------------------------------------------------- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement