Ellye

EscapeByTP

Mar 26th, 2016
37
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Place file inside /js/plugins
  2. // Remember to save after adding plugins or changing parameters.
  3. /*:
  4.  *
  5.  * @plugindesc  V.2016-03-26-1152. Escape via TP
  6.  * @author https://ellyeblog.wordpress.com/ || http://steamcommunity.com/id/Ellye
  7.  */
  8.  
  9. (function() {
  10.  
  11.     Game_Unit.prototype.avgTP = function() {
  12.         var members = this.members();
  13.         if (members.length === 0) {
  14.             return 1;
  15.         }
  16.         var sum = members.reduce(function(r, member) {
  17.             return r + member.tpRate();
  18.         }, 0);
  19.         return sum / members.length;
  20.     };
  21.  
  22.     BattleManager.makeEscapeRatio = function() {
  23.         this._escapeRatio = $gameParty.avgTP();
  24.     };
  25.  
  26.     _alias_pe = BattleManager.processEscape;
  27.     BattleManager.processEscape = function() {
  28.         this.makeEscapeRatio();
  29.         _alias_pe.call(this);
  30.     };
  31.  
  32. })();
RAW Paste Data