Advertisement
Double_X

DoubleX RMMV Popularized ATB Rate v100b

Nov 30th, 2015 (edited)
630
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 Popularized ATB Rate                                    
  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.  *      Plugins:                                                              
  15.  *      1. DoubleX RMMV Popularized ATB Core                                  
  16.  *      Abilities:                                                            
  17.  *      1. Little Javascript coding proficiency to fully utilize this plugin  
  18.  *----------------------------------------------------------------------------
  19.  *    # Links                                                                
  20.  *      This plugin:                                                          
  21.  *      1. http://pastebin.com/AB1XcyvY                                      
  22.  *      Mentioned Patreon Supporters:
  23.  *      https://www.patreon.com/posts/71738797
  24.  *----------------------------------------------------------------------------
  25.  *    # Author                                                                
  26.  *      DoubleX                                                              
  27.  *----------------------------------------------------------------------------
  28.  *    # Changelog                                                            
  29.  *      v1.00b(GMT 0900 31-1-2016):                                          
  30.  *      1. Fixed user atb rate notetag updates not reflected to the atb rate  
  31.  *      v1.00a(GMT 0500 23-1-2016):                                          
  32.  *      1. Fixed undefined DataManager.this bug                              
  33.  *      2. Fixed not loading this plugin's notetag bug                        
  34.  *      3. Fixed name clashes between function patb_rate and getter patb_rate
  35.  *      4. Deleted some meaningless, pointless and useless documentations    
  36.  *      5. 1st completed version of this plugin finished                      
  37.  *      v0.00a(GMT 1300 29-11-2015):                                          
  38.  *      1. 1st testing version of this plugin finished                        
  39.  *============================================================================*/
  40. /*:
  41.  * @plugindesc Lets users alter individual battlers' atb rate by data notetags
  42.  * @author DoubleX
  43.  *
  44.  * @help
  45.  *============================================================================
  46.  *    ## Notetag Info                                                        
  47.  *----------------------------------------------------------------------------
  48.  *    # Actor/Class/Weapon/Armor/Enemy/State Notetags:                        
  49.  *      State notetags take the highest priority, followed by enemy, weapon,  
  50.  *      armor, class and actor                                                
  51.  *      1. <operator patb rate: rate>                                        
  52.  *         - Assigns rate to the battler's atb rate via operator              
  53.  *         - operator can be either =, +, -, *, / or %, meaning set to, add  
  54.  *           by, subtract by, multiply by, divide by or modulo by respectively
  55.  *         - All instances of this notetag will be used sequentially          
  56.  *============================================================================
  57.  *    ## Plugin Call Info                                                    
  58.  *----------------------------------------------------------------------------
  59.  *    # Data Actor/Class/Weapon/Armor/Enemy/State manipulations              
  60.  *      1. meta.patb_rate                                                    
  61.  *         - Returns the maximum atb value with the operator stored in        
  62.  *           <operator patb rate: rate> in the form of [opeartor, rate]      
  63.  *      2. meta.patb_rate = [opeartor, rate]                                  
  64.  *         - Sets the atb rate with the operator stored in                    
  65.  *           <operator patb rate: rate> as string operator and Number rate    
  66.  *         - All meta.patb_rate changes can be saved if                      
  67.  *           DoubleX RMMV Dynamic Data is used                                
  68.  *============================================================================
  69.  */
  70.  
  71. "use strict";
  72. var DoubleX_RMMV = DoubleX_RMMV || {};
  73. DoubleX_RMMV["PATB Rate"] = "v1.00b";
  74.  
  75. /*============================================================================
  76.  *    ## Plugin Implementations                                              
  77.  *       You need not edit this part as it's about how this plugin works      
  78.  *----------------------------------------------------------------------------
  79.  *    # Plugin Support Info:                                                  
  80.  *      1. Prerequisites                                                      
  81.  *         - Basic knowledge of this plugin on the user level, the default    
  82.  *           battle system implementations and the atb system concepts        
  83.  *         - Some Javascript coding proficiency to fully comprehend this      
  84.  *           plugin                                                          
  85.  *      2. Function documentation                                            
  86.  *         - The 1st part describes why this function's rewritten/extended for
  87.  *           rewritten/extended functions or what the function does for new  
  88.  *           functions                                                        
  89.  *         - The 2nd part describes what the arguments of the function are    
  90.  *         - The 3rd part informs which version rewritten, extended or created
  91.  *           this function                                                    
  92.  *         - The 4th part informs whether the function's rewritten or new    
  93.  *         - The 5th part informs whether the function's a real or potential  
  94.  *           hotspot                                                          
  95.  *         - The 6th part describes how this function works for new functions
  96.  *           only, and describes the parts added, removed or rewritten for    
  97.  *           rewritten or extended functions only                            
  98.  *         Example:                                                          
  99.  * /*----------------------------------------------------------------------
  100.  *  *    Why rewrite/extended/What this function does                      
  101.  *  *----------------------------------------------------------------------*/
  102. /* // arguments: What these arguments are                                    
  103.  * function_name = function(arguments) { // Version X+; Rewrite/New; Hotspot  
  104.  *     // Added/Removed/Rewritten to do something/How this function works    
  105.  *     function_name_code;                                                    
  106.  *     //                                                                    
  107.  * } // function_name                                                        
  108.  *----------------------------------------------------------------------------*/
  109.  
  110. if (DoubleX_RMMV["PATB Core"]) {
  111.  
  112. /*----------------------------------------------------------------------------*/
  113.  
  114. /*----------------------------------------------------------------------------
  115.  *    # Edit class: DataManager                                              
  116.  *----------------------------------------------------------------------------*/
  117.  
  118. // data: The data to have its notetags read
  119. DataManager.load_patb_rate_data_notes = DataManager.load_patb_data_notes;
  120. DataManager.load_patb_data_notes = function(data) {
  121.     this.load_patb_rate_data_notes(data);
  122.     this.load_patb_rate_notes(data); // Added
  123. }; // DataManager.load_patb_data_notes
  124.  
  125. // data: The data to have its notetags read
  126. DataManager.load_patb_rate_notes = function(data) { // New
  127.     var rate = /< *(.+) +patb +rate *: *(\d+) *>/i, meta = data.meta;
  128.     meta.patb_rate = [];
  129.     data.note.split(/[\r\n]+/).forEach(function(line) {
  130.         if (line.match(rate)) { meta.patb_rate.push([RegExp.$1, +RegExp.$2]); }
  131.     });
  132. }; // DataManager.load_patb_rate_notes
  133.  
  134. /*----------------------------------------------------------------------------
  135.  *    # Edit class: Game_Battler                                              
  136.  *----------------------------------------------------------------------------*/
  137.  
  138. Game_Battler.prototype.init_patb_rate = Game_Battler.prototype.init_patb;
  139. Game_Battler.prototype.init_patb = function() { // v1.00b+
  140.     this.init_patb_rate();
  141.     // Added
  142.     this._patb_battler_change.atb_rate = true;
  143.     this._patb_note_change.atb_rate = true;
  144.     //
  145. }; // Game_Battler.prototype.init_patb
  146.  
  147. Game_Battler.prototype.get_base_patb_rate = Game_Battler.prototype.get_patb_rate;
  148. Game_Battler.prototype.get_patb_rate = function() { // Hotspot
  149.     // Rewritten
  150.     var rate, last_rate = this._patb_rate.atb;
  151.     this._patb_rate.atb = this.get_base_patb_rate();
  152.     var change = last_rate !== this._patb_rate.atb;
  153.     if (change || this.are_patb_battler_changed("atb_rate")) {
  154.         rate = this._patb_rate.atb;
  155.         this._patb_rate.atb = this.set_multi_patb_notes(rate, "patb_rate");
  156.     }
  157.     return this._patb_rate.atb;
  158.     //
  159. }; // Game_Battler.prototype.get_patb_rate
  160.  
  161. /*----------------------------------------------------------------------------*/
  162.  
  163. } else {
  164.     alert("To use PATB Rate, place it below PATB Core.");
  165. }
  166.  
  167. /*============================================================================*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement