SHARE
TWEET

DoubleX RMMV Popularized ATB CTB v100c

Double_X Jan 23rd, 2016 (edited) 328 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 CTB                                      
  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/rFw3nsAZ                                      
  22.  *      Video:                                                                
  23.  *      1. https://www.youtube.com/watch?v=o-DF-tPTsF0                        
  24.  *----------------------------------------------------------------------------
  25.  *    # Author                                                                
  26.  *      DoubleX                                                              
  27.  *----------------------------------------------------------------------------
  28.  *    # Changelog                                                            
  29.  *      v1.00c(GMT 0500 3-7-2016):                                            
  30.  *      1. Fixed below configuration changes not taking place in same battle:
  31.  *         - battle_system_window_x                                          
  32.  *         - battle_system_window_y                                          
  33.  *         - battle_system_window_width                                      
  34.  *         - battle_system_window_height                                      
  35.  *         - battle_system_text_size                                          
  36.  *         - battle_system_text_x                                            
  37.  *         - battle_system_text_y                                            
  38.  *      2. Increased this plugin's effectiveness, efficiency and flexibility  
  39.  *      v1.00b(GMT 1000 24-1-2016):                                          
  40.  *      1. Fixed not clearing old text before showing new ones bug            
  41.  *      2. Increased this plugin's compactness, readability and simplicity    
  42.  *      v1.00a(GMT 1400 23-1-2016):                                          
  43.  *      1. 1st completed version of this plugin finished                      
  44.  *============================================================================*/
  45. /*:
  46.  * @plugindesc Lets users switch the battle system to mimic charge turn battle
  47.  * @author DoubleX
  48.  *
  49.  * @param show_battle_system_window
  50.  * @desc Setups a window in battle indicating whether atb or ctb's used if
  51.  *       show_battle_system_window is set as true
  52.  * @default true
  53.  *
  54.  * @param battle_system_window_x
  55.  * @desc Sets the x position of the battle system indicator window as
  56.  *       battle_system_window_x
  57.  * @default 0
  58.  *
  59.  * @param battle_system_window_y
  60.  * @desc Sets the y position of the battle system indicator window as
  61.  *       battle_system_window_y
  62.  * @default 108
  63.  *
  64.  * @param battle_system_window_width
  65.  * @desc Sets the width of the battle system indicator window as
  66.  *       battle_system_window_width
  67.  * @default 220
  68.  *
  69.  * @param battle_system_window_height
  70.  * @desc Sets the height of the battle system indicator window as
  71.  *       battle_system_window_height
  72.  * @default 60
  73.  *
  74.  * @param battle_system_text_size
  75.  * @desc Sets the size of the text shown in the battle system indicator window
  76.  *       as battle_system_text_size
  77.  * @default 20
  78.  *
  79.  * @param battle_system_text_x
  80.  * @desc Sets the x position of the text shown in the battle system indicator
  81.  *       window as battle_system_text_x
  82.  * @default 0
  83.  *
  84.  * @param battle_system_text_y
  85.  * @desc Sets the y position of the text shown in the battle system indicator
  86.  *       window as battle_system_text_y
  87.  * @default -8
  88.  *
  89.  * @param atb_battle_system_text
  90.  * @desc Sets the text shown in a window indicating atb's used in battle as
  91.  *       atb_battle_system_text
  92.  * @default Active Time Battle
  93.  *
  94.  * @param ctb_battle_system_text
  95.  * @desc Sets the text shown in a window indicating ctb's used in battle as
  96.  *       ctb_battle_system_text
  97.  * @default Charge Turn Battle
  98.  *
  99.  * @help
  100.  * battle_system_code now supports ctb as well, which changes the battle
  101.  * system into ctb
  102.  * The default plugin file name is DoubleX RMMV Popularized ATB CTB v100c
  103.  * If you want to change that, you must edit the value of
  104.  * DoubleX_RMMV.PATB_CTB_File, which must be done via opening the plugin js
  105.  * file directly
  106.  *============================================================================
  107.  *    ## Plugin Call Info                                                    
  108.  *----------------------------------------------------------------------------
  109.  *    # Configuration manipulations                                          
  110.  *      1. $gameSystem.patb.param                                            
  111.  *         - Returns the value of param listed in the plugin manager          
  112.  *      2. $gameSystem.patb.param = val                                      
  113.  *         - Sets the value of param listed in the plugin manager as val      
  114.  *         - All $gameSystem.patb.param changes will be saved                
  115.  *============================================================================
  116.  */
  117.  
  118. "use strict";
  119. var DoubleX_RMMV = DoubleX_RMMV || {};
  120. DoubleX_RMMV["PATB CTB"] = "v1.00c";
  121.  
  122. // The plugin file name must be the same as DoubleX_RMMV.PATB_CTB_File
  123. DoubleX_RMMV.PATB_CTB_File = "DoubleX RMMV Popularized ATB CTB v100c";
  124.  
  125. /*============================================================================
  126.  *    ## Plugin Implementations                                              
  127.  *       You need not edit this part as it's about how this plugin works      
  128.  *----------------------------------------------------------------------------
  129.  *    # Plugin Support Info:                                                  
  130.  *      1. Prerequisites                                                      
  131.  *         - Basic knowledge of this plugin on the user level, the default    
  132.  *           battle system implementations and the atb system concepts        
  133.  *         - Some Javascript coding proficiency to fully comprehend this      
  134.  *           plugin                                                          
  135.  *      2. Function documentation                                            
  136.  *         - The 1st part describes why this function's rewritten/extended for
  137.  *           rewritten/extended functions or what the function does for new  
  138.  *           functions                                                        
  139.  *         - The 2nd part describes what the arguments of the function are    
  140.  *         - The 3rd part informs which version rewritten, extended or created
  141.  *           this function                                                    
  142.  *         - The 4th part informs whether the function's rewritten or new    
  143.  *         - The 5th part informs whether the function's a real or potential  
  144.  *           hotspot                                                          
  145.  *         - The 6th part describes how this function works for new functions
  146.  *           only, and describes the parts added, removed or rewritten for    
  147.  *           rewritten or extended functions only                            
  148.  *         Example:                                                          
  149.  * /*----------------------------------------------------------------------
  150.  *  *    Why rewrite/extended/What this function does                      
  151.  *  *----------------------------------------------------------------------*/
  152. /* // arguments: What these arguments are                                    
  153.  * function_name = function(arguments) { // Version X+; Rewrite/New; Hotspot  
  154.  *     // Added/Removed/Rewritten to do something/How this function works    
  155.  *     function_name_code;                                                    
  156.  *     //                                                                    
  157.  * } // function_name                                                        
  158.  *----------------------------------------------------------------------------*/
  159.  
  160. function Window_Patb_Ctb() { this.initialize.apply(this, arguments); }
  161.  
  162. if (DoubleX_RMMV["PATB Core"]) {
  163.  
  164. /*----------------------------------------------------------------------------*/
  165.  
  166. /*----------------------------------------------------------------------------
  167.  *    # Edit class: BattleManager                                            
  168.  *      - Implements the ctb system replication when it's asked and allowed  
  169.  *----------------------------------------------------------------------------*/
  170.  
  171. /*----------------------------------------------------------------------------
  172.  *    Runs the global and battler atb clocks until they've to stop            
  173.  *----------------------------------------------------------------------------*/
  174. BattleManager.update_patb_ctb = BattleManager.update_patb;
  175. BattleManager.update_patb = function() { // Hotspot
  176.     // Rewritten
  177.     do { this.update_patb_ctb(); } while (this.can_update_patb_ctb());
  178.     //
  179. }; // BattleManager.update_patb
  180.  
  181. /*----------------------------------------------------------------------------
  182.  *    Checks if the atb frame updates can behave in the ctb manner            
  183.  *----------------------------------------------------------------------------*/
  184. BattleManager.can_update_patb_ctb = function() { // New; Hotspot
  185.     if ($gameSystem.patb.battle_system_code !== "ctb") { return false; }
  186.     if (this._phase === 'action' || this.isInputting()) { return false; }
  187.     return !this.isBusy() && !this._need_patb_refresh;
  188. }; // BattleManager.can_update_patb_ctb
  189.  
  190. /*----------------------------------------------------------------------------
  191.  *    # Edit class: Game_System                                              
  192.  *      - Stores the values of all configurations listed in the plugin manager
  193.  *----------------------------------------------------------------------------*/
  194.  
  195. Game_System.prototype.init_patb_ctb_params =
  196. Game_System.prototype.init_patb_params;
  197. Game_System.prototype.init_patb_params = function() {
  198.     this.init_patb_ctb_params();
  199.     // Added
  200.     var val, params = PluginManager.parameters(DoubleX_RMMV.PATB_CTB_File);
  201.     Object.keys(params).forEach(function(param) {
  202.         val = +params[param];
  203.         this._patb[param] = isNaN(val) ? params[param] : val;
  204.     }, this);
  205.     this._patb.show_battle_system_window =
  206.     params.show_battle_system_window === "true";
  207.     //
  208. }; // Game_System.prototype.init_patb_params
  209.  
  210. Game_System.prototype.is_patb_ctb = Game_System.prototype.is_patb;
  211. Game_System.prototype.is_patb = function() { // Hotspot
  212.     // Rewritten
  213.     return this.is_patb_ctb() || this._patb.battle_system_code === "ctb";
  214.     //
  215. }; // Game_System.prototype.is_patb
  216.  
  217. /*----------------------------------------------------------------------------
  218.  *    # New class: Window_Patb_Ctb                                            
  219.  *----------------------------------------------------------------------------*/
  220.  
  221. /*----------------------------------------------------------------------------
  222.  *    New private instance variables                                          
  223.  *----------------------------------------------------------------------------*/
  224. // _text: The cached battle system text
  225. // _textSize: The cached battle system text size
  226.  
  227. Window_Patb_Ctb.prototype = Object.create(Window_Base.prototype);
  228. Window_Patb_Ctb.prototype.constructor = Window_Patb_Ctb;
  229.  
  230. Window_Patb_Ctb.prototype.initialize = function() {
  231.     var patb = $gameSystem.patb, width = patb.battle_system_window_width;
  232.     var x = patb.battle_system_window_x, y = patb.battle_system_window_y;
  233.     var height = patb.battle_system_window_height;
  234.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  235. }; // Window_Patb_Ctb.prototype.initialize
  236.  
  237. Window_Patb_Ctb.prototype.update = function() { // v1.00b+; Hotspot
  238.     Window_Base.prototype.update.call(this);
  239.     this.visible = $gameSystem.patb.show_battle_system_window;
  240.     if (!this.visible) { return; }
  241.     this.updateXYWH();
  242.     this.updateText();
  243. }; // Window_Patb_Ctb.prototype.update
  244.  
  245. Window_Patb_Ctb.prototype.updateXYWH = function() { // v1.00b+; Hotspot
  246.     var patb = $gameSystem.patb, width = patb.battle_system_window_width;
  247.     var x = patb.battle_system_window_x, y = patb.battle_system_window_y;
  248.     var height = patb.battle_system_window_height;
  249.     if (this.x !== x) this.x = x;
  250.     if (this.y !== y) this.y = y;
  251.     if (this.width !== width) this.width = width;
  252.     if (this.height !== height) this.height = height;
  253. }; // Window_Patb_Ctb.prototype.updateXYWH
  254.  
  255. Window_Patb_Ctb.prototype.updateText = function() { // Hotspot
  256.     var patb = $gameSystem.patb, textSize = this._textSize, updateText;
  257.     var textX = this._textX, textY = this._textY;
  258.     var text = patb[patb.battle_system_code + "_battle_system_text"];
  259.     this._textSize = patb.battle_system_text_size;
  260.     this._textX = patb.battle_system_text_x;
  261.     this._textY = patb.battle_system_text_y;
  262.     updateText = this._text !== text || this._textSize !== textSize;
  263.     updateText = updateText || this._textX !== textX || this._textY !== textY;
  264.     if (!updateText) { return; }
  265.     if (this._textSize !== textSize) { this.resetFontSettings(); }
  266.     this._text = text, textX = this._textX, textY = this._textY;
  267.     this.contents.clear();
  268.     this.drawText(this._text, textX, textY, this.textWidth(this._text));
  269. }; // Window_Patb_Ctb.prototype.updateText
  270.  
  271. Window_Patb_Ctb.prototype.standardFontSize = function() { // Potential Hotspot
  272.     return this._textSize;
  273. }; // Window_Patb_Ctb.prototype.standardFontSize
  274.  
  275. /*----------------------------------------------------------------------------
  276.  *    # Edit class: Scene_Battle                                              
  277.  *----------------------------------------------------------------------------*/
  278.  
  279. /*----------------------------------------------------------------------------
  280.  *    New private instance variable                                          
  281.  *----------------------------------------------------------------------------*/
  282. // _patb_ctb_window: The battle system indicator window
  283.  
  284. Scene_Battle.prototype.createAllWindowsPatbCtb =
  285. Scene_Battle.prototype.createAllWindows;
  286. Scene_Battle.prototype.createAllWindows = function() {
  287.     this.createAllWindowsPatbCtb();
  288.     if ($gameSystem.is_patb()) { this.create_patb_ctb_window(); } // Added
  289. }; // Scene_Battle.prototype.createAllWindows
  290.  
  291. Scene_Battle.prototype.update_patb_process_ctb =
  292. Scene_Battle.prototype.update_patb_process;
  293. Scene_Battle.prototype.update_patb_process = function() { // Hotspot
  294.     this.update_patb_process_ctb();
  295.     this._patb_ctb_window.update; // Added
  296. }; // Scene_Battle.prototype.update_patb_process
  297.  
  298. Scene_Battle.prototype.close_patb_windows_ctb =
  299. Scene_Battle.prototype.close_patb_windows;
  300. Scene_Battle.prototype.close_patb_windows = function() {
  301.     this.close_patb_windows_ctb();
  302.     this.close_patb_ctb_windows(); // Added
  303. }; // Scene_Battle.prototype.close_patb_windows
  304.  
  305. Scene_Battle.prototype.create_patb_ctb_window = function() { // New
  306.     this._patb_ctb_window = new Window_Patb_Ctb();
  307.     this.addWindow(this._patb_ctb_window);
  308. }; // Scene_Battle.prototype.create_patb_ctb_window
  309.  
  310. Scene_Battle.prototype.close_patb_ctb_windows = function() { // New
  311.     this._patb_ctb_window.hide();
  312.     this._patb_ctb_window.deactivate();
  313.     this._patb_ctb_window.close();
  314. }; // Scene_Battle.prototype.close_patb_ctb_windows
  315.  
  316. /*----------------------------------------------------------------------------*/
  317.  
  318. } else {
  319.     alert("To use PATB CTB, place it below PATB Core.");
  320. }
  321.  
  322. /*============================================================================*/
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top