Advertisement
Double_X

DoubleX RMMV Popularized ATB Hotkey v100b

Jul 10th, 2016 (edited)
909
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 Hotkey                                  
  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/hPe0kGCm                                      
  22.  *      Video:                                                                
  23.  *      1. https://www.youtube.com/watch?v=ixFqDbzgacQ                        
  24.  *      Mentioned Patreon Supporters:
  25.  *      https://www.patreon.com/posts/71738797
  26.  *----------------------------------------------------------------------------
  27.  *    # Author                                                                
  28.  *      DoubleX                                                              
  29.  *----------------------------------------------------------------------------
  30.  *    # Changelog                                                            
  31.  *      v1.00b(GMT 0500 11-8-2017):                                          
  32.  *      1. Fixed actors selected by hotkeys not performing the waiting pose  
  33.  *         bug                                                                
  34.  *      v1.00a(GMT 0900 10-7-2016):                                          
  35.  *      1. 1st version of this plugin finished                                
  36.  *============================================================================*/
  37. /*:
  38.  * @plugindesc Lets users set some hotkeys to select various inputable actors
  39.  * @author DoubleX
  40.  *
  41.  * @param prior_inputable_actor
  42.  * @desc Sets the key setting up the inputable actor at the left of the
  43.  *       current one as prior_inputable_actor
  44.  *       If the current one's the leftmost one, the rightmost one will be
  45.  *       setup instead
  46.  *       Holding prior_inputable_actor can repeatedly setup inputable actors
  47.  *       prior_inputable_actor should remain unchanged during the same battle
  48.  * @default left
  49.  *
  50.  * @param next_inputable_actor
  51.  * @desc Sets the key setting up the inputable actor at the right of the
  52.  *       current one as next_inputable_actor
  53.  *       If the current one's the rightmost one, the leftmost one will be
  54.  *       setup instead
  55.  *       Holding next_inputable_actor can repeatedly setup inputable actors
  56.  *       next_inputable_actor should remain unchanged during the same battle
  57.  * @default right
  58.  *
  59.  * @help
  60.  * The default plugin file name is DoubleX RMMV Popularized ATB Hotkey v100b
  61.  * If you want to change that, you must edit the value of
  62.  * DoubleX_RMMV.PATB_Hotkey_File, which must be done via opening this plugin
  63.  * js file directly
  64.  * You're supposed to edit this js file directly to setup hotkeys setting up
  65.  * inputable actors with specified party member index
  66.  *============================================================================
  67.  *    ## Plugin Call Info                                                    
  68.  *----------------------------------------------------------------------------
  69.  *    # Configuration manipulations                                          
  70.  *      1. $gameSystem.patb.param                                            
  71.  *         - Returns the value of param listed in the plugin manager          
  72.  *      2. $gameSystem.patb.param = val                                      
  73.  *         - Sets the value of param listed in the plugin manager as val      
  74.  *         - All $gameSystem.patb.param changes will be saved                
  75.  *      3. $gameSystem.patb.hotkey_actor_index                                
  76.  *         - Returns the keyboard mapping of hotkey selecting the inputable  
  77.  *           actor with the specified party member index                      
  78.  *      4. $gameSystem.patb.hotkey_actor_index = keyboard_mapping            
  79.  *         - Sets the keyboard mapping of hotkey selecting the inputable actor
  80.  *           with the specified party member index as keyboard_mapping        
  81.  *         - All $gameSystem.patb.hotkey_actor_index changes will be saved    
  82.  *      5. $gameSystem.patb.hotkey_actor_count                                
  83.  *         - Returns the number of hotkeys selecting the inputable actor with
  84.  *           specified party member indices                                  
  85.  *      6. $gameSystem.patb.hotkey_actor_count = count                        
  86.  *         - Sets the number of hotkeys selecting the inputable actor with    
  87.  *           specified party member indices as count                          
  88.  *         - All $gameSystem.hotkey_actor_count changes will be saved        
  89.  *============================================================================
  90.  */
  91.  
  92. "use strict";
  93. var DoubleX_RMMV = DoubleX_RMMV || {};
  94. DoubleX_RMMV["PATB Hotkey"] = "v1.00b";
  95.  
  96. // The plugin file name must be the same as DoubleX_RMMV.PATB_Hotkey_File
  97. DoubleX_RMMV.PATB_Hotkey_File = "DoubleX RMMV Popularized ATB Hotkey v100b";
  98.  
  99. /*============================================================================
  100.  *    ## Plugin Configurations                                                
  101.  *       You only need to edit this part as it's about what this plugin does  
  102.  *----------------------------------------------------------------------------*/
  103.  
  104. DoubleX_RMMV.PATB_Hotkey = {
  105.  
  106.     /* Sets hotkeys selecting the inputable actor with the specified party
  107.      * member index
  108.      * None of these hotkeys are supposed to be changed during the same battle
  109.      * Each hotkey will be referenced by $gameSystem.patb.hotkey_actor_index,
  110.      * where index is the index of the hotkey
  111.      * $gameSystem.patb.hotkey_actor_count must always be updated to maintain
  112.      * the exact number of these hotkeys
  113.      * The ith hotkey will try to select the inputable actor with party memver
  114.      * index i - 1
  115.      * Each of these hotkey must be a String
  116.      * Using a keyboard mapping plugin, like Quasi Input, can be useful here
  117.      */
  118.     inputable_actors: [
  119.         "#1", // Referenced by $gameSystem.patb.hotkey_actor_0
  120.         "#2", // Referenced by $gameSystem.patb.hotkey_actor_1
  121.         "#3", // Referenced by $gameSystem.patb.hotkey_actor_2
  122.         "#4", // Referenced by $gameSystem.patb.hotkey_actor_3
  123.         "#5", // Referenced by $gameSystem.patb.hotkey_actor_4
  124.         "#6", // Referenced by $gameSystem.patb.hotkey_actor_5
  125.         "#7", // Referenced by $gameSystem.patb.hotkey_actor_6
  126.         "#8", // Referenced by $gameSystem.patb.hotkey_actor_7
  127.         "#9", // Referenced by $gameSystem.patb.hotkey_actor_8
  128.         "#0" // Referenced by $gameSystem.patb.hotkey_actor_9
  129.     ]
  130.  
  131. }; // DoubleX_RMMV.PATB_Hotkey
  132.  
  133. /*============================================================================
  134.  *    ## Plugin Implementations                                              
  135.  *       You need not edit this part as it's about how this plugin works      
  136.  *----------------------------------------------------------------------------
  137.  *    # Plugin Support Info:                                                  
  138.  *      1. Prerequisites                                                      
  139.  *         - Basic knowledge of this plugin on the user level, the default    
  140.  *           battle system implementations and the atb system concepts        
  141.  *         - Some Javascript coding proficiency to fully comprehend this      
  142.  *           plugin                                                          
  143.  *      2. Function documentation                                            
  144.  *         - The 1st part describes why this function's rewritten/extended for
  145.  *           rewritten/extended functions or what the function does for new  
  146.  *           functions                                                        
  147.  *         - The 2nd part describes what the arguments of the function are    
  148.  *         - The 3rd part informs which version rewritten, extended or created
  149.  *           this function                                                    
  150.  *         - The 4th part informs whether the function's rewritten or new    
  151.  *         - The 5th part informs whether the function's a real or potential  
  152.  *           hotspot                                                          
  153.  *         - The 6th part describes how this function works for new functions
  154.  *           only, and describes the parts added, removed or rewritten for    
  155.  *           rewritten or extended functions only                            
  156.  *         Example:                                                          
  157.  * /*----------------------------------------------------------------------
  158.  *  *    Why rewrite/extended/What this function does                      
  159.  *  *----------------------------------------------------------------------*/
  160. /* // arguments: What these arguments are                                    
  161.  * function_name = function(arguments) { // Version X+; Rewrite/New; Hotspot  
  162.  *     // Added/Removed/Rewritten to do something/How this function works    
  163.  *     function_name_code;                                                    
  164.  *     //                                                                    
  165.  * } // function_name                                                        
  166.  *----------------------------------------------------------------------------*/
  167.  
  168. if (DoubleX_RMMV["PATB Core"]) {
  169.  
  170. /*----------------------------------------------------------------------------*/
  171.  
  172. /*----------------------------------------------------------------------------
  173.  *    # Edit class: Game_System                                              
  174.  *      - Stores the values of all configurations listed in the plugin manager
  175.  *----------------------------------------------------------------------------*/
  176.  
  177. Game_System.prototype.init_patb_hotkey_params =
  178. Game_System.prototype.init_patb_params;
  179. Game_System.prototype.init_patb_params = function() {
  180.     this.init_patb_hotkey_params();
  181.     // Added
  182.     var params = PluginManager.parameters(DoubleX_RMMV.PATB_Hotkey_File);
  183.     Object.keys(params).forEach(function(param) {
  184.         this._patb[param] = params[param];
  185.     }, this);
  186.     var hotkeys = DoubleX_RMMV.PATB_Hotkey.inputable_actors;
  187.     var length = hotkeys.length;
  188.     this._patb.hotkey_actor_count = length;
  189.     for (var index = 0; index < length; index++) {
  190.         this._patb["hotkey_actor_" + index.toString()] = hotkeys[index];
  191.     }
  192.     //
  193. }; // Game_System.prototype.init_patb_params
  194.  
  195. /*----------------------------------------------------------------------------
  196.  *    # Edit class: Window_ActorCommand                                      
  197.  *----------------------------------------------------------------------------*/
  198.  
  199. Window_ActorCommand.prototype.processHandling = function() { // New
  200.     Window_Selectable.prototype.processHandling.call(this);
  201.     if (!this.isOpenAndActive()) { return; }
  202.     var patb = $gameSystem.patb, hotkey;
  203.     var prior = patb.prior_inputable_actor, next = patb.next_inputable_actor;
  204.     this.process_patb_hotkey(prior);
  205.     this.process_patb_hotkey(next);
  206.     for (var i = 0, length = patb.hotkey_actor_count; i < length; i++) {
  207.         hotkey = patb["hotkey_actor_" + i.toString()];
  208.         if (Input.isTriggered(hotkey)) { this.callHandler(hotkey); };
  209.     }
  210. }; // Window_ActorCommand.prototype.processHandling
  211.  
  212. // hotkey: The hotkey to be processed
  213. Window_ActorCommand.prototype.process_patb_hotkey = function(hotkey) { // New
  214.     if (!Input.isTriggered(hotkey) && !Input.isRepeated(hotkey)) { return; }
  215.     this.callHandler(hotkey);
  216. }; // Window_ActorCommand.prototype.process_patb_hotkey
  217.  
  218. /*----------------------------------------------------------------------------
  219.  *    # Edit class: Scene_Battle                                              
  220.  *----------------------------------------------------------------------------*/
  221.  
  222. Scene_Battle.prototype.createActorCommandWindowPatbHotkey =
  223. Scene_Battle.prototype.createActorCommandWindow;
  224. Scene_Battle.prototype.createActorCommandWindow = function() {
  225.     this.createActorCommandWindowPatbHotkey();
  226.     this.set_patb_hotkey_handler();
  227. }; // Scene_Battle.prototype.createActorCommandWindow
  228.  
  229. Scene_Battle.prototype.set_patb_hotkey_handler = function() { // New
  230.     var patb = $gameSystem.patb, h_p_n = this.set_patb_hotkey_prior_next_actor;
  231.     var prior = patb.prior_inputable_actor, next = patb.next_inputable_actor;
  232.     this._actorCommandWindow.setHandler(prior, h_p_n.bind(this, -1));
  233.     this._actorCommandWindow.setHandler(next, h_p_n.bind(this, 1));
  234.     var h_i = this.set_patb_hotkey_index_actor, hotkey;
  235.     for (var i = 0, length = patb.hotkey_actor_count; i < length; i++) {
  236.         hotkey = patb["hotkey_actor_" + i.toString()];
  237.         this._actorCommandWindow.setHandler(hotkey, h_i.bind(this, i));
  238.     }
  239. }; // Scene_Battle.prototype.set_patb_hotkey_handler
  240.  
  241. // sign: The direction to search for new inputable actors
  242. Scene_Battle.prototype.set_patb_hotkey_prior_next_actor = function(sign) {
  243.     var actor_indices = BattleManager.action_battlers.filter(function(battler) {
  244.         return battler.canInput() && battler !== BattleManager.actor();
  245.     }).map(function(battler) { return battler.index(); });
  246.     var length = actor_indices.length;
  247.     if (length <= 0) { return SoundManager.playBuzzer(); }
  248.     SoundManager.playCursor();
  249.     this.close_patb_selection_windows();
  250.     if (length > 1) {
  251.         actor_indices.sort(function(a, b) { return (a - b) * sign; });
  252.         var actor_index = BattleManager.actor().index();
  253.         for (var index = 0; index < length; index++) {
  254.             if (actor_indices[index] * sign > actor_index * sign) {
  255.                 BattleManager.changeActor(actor_indices[index], 'waiting');
  256.                 return this.startActorCommandSelection();
  257.             }
  258.         }
  259.     }
  260.     BattleManager.changeActor(actor_indices[0], 'waiting');
  261.     this.startActorCommandSelection();
  262. }; // Scene_Battle.prototype.set_patb_hotkey_prior_next_actor
  263.  
  264. // index: The party member index of the actor to be setup
  265. Scene_Battle.prototype.set_patb_hotkey_index_actor = function(index) {
  266.     var actor = $gameParty.battleMembers()[index];
  267.     if (BattleManager.actor() === actor) { return SoundManager.playBuzzer(); }
  268.     if (!actor || !actor.canInput()) { return SoundManager.playBuzzer(); }
  269.     var actor_index = BattleManager.action_battlers.indexOf(actor);
  270.     if (actor_index < 0) { return SoundManager.playBuzzer(); }
  271.     SoundManager.playCursor();
  272.     this.close_patb_selection_windows();
  273.     BattleManager.changeActor(index, 'waiting');
  274.     this.startActorCommandSelection();
  275. }; // Scene_Battle.prototype.set_patb_hotkey_index_actor
  276.  
  277. /*----------------------------------------------------------------------------*/
  278.  
  279. } else {
  280.     alert("To use PATB Hotkey, place it below PATB Core.");
  281. }
  282.  
  283. /*============================================================================*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement