SHARE
TWEET

DoubleX RMMV Popularized ATB SE v100b

Double_X Nov 27th, 2015 (edited) 213 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 SE                                      
  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/1WAnkLrW                                      
  22.  *      Video:                                                                
  23.  *      1. https://www.youtube.com/watch?v=n2kzUs1xMvY                        
  24.  *----------------------------------------------------------------------------
  25.  *    # Author                                                                
  26.  *      DoubleX                                                              
  27.  *----------------------------------------------------------------------------
  28.  *    # Changelog                                                            
  29.  *      v1.00b(GMT 1300 31-8-2016):                                          
  30.  *      1. In sync with the latest DoubleX RMMV Popularized ATB Core version  
  31.  *      v1.00a(GMT 0800 23-1-2016):                                          
  32.  *      1. Fixed not loading this plugin's notetag bug                        
  33.  *      2. Increased this plugin's compactness                                
  34.  *      3. 1st completed version of this plugin finished                      
  35.  *      v0.00b(GMT 0700 29-11-2015):                                          
  36.  *      1. Increased this plugin's compactness and readability                
  37.  *      v0.00a(GMT 0400 28-11-2015):                                          
  38.  *      1. 1st testing version of this plugin finished                        
  39.  *============================================================================*/
  40. /*:
  41.  * @plugindesc Lets users add SE to be played when battlers become able to act
  42.  * @author DoubleX
  43.  *
  44.  * @param battler_can_act_se_file
  45.  * @desc Sets the filename of the se to be played when battlers become able to
  46.  *       act as battler_can_act_se_file
  47.  *       It'll only be used on battlers having no effective
  48.  *       <patb can act se: file, vol, pitch, pan> notetags
  49.  *       If battler_can_act_se_file doesn't return an existing se filename,
  50.  *       the default will be not playing se when battlers become able to act
  51.  * @default Bell3
  52.  *
  53.  * @param battler_can_act_se_vol
  54.  * @desc Sets the volume of the se to be played when battlers become able to
  55.  *       act as battler_can_act_se_vol
  56.  *       It'll only be used on battlers having no effective
  57.  *       <patb can act se: file, vol, pitch, pan> notetags
  58.  *       battler_can_act_se_vol must return a Number between 0 and 100
  59.  * @default 80
  60.  *
  61.  * @param battler_can_act_se_pitch
  62.  * @desc Sets the pitch of the se to be played when battlers become able to
  63.  *       act as battler_can_act_se_pitch
  64.  *       It'll only be used on battlers having no effective                  
  65.  *       <patb can act se: file, vol, pitch, pan> notetags          
  66.  *       battler_can_act_se_pitch must return a Number between 50 and 150
  67.  * @default 100
  68.  *
  69.  * @param battler_can_act_se_pan
  70.  * @desc Sets the pan of the se to be played when battlers become able to
  71.  *       act as battler_can_act_se_pan
  72.  *       It'll only be used on battlers having no effective                  
  73.  *       <patb can act se: file, vol, pitch, pan> notetags          
  74.  *       battler_can_act_se_pan must return a Number between -100 and 100
  75.  * @default 0
  76.  *
  77.  * @help
  78.  * The default plugin file name is DoubleX RMMV Popularized ATB SE v100b
  79.  * If you want to change that, you must edit the value of
  80.  * DoubleX_RMMV.PATB_SE_File, which must be done via opening this plugin js
  81.  * file directly
  82.  *============================================================================
  83.  *    ## Notetag Info                                                        
  84.  *----------------------------------------------------------------------------
  85.  *    # Actor/Class/Weapon/Armor/Enemy/State Notetags:                        
  86.  *      State notetags take the highest priority, followed by enemy, weapon,  
  87.  *      armor, class and actor                                                
  88.  *      1. <patb can act se: file, vol, pitch, pan>                        
  89.  *         - Sets the filename, volume, pitch and pan of the se to be played  
  90.  *           when the battler becomes able to act as file, vol, pitch and pan
  91.  *           respectively                                                    
  92.  *         - The 1st notetag that's being read by the battler will be used    
  93.  *============================================================================
  94.  *    ## Plugin Call Info                                                    
  95.  *----------------------------------------------------------------------------
  96.  *    # Configuration manipulations                                          
  97.  *      1. $gameSystem.patb.param                                            
  98.  *         - Returns the value of param listed in the plugin manager          
  99.  *      2. $gameSystem.patb.param = val                                      
  100.  *         - Sets the value of param listed in the plugin manager as val      
  101.  *         - All $gameSystem.patb.param changes will be saved                
  102.  *    # State manipulations                                                  
  103.  *      1. meta.patb_can_act_se                                              
  104.  *         - Returns the filename, volume, pitch and pan in                  
  105.  *           <patb can act se: file, vol, pitch, pan> in the form of        
  106.  *           [file, vol, pitch, pan]                                          
  107.  *      2. meta.patb_can_act_se = [file, vol, pitch, pan]                    
  108.  *         - Sets the filename, volume, pitch and pan in                      
  109.  *           <patb can act se: file, vol, pitch, pan> as                    
  110.  *           file, vol, pitch and pan                                        
  111.  *         - All meta.patb_can_act_se changes can be saved if                
  112.  *           DoubleX RMMV Dynamic Data is used                                
  113.  *============================================================================
  114.  */
  115.  
  116. "use strict";
  117. var DoubleX_RMMV = DoubleX_RMMV || {};
  118. DoubleX_RMMV["PATB SE"] = "v1.00b";
  119.  
  120. // The plugin file name must be the same as DoubleX_RMMV.PATB_SE_File
  121. DoubleX_RMMV.PATB_SE_File = "DoubleX RMMV Popularized ATB SE v100b";
  122.  
  123. /*============================================================================
  124.  *    ## Plugin Implementations                                              
  125.  *       You need not edit this part as it's about how this plugin works      
  126.  *----------------------------------------------------------------------------
  127.  *    # Plugin Support Info:                                                  
  128.  *      1. Prerequisites                                                      
  129.  *         - Basic knowledge of this plugin on the user level, the default    
  130.  *           battle system implementations and the atb system concepts        
  131.  *         - Some Javascript coding proficiency to fully comprehend this      
  132.  *           plugin                                                          
  133.  *      2. Function documentation                                            
  134.  *         - The 1st part describes why this function's rewritten/extended for
  135.  *           rewritten/extended functions or what the function does for new  
  136.  *           functions                                                        
  137.  *         - The 2nd part describes what the arguments of the function are    
  138.  *         - The 3rd part informs which version rewritten, extended or created
  139.  *           this function                                                    
  140.  *         - The 4th part informs whether the function's rewritten or new    
  141.  *         - The 5th part informs whether the function's a real or potential  
  142.  *           hotspot                                                          
  143.  *         - The 6th part describes how this function works for new functions
  144.  *           only, and describes the parts added, removed or rewritten for    
  145.  *           rewritten or extended functions only                            
  146.  *         Example:                                                          
  147.  * /*----------------------------------------------------------------------
  148.  *  *    Why rewrite/extended/What this function does                      
  149.  *  *----------------------------------------------------------------------*/
  150. /* // arguments: What these arguments are                                    
  151.  * function_name = function(arguments) { // Version X+; Rewrite/New; Hotspot  
  152.  *     // Added/Removed/Rewritten to do something/How this function works    
  153.  *     function_name_code;                                                    
  154.  *     //                                                                    
  155.  * } // function_name                                                        
  156.  *----------------------------------------------------------------------------*/
  157.  
  158. if (DoubleX_RMMV["PATB Core"]) {
  159.  
  160. /*----------------------------------------------------------------------------*/
  161.  
  162. /*----------------------------------------------------------------------------
  163.  *    # Edit class: DataManager                                              
  164.  *----------------------------------------------------------------------------*/
  165.  
  166. // data: The data to have its notetags read
  167. DataManager.load_patb_se_data_notes = DataManager.load_patb_data_notes;
  168. DataManager.load_patb_data_notes = function(data) {
  169.     this.load_patb_se_data_notes(data);
  170.     this.load_patb_se_notes(data); // Added
  171. }; // DataManager.load_patb_data_notes
  172.  
  173. // data: The data to have its notetags read
  174. DataManager.load_patb_se_notes = function(data) { // New
  175.     var lines = data.note.split(/[\r\n]+/), m = data.meta, se;
  176.     se = /< *patb +can +act +se *: *(\w+) *, *(\d+) *, *(\d+) *, *(\d+) *>/i;
  177.     for (var index = 0, length = lines.length; index < length; index++) {
  178.         if (!lines[index].match(se)) { continue; }
  179.         m.patb_can_act_se = [RegExp.$1, +RegExp.$2, +RegExp.$3, +RegExp.$4];
  180.         return;
  181.     }
  182. }; // DataManager.load_patb_se_notes
  183.  
  184. /*----------------------------------------------------------------------------
  185.  *    # (v1.00b+)Edit class: BattleManager                                    
  186.  *----------------------------------------------------------------------------*/
  187.  
  188. // battler: The battler to be makred as actable
  189. BattleManager.add_patb_se_action_battler =
  190. BattleManager.add_patb_action_battler;
  191. BattleManager.add_patb_action_battler = function(battler) {
  192.     var s, actable = this._actionBattlers.indexOf(battler) >= 0; // Added
  193.     this.add_patb_se_action_battler(battler);
  194.     // Added
  195.     if (actable) { return; }
  196.     s = battler.patb_can_act_se();
  197.     AudioManager.playSe({ name: s[0], volume: s[1], pitch: s[2], pan: s[3] });
  198.     //
  199. }; // BattleManager.add_patb_action_battler
  200.  
  201. /*----------------------------------------------------------------------------
  202.  *    # Edit class: Game_System                                              
  203.  *      - Stores the values of all configurations listed in the plugin manager
  204.  *----------------------------------------------------------------------------*/
  205.  
  206. Game_System.prototype.init_patb_se_params =
  207. Game_System.prototype.init_patb_params;
  208. Game_System.prototype.init_patb_params = function() {
  209.     this.init_patb_se_params();
  210.     // Added
  211.     var val, params;
  212.     params = PluginManager.parameters(DoubleX_RMMV.PATB_SE_File);
  213.     Object.keys(params).forEach(function(param) {
  214.         val = +params[param];
  215.         this._patb[param] = isNaN(val) ? params[param] : val;
  216.     }, this);
  217.     //
  218. }; // Game_System.prototype.init_patb_params
  219.  
  220. /*----------------------------------------------------------------------------
  221.  *    # Edit class: Game_Battler                                              
  222.  *----------------------------------------------------------------------------*/
  223.  
  224. /*----------------------------------------------------------------------------
  225.  *    New private instance variable                                          
  226.  *----------------------------------------------------------------------------*/
  227. // _patb_can_act_se: The array of battler can act se file, volume, pitch and pan
  228.  
  229. Game_Battler.prototype.make_patb_act_se = Game_Battler.prototype.make_patb_act;
  230. Game_Battler.prototype.make_patb_act = function() {
  231.     var s, actable = BattleManager.action_battlers.indexOf(this) >= 0; // Added
  232.     this.make_patb_act_se();
  233.     // Added
  234.     if (actable) { return; }
  235.     s = this.patb_can_act_se();
  236.     AudioManager.playSe({ name: s[0], volume: s[1], pitch: s[2], pan: s[3] });
  237.     //
  238. }; // Game_Battler.prototype.make_patb_act
  239.  
  240. Game_Battler.prototype.init_patb_se = Game_Battler.prototype.init_patb;
  241. Game_Battler.prototype.init_patb = function() {
  242.     this.init_patb_se();
  243.     // Added
  244.     this._patb_battler_change.can_act_se = true;
  245.     this._patb_note_change.can_act_se = true;
  246.     //
  247. }; // Game_Battler.prototype.init_patb
  248.  
  249. /*----------------------------------------------------------------------------
  250.  *    Rereads the effective can act se notetag only if its values can change  
  251.  *----------------------------------------------------------------------------*/
  252. Game_Battler.prototype.patb_can_act_se = function() { // New
  253.     if (this.are_patb_battler_changed("can_act_se")) {
  254.         this.set_patb_can_act_se();
  255.     }
  256.     return this._patb_can_act_se;
  257. }; // Game_Battler.prototype.patb_can_act_se
  258.  
  259. Game_Battler.prototype.set_patb_can_act_se = function() { // New
  260.     this._patb_can_act_se = this.set_patb_notes("patb_can_act_se");
  261.     if (this._patb_can_act_se) { return; }
  262.     var patb = $gameSystem.patb, file = patb.battler_can_act_se_file;
  263.     var vol = patb.battler_can_act_se_vol, pan = patb.battler_can_act_se_pan;
  264.     var pitch = patb.battler_can_act_se_pitch;
  265.     this._patb_can_act_se = [file, vol, pitch, pan];
  266. }; // Game_Battler.prototype.set_patb_can_act_se
  267.  
  268. /*----------------------------------------------------------------------------*/
  269.  
  270. } else {
  271.     alert("To use PATB SE, place it below PATB Core.");
  272. }
  273.  
  274. /*============================================================================*/
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top