Advertisement
Double_X

DoubleX RMMV Popularized ATB Event v100b

Nov 28th, 2015 (edited)
707
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 Event                                    
  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/QxbNQttB                                      
  22.  *      Mentioned Patreon Supporters:
  23.  *      https://www.patreon.com/posts/71738797
  24.  *----------------------------------------------------------------------------
  25.  *    # Author                                                                
  26.  *      DoubleX                                                              
  27.  *----------------------------------------------------------------------------
  28.  *    # Changelog                                                            
  29.  *      v1.00b(GMT 0200 20-2-2016):                                          
  30.  *      1. Improved this plugin's performance, readability and simplicity    
  31.  *      v1.00a(GMT 0200 7-2-2016):                                            
  32.  *      1. 1st completed version of this plugin finished                      
  33.  *      v0.00b(GMT 0700 29-11-2015):                                          
  34.  *      1. Increased this plugin's compactness                                
  35.  *      v0.00a(GMT 0900 28-11-2015):                                          
  36.  *      1. 1st testing version of this plugin finished                        
  37.  *============================================================================*/
  38. /*:
  39.  * @plugindesc Lets users calls some common events at some specific atb timing
  40.  * @author DoubleX
  41.  *
  42.  * @param pre_input_common_event_id
  43.  * @desc Sets the common event with id pre_input_common_event_id to be called
  44.  *       whenever a battler just becomes able to act
  45.  *       pre_input_common_event_id must return a Number
  46.  *       If pre_input_common_event_id doesn't return the id of an existing
  47.  *       common event, no common event will be called with this timing
  48.  * @default 0
  49.  *
  50.  * @param post_input_common_event_id
  51.  * @desc Sets the common event with id post_input_common_event_id to be called
  52.  *       whenever a battler just finished inputting actions
  53.  *       post_input_common_event_id must return a Number
  54.  *       If post_input_common_event_id doesn't return the id of an existing
  55.  *       common event, no common event will be called with this timing
  56.  * @default 0
  57.  *
  58.  * @param pre_reset_common_event_id
  59.  * @desc Sets the common event with id pre_reset_common_event_id to be called
  60.  *       right before resetting a battler's atb
  61.  *       pre_reset_common_event_id must return a Number
  62.  *       If pre_reset_common_event_id doesn't return the id of an existing
  63.  *       common event, no common event will be called with this timing
  64.  * @default 0
  65.  *
  66.  * @param post_reset_common_event_id
  67.  * @desc Sets the common event with id post_reset_common_event_id to be called
  68.  *       right after resetting a battler's atb
  69.  *       post_reset_common_event_id must return a Number
  70.  *       If post_reset_common_event_id doesn't return the id of an existing
  71.  *       common event, no common event will be called with this timing
  72.  * @default 0
  73.  *
  74.  * @param pre_update_common_event_id
  75.  * @desc Sets the common event with id pre_update_common_event_id to be called
  76.  *       right before running a global atb frame update
  77.  *       pre_update_common_event_id must return a Number
  78.  *       If pre_update_common_event_id doesn't return the id of an existing
  79.  *       common event, no common event will be called with this timing
  80.  * @default 0
  81.  *
  82.  * @param post_update_common_event_id
  83.  * @desc Sets the common event with id post_update_common_event_id to be called
  84.  *       right after running a global atb frame update
  85.  *       post_update_common_event_id must return a Number
  86.  *       If post_update_common_event_id doesn't return the id of an existing
  87.  *       common event, no common event will be called with this timing
  88.  * @default 0
  89.  *
  90.  * @help
  91.  * The default plugin file name is DoubleX RMMV Popularized ATB Event v100b
  92.  * If you want to change that, you must edit the value of
  93.  * DoubleX_RMMV.PATB_Event_File, which must be done via opening the plugin js
  94.  * file directly
  95.  *============================================================================
  96.  *    ## Plugin Call Info                                                    
  97.  *----------------------------------------------------------------------------
  98.  *    # Configuration manipulations                                          
  99.  *      1. $gameSystem.patb.param                                            
  100.  *         - Returns the value of param listed in the plugin manager          
  101.  *      2. $gameSystem.patb.param = val                                      
  102.  *         - Sets the value of param listed in the plugin manager as val      
  103.  *         - All $gameSystem.patb.param changes will be saved                
  104.  *============================================================================
  105.  */
  106.  
  107. "use strict";
  108. var DoubleX_RMMV = DoubleX_RMMV || {};
  109. DoubleX_RMMV["PATB Event"] = "v1.00b";
  110.  
  111. // The plugin file name must be the same as DoubleX_RMMV.PATB_Event_File
  112. DoubleX_RMMV.PATB_Event_File = "DoubleX RMMV Popularized ATB Event v100b";
  113.  
  114. /*============================================================================
  115.  *    ## Plugin Implementations                                              
  116.  *       You need not edit this part as it's about how this plugin works      
  117.  *----------------------------------------------------------------------------
  118.  *    # Plugin Support Info:                                                  
  119.  *      1. Prerequisites                                                      
  120.  *         - Basic knowledge of this plugin on the user level, the default    
  121.  *           battle system implementations and the atb system concepts        
  122.  *         - Some Javascript coding proficiency to fully comprehend this      
  123.  *           plugin                                                          
  124.  *      2. Function documentation                                            
  125.  *         - The 1st part describes why this function's rewritten/extended for
  126.  *           rewritten/extended functions or what the function does for new  
  127.  *           functions                                                        
  128.  *         - The 2nd part describes what the arguments of the function are    
  129.  *         - The 3rd part informs which version rewritten, extended or created
  130.  *           this function                                                    
  131.  *         - The 4th part informs whether the function's rewritten or new    
  132.  *         - The 5th part informs whether the function's a real or potential  
  133.  *           hotspot                                                          
  134.  *         - The 6th part describes how this function works for new functions
  135.  *           only, and describes the parts added, removed or rewritten for    
  136.  *           rewritten or extended functions only                            
  137.  *         Example:                                                          
  138.  * /*----------------------------------------------------------------------
  139.  *  *    Why rewrite/extended/What this function does                      
  140.  *  *----------------------------------------------------------------------*/
  141. /* // arguments: What these arguments are                                    
  142.  * function_name = function(arguments) { // Version X+; Rewrite/New; Hotspot  
  143.  *     // Added/Removed/Rewritten to do something/How this function works    
  144.  *     function_name_code;                                                    
  145.  *     //                                                                    
  146.  * } // function_name                                                        
  147.  *----------------------------------------------------------------------------*/
  148.  
  149. if (DoubleX_RMMV["PATB Core"]) {
  150.  
  151. /*----------------------------------------------------------------------------*/
  152.  
  153. /*----------------------------------------------------------------------------
  154.  *    # Edit class: Game_Temp                                                
  155.  *----------------------------------------------------------------------------*/
  156.  
  157. // timing: The common event trigger timing
  158. Game_Temp.prototype.call_patb_event = function(timing) { // New
  159.     var id = $gameSystem.patb[timing + "_common_event_id"];
  160.     if ($dataCommonEvents[id]) { this.reserveCommonEvent(id); }
  161. }; // Game_Temp.prototype.call_patb_event
  162.  
  163. /*----------------------------------------------------------------------------
  164.  *    # Edit class: Game_System                                              
  165.  *      - Stores the values of all configurations listed in the plugin manager
  166.  *----------------------------------------------------------------------------*/
  167.  
  168. Game_System.prototype.init_patb_event_params =
  169. Game_System.prototype.init_patb_params;
  170. Game_System.prototype.init_patb_params = function() {
  171.     this.init_patb_event_params();
  172.     // Added
  173.     var params = PluginManager.parameters(DoubleX_RMMV.PATB_Event_File);
  174.     Object.keys(params).forEach(function(param) {
  175.         this._patb[param] = +params[param];
  176.         if (isNaN(this._patb[param])) {
  177.             throw new Error(param + " must be Number but is: " + params[param]);
  178.         }
  179.     }, this);
  180.     //
  181. }; // Game_System.prototype.init_patb_params
  182.  
  183. /*----------------------------------------------------------------------------
  184.  *    # Edit class: Game_Battler                                              
  185.  *----------------------------------------------------------------------------*/
  186.  
  187. Game_Battler.prototype.make_patb_act_event =
  188. Game_Battler.prototype.make_patb_act;
  189. Game_Battler.prototype.make_patb_act = function() {
  190.     // Added
  191.     if (BattleManager.action_battlers.indexOf(this) < 0) {
  192.         $gameTemp.call_patb_event("pre_input");
  193.     }
  194.     //
  195.     this.make_patb_act_event();
  196. }; // Game_Battler.prototype.make_patb_act
  197.  
  198. Game_Battler.prototype.reset_patb_event = Game_Battler.prototype.reset_patb;
  199. Game_Battler.prototype.reset_patb = function() {
  200.     $gameTemp.call_patb_event("pre_reset"); // Added
  201.     this.reset_patb_event();
  202.     $gameTemp.call_patb_event("post_reset"); // Added
  203. }; // Game_Battler.prototype.reset_patb
  204.  
  205. /*----------------------------------------------------------------------------
  206.  *    # Edit class: Game_Actor                                                
  207.  *----------------------------------------------------------------------------*/
  208.  
  209. Game_Actor.prototype.makeAutoBattleActionsPatbEvent =
  210. Game_Actor.prototype.makeAutoBattleActions;
  211. Game_Actor.prototype.makeAutoBattleActions = function() {
  212.     this.makeAutoBattleActionsPatbEvent();
  213.     // Added
  214.     if ($gameSystem.is_patb()) { $gameTemp.call_patb_event("post_input"); }
  215.     //
  216. }; // Game_Actor.prototype.makeAutoBattleActions
  217.  
  218. Game_Actor.prototype.makeConfusionActionsPatbEvent =
  219. Game_Actor.prototype.makeConfusionActions ;
  220. Game_Actor.prototype.makeConfusionActions = function() {
  221.     this.makeConfusionActionsPatbEvent();
  222.     // Added
  223.     if ($gameSystem.is_patb()) { $gameTemp.call_patb_event("post_input"); }
  224.     //
  225. }; // Game_Actor.prototype.makeConfusionActions
  226.  
  227. /*----------------------------------------------------------------------------
  228.  *    # Edit class: Game_Enemy                                                
  229.  *----------------------------------------------------------------------------*/
  230.  
  231. Game_Enemy.prototype.makeActionsPatbEvent = Game_Enemy.prototype.makeActions;
  232. Game_Enemy.prototype.makeActions = function() {
  233.     this.makeActionsPatbEvent();
  234.     // Added
  235.     if ($gameSystem.is_patb()) { $gameTemp.call_patb_event("post_input"); }
  236.     //
  237. }; // Game_Enemy.prototype.makeActions
  238.  
  239. /*----------------------------------------------------------------------------
  240.  *    # Edit class: Scene_Battle                                              
  241.  *----------------------------------------------------------------------------*/
  242.  
  243. Scene_Battle.prototype.update_patb_event = Scene_Battle.prototype.update_patb;
  244. Scene_Battle.prototype.update_patb = function() { // Hotspot
  245.     $gameTemp.call_patb_event("pre_update"); // Added
  246.     this.update_patb_event();
  247.     $gameTemp.call_patb_event("post_update"); // Added
  248. }; // Scene_Battle.prototype.update_patb
  249.  
  250. Scene_Battle.prototype.confirm_patb_event_act =
  251. Scene_Battle.prototype.confirm_patb_act;
  252. Scene_Battle.prototype.confirm_patb_act = function() {
  253.     this.confirm_patb_event_act();
  254.     $gameTemp.call_patb_event("post_input"); // Added
  255. }; // Scene_Battle.prototype.confirm_patb_act
  256.  
  257. /*----------------------------------------------------------------------------*/
  258.  
  259. } else {
  260.     alert("To use PATB Event, place it below PATB Core.");
  261. }
  262.  
  263. /*============================================================================*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement