Advertisement
Maliki79

MalLevelexpBoost

Feb 20th, 2019
598
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // Maliki's Level Based Experience Point Boost
  3. // MalLevelexpBoost.js
  4. // version 1.0
  5. //=============================================================================
  6. /*:  
  7.  * @plugindesc Version 1.0 Allows devs to implement a slight curve on Exp gain
  8.  * based on actor level.
  9.  * @author Maliki79
  10.  * @help You need two steps to use this plugin:
  11.  * 1: Create an Enemy troop
  12.  * 2: Use a Script Call during turn 0 - 0 to set Enemy "Level" to base curve on.
  13.  *    
  14.  * To use this, you first set an enemy troop level. (This plugin will not work
  15.  * with individual enemy levels)  By default, RPG Maker MV does not give enemies
  16.  * levels, so we must set them per troop via a script call.
  17.  *
  18.  * $gameParty.setEnemyLevel(x);
  19.  * with x being a positive integer.
  20.  *
  21.  * After battle, this number will be compared against each actor's level and a bonus
  22.  * will be granted based on the difference.
  23.  * For each level higher the troop is than an actor, 10% exp gain will be added.
  24.  * Conversly, every level below will reduce the gain by 10%.
  25.  * There is no cap to how much it is rasied, but the lowest it currently will go is
  26.  * 10%.
  27.  * (If there is no number set at the start of battle, the troop level will be set to
  28.  * the actor team's average level.)
  29.  *
  30.  * Note that while you technically do not need it, without YF's VictoryAftermath
  31.  * plugin, you won't see the difference in exp gain between actors.
  32.  */
  33.  
  34.  Game_Party.prototype.averageLevel = function() {
  35.     var level = 0;
  36.     for (var i = 0; i < this.members().length; ++i) {
  37.       var member = this.members()[i];
  38.       if (member) level += member.level;
  39.     }
  40.     level /= this.members().length;
  41.     return level;
  42. };
  43.  
  44. var MalStartBattle = BattleManager.startBattle;
  45. BattleManager.startBattle = function() {
  46.     MalStartBattle.call(this);
  47.     $gameParty._troupeLevel = Number($gameParty.averageLevel());
  48. };
  49.  
  50. Game_Party.prototype.setEnemyLevel = function(tLevel) {
  51.     var level = Number(tLevel);
  52.     this._troupeLevel = level;
  53. };
  54.  
  55. BattleManager.gainExp = function() {
  56.     var exp = this._rewards.exp;
  57.     var diff = 0;
  58.     $gameParty.allMembers().forEach(function(actor) {
  59.         diff = 1 + (($gameParty._troupeLevel - actor._level) * 0.1);
  60.         if (diff < 0.1) diff = 0.1;
  61.         var finalNum = Math.round(exp * diff);
  62.         actor.gainExp(finalNum);
  63.     });
  64. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement