Advertisement
Double_X

DoubleX RMMV Popularized ATB Charge v103b

Feb 8th, 2016 (edited)
653
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 Charge
  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/mgtuHVSt
  22.  *      Video:
  23.  *      1. https://www.youtube.com/watch?v=2T6cnXh_r7c
  24.  *      Mentioned Patreon Supporters:
  25.  *      https://www.patreon.com/posts/71738797
  26.  *----------------------------------------------------------------------------
  27.  *    # Author
  28.  *      DoubleX
  29.  *----------------------------------------------------------------------------
  30.  *    # Changelog
  31.  *      v1.03b(GMT 1400 15-6-2020):
  32.  *      1. Added battler manipulation plugin call fill_up_patb_charge()
  33.  *      v1.03a(GMT 1100 22-8-2017):
  34.  *      1. Lets users cancel all skills/items of the selected charging actor
  35.  *      v1.02a(GMT 1500 12-8-2016):
  36.  *      1. Added post_charge_common_event_id
  37.  *      2. In sync with the latest DoubleX RMMV Popularized ATB Core version
  38.  *      v1.01a(GMT 1000 20-2-2016):
  39.  *      1. Lets users set the charge bar description text via notetags
  40.  *      2. Lets users set skill/item to be charged before paying its costs
  41.  *      3. Fixed not refreshing the battler upon starting/ending charging bug
  42.  *      v1.00a(GMT 0500 9-2-2016):
  43.  *      1. 1st testing version of this plugin finished
  44.  *============================================================================*/
  45. /*:
  46.  * @plugindesc Lets users set skills/items to need time to charge before using
  47.  * @author DoubleX
  48.  *
  49.  * @param charge_c1
  50.  * @desc Sets the 1st atb charge bar color as text color charge_c1
  51.  *       charge_c1 must return a valid text color code
  52.  *       charge_c1 should return the same value during the same battle to
  53.  *       ensure proper atb charge bar color displays
  54.  * @default 30
  55.  *
  56.  * @param charge_c2
  57.  * @desc Sets the 2nd atb charge bar color as text color charge_c2
  58.  *       charge_c2 must return a valid text color code
  59.  *       charge_c2 should return the same value during the same battle to
  60.  *       ensure proper atb charge bar color displays
  61.  * @default 31
  62.  *
  63.  * @param charge_bar_text
  64.  * @desc Sets the code of the charge bar description text as charge_bar_text
  65.  *       It'll only be used if no <patb charge text: text> notetag's used
  66.  *       Available charge_bar_text code:
  67.  *       item - The name of the currently charging skill/item will be the charge
  68.  *              bar description text
  69.  *       Setting charge_bar_text as an unavailable code means atb_bar_text
  70.  *       will be the charge bar description text
  71.  *       charge_bar_text should return the same code during the same battle to
  72.  *       ensure proper charge bar text displays
  73.  * @default item
  74.  *
  75.  * @param charge_prior_item_cost
  76.  * @desc Sets the skill/item charging to take place before paying its costs if
  77.  *       charge_prior_item_cost is true
  78.  *       It'll only be used if no <patb charge prior item cost> notetag's used
  79.  *       charge_prior_item_cost should return the same value for the same action
  80.  * @default true
  81.  *
  82.  * @param post_charge_common_event_id
  83.  * @desc Sets the common event with id ppost_charge_common_event_id to be
  84.  *       called right after a battler has finished charging a skill/item
  85.  *       post_charge_common_event_id must return a Number
  86.  *       If post_charge_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.  * Skills/items without the <patb charge: scale, code> notetag will be fully
  92.  * charged in 1 frame
  93.  * The default plugin file name is DoubleX RMMV Popularized ATB Charge v103b
  94.  * If you want to change that, you must edit the value of
  95.  * DoubleX_RMMV.PATB_Charge_File, which must be done via opening this plugin
  96.  * js file directly
  97.  * (v1.03a+)You're supposed to edit this js file directly to setup hotkeys
  98.  * cancelling the charging of charging actors with specified party member index
  99.  *============================================================================
  100.  *    ## Notetag Info
  101.  *----------------------------------------------------------------------------
  102.  *    # Skill/Item Notetags:
  103.  *      1. <patb charge: scale, code>
  104.  *         - Sets the charge rate to use the skill/item's invocation speed,
  105.  *           which will be multiplied by scale
  106.  *         - code can be either of the below:
  107.  *           set - The charge value per frame will be the skill/item's
  108.  *                 invocation speed * scale, which should be nonnegative
  109.  *           add - The charge value per frame will be the absolute value of
  110.  *                 the battler atb gain value per frame + the skill/item's
  111.  *                 invocation speed * scale
  112.  *           multiply - If the skill/item's invocation speed * scale is
  113.  *                      positive, the charge value per frame will be the
  114.  *                      battler atb gain value per frame * the skill/item's
  115.  *                      invocation speed * scale
  116.  *                      If the skill/item's invocation speed * scale is
  117.  *                      negative, the charge value per frame will be the
  118.  *                      battler atb gain value per frame / (the skill/item's
  119.  *                      invocation speed * scale)
  120.  *                      If the skill/item's invocation speed * scale is 0, the
  121.  *                      skill/item will be fully charged in 1 frame
  122.  *      2. <patb charge colors: text color 1, text color 2>
  123.  *         - Changes the atb charge bar color 1 and 2 to text color 1 and 2
  124.  *           respectively when this notetag's used
  125.  *      3. <patb charge text: text>
  126.  *         - Changes the atb charge bar description text as text when this
  127.  *           notetag's used
  128.  *      4. <patb charge prior item cost>
  129.  *         - Sets the skill/item charging to take place before paying its cost
  130.  *============================================================================
  131.  *    ## Plugin Call Info
  132.  *----------------------------------------------------------------------------
  133.  *    # Data Skill/Item manipulations
  134.  *      1. meta.patb_charge
  135.  *         - Returns the skill/item invocation speed scale and charge rate
  136.  *           code in the form of { scale: scale, code: code }
  137.  *      2. meta.patb_charge = { scale: scale, code: code }
  138.  *         - Sets the skill/item invocation speed scale and charge rate code
  139.  *           in the form of { scale: scale, code: code }
  140.  *         - All meta.patb_charge changes can be saved if
  141.  *           DoubleX RMMV Dynamic Data is used
  142.  *      3. meta.patb_charge_colors
  143.  *         - Returns the text colors stored in
  144.  *           <patb charge colors: text color 1, text color 2> in the form of
  145.  *           [text color 1, text color 2]
  146.  *      4. meta.patb_charge_colors = [text color 1, text color 2]
  147.  *         - Sets the text colors stored in
  148.  *           <patb charge colors: text color 1, text color 2> as text color 1
  149.  *           and 2
  150.  *         - All meta.patb_charge_colors changes can be saved if
  151.  *           DoubleX RMMV Dynamic Data is used
  152.  *      5. meta.patb_charge_text
  153.  *         - Returns the text stored in <patb charge text: text>
  154.  *      6. meta.patb_charge_text = text
  155.  *         - Sets the text stored in <patb charge text: text> as text
  156.  *         - All meta.patb_charge_text changes can be saved if
  157.  *           DoubleX RMMV Dynamic Data is used
  158.  *      7. meta.patb_charge_prior_item_cost
  159.  *         - Returns whether the skill/item charging will take place before
  160.  *           paying its costs
  161.  *      8. meta.patb_charge_prior_item_cost = boolean
  162.  *         - Sets whether the skill/item charging will take place before
  163.  *           paying its costs
  164.  *         - All meta.patb_charge_prior_item_cost changes can be saved if
  165.  *           DoubleX RMMV Dynamic Data is used
  166.  *    # Battler manipulations
  167.  *      1. patb_val.charge
  168.  *         - Returns the battler's charge value
  169.  *      2. patb_val.charge = val
  170.  *         - Set the battler's charge value as val
  171.  *           (v1.04b+)Use fill_up_patb_charge() instead if val = max_patb_val
  172.  *           in non-delay fill code and val = 0 in delay fill code, or the
  173.  *           post charge event wouldn't trigger
  174.  *      3. patb_rate.charge
  175.  *         - Returns the battler's charge rate
  176.  *      4. patb_rate.charge = rate
  177.  *         - Set the battler's charge rate as rate
  178.  *         - It'll be reevaluated if it can be changed without plugin calls
  179.  *      5. patb_val_change.atb = true
  180.  *         - Notifies that the charge value's changed
  181.  *         - It must be used right after the atb bar length changed
  182.  *      6. fill_up_patb_charge()
  183.  *          - (v1.04b+)Fully fills up the battler's atb charge to its maximum
  184.  *============================================================================
  185.  */
  186.  
  187. "use strict";
  188. var DoubleX_RMMV = DoubleX_RMMV || {};
  189. DoubleX_RMMV["PATB Charge"] = "v1.03b";
  190.  
  191. // The plugin file name must be the same as DoubleX_RMMV.PATB_Charge_File
  192. DoubleX_RMMV.PATB_Charge_File = "DoubleX RMMV Popularized ATB Charge v103b";
  193.  
  194. /*============================================================================
  195.  *    ## (v1.03a+)Plugin Configurations
  196.  *       You only need to edit this part as it's about what this plugin does
  197.  *----------------------------------------------------------------------------*/
  198.  
  199. DoubleX_RMMV.PATB_Charge = {
  200.  
  201.     /* Sets hotkeys cancelling the charging of the charging actor with the
  202.      * specified party member index
  203.      * The effects will be the same as calling the reset_patb() plugin call
  204.      * None of these hotkeys are supposed to be changed during the same battle
  205.      * Each hotkey will be referenced by $gameSystem.patb.charge_actor_index,
  206.      * where index is the index of the hotkey
  207.      * $gameSystem.patb.charge_actor_count must always be updated to maintain
  208.      * the exact number of these hotkeys
  209.      * The ith hotkey will try to select the charging actor with party member
  210.      * index i - 1
  211.      * Each of these hotkey must be a String
  212.      * Using a keyboard mapping plugin, like Quasi Input, can be useful here
  213.      */
  214.     charging_actors: [
  215.         // Setting these as the same as those in inputable_actors in the hotkey
  216.         // addon would cause the buzzer sound to be played on valid cases too
  217.         "#1", // Referenced by $gameSystem.patb.charge_actor_0
  218.         "#2", // Referenced by $gameSystem.patb.charge_actor_1
  219.         "#3", // Referenced by $gameSystem.patb.charge_actor_2
  220.         "#4", // Referenced by $gameSystem.patb.charge_actor_3
  221.         "#5", // Referenced by $gameSystem.patb.charge_actor_4
  222.         "#6", // Referenced by $gameSystem.patb.charge_actor_5
  223.         "#7", // Referenced by $gameSystem.patb.charge_actor_6
  224.         "#8", // Referenced by $gameSystem.patb.charge_actor_7
  225.         "#9", // Referenced by $gameSystem.patb.charge_actor_8
  226.         "#0" // Referenced by $gameSystem.patb.charge_actor_9
  227.         //
  228.     ]
  229.  
  230. }; // DoubleX_RMMV.PATB_Charge
  231.  
  232. /*============================================================================
  233.  *    ## Plugin Implementations
  234.  *       You need not edit this part as it's about how this plugin works
  235.  *----------------------------------------------------------------------------
  236.  *    # Plugin Support Info:
  237.  *      1. Prerequisites
  238.  *         - Basic knowledge of this plugin on the user level, the default
  239.  *           battle system implementations and the atb system concepts
  240.  *         - Some Javascript coding proficiency to fully comprehend this
  241.  *           plugin
  242.  *      2. Function documentation
  243.  *         - The 1st part describes why this function's rewritten/extended for
  244.  *           rewritten/extended functions or what the function does for new
  245.  *           functions
  246.  *         - The 2nd part describes what the arguments of the function are
  247.  *         - The 3rd part informs which version rewritten, extended or created
  248.  *           this function
  249.  *         - The 4th part informs whether the function's rewritten or new
  250.  *         - The 5th part informs whether the function's a real or potential
  251.  *           hotspot
  252.  *         - The 6th part describes how this function works for new functions
  253.  *           only, and describes the parts added, removed or rewritten for
  254.  *           rewritten or extended functions only
  255.  *         Example:
  256.  * /*----------------------------------------------------------------------
  257.  *  *    Why rewrite/extended/What this function does
  258.  *  *----------------------------------------------------------------------*/
  259. /* // arguments: What these arguments are
  260.  * function_name = function(arguments) { // Version X+; Rewrite/New; Hotspot
  261.  *     // Added/Removed/Rewritten to do something/How this function works
  262.  *     function_name_code;
  263.  *     //
  264.  * } // function_name
  265.  *----------------------------------------------------------------------------*/
  266.  
  267. if (DoubleX_RMMV["PATB Core"]) {
  268.  
  269. /*----------------------------------------------------------------------------*/
  270.  
  271. /*----------------------------------------------------------------------------
  272.  *    # Edit class: DataManager
  273.  *----------------------------------------------------------------------------*/
  274.  
  275. // data: The data to have its notetags read
  276. DataManager.load_all_patb_charge_notes = DataManager.load_all_patb_notes;
  277. DataManager.load_all_patb_notes = function() {
  278.     // Added
  279.     [$dataSkills, $dataItems].forEach(function(type) {
  280.         type.forEach(function(data) {
  281.             if (data) { this.load_patb_charge_notes(data); }
  282.         }, this);
  283.     }, this);
  284.     //
  285.     return this.load_all_patb_charge_notes();
  286. }; // DataManager.load_all_patb_notes
  287.  
  288. // data: The data to have its notetags read
  289. DataManager.load_patb_charge_notes = function(data) { // New
  290.     var charge = /< *patb +charge *: *(\d+) *, *(\w+) *>/i;
  291.     var color = /< *patb +charge +colors *: *(\d+) *, *(\d+) *>/i;
  292.     var text = /< *patb +charge +text *: *(\w+) *>/i;
  293.     var cost = /< *patb +charge +prior +item +cost *>/i, m = data.meta;
  294.     data.note.split(/[\r\n]+/).forEach(function(line) {
  295.         if (line.match(charge)) {
  296.             return m.patb_charge = { scale: +RegExp.$1, code: RegExp.$2 };
  297.         } else if (line.match(color)) {
  298.             return m.patb_charge_colors = [+RegExp.$1, +RegExp.$2];
  299.         }
  300.         if (line.match(text)) { return m.patb_charge_text = RegExp.$1; }
  301.         if (line.match(cost)) { return m.patb_charge_prior_item_cost = true; }
  302.     });
  303.     // Sets the default to be fully charged in 1 frame
  304.     m.patb_charge = m.patb_charge || { scale: 0, code: "multiply" };
  305.     //
  306. }; // DataManager.load_patb_charge_notes
  307.  
  308. /*----------------------------------------------------------------------------
  309.  *    # Edit class: BattleManager
  310.  *----------------------------------------------------------------------------*/
  311.  
  312. BattleManager.endActionPatbCharge = BattleManager.endAction;
  313. BattleManager.endAction = function() {
  314.     // Added to cache the charge notetags for the next action if there's any
  315.     if ($gameSystem.is_patb()) { this._subject.set_patb_charge(); }
  316.     //
  317.     this.endActionPatbCharge();
  318.     // Added to ensure the action execution subject won't be charging actions
  319.     if ($gameSystem.is_patb()) { this._subject = null; }
  320.     //
  321. }; // BattleManager.endAction
  322.  
  323. /*----------------------------------------------------------------------------
  324.  *    # (v1.02a+)Edit class: Game_Temp
  325.  *----------------------------------------------------------------------------*/
  326.  
  327. // timing: The common event trigger timing
  328. Game_Temp.prototype.call_patb_event = function(timing) { // New
  329.     var id = $gameSystem.patb[timing + "_common_event_id"];
  330.     if ($dataCommonEvents[id]) { this.reserveCommonEvent(id); }
  331. }; // Game_Temp.prototype.call_patb_event
  332.  
  333. /*----------------------------------------------------------------------------
  334.  *    # Edit class: Game_System
  335.  *      - Stores the values of all configurations listed in the plugin manager
  336.  *----------------------------------------------------------------------------*/
  337.  
  338. Game_System.prototype.init_patb_charge_params =
  339. Game_System.prototype.init_patb_params;
  340. Game_System.prototype.init_patb_params = function() {
  341.     this.init_patb_charge_params();
  342.     // Added
  343.     var ps = PluginManager.parameters(DoubleX_RMMV.PATB_Charge_File), val;
  344.     Object.keys(ps).forEach(function(param) {
  345.         val = +ps[param];
  346.         this._patb[param] = isNaN(val) ? ps[param] : val;
  347.     }, this);
  348.     this._patb.charge_prior_item_cost = ps.charge_prior_item_cost === "true";
  349.     var hotkeys = DoubleX_RMMV.PATB_Charge.charging_actors;
  350.     var length = hotkeys.length;
  351.     this._patb.charge_actor_count = length;
  352.     for (var index = 0; index < length; index++) {
  353.         this._patb["charge_actor_" + index.toString()] = hotkeys[index];
  354.     }
  355.     //
  356. }; // Game_System.prototype.init_patb_params
  357.  
  358. /*----------------------------------------------------------------------------
  359.  *    # Edit class: Game_Battler
  360.  *----------------------------------------------------------------------------*/
  361.  
  362. /*----------------------------------------------------------------------------
  363.  *    New private instance variables
  364.  *----------------------------------------------------------------------------*/
  365. /* _patb_charge_item: The cached skill/item for reading its name and notetags
  366.  * _patb_charge_text: The cached charge bar description text
  367.  */
  368.  
  369. Game_Battler.prototype.useItemPatbCharge = Game_Battler.prototype.useItem;
  370. Game_Battler.prototype.useItem = function(item) { // v1.01a+
  371.     // Rewritten
  372.     if (!$gameSystem.is_patb() || this.patb_charge_prior_item_cost(item)) {
  373.         this.useItemPatbCharge(item);
  374.     }
  375.     //
  376. }; // Game_Battler.prototype.useItem
  377.  
  378. Game_Battler.prototype.init_patb_charge = Game_Battler.prototype.init_patb;
  379. Game_Battler.prototype.init_patb = function() {
  380.     this.init_patb_charge();
  381.     // Added
  382.     this._patb_colors.charge = [];
  383.     this._patb_rate.charge = 0;
  384.     this.mark_patb_charge_change();
  385.     if ($gameSystem.patb.atb_fill_code === "delay") {
  386.         return this._patb_val.charge = this._max_patb_val;
  387.     }
  388.     this._patb_val.charge = 0;
  389.     //
  390. }; // Game_Battler.prototype.init_patb
  391.  
  392. Game_Battler.prototype.update_patb_charge_val =
  393. Game_Battler.prototype.update_patb_val;
  394. Game_Battler.prototype.update_patb_val = function(cap, sign) { // Hotspot
  395.     // Added
  396.     if (this.can_patb_charge(cap, sign)) {
  397.         return this.update_patb_charge(cap, sign);
  398.     }
  399.     //
  400.     this.update_patb_charge_val(cap, sign);
  401. }; // Game_Battler.prototype.update_patb_val
  402.  
  403. Game_Battler.prototype.set_patb_colors_charge =
  404. Game_Battler.prototype.set_patb_colors;
  405. Game_Battler.prototype.set_patb_colors = function(type) { // Potential Hotspot
  406.     if (type === "charge") { return this.set_patb_charge_colors(); } // Added
  407.     this.set_patb_colors_charge(type);
  408. }; // Game_Battler.prototype.set_patb_colors
  409.  
  410. Game_Battler.prototype.reset_patb_charge = Game_Battler.prototype.reset_patb;
  411. Game_Battler.prototype.reset_patb = function() { // New
  412.     this.reset_patb_charge_val(); // Added
  413.     this.reset_patb_charge();
  414. }; // Game_Battler.prototype.reset_patb
  415.  
  416. Game_Battler.prototype.can_patb_act_charge =
  417. Game_Battler.prototype.can_patb_act;
  418. Game_Battler.prototype.can_patb_act = function() { // Hotspot
  419.     // Rewritten
  420.     return this.can_patb_act_charge() && this.has_full_patb_charge();
  421.     //
  422. }; // Game_Battler.prototype.can_patb_act
  423.  
  424. Game_Battler.prototype.patb_type_charge = Game_Battler.prototype.patb_type;
  425. Game_Battler.prototype.patb_type = function() { // Hotspot
  426.     // Rewritten
  427.     return this.is_patb_charge() ? "charge" : this.patb_type_charge();
  428.     //
  429. }; // Game_Battler.prototype.patb_type_charge
  430.  
  431. Game_Battler.prototype.patb_bar_text_charge =
  432. Game_Battler.prototype.patb_bar_text;
  433. Game_Battler.prototype.patb_bar_text = function() { // v1.01a+; Hotspot
  434.     // Added
  435.     if (this.is_patb_charge()) { return this.patb_charge_bar_text(); }
  436.     //
  437.     return this.patb_bar_text_charge();
  438. }; // Game_Battler.prototype.patb_bar_text
  439.  
  440. /*----------------------------------------------------------------------------
  441.  *    Ensures charging won't take place when cooldown's taking place
  442.  *----------------------------------------------------------------------------*/
  443. if (DoubleX_RMMV["PATB Cooldown"]) {
  444.  
  445. /* cap: The atb value cap stopping further atb value updates
  446.  * sign: The atb value update direction sign
  447.  */
  448. Game_Battler.prototype.can_patb_charge = function(cap, sign) { // New; Hotspot
  449.     if (this.is_patb_cooldown()) { return false; }
  450.     if (this._patb_val.atb * sign < cap * sign) { return false; }
  451.     if (this._patb_val.charge * sign >= cap * sign) { return false; }
  452.     return this._patb_charge_item;
  453. }; // Game_Battler.prototype.can_patb_charge
  454.  
  455. } else {
  456.  
  457. /* cap: The atb value cap stopping further atb value updates
  458.  * sign: The atb value update direction sign
  459.  */
  460. Game_Battler.prototype.can_patb_charge = function(cap, sign) { // New; Hotspot
  461.     if (this._patb_val.atb * sign < cap * sign) { return false; }
  462.     if (this._patb_val.charge * sign >= cap * sign) { return false; }
  463.     return this._patb_charge_item;
  464. }; // Game_Battler.prototype.can_patb_charge
  465.  
  466. } // Game_Battler.prototype.can_patb_charge
  467.  
  468. Game_Battler.prototype.fill_up_patb_charge = function() { // v1.04b+; New
  469.     // Refreshes the status window when the charging starts
  470.     if (!this.is_patb_charge()) { this.set_patb_refresh(); }
  471.     //
  472.     if ($gameSystem.patb.atb_fill_code === "delay") {
  473.         if (this._patb_val.charge <= 0) { return; }
  474.         this._patb_val.charge = 0;
  475.     } else {
  476.         if (this._patb_val.charge >= this._max_patb_val) { return; }
  477.         this._patb_val.charge = this._max_patb_val;
  478.     }
  479.     //
  480.     this._patb_val_change.charge = true;
  481.     $gameTemp.call_patb_event("post_charge");
  482. }; // Game_Battler.prototype.fill_up_patb_charge
  483.  
  484. /* cap: The atb value cap stopping further atb value updates
  485.  * sign: The atb value update direction sign
  486.  */
  487. Game_Battler.prototype.update_patb_charge = function(cap, sign) {
  488. // New; Hotspot
  489.     // Refreshes the status window when the charging starts
  490.     if (!this.is_patb_charge()) { this.set_patb_refresh(); }
  491.     //
  492.     var last_val = this._patb_val.charge;
  493.     this._patb_val.charge += this.get_patb_charge_rate() * sign;
  494.     this._patb_val_change.charge = last_val !== this._patb_val.charge;
  495.     if (this._patb_val.charge * sign <= cap * sign) { return; }
  496.     $gameTemp.call_patb_event("post_charge");
  497.     this._patb_val.charge = cap;
  498. }; // Game_Battler.prototype.update_patb_charge
  499.  
  500. Game_Battler.prototype.get_patb_charge_rate = function() {
  501. // New; Hotspot
  502.     if (this.can_patb_charge_rate_change()) {
  503.         this._patb_rate.charge = this.set_patb_charge_rate();
  504.     }
  505.     return this._patb_rate.charge;
  506. }; // Game_Battler.prototype.get_patb_charge_rate
  507.  
  508. Game_Battler.prototype.can_patb_charge_rate_change = function() {
  509. // New; Hotspot
  510.     if (this._patb_rate.atb !== this.get_patb_rate()) { return true; }
  511.     return this.are_patb_battler_changed("charge_rate");
  512. }; // Game_Battler.prototype.can_patb_charge_rate_change
  513.  
  514. Game_Battler.prototype.set_patb_charge_rate = function() {
  515. // New; Potential Hotspot
  516.     var item = this._actions[0].item(), charge = item.meta.patb_charge;
  517.     var r = this._patb_rate.atb, s = item.speed * charge.scale;
  518.     switch (charge.code) {
  519.         case "set": return s;
  520.         case "add": return Math.abs(r + s);
  521.         case "multiply":
  522.             return s > 0 ? r * s : s < 0 ? r / -s : this._max_patb_val;
  523.         default:
  524.             console.log("Invalid code " + charge.code + " as notetag values");
  525.             return this._max_patb_val;
  526.     }
  527. }; // Game_Battler.prototype.set_patb_charge_rate
  528.  
  529. Game_Battler.prototype.reset_patb_charge_val = function() { // New
  530.     this._patb_charge_item = null;
  531.     this._patb_val_change.charge = true;
  532.     if ($gameSystem.patb.atb_fill_code === "delay") {
  533.         return this._patb_val.charge = this._max_patb_val;
  534.     }
  535.     this._patb_val.charge = 0;
  536. }; // Game_Battler.prototype.reset_patb_charge_val
  537.  
  538. Game_Battler.prototype.has_full_patb_charge = function() { // New; Hotspot
  539.     if ($gameSystem.patb.atb_fill_code === "delay") {
  540.         return this._patb_val.charge <= 0;
  541.     }
  542.     return this._patb_val.charge >= this._max_patb_val;
  543. }; // Game_Battler.prototype.has_full_patb_charge
  544.  
  545. Game_Battler.prototype.is_patb_charge = function() { // New; Hotspot
  546.     if ($gameSystem.patb.atb_fill_code === "delay") {
  547.         return this._patb_val.charge < this._max_patb_val;
  548.     }
  549.     return this._patb_val.charge > 0;
  550. }; // Game_Battler.prototype.is_patb_charge
  551.  
  552. Game_Battler.prototype.set_patb_charge_colors = function() {
  553. // New; Potential Hotspot
  554.     if (this._patb_charge_item) {
  555.         var colors = this._patb_charge_item.meta.patb_charge_colors;
  556.         this._patb_colors.charge = colors;
  557.     }
  558.     if (this._patb_colors.charge) { return; }
  559.     var patb = $gameSystem.patb;
  560.     this._patb_colors.charge = [patb.charge_c1, patb.charge_c2];
  561. }; // Game_Battler.prototype.set_patb_charge_colors
  562.  
  563. Game_Battler.prototype.set_patb_charge = function() { // New
  564.     this.set_patb_refresh();
  565.     this.mark_patb_charge_change();
  566.     if (this._actions[0] && this._actions[0].item()) {
  567.         return this.set_patb_charge_item();
  568.     }
  569.     // Ensures the battler will be reset right after executing the last action
  570.     if ($gameSystem.patb.atb_fill_code === "delay") {
  571.         return this._patb_val.charge = 0;
  572.     }
  573.     this._patb_val.charge = this._max_patb_val;
  574.     //
  575. }; // Game_Battler.prototype.set_patb_charge
  576.  
  577. Game_Battler.prototype.set_patb_charge_item = function() { // New
  578.     this.mark_patb_charge_change();
  579.     this._patb_charge_item = this._actions[0].item();
  580.     if ($gameSystem.patb.atb_fill_code === "delay") {
  581.         return this._patb_val.charge = this._max_patb_val;
  582.     }
  583.     this._patb_val.charge = 0;
  584. }; // Game_Battler.prototype.set_patb_charge_item
  585.  
  586. Game_Battler.prototype.mark_patb_charge_change = function() { // v1.01a+; New
  587.     this._patb_note_change.charge_color = true;
  588.     this._patb_note_change.charge_rate = true;
  589.     this._patb_note_change.charge_text = true;
  590.     this._patb_val_change.charge = true;
  591. }; // Game_Battler.prototype.mark_patb_charge_change
  592.  
  593. Game_Battler.prototype.patb_charge_bar_text = function() {
  594. // v1.01a+; New; Hotspot
  595.     if (this.are_patb_battler_changed("charge_text")) {
  596.         this.set_patb_charge_bar_text();
  597.     }
  598.     return this._patb_charge_text;
  599. }; // Game_Battler.prototype.patb_charge_bar_text
  600.  
  601. Game_Battler.prototype.set_patb_charge_bar_text = function() {
  602. // v1.01a+; New; Potential Hotspot
  603.     if (this._patb_charge_item) {
  604.         var text = this._patb_charge_item.meta.patb_charge_text;
  605.         if (text) { return this._patb_charge_text = text; }
  606.         if ($gameSystem.patb.charge_bar_text === "item") {
  607.             return this._patb_charge_text = this._patb_charge_item.name;
  608.         }
  609.     }
  610.     this._patb_charge_text = $gameSystem.patb.atb_bar_text;
  611. }; // Game_Battler.prototype.set_patb_charge_bar_text
  612.  
  613. Game_Battler.prototype.patb_charge_prior_item_cost = function(item) {
  614. // v1.01a+; New
  615.     if (item && item.meta.patb_charge_prior_item_cost !== undefined) {
  616.         return item.meta.patb_charge_prior_item_cost;
  617.     }
  618.     return $gameSystem.patb.charge_prior_item_cost;
  619. }; // Game_Battler.prototype.patb_charge_prior_item_cost
  620.  
  621. /*----------------------------------------------------------------------------
  622.  *    # Edit class: Game_Actor
  623.  *----------------------------------------------------------------------------*/
  624.  
  625. Game_Actor.prototype.confirm_patb_charge_act =
  626. Game_Actor.prototype.confirm_patb_act;
  627. Game_Actor.prototype.confirm_patb_act = function() { // v1.02a+
  628.     this.confirm_patb_charge_act();
  629.     // Added
  630.     var act = this.inputtingAction();
  631.     if (!act) { return; }
  632.     this.set_patb_charge_item();
  633.     var item = act.item();
  634.     if (this.patb_charge_prior_item_cost(item)) { return; }
  635.     this.useItemPatbCharge(item);
  636.     //
  637. }; // Game_Actor.prototype.confirm_patb_act
  638.  
  639. Game_Actor.prototype.confirm_patb_charge_acts =
  640. Game_Actor.prototype.confirm_patb_acts;
  641. Game_Actor.prototype.confirm_patb_acts = function() {
  642.     this.confirm_patb_charge_acts();
  643.     // Added
  644.     this.set_patb_charge_item();
  645.     this._actions.map(function(act) {
  646.         return act.item();
  647.     }).forEach(function(item) {
  648.         if (this.patb_charge_prior_item_cost(item)) { return; }
  649.         this.useItemPatbCharge(item);
  650.     }, this);
  651.     //
  652. }; // Game_Actor.prototype.confirm_patb_acts
  653.  
  654. /*----------------------------------------------------------------------------
  655.  *    # Edit class: Game_Enemy
  656.  *----------------------------------------------------------------------------*/
  657.  
  658. Game_Enemy.prototype.makeActionsPatbCharge = Game_Enemy.prototype.makeActions;
  659. Game_Enemy.prototype.makeActions = function() {
  660.     this.makeActionsPatbCharge();
  661.     if ($gameSystem.is_patb()) { this.set_patb_charge_item(); } // Added
  662. }; // Game_Enemy.prototype.makeActions
  663.  
  664. /*----------------------------------------------------------------------------
  665.  *    # (v1.03a+)Edit class: Window_BattleStatus
  666.  *----------------------------------------------------------------------------*/
  667.  
  668. Window_BattleStatus.prototype.processHandling = function() { // New
  669.     Window_Selectable.prototype.processHandling.call(this);
  670.     if (!this.isOpen()) { return; }
  671.     var patb = $gameSystem.patb, hotkey;
  672.     for (var i = 0, length = patb.charge_actor_count; i < length; i++) {
  673.         hotkey = patb["charge_actor_" + i.toString()];
  674.         if (Input.isTriggered(hotkey)) { this.callHandler(hotkey); };
  675.     }
  676. }; // Window_ActorCommand.prototype.processHandling
  677.  
  678. /*----------------------------------------------------------------------------
  679.  *    # (v1.03a+)Edit class: Scene_Battle
  680.  *----------------------------------------------------------------------------*/
  681.  
  682. Scene_Battle.prototype.createStatusWindowPatbCharge =
  683. Scene_Battle.prototype.createStatusWindow;
  684. Scene_Battle.prototype.createStatusWindow = function() {
  685.     this.createStatusWindowPatbCharge();
  686.     this.set_patb_charge_handler();
  687. }; // Scene_Battle.prototype.createStatusWindow
  688.  
  689. Scene_Battle.prototype.set_patb_charge_handler = function() { // New
  690.     var patb = $gameSystem.patb, c_i = this.set_patb_charge_index_actor, hotkey;
  691.     for (var i = 0, length = patb.charge_actor_count; i < length; i++) {
  692.         hotkey = patb["charge_actor_" + i.toString()];
  693.         this._statusWindow.setHandler(hotkey, c_i.bind(this, i));
  694.     }
  695. }; // Scene_Battle.prototype.set_patb_charge_handler
  696.  
  697. // index: The party member index of the actor to stop charging actions
  698. Scene_Battle.prototype.set_patb_charge_index_actor = function(index) {
  699.     var actor = $gameParty.battleMembers()[index];
  700.     actor.is_patb_charge() ? actor.reset_patb() : SoundManager.playBuzzer();
  701. }; // Scene_Battle.prototype.set_patb_charge_index_actor
  702.  
  703. /*----------------------------------------------------------------------------*/
  704.  
  705. } else {
  706.     alert("To use PATB Charge, place it below PATB Core.");
  707. }
  708.  
  709. /*============================================================================*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement