Advertisement
Double_X

DoubleX RMMV Popularized ATB Force v100b

Jan 24th, 2016 (edited)
674
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 Force                                    
  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/575qkWzC                                      
  22.  *      Video:                                                                
  23.  *      1. https://www.youtube.com/watch?v=u8CITsswgPI                        
  24.  *      Mentioned Patreon Supporters:
  25.  *      https://www.patreon.com/posts/71738797
  26.  *----------------------------------------------------------------------------
  27.  *    # Author                                                                
  28.  *      DoubleX                                                              
  29.  *----------------------------------------------------------------------------
  30.  *    # Changelog                                                            
  31.  *      v1.00b(GMT 0500 3-7-2016):                                            
  32.  *      1. Fixed below configuration changes not taking place in same battle:
  33.  *         - force_atb_window_x                                              
  34.  *         - force_atb_window_y                                              
  35.  *         - force_atb_window_width                                          
  36.  *         - force_atb_window_height                                          
  37.  *         - force_atb_text_size                                              
  38.  *         - force_atb_text_x                                                
  39.  *         - force_atb_text_y                                                
  40.  *         - no_force_atb_text                                                
  41.  *         - force_run_atb_text                                              
  42.  *         - force_stop_atb_text                                              
  43.  *      2. Increased this plugin's effectiveness, efficiency and flexibility  
  44.  *      v1.00a(GMT 1100 24-1-2016):                                          
  45.  *      1. 1st completed version of this plugin finished                      
  46.  *============================================================================*/
  47. /*:
  48.  * @plugindesc Lets users set some keys to force run/stop the atb frame update
  49.  * @author DoubleX
  50.  *
  51.  * @param show_force_atb_window
  52.  * @desc Setups a window in battle indicating the atb force status if
  53.  *       show_force_atb_window is set as true
  54.  * @default true
  55.  *
  56.  * @param force_atb_window_x
  57.  * @desc Sets the x position of the atb force status window as
  58.  *       force_atb_window_x
  59.  * @default 220
  60.  *
  61.  * @param force_atb_window_y
  62.  * @desc Sets the y position of the atb force status window as
  63.  *       force_atb_window_y
  64.  * @default 108
  65.  *
  66.  * @param force_atb_window_width
  67.  * @desc Sets the width of the atb force status window as
  68.  *       force_atb_window_width
  69.  * @default 180
  70.  *
  71.  * @param force_atb_window_height
  72.  * @desc Sets the height of the atb force status window as
  73.  *       force_atb_window_height
  74.  * @default 60
  75.  *
  76.  * @param force_atb_text_size
  77.  * @desc Sets the size of the text shown in the atb force status window as
  78.  *       force_atb_text_size
  79.  * @default 20
  80.  *
  81.  * @param force_atb_text_x
  82.  * @desc Sets the x position of the text shown in the atb force status window
  83.  *       as force_atb_text_x
  84.  * @default 8
  85.  *
  86.  * @param force_atb_text_y
  87.  * @desc Sets the y position of the text shown in the atb force status window
  88.  *       as force_atb_text_y
  89.  * @default -8
  90.  *
  91.  * @param no_force_atb_text
  92.  * @desc Sets the text shown in a window indicating atb's not forced as
  93.  *       no_force_atb_text
  94.  * @default No Force ATB
  95.  *
  96.  * @param force_run_atb_text
  97.  * @desc Sets the text shown in a window indicating atb's forced to run as
  98.  *       force_run_atb_text
  99.  * @default ATB Force Run
  100.  *
  101.  * @param force_stop_atb_text
  102.  * @desc Sets the text shown in a window indicating atb's forced to stop as
  103.  *       force_stop_atb_text
  104.  * @default ATB Force Stop
  105.  *
  106.  * @param force_run_atb_key
  107.  * @desc Sets the key changing the atb force status from force stop to no
  108.  *       force or no force to force run as force_run_atb_key
  109.  * @default shift
  110.  *
  111.  * @param force_stop_atb_key
  112.  * @desc Sets the key changing the atb force status from force run to no force
  113.  *       or no force to force stop as force_stop_atb_key
  114.  * @default control
  115.  *
  116.  * @help
  117.  * The default plugin file name is DoubleX RMMV Popularized ATB Force v100b
  118.  * If you want to change that, you must edit the value of
  119.  * DoubleX_RMMV.PATB_Force_File, which must be done via opening the plugin js
  120.  * file directly
  121.  *============================================================================
  122.  *    ## Plugin Call Info                                                    
  123.  *----------------------------------------------------------------------------
  124.  *    # Configuration manipulations                                          
  125.  *      1. $gameSystem.patb.param                                            
  126.  *         - Returns the value of param listed in the plugin manager          
  127.  *      2. $gameSystem.patb.param = val                                      
  128.  *         - Sets the value of param listed in the plugin manager as val      
  129.  *         - All $gameSystem.patb.param changes will be saved                
  130.  *============================================================================
  131.  */
  132.  
  133. "use strict";
  134. var DoubleX_RMMV = DoubleX_RMMV || {};
  135. DoubleX_RMMV["PATB Force"] = "v1.00b";
  136.  
  137. // The plugin file name must be the same as DoubleX_RMMV.PATB_Force_File
  138. DoubleX_RMMV.PATB_Force_File = "DoubleX RMMV Popularized ATB Force v100b";
  139.  
  140. /*============================================================================
  141.  *    ## Plugin Implementations                                              
  142.  *       You need not edit this part as it's about how this plugin works      
  143.  *----------------------------------------------------------------------------
  144.  *    # Plugin Support Info:                                                  
  145.  *      1. Prerequisites                                                      
  146.  *         - Basic knowledge of this plugin on the user level, the default    
  147.  *           battle system implementations and the atb system concepts        
  148.  *         - Some Javascript coding proficiency to fully comprehend this      
  149.  *           plugin                                                          
  150.  *      2. Function documentation                                            
  151.  *         - The 1st part describes why this function's rewritten/extended for
  152.  *           rewritten/extended functions or what the function does for new  
  153.  *           functions                                                        
  154.  *         - The 2nd part describes what the arguments of the function are    
  155.  *         - The 3rd part informs which version rewritten, extended or created
  156.  *           this function                                                    
  157.  *         - The 4th part informs whether the function's rewritten or new    
  158.  *         - The 5th part informs whether the function's a real or potential  
  159.  *           hotspot                                                          
  160.  *         - The 6th part describes how this function works for new functions
  161.  *           only, and describes the parts added, removed or rewritten for    
  162.  *           rewritten or extended functions only                            
  163.  *         Example:                                                          
  164.  * /*----------------------------------------------------------------------
  165.  *  *    Why rewrite/extended/What this function does                      
  166.  *  *----------------------------------------------------------------------*/
  167. /* // arguments: What these arguments are                                    
  168.  * function_name = function(arguments) { // Version X+; Rewrite/New; Hotspot  
  169.  *     // Added/Removed/Rewritten to do something/How this function works    
  170.  *     function_name_code;                                                    
  171.  *     //                                                                    
  172.  * } // function_name                                                        
  173.  *----------------------------------------------------------------------------*/
  174.  
  175. function Window_Patb_Force() { this.initialize.apply(this, arguments); }
  176.  
  177. if (DoubleX_RMMV["PATB Core"]) {
  178.  
  179. /*----------------------------------------------------------------------------*/
  180.  
  181. /*----------------------------------------------------------------------------
  182.  *    # Edit class: Game_System                                              
  183.  *      - Stores the values of all configurations listed in the plugin manager
  184.  *----------------------------------------------------------------------------*/
  185.  
  186. Game_System.prototype.init_patb_force_params =
  187. Game_System.prototype.init_patb_params;
  188. Game_System.prototype.init_patb_params = function() {
  189.     this.init_patb_force_params();
  190.     // Added
  191.     var val, params = PluginManager.parameters(DoubleX_RMMV.PATB_Force_File);
  192.     Object.keys(params).forEach(function(param) {
  193.         val = +params[param];
  194.         this._patb[param] = isNaN(val) ? params[param] : val;
  195.     }, this);
  196.     this._patb.show_force_atb_window = params.show_force_atb_window === "true";
  197.     //
  198. }; // Game_System.prototype.init_patb_params
  199.  
  200. /*----------------------------------------------------------------------------
  201.  *    # New class: Window_Patb_Force                                            
  202.  *----------------------------------------------------------------------------*/
  203.  
  204. Window_Patb_Force.prototype = Object.create(Window_Base.prototype);
  205. Window_Patb_Force.prototype.constructor = Window_Patb_Force;
  206.  
  207. /*----------------------------------------------------------------------------
  208.  *    New public instance variable                                            
  209.  *----------------------------------------------------------------------------*/
  210. // (v1.00b+)The atb force status
  211. Object.defineProperty(Window_Patb_Force.prototype, "forceStatus", { // Hotspot
  212.     get: function() { return this._forceStatus; },
  213.     set: function(forceStatus) { this._forceStatus = forceStatus; },
  214.     configurable: true
  215. });
  216.  
  217. /*----------------------------------------------------------------------------
  218.  *    New private instance variables                                          
  219.  *----------------------------------------------------------------------------*/
  220. // _text: The cached atb force status text
  221. // _textSize: The cached atb force status text size
  222.  
  223. // forceStatus: The atb force status
  224. Window_Patb_Force.prototype.initialize = function(forceStatus) {
  225.     this._forceStatus = forceStatus;
  226.     var patb = $gameSystem.patb, x = patb.force_atb_window_x;
  227.     var y = patb.force_atb_window_y, width = patb.force_atb_window_width;
  228.     var height = patb.force_atb_window_height;
  229.     Window_Base.prototype.initialize.call(this, x, y, width, height);
  230. }; // Window_Patb_Force.prototype.initialize
  231.  
  232. Window_Patb_Force.prototype.update = function() { // v1.00b+; Hotspot
  233.     Window_Base.prototype.update.call(this);
  234.     this.visible = $gameSystem.patb.show_force_atb_window;
  235.     if (!this.visible) { return; }
  236.     this.updateXYWH();
  237.     this.updateText();
  238. }; // Window_Patb_Force.prototype.update
  239.  
  240. Window_Patb_Force.prototype.updateXYWH = function() { // v1.00b+; Hotspot
  241.     var patb = $gameSystem.patb, width = patb.force_atb_window_width;
  242.     var x = patb.force_atb_window_x, y = patb.force_atb_window_y;
  243.     var height = patb.force_atb_window_height;
  244.     if (this.x !== x) this.x = x;
  245.     if (this.y !== y) this.y = y;
  246.     if (this.width !== width) this.width = width;
  247.     if (this.height !== height) this.height = height;
  248. }; // Window_Patb_Force.prototype.updateXYWH
  249.  
  250. Window_Patb_Force.prototype.updateText = function() { // Hotspot
  251.     var patb = $gameSystem.patb, textSize = this._textSize, updateText;
  252.     var textX = this._textX, textY = this._textY;
  253.     this._textX = patb.force_atb_text_x, this._textY = patb.force_atb_text_y;
  254.     var text = patb[this._forceStatus + "_atb_text"];
  255.     this._textSize = patb.force_atb_text_size;
  256.     updateText = this._text !== text || this._textSize !== textSize;
  257.     updateText = updateText || this._textX !== textX || this._textY !== textY;
  258.     if (!updateText) { return; }
  259.     if (this._textSize !== textSize) { this.resetFontSettings(); }
  260.     this._text = text, textX = this._textX, textY = this._textY;;
  261.     this.contents.clear();
  262.     this.drawText(this._text, textX, textY, this.textWidth(this._text));
  263. }; // Window_Patb_Force.prototype.updateText
  264.  
  265. Window_Patb_Force.prototype.standardFontSize = function() { // Potential Hotspot
  266.     return this._textSize;
  267. }; // Window_Patb_Force.prototype.standardFontSize
  268.  
  269. /*----------------------------------------------------------------------------
  270.  *    # Edit class: Scene_Battle                                              
  271.  *----------------------------------------------------------------------------*/
  272.  
  273. /*----------------------------------------------------------------------------
  274.  *    New private instance variable                                          
  275.  *----------------------------------------------------------------------------*/
  276. // _patb_force_window: The battle system indicator window
  277.  
  278. Scene_Battle.prototype.createAllWindowsPatbForce =
  279. Scene_Battle.prototype.createAllWindows;
  280. Scene_Battle.prototype.createAllWindows = function() {
  281.     this.createAllWindowsPatbForce();
  282.     if ($gameSystem.is_patb()) { this.create_patb_force_window(); } // Added
  283. }; // Scene_Battle.prototype.createAllWindows
  284.  
  285. Scene_Battle.prototype.update_patb_process_force =
  286. Scene_Battle.prototype.update_patb_process;
  287. Scene_Battle.prototype.update_patb_process = function() { // Hotspot
  288.     this.update_patb_force_status(); // Added
  289.     this.update_patb_process_force();
  290.     this._patb_force_window.update(); // Added
  291. }; // Scene_Battle.prototype.update_patb_process
  292.  
  293. Scene_Battle.prototype.can_update_patb_force =
  294. Scene_Battle.prototype.can_update_patb;
  295. Scene_Battle.prototype.can_update_patb = function() { // Hotspot
  296.     // Added
  297.     if (this._patb_force_window.forceStatus === "force_run") { return true; }
  298.     if (this._patb_force_window.forceStatus === "force_stop") { return false; }
  299.     //
  300.     return this.can_update_patb_force();
  301. }; // Scene_Battle.prototype.can_update_patb
  302.  
  303. Scene_Battle.prototype.close_patb_windows_force =
  304. Scene_Battle.prototype.close_patb_windows;
  305. Scene_Battle.prototype.close_patb_windows = function() {
  306.     this.close_patb_windows_force();
  307.     this.close_patb_force_windows(); // Added
  308. }; // Scene_Battle.prototype.close_patb_windows
  309.  
  310. Scene_Battle.prototype.create_patb_force_window = function() { // New
  311.     this._patb_force_window = new Window_Patb_Force("no_force");
  312.     this.addWindow(this._patb_force_window);
  313. }; // Scene_Battle.prototype.create_patb_force_window
  314.  
  315. Scene_Battle.prototype.update_patb_force_status = function() { // Hotspot
  316.     if (Input.isTriggered($gameSystem.patb.force_run_atb_key)) {
  317.         if (this._patb_force_window.forceStatus === "force_stop") {
  318.             return this._patb_force_window.forceStatus = "no_force";
  319.         }
  320.         this._patb_force_window.forceStatus = "force_run";
  321.     } else if (Input.isTriggered($gameSystem.patb.force_stop_atb_key)) {
  322.         if (this._patb_force_window.forceStatus === "force_run") {
  323.             return this._patb_force_window.forceStatus = "no_force";
  324.         }
  325.         this._patb_force_window.forceStatus = "force_stop";
  326.     }
  327. }; // Scene_Battle.prototype.update_patb_force_status
  328.  
  329. Scene_Battle.prototype.close_patb_force_windows = function() { // New
  330.     this._patb_force_window.hide();
  331.     this._patb_force_window.deactivate();
  332.     this._patb_force_window.close();
  333. }; // Scene_Battle.prototype.close_patb_force_windows
  334.  
  335. /*----------------------------------------------------------------------------*/
  336.  
  337. } else {
  338.     alert("To use PATB Force, place it below PATB Core.");
  339. }
  340.  
  341. /*============================================================================*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement