Advertisement
Double_X

DoubleX RMMV Formulae Edit v101b

Nov 10th, 2015 (edited)
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*============================================================================
  2.  *    ## Plugin Info                                                          
  3.  *----------------------------------------------------------------------------
  4.  *    # Plugin Name                                                          
  5.  *      DoubleX RMMV Formulae Edit                                            
  6.  *----------------------------------------------------------------------------
  7.  *    # Terms Of Use                                                          
  8.  *      You shall keep this plugin's Plugin Info part's contents intact      
  9.  *      You shalln't claim that this plugin's written by anyone other than    
  10.  *      DoubleX or his aliases                                                
  11.  *      None of the above applies to DoubleX or his aliases                  
  12.  *----------------------------------------------------------------------------
  13.  *    # Prerequisites                                                        
  14.  *      Abilities:                                                            
  15.  *      1. Some Javascript coding proficiency to fully utilize this plugin    
  16.  *----------------------------------------------------------------------------
  17.  *    # Links                                                                
  18.  *      This plugin:                                                          
  19.  *      1. http://pastebin.com/8Ynig2Ht                                      
  20.  *      Mentioned Patreon Supporters:
  21.  *      https://www.patreon.com/posts/71738797
  22.  *----------------------------------------------------------------------------
  23.  *    # Author                                                                
  24.  *      DoubleX                                                              
  25.  *----------------------------------------------------------------------------
  26.  *    # Changelog                                                            
  27.  *      v1.01b(GMT 0400 9-9-2017):                                            
  28.  *      1. Fixed not loading the edited formulae from save files bug          
  29.  *      v1.01a(GMT 1400 27-1-2016):                                          
  30.  *      1. Fixed called DoubleX_RMMV.Formulae_Edit before it's defined bug    
  31.  *      2. All configuration values will be saved in $gameSystem              
  32.  *      3. Increased this plugin's readability                                
  33.  *      v1.00b(GMT 1200 17-11-2015):                                          
  34.  *      1. Fixed wrong number of arugments bug for lukEffectRate and          
  35.  *         makeEncounterCount                                                
  36.  *      2. Increased this plugin's efficiency                                
  37.  *      v1.00a(GMT 1300 10-11-2015):                                          
  38.  *      1. 1st version of this plugin finished                                
  39.  *============================================================================*/
  40. /*:
  41.  * @plugindesc Lets users modify some hardcoded default RMMV formulae on the fly
  42.  * @author DoubleX
  43.  *
  44.  * @param makeEscapeRatio
  45.  * @desc Sets the party escape ratio upon battle start as makeEscapeRatio, which
  46.  *       must return the content of a function that takes the party and troop's
  47.  *       agi, which can be referenced by partyAgi and troopAgi respectively, as
  48.  *       the arguments
  49.  *       The content of the function returned by makeEscapeRatio will be bound
  50.  *       to BattleManager upon use
  51.  * @default this._escapeRatio = 0.5 * partyAgi / troopAgi;
  52.  *
  53.  * @param speed
  54.  * @desc Sets the action speed as speed, which must return the content of a
  55.  *       function that takes the subject's agi, which can be referenced by agi,
  56.  *       as the argument and returns a Number
  57.  *       The content of the function returned by speed will be bound to
  58.  *       Game_Action upon use
  59.  * @default return agi + Math.randomInt(Math.floor(5 + agi / 4));
  60.  *
  61.  * @param lukEffectRate
  62.  * @desc Sets the luk effect rate multiplier applied to adding states and
  63.  *       debuffs to a target as lukEffectRate, which must return the content of
  64.  *       a function that takes a subject and target, which can be referenced by
  65.  *       subject and target respectively, as the arguments and returns a Number
  66.  *       The content of the function returned by lukEffectRate will be bound to
  67.  *       Game_Action upon use
  68.  * @default return Math.max(1.0 + (subject.luk - target.luk) * 0.001, 0.0);
  69.  *
  70.  * @param expForLevel
  71.  * @desc Sets the required experience for levelling up to level as expForLevel,
  72.  *       which must return the content of a function that takes the level,
  73.  *       actor's class, experience basis, extra, acceleration a and b, which can
  74.  *       be referenced by level, c, basis, extra, acc_a and acc_b respectively,
  75.  *       as the arguments and returns a Number
  76.  *       The content of the function returned by expForLevel will be bound to
  77.  *       Game_Actor upon use
  78.  * @default return Math.round(basis * (Math.pow(level - 1, 0.9 + acc_a / 250)) * level * (level + 1) / (6 + Math.pow(level, 2) / 50 / acc_b) + (level - 1) * extra);
  79.  *
  80.  * @param distancePerFrame
  81.  * @desc Sets the characters' moving distance per frame as distancePerFrame,
  82.  *       which must return the content of a function that takes the real move
  83.  *       speed, which can be referenced by speed, as the argument and returns a
  84.  *       Number
  85.  *       The content of the function returned by expForLevel will be bound to
  86.  *       Game_CharacterBase upon use
  87.  * @default return Math.pow(2, speed) / 256;
  88.  *
  89.  * @param makeEncounterCount
  90.  * @desc Sets the number of steps needed to trigger an encounter as
  91.  *       makeEncounterCount, which must return the content of a function that
  92.  *       takes the encounter count, which can be referenced by n, as the
  93.  *       argument
  94.  *       The content of the function returned by makeEncounterCount will be
  95.  *       bound to Game_Player upon use
  96.  * @default this._encounterCount = Math.randomInt(n) + Math.randomInt(n) + 1;
  97.  *
  98.  * @help
  99.  * The default plugin file name is DoubleX RMMV Formulae Edit v101b
  100.  * If you want to change that, you must edit the value of
  101.  * DoubleX_RMMV.Formulae_Edit_File, which must be done via opening the plugin
  102.  * js file directly
  103.  *============================================================================
  104.  *    ## Plugin Call Info                                                    
  105.  *----------------------------------------------------------------------------
  106.  *    # Configuration manipulations                                          
  107.  *      1. $gameSystem.formulaeEdit.param                                    
  108.  *         - Returns the function param under DoubleX_RMMV.Formulae_Edit      
  109.  *      2. $gameSystem.formulaeEdit.param = function                          
  110.  *         - Sets the function param under DoubleX_RMMV.Formulae_Edit as      
  111.  *           function                                                        
  112.  *         - All DoubleX_RMMV.Formulae_Edit.param changes will be saved      
  113.  *============================================================================
  114.  */
  115.  
  116. "use strict";
  117. var DoubleX_RMMV = DoubleX_RMMV || {};
  118. DoubleX_RMMV["Formulae Edit"] = "v1.01b";
  119.  
  120. // The plugin file name must be the same as DoubleX_RMMV.Formulae_Edit_File
  121. DoubleX_RMMV.Formulae_Edit_File = "DoubleX RMMV Formulae Edit v101b";
  122.  
  123. /*============================================================================
  124.  *    ## Plugin Implementations                                              
  125.  *       You need not edit this part as it's about how this plugin works      
  126.  *----------------------------------------------------------------------------
  127.  *    # Plugin Support Info:                                                  
  128.  *      1. Prerequisites                                                      
  129.  *         - Some Javascript coding proficiency to fully comprehend this      
  130.  *           plugin                                                          
  131.  *      2. Function documentation                                            
  132.  *         - The 1st part describes why this function's rewritten/extended for
  133.  *           rewritten/extended functions or what the function does for new  
  134.  *           functions                                                        
  135.  *         - The 2nd part describes what the arguments of the function are    
  136.  *         - The 3rd part informs which version rewritten, extended or created
  137.  *           this function                                                    
  138.  *         - The 4th part informs whether the function's rewritten or new    
  139.  *         - The 5th part informs whether the function's a real or potential  
  140.  *           hotspot                                                          
  141.  *         - The 6th part describes how this function works for new functions
  142.  *           only, and describes the parts added, removed or rewritten for    
  143.  *           rewritten or extended functions only                            
  144.  *         Example:                                                          
  145.  * /*----------------------------------------------------------------------
  146.  *  *    Why rewrite/extended/What this function does                      
  147.  *  *----------------------------------------------------------------------*/
  148. /* // arguments: What these arguments are                                    
  149.  * functionName = function(arguments) { // Version X+; Hotspot                
  150.  *     // Added/Removed/Rewritten to do something/How this function works    
  151.  *     functionContents                                                      
  152.  *     //                                                                    
  153.  * } // functionName                                                          
  154.  *----------------------------------------------------------------------------*/
  155.  
  156. DoubleX_RMMV.Formulae_Edit = {};
  157. (function(FE) {
  158.  
  159.     FE.DataManager = {};
  160.     var DM = FE.DataManager;
  161.  
  162.     DM.extractSaveContents = DataManager.extractSaveContents;
  163.     DataManager.extractSaveContents = function(contents) { // v1.01b+
  164.         DM.extractSaveContents.apply(this, arguments);
  165.         $gameTemp.formulaeEdit = GS.formulaeEditFuncs.call($gameSystem);
  166.     }; // DataManager.extractSaveContents
  167.  
  168.     /*------------------------------------------------------------------------
  169.      *    * Edit class: BattleManager                                        
  170.      *------------------------------------------------------------------------*/
  171.  
  172.     BattleManager.makeEscapeRatio = function() { // Rewrite
  173.         // Rewritten
  174.         $gameTemp.formulaeEdit.makeEscapeRatio.call(
  175.                 this, $gameParty.agility(), $gameTroop.agility());
  176.         //
  177.     }; // BattleManager.makeEscapeRatio
  178.  
  179.     FE.Game_Temp = {};
  180.     var GT = FE.Game_Temp;
  181.  
  182.     /*------------------------------------------------------------------------
  183.      *    New public instance variable                                        
  184.      *------------------------------------------------------------------------*/
  185.     // The storage of all configuration values
  186.     Object.defineProperty(Game_Temp.prototype, "formulaeEdit", {
  187.         get: function() { return this._formulaeEdit; },
  188.         set: function(formulaeEdit) {
  189.             return this._formulaeEdit = formulaeEdit;
  190.         },
  191.         configurable: true
  192.     });
  193.  
  194.     FE.Game_System = {};
  195.     var GS = FE.Game_System;
  196.  
  197.     /*------------------------------------------------------------------------
  198.      *    New public instance variable                                        
  199.      *------------------------------------------------------------------------*/
  200.     // The storage of all configuration values
  201.     Object.defineProperty(Game_System.prototype, "formulaeEdit", {
  202.         get: function() { return this._formulaeEdit; },
  203.         configurable: true
  204.     });
  205.  
  206.     GS.initialize = Game_System.prototype.initialize;
  207.     Game_System.prototype.initialize = function() {
  208.         GS.initialize.apply(this, arguments);
  209.         GS.initFormulaeEditParams.call(this);
  210.     }; // Game_System.prototype.initialize
  211.  
  212.     GS.initFormulaeEditParams = function() {
  213.         this._formulaeEdit = GS.formulaeEditParams.call(this);
  214.         $gameTemp.formulaeEdit = GS.formulaeEditFuncs.call(this);
  215.     }; // GS.initFormulaeEditParams
  216.  
  217.     GS.formulaeEditParams = function() { // v1.01b+
  218.         var params = PluginManager.parameters(DoubleX_RMMV.Formulae_Edit_File);
  219.         return {
  220.             makeEscapeRatio: params.makeEscapeRatio,
  221.             speed: params.speed,
  222.             lukEffectRate: params.lukEffectRate,
  223.             expForLevel: params.expForLevel,
  224.             distancePerFrame: params.distancePerFrame,
  225.             makeEncounterCount: params.makeEncounterCount
  226.         };
  227.     }; // GS.formulaeEditParams
  228.  
  229.     GS.formulaeEditFuncs = function() { // v1.01b+
  230.         return {
  231.             makeEscapeRatio: new Function(
  232.                     "partyAgi", "troopAgi", this._formulaeEdit.makeEscapeRatio),
  233.             speed: new Function("agi", this._formulaeEdit.speed),
  234.             lukEffectRate: new Function(
  235.                     "subject", "target", this._formulaeEdit.lukEffectRate),
  236.             expForLevel: new Function("level", "c", "basis", "extra", "acc_a",
  237.                     "acc_b", this._formulaeEdit.expForLevel),
  238.             distancePerFrame: new Function(
  239.                     "speed", this._formulaeEdit.distancePerFrame),
  240.             makeEncounterCount: new Function(
  241.                     "n", this._formulaeEdit.makeEncounterCount)
  242.         };;
  243.     }; // GS.formulaeEditParams
  244.  
  245.     /*------------------------------------------------------------------------
  246.      *    * Edit class: Game_Action                                          
  247.      *------------------------------------------------------------------------*/
  248.  
  249.     Game_Action.prototype.speed = function() { // Rewrite
  250.         var agi = this.subject().agi;
  251.         var speed = $gameTemp.formulaeEdit.speed.call(this, agi); // Rewritten
  252.         if (this.item()) {
  253.             speed += this.item().speed;
  254.         }
  255.         if (this.isAttack()) {
  256.             speed += this.subject().attackSpeed();
  257.         }
  258.         return speed;
  259.     }; // Game_Action.prototype.speed
  260.  
  261.     Game_Action.prototype.lukEffectRate = function(target) { // Rewrite
  262.         // Rewritten
  263.         return $gameTemp.formulaeEdit.lukEffectRate.call(
  264.                 this, this.subject(), target);
  265.         //
  266.     }; // Game_Action.prototype.lukEffectRate
  267.  
  268.     /*------------------------------------------------------------------------
  269.      *    * Edit class: Game_Actor                                            
  270.      *------------------------------------------------------------------------*/
  271.  
  272.     Game_Actor.prototype.expForLevel = function(level) { // Rewrite
  273.         var c = this.currentClass();
  274.         var basis = c.expParams[0], extra = c.expParams[1];
  275.         var acc_a = c.expParams[2], acc_b = c.expParams[3];
  276.         // Rewritten
  277.         return $gameTemp.formulaeEdit.expForLevel.call(
  278.                 this, level, c, basis, extra, acc_a, acc_b);
  279.         //
  280.     }; // Game_Actor.prototype.expForLevel
  281.  
  282.     /*------------------------------------------------------------------------
  283.      *    * Edit class: Game_CharacterBase                                    
  284.      *------------------------------------------------------------------------*/
  285.  
  286.     Game_CharacterBase.prototype.distancePerFrame = function() { // Rewrite
  287.         // Rewritten
  288.         return $gameTemp.formulaeEdit.distancePerFrame.call(
  289.                 this, this.realMoveSpeed());
  290.         //
  291.     }; // Game_CharacterBase.prototype.distancePerFrame
  292.  
  293.     /*------------------------------------------------------------------------
  294.      *    * Edit class: Game_Player                                          
  295.      *------------------------------------------------------------------------*/
  296.  
  297.     Game_Player.prototype.makeEncounterCount = function() { // Rewrite
  298.         $gameTemp.formulaeEdit.makeEncounterCount.call(
  299.                 this, $gameMap.encounterStep()); // Rewritten
  300.     }; // Game_Player.prototype.makeEncounterCount
  301.  
  302. })(DoubleX_RMMV.Formulae_Edit);
  303.  
  304. /*============================================================================*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement