Double_X

DoubleX RMMV Targeting Hotkeys v100a

Aug 14th, 2016
259
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 Targeting Hotkeys                                        
  6.  *----------------------------------------------------------------------------
  7.  *    # Terms Of Use                                                          
  8.  *      1. Commercial use's always allowed and crediting me's always optional.
  9.  *      2. You shall keep this plugin's Plugin Info part's contents intact.  
  10.  *      3. You shalln't claim that this plugin's written by anyone other than
  11.  *         DoubleX or my aliases. I always reserve the right to deny you from
  12.  *         using any of my plugins anymore if you've violated this.          
  13.  *      4. CC BY 4.0, except those conflicting with any of the above, applies
  14.  *         to this plugin, unless you've my permissions not needing follow so.
  15.  *      5. I always reserve the right to deny you from using this plugin      
  16.  *         anymore if you've violated any of the above.                      
  17.  *----------------------------------------------------------------------------
  18.  *    # Prerequisites                                                        
  19.  *      Abilities:                                                            
  20.  *      1. Nothing special for most ordinary use cases                        
  21.  *      2. Little Javascript coding proficiency to fully utilize this plugin  
  22.  *----------------------------------------------------------------------------
  23.  *    # Links                                                                
  24.  *      This plugin:                                                          
  25.  *      1. http://pastebin.com/9X4H8K8A                                      
  26.  *----------------------------------------------------------------------------
  27.  *    # Author                                                                
  28.  *      DoubleX                                                              
  29.  *----------------------------------------------------------------------------
  30.  *    # Changelog                                                            
  31.  *      v1.00a(GMT 0900 14-8-2016):                                          
  32.  *      1. 1st version of this plugin finished                                
  33.  *============================================================================*/
  34. /*:
  35.  * @plugindesc Lets you set some hotkeys selecting actor/enemy target by index
  36.  * @author DoubleX
  37.  *
  38.  * @help
  39.  * You're supposed to edit this plugin js file directly
  40.  *============================================================================
  41.  *    ## Plugin Call Info                                                    
  42.  *----------------------------------------------------------------------------
  43.  *    # Configuration manipulations                                          
  44.  *      1. $gameSystem.targetingHotkeys[index]                                
  45.  *         - Returns the keyboard mapping of hotkey selecting the actor/enemy
  46.  *           with the specified member index as the target                    
  47.  *      2. $gameSystem.targetingHotkeys[index] = keyboardMapping              
  48.  *         - Sets the keyboard mapping of hotkey selecting the actor/enemy    
  49.  *           with the specified member index as the target as keyboardMapping
  50.  *         - All $gameSystem.targetingHotkeys[index] changes will be saved    
  51.  *============================================================================
  52.  */
  53.  
  54. var DoubleX_RMMV = DoubleX_RMMV || {};
  55. DoubleX_RMMV['Targeting Hotkeys'] = 'v1.00a';
  56.  
  57. DoubleX_RMMV.Targeting_Hotkeys = {
  58.  
  59.     /* Sets hotkeys selecting the actor/enemy target with the specified index
  60.      * None of these hotkeys are supposed to be changed during the same battle
  61.      * Each hotkey will be referenced by $gameSystem.targetingHotkeys[index],
  62.      * where index is the index of the hotkey
  63.      * The ith hotkey will try to select the actor/enemy target with index i - 1
  64.      * Each of these hotkey must be a String
  65.      * Using a keyboard mapping plugin, like Quasi Input, can be useful here
  66.      */
  67.     hotkeys: [
  68.         "#1", // Referenced by $gameSystem.targetingHotkeys[0]
  69.         "#2", // Referenced by $gameSystem.targetingHotkeys[1]
  70.         "#3", // Referenced by $gameSystem.targetingHotkeys[2]
  71.         "#4", // Referenced by $gameSystem.targetingHotkeys[3]
  72.         "#5", // Referenced by $gameSystem.targetingHotkeys[4]
  73.         "#6", // Referenced by $gameSystem.targetingHotkeys[5]
  74.         "#7", // Referenced by $gameSystem.targetingHotkeys[6]
  75.         "#8", // Referenced by $gameSystem.targetingHotkeys[7]
  76.         "#9", // Referenced by $gameSystem.targetingHotkeys[8]
  77.         "#0" // Referenced by $gameSystem.targetingHotkeys[9]
  78.     ]
  79.  
  80. }; // DoubleX_RMMV.Targeting_Hotkeys
  81.  
  82. /*============================================================================
  83.  *    ## Plugin Implementations                                              
  84.  *       You need not edit this part as it's about how this plugin works      
  85.  *----------------------------------------------------------------------------
  86.  *    # Plugin Support Info:                                                  
  87.  *      1. Prerequisites                                                      
  88.  *         - Little plugin development proficiency to fully comprehend this  
  89.  *           plugin                                                          
  90.  *----------------------------------------------------------------------------*/
  91.  
  92. (function(TH) {
  93.  
  94.     'use strict';
  95.  
  96.     TH.Game_System = {};
  97.     var GS = TH.Game_System;
  98.  
  99.     GS.initialize = Game_System.prototype.initialize;
  100.     Game_System.prototype.initialize = function() { // v1.00a - v1.00a
  101.         GS.initialize.apply(this, arguments);
  102.         GS.initializeTargetingHotkeys.call(this); // Added
  103.     }; // Game_System.prototype.initialize
  104.  
  105.     /* Initializes the hotkey mappings that will be stored in save files
  106.      * Functional cohesion/Message coupling/Idempotent
  107.      */
  108.     GS.initializeTargetingHotkeys = function() { // v1.00a - v1.00a
  109.         this.targetingHotkeys = TH.hotkeys;
  110.     }; // GS.initializeTargetingHotkeys
  111.  
  112.     /* Selects the ith actor/enemy target when the (i - 1)th hotkey's pressed
  113.      * Functional cohesion/Message coupling/Idempotent
  114.      */
  115.     var windows = [Window_BattleActor.prototype, Window_BattleEnemy.prototype];
  116.     windows.forEach(function(window) {
  117.         window.processHandling = function() { // v1.00a - v1.00a
  118.             Window_Selectable.prototype.processHandling.call(this);
  119.             if (!this.isOpenAndActive()) { return; }
  120.             var hotkeys = $gameSystem.targetingHotkeys;
  121.             for (var i = 0, length = hotkeys.length; i < length; i++) {
  122.                 if (Input.isTriggered(hotkeys[i])) { this.select([i]); };
  123.             }
  124.         }; // Window_ActorCommand.prototype.processHandling
  125.     });
  126.  
  127. })(DoubleX_RMMV.Targeting_Hotkeys);
  128.  
  129. /*============================================================================*/
RAW Paste Data