Advertisement
Double_X

DoubleX RMMV Popularized ATB SE v100b

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