Advertisement
Double_X

DoubleX RMMV Popularized ATB Delay v100a

Feb 9th, 2016 (edited)
602
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 Delay                                    
  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/H6fgENvB                                      
  22.  *      Mentioned Patreon Supporters:
  23.  *      https://www.patreon.com/posts/71738797
  24.  *----------------------------------------------------------------------------
  25.  *    # Author                                                                
  26.  *      DoubleX                                                              
  27.  *----------------------------------------------------------------------------
  28.  *    # Changelog                                                            
  29.  *      v1.00a(GMT 1400 9-2-2016):                                            
  30.  *      1. 1st completed version of this plugin finished                      
  31.  *============================================================================*/
  32. /*:
  33.  * @plugindesc Lets users set some enemies and/or autobattle/confusion actors
  34.  *             to wait for a while after being actable before inputting action
  35.  * @author DoubleX
  36.  *
  37.  * @help
  38.  *============================================================================
  39.  *    ## Notetag Info                                                        
  40.  *----------------------------------------------------------------------------
  41.  *    # Actor/Class/Weapon/Armor/Enemy/State Notetags:                        
  42.  *      State notetags take the highest priority, followed by enemy, weapon,  
  43.  *      armor, class and actor                                                
  44.  *      1. <operator patb delay: frame>                                      
  45.  *         - Assigns frame frames to the battler's delay via operator        
  46.  *         - The number of frames per second's hardcoded as 60 in RMMV default
  47.  *         - operator can be either =, +, -, *, / or %, meaning set to, add  
  48.  *           by, subtract by, multiply by, divide by or modulo by respectively
  49.  *         - All instances of this notetag will be used sequentially          
  50.  *============================================================================
  51.  *    ## Plugin Call Info                                                    
  52.  *----------------------------------------------------------------------------
  53.  *    # Data Actor/Class/Weapon/Armor/Enemy/State manipulations              
  54.  *      1. meta.patb_delay                                                    
  55.  *         - Returns the delay in frame frames with the operator stored in    
  56.  *           <operator patb delay: frame> in the form of [opeartor, frame]    
  57.  *      2. meta.patb_delay = [opeartor, frame]                                
  58.  *         - Sets the delay in frame frames with the operator stored in      
  59.  *           <operator patb delay: frame> in the form of [opeartor, frame]    
  60.  *         - The number of frames per second's hardcoded as 60 in RMMV default
  61.  *         - All meta.patb_delay changes can be saved if                      
  62.  *           DoubleX RMMV Dynamic Data is used                                
  63.  *    # Battler manipulations                                                
  64.  *      1. patb_delay                                                        
  65.  *         - Returns the number of frames as delay for enemies or            
  66.  *           autobattle/confusion actors after being actable before inputting
  67.  *           actions                                                          
  68.  *      2. patb_delay = frame                                                
  69.  *         - Sets the number of frames as delay for enemies or                
  70.  *           autobattle/confusion actors after being actable before inputting
  71.  *           actions as frame                                                
  72.  *         - The number of frames per second's hardcoded as 60 in RMMV default
  73.  *============================================================================
  74.  */
  75.  
  76. "use strict";
  77. var DoubleX_RMMV = DoubleX_RMMV || {};
  78. DoubleX_RMMV["PATB Delay"] = "v1.00a";
  79.  
  80. /*============================================================================
  81.  *    ## Plugin Implementations                                              
  82.  *       You need not edit this part as it's about how this plugin works      
  83.  *----------------------------------------------------------------------------
  84.  *    # Plugin Support Info:                                                  
  85.  *      1. Prerequisites                                                      
  86.  *         - Basic knowledge of this plugin on the user level, the default    
  87.  *           battle system implementations and the atb system concepts        
  88.  *         - Some Javascript coding proficiency to fully comprehend this      
  89.  *           plugin                                                          
  90.  *      2. Function documentation                                            
  91.  *         - The 1st part describes why this function's rewritten/extended for
  92.  *           rewritten/extended functions or what the function does for new  
  93.  *           functions                                                        
  94.  *         - The 2nd part describes what the arguments of the function are    
  95.  *         - The 3rd part informs which version rewritten, extended or created
  96.  *           this function                                                    
  97.  *         - The 4th part informs whether the function's rewritten or new    
  98.  *         - The 5th part informs whether the function's a real or potential  
  99.  *           hotspot                                                          
  100.  *         - The 6th part describes how this function works for new functions
  101.  *           only, and describes the parts added, removed or rewritten for    
  102.  *           rewritten or extended functions only                            
  103.  *         Example:                                                          
  104.  * /*----------------------------------------------------------------------
  105.  *  *    Why rewrite/extended/What this function does                      
  106.  *  *----------------------------------------------------------------------*/
  107. /* // arguments: What these arguments are                                    
  108.  * function_name = function(arguments) { // Version X+; Rewrite/New; Hotspot  
  109.  *     // Added/Removed/Rewritten to do something/How this function works    
  110.  *     function_name_code;                                                    
  111.  *     //                                                                    
  112.  * } // function_name                                                        
  113.  *----------------------------------------------------------------------------*/
  114.  
  115. if (DoubleX_RMMV["PATB Core"]) {
  116.  
  117. /*----------------------------------------------------------------------------*/
  118.  
  119. /*----------------------------------------------------------------------------
  120.  *    # Edit class: DataManager                                              
  121.  *----------------------------------------------------------------------------*/
  122.  
  123. // data: The data to have its notetags read
  124. DataManager.load_patb_delay_data_notes = DataManager.load_patb_data_notes;
  125. DataManager.load_patb_data_notes = function(data) {
  126.     this.load_patb_delay_data_notes(data);
  127.     this.load_patb_delay_notes(data); // Added
  128. }; // DataManager.load_patb_data_notes
  129.  
  130. // data: The data to have its notetags read
  131. DataManager.load_patb_delay_notes = function(data) { // New
  132.     var delay = /< *(.+) +patb +delay *: *(\d+) *>/i, meta = data.meta;
  133.     meta.patb_delay = [];
  134.     data.note.split(/[\r\n]+/).forEach(function(line) {
  135.         if (!line.match(delay)) { return; }
  136.         meta.patb_delay.push([RegExp.$1, +RegExp.$2]);
  137.     });
  138. }; // DataManager.load_patb_delay_notes
  139.  
  140. /*----------------------------------------------------------------------------
  141.  *    # Edit class: Game_Battler                                              
  142.  *----------------------------------------------------------------------------*/
  143.  
  144. /*----------------------------------------------------------------------------
  145.  *    New public instance variable                                            
  146.  *----------------------------------------------------------------------------*/
  147. // The number of frames to be delayed after being actable before inputting acts
  148. Object.defineProperty(Game_Battler.prototype, "patb_delay", {
  149.     get: function() { /* Potential Hotspot */ return this._patb_delay; },
  150.     set: function(frame) { /* Potential Hotspot */ this._patb_delay = frame; },
  151.     configurable: true
  152. });
  153.  
  154. /*----------------------------------------------------------------------------
  155.  *    New private instance variable                                          
  156.  *----------------------------------------------------------------------------*/
  157. // _last_patb_delay: The last number of frames to be delayed
  158.  
  159. Game_Battler.prototype.init_patb_delay = Game_Battler.prototype.init_patb;
  160. Game_Battler.prototype.init_patb = function() {
  161.     this.init_patb_delay();
  162.     // Added
  163.     this._patb_delay = this._last_patb_delay = 0;
  164.     this._patb_battler_change.atb_delay = true;
  165.     this._patb_note_change.atb_delay = true;
  166.     //
  167. }; // Game_Battler.prototype.init_patb
  168.  
  169. Game_Battler.prototype.update_patb_delay = Game_Battler.prototype.update_patb;
  170. Game_Battler.prototype.update_patb = function() { // Hotspot
  171.     // Added
  172.     if (this._patb_delay > 0) { return this.update_patb_delay_frames(); }
  173.     //
  174.     this.update_patb_delay();
  175. }; // Game_Battler.prototype.update_patb
  176.  
  177. Game_Battler.prototype.reset_patb_delay = Game_Battler.prototype.reset_patb;
  178. Game_Battler.prototype.reset_patb = function() {
  179.     this._patb_delay = 0; // Added
  180.     this.reset_patb_delay();
  181. }; // Game_Battler.prototype.reset_patb
  182.  
  183. Game_Battler.prototype.update_patb_delay_frames = function() { // New; Hotspot
  184.     this.update_max_patb_val();
  185.     this._patb_delay -= 1;
  186. }; // Game_Battler.prototype.update_patb_delay_frames
  187.  
  188. Game_Battler.prototype.set_patb_delay_frames = function() { // New
  189.     if (this.are_patb_battler_changed("atb_delay")) {
  190.         this._last_patb_delay = this.set_multi_patb_notes(0, "patb_delay");
  191.     }
  192.     this._patb_delay = this._last_patb_delay;
  193. }; // Game_Battler.prototype.set_patb_delay_frames
  194.  
  195. /*----------------------------------------------------------------------------
  196.  *    # Edit class: Game_Actor                                                
  197.  *----------------------------------------------------------------------------*/
  198.  
  199. Game_Actor.prototype.makeAutoBattleActionsPatbDelay =
  200. Game_Actor.prototype.makeAutoBattleActions;
  201. Game_Actor.prototype.makeAutoBattleActions = function() {
  202.     this.makeAutoBattleActionsPatbDelay();
  203.     if ($gameSystem.is_patb()) { this.set_patb_delay_frames(); } // Added
  204. }; // Game_Actor.prototype.makeAutoBattleActions
  205.  
  206. Game_Actor.prototype.makeConfusionActionsPatbDelay =
  207. Game_Actor.prototype.makeConfusionActions ;
  208. Game_Actor.prototype.makeConfusionActions = function() {
  209.     this.makeConfusionActionsPatbDelay();
  210.     if ($gameSystem.is_patb()) { this.set_patb_delay_frames(); } // Added
  211. }; // Game_Actor.prototype.makeConfusionActions
  212.  
  213. /*----------------------------------------------------------------------------
  214.  *    # Edit class: Game_Enemy                                                
  215.  *----------------------------------------------------------------------------*/
  216.  
  217. Game_Enemy.prototype.makeActionsPatbDelay = Game_Enemy.prototype.makeActions;
  218. Game_Enemy.prototype.makeActions = function() {
  219.     this.makeActionsPatbDelay();
  220.     if ($gameSystem.is_patb()) { this.set_patb_delay_frames(); } // Added
  221. }; // Game_Enemy.prototype.makeActions
  222.  
  223. /*----------------------------------------------------------------------------*/
  224.  
  225. } else {
  226.     alert("To use PATB Delay, place it below PATB Core.");
  227. }
  228.  
  229. /*============================================================================*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement