Double_X

DoubleX RMMV Popularized ATB Compatibility v104a

Apr 12th, 2016 (edited)
939
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 Compatibility
  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. Nothing special
  18.  *----------------------------------------------------------------------------
  19.  *    # Links
  20.  *      This plugin:
  21.  *      1. http://pastebin.com/SXpV9Zwt
  22.  *      Video:
  23.  *      1. https://www.youtube.com/watch?v=aoBI3DaE3g8
  24.  *----------------------------------------------------------------------------
  25.  *    # Instructions
  26.  *      1. Place this plugin below all DoubleX RMMV Popularized ATB addons
  27.  *----------------------------------------------------------------------------
  28.  *    # Author
  29.  *      DoubleX
  30.  *----------------------------------------------------------------------------
  31.  *    # Changelog
  32.  *      v1.04a(GMT 0500 1-1-2022):
  33.  *      1. Compatible With Yanfly Engine Plugins - Battle Engine Extension -
  34.  *         Animated Sideview Enemies
  35.  *      v1.03f(GMT 0700 23-6-2021):
  36.  *      1. Fixed the visuals of the action sequences of actor sprites being
  37.  *         reset when other actors are inputable bug
  38.  *      v1.03e(GMT 0700 19-6-2020):
  39.  *      1. Fixed the <= patb reset: val> notetag always resetting the ATB to 0
  40.  *         with Yanfly Engine Plugins - Battle Engine Core bug
  41.  *      v1.03d(GMT 0300 14-5-2020):
  42.  *      1. Fixed target cursor disappearing when the windows' refreshed
  43.  *      2. Fixed skill/item/target help window not showing after it's closed
  44.  *      v1.03c(GMT 0400 28-4-2020):
  45.  *      1. Fixed not closing the target help window when the actor's dead with
  46.  *         Yanfly Engine Plugins - Battle Engine Core enabled
  47.  *      v1.03b(GMT 0200 7-9-2017):
  48.  *      1. Fixed returning the sprite of the currently inputable actor to its
  49.  *         home position when an action performs its finish sequence
  50.  *         compatiblity issue
  51.  *      v1.03a(GMT 0400 27-8-2017):
  52.  *      1. Supports Action Sequences in
  53.  *         Yanfly Engine Plugins - Battle Engine Core
  54.  *      2. Fixed more changing currently inputable actor with
  55.  *         Yanfly Engine Plugins - Target Extension - Selection Control
  56.  *         compatibility issues
  57.  *      v1.02b(GMT 1400 26-8-2017):
  58.  *      1. Fixed showing status window with MOG_BattleHud compatility issue
  59.  *      2. Fixed changing currently inputable actor with
  60.  *         Yanfly Engine Plugins - Target Extension - Selection Control
  61.  *         compatibility issue
  62.  *      v1.02a(GMT 1400 13-8-2017):
  63.  *      1. Compatible with
  64.  *         Yanfly Engine Plugins - Target Extension - Selection Control
  65.  *      v1.01b(GMT 0400 11-8-2017):
  66.  *      1. Fixed the wrong actor window position bug when using skills/items
  67.  *         on party members
  68.  *      v1.01a(GMT 0500 10-8-2017):
  69.  *      1. Compatible with MOG_BattleHud
  70.  *      v1.00e(GMT 1200 5-8-2017):
  71.  *      1. Fixed the next action incorrectly highlighting all members in the
  72.  *         same party/troop after using an party/troop targeting skill/item
  73.  *      v1.00d(GMT 1500 11-8-2016):
  74.  *      1. In sync with the latest DoubleX RMMV Popularized ATB Core version
  75.  *      v1.00c(GMT 1400 9-8-2016):
  76.  *      1. Fixed skills/items not needing selections not working when
  77.  *         Select Help Window in Yanfly Engine Plugins - Battle Engine Core is
  78.  *         set as false
  79.  *      v1.00b(GMT 0400 16-7-2016):
  80.  *      1. PATB Hotkey supports selecting inputable actors via touch input
  81.  *         when Yanfly Engine Plugins - Battle Engine Core is used with
  82.  *         Visual Actor Select being set as true as well
  83.  *         Mouse Over applies to PATB Hotkey as well
  84.  *      v1.00a(GMT 1600 12-4-2016):
  85.  *      1. 1st version of this plugin finished
  86.  *============================================================================*/
  87. /*:
  88.  * @plugindesc Fixes DoubleX RMMV Popularized ATB compatibility issues
  89.  * @author DoubleX
  90.  *
  91.  * @help
  92.  *============================================================================
  93.  *    ## (v1.03a+)Action Sequences(Yanfly Engine Plugins - Battle Engine Core)
  94.  *       Reference tag: YEP_BattleEngineCore_ActionSequences
  95.  *----------------------------------------------------------------------------
  96.  *    # DoubleX RMMV Popularized ATB Core
  97.  *      1. atb val: Target Typing, Operator Value
  98.  *         - Use Operator to assign Value to the atb value of targets included
  99.  *           by Target Typing, which can be any Target Typing supported by
  100.  *           Action Sequences that targets battlers not cooling down
  101.  *         - Operator can be either =, +, -, *, / or %, meaning set to, add
  102.  *           by, subtract by, multiply by, divide by or modulo by respectively
  103.  *      2. atb val %: Target Typing, Operator Value
  104.  *         - Use Operator to assign Value% of the maximum atb value to the atb
  105.  *           value of targets included by Target Typing, which can be any
  106.  *           Target Typing supported by Action Sequences that targets battlers
  107.  *           not cooling down
  108.  *         - Operator can be either =, +, -, *, / or %, meaning set to, add
  109.  *           by, subtract by, multiply by, divide by or modulo by respectively
  110.  *      3. reset atb val: Target Typing
  111.  *         - Resets the atb value of targets included by Target Typing, which
  112.  *           can be any Target Typing supported by Action Sequences, to the
  113.  *           maximum atb value in delay fill mode and 0 if otherwise
  114.  *      4. reset atb: Target Typing
  115.  *         - Clears all actions of targets included by Target Typing, which
  116.  *           can be any Target Typing supported by Action Sequences
  117.  *    # DoubleX RMMV Popularized ATB Charge
  118.  *      1. charge val: Target Typing, Operator Value
  119.  *         - Use Operator to assign Value to the charge value of targets
  120.  *           included by Target Typing, which can be any Target Typing
  121.  *           supported by Action Sequences that targets battlers charging
  122.  *           actions
  123.  *         - Operator can be either =, +, -, *, / or %, meaning set to, add
  124.  *           by, subtract by, multiply by, divide by or modulo by respectively
  125.  *      2. charge val %: Target Typing, Operator Value
  126.  *         - Use Operator to assign Value% of the maximum atb value to the
  127.  *           charge value of targets included by Target Typing, which can be
  128.  *           any Target Typing supported by Action Sequences that targets
  129.  *           battlers charging actions
  130.  *         - Operator can be either =, +, -, *, / or %, meaning set to, add
  131.  *           by, subtract by, multiply by, divide by or modulo by respectively
  132.  *    # DoubleX RMMV Popularized ATB Cooldown
  133.  *      1. cooldown val: Target Typing, Operator Value
  134.  *         - Use Operator to assign Value to the cooldown value of targets
  135.  *           included by Target Typing, which can be any Target Typing
  136.  *           supported by Action Sequences that targets battlers cooling down
  137.  *         - Operator can be either =, +, -, *, / or %, meaning set to, add
  138.  *           by, subtract by, multiply by, divide by or modulo by respectively
  139.  *      2. cooldown val %: Target Typing, Operator Value
  140.  *         - Use Operator to assign Value% of the maximum atb value to the
  141.  *           cooldown value of targets included by Target Typing, which can be
  142.  *           any Target Typing supported by Action Sequences that targets
  143.  *           battlers cooling down
  144.  *         - Operator can be either =, +, -, *, / or %, meaning set to, add
  145.  *           by, subtract by, multiply by, divide by or modulo by respectively
  146.  *    # DoubleX RMMV Popularized ATB Countdown
  147.  *      1. countdown clock: Target Typing, Operator Value State
  148.  *         - Use operator to assign Value to the number of frames as the
  149.  *           countdown clock of state with id State for targets included by
  150.  *           Target Typing, which can be any any Target Typing supported by
  151.  *           Action Sequences that targets battlers having said state
  152.  *         - The fps is assumed to be always 60
  153.  *         - Operator can be either =, +, -, *, / or %, meaning set to, add
  154.  *           by, subtract by, multiply by, divide by or modulo by respectively
  155.  *      2. countdown freeze: Target Typing, Flag State
  156.  *         - Assign Flag, which is either true or false, to set whether the
  157.  *           countdown clock of state with id State is frozen for targets
  158.  *           included by Target Typing, which can be any any Target Typing
  159.  *           supported by Action Sequences that targets battlers having said
  160.  *           state
  161.  *    # DoubleX RMMV Popularized ATB Delay
  162.  *      1. delay frame: Target Typing, Operator Value
  163.  *         - Use Operator to assign Value to the number of frames as delay for
  164.  *           targets included by Target Typing, which can be any Target Typing
  165.  *           supported by Action Sequences
  166.  *         - The fps is assumed to be always 60
  167.  *         - Operator can be either =, +, -, *, / or %, meaning set to, add
  168.  *           by, subtract by, multiply by, divide by or modulo by respectively
  169.  *    # DoubleX RMMV Popularized ATB Reset
  170.  *      1. reset val: Target Typing, Operator Value
  171.  *         - Use Operator to assign Value to the atb reset value for targets
  172.  *           included by Target Typing, which can be any Target Typing
  173.  *           supported by Action Sequences
  174.  *         - Operator can be either =, +, -, *, / or %, meaning set to, add
  175.  *           by, subtract by, multiply by, divide by or modulo by respectively
  176.  *      2. reset val %: Target Typing, Operator Value
  177.  *         - Use Operator to assign Value% of the maximum atb value to the atb
  178.  *           reset value for targets included by Target Typing, which can be
  179.  *           any Target Typing supported by Action Sequences
  180.  *         - Operator can be either =, +, -, *, / or %, meaning set to, add
  181.  *           by, subtract by, multiply by, divide by or modulo by respectively
  182.  *============================================================================
  183.  *    ## Addressed Plugins
  184.  *----------------------------------------------------------------------------
  185.  *    # (v1.04a+)Yanfly Engine Plugins - Battle Engine Extension -
  186.  *      Animated Sideview Enemies
  187.  *      1. The ATB bars in DoubleX RMMV Popularized ATB Bar are needlessly
  188.  *         mirrored as well when mirroring animated sideview enemies
  189.  *         - Reference tag: YEP_X_AnimatedSVEnemies_UnmirrorMirroredATBBars
  190.  *         - Extended Window_Patb_Bar.prototype.updateBar to mirror the ATB
  191.  *           bars again if their parents are mirrored
  192.  *         - This fix might cause minor performance issues on low-end mobiles
  193.  *    # (v1.02a+)Yanfly Engine Plugins - Target Extension - Selection Control
  194.  *      1. The enemy window freezes when the current inputable actor becomes
  195.  *         not inputable
  196.  *         - Reference tag: YEP_X_SelectionControl_StopUnlockingEnemyWindow
  197.  *         - Extended Scene_Battle.prototype.close_patb_selection_windows to
  198.  *           stop closing the enemy window upon the aforementioned event
  199.  *      2. (v1.02b+)The currently inputable actor changes when picking targets
  200.  *         - Reference tag: YEP_X_SelectionControl_NewStatusWindowIndex
  201.  *         - Added get property patb_index in Window_BattleStatus
  202.  *         - Extended Window_BattleStatus.prototype.select to use a new
  203.  *           variable to store the index that are not affected by selecting
  204.  *           targets
  205.  *         - Extended Window_BattleEnemy.prototype.hide and
  206.  *           Window_BattleEnemy.prototype.select to select targets without
  207.  *           changing the new index
  208.  *    # (v1.01a+)MOG_BattleHud:
  209.  *      1. The ATB bar doesn't gather any DoubleX RMMV Popularized ATB data
  210.  *         - Reference tag: MOG_BattleHud_PATB_Data
  211.  *         - Rewritten Battle_Hud.prototype.update_at to support cooldown too
  212.  *         - Extended Battle_Hud.prototype.at, Battle_Hud.prototype.max_at,
  213.  *           Battle_Hud.prototype.cast_at, Battle_Hud.prototype.cast_max_at
  214.  *           and Battle_Hud.prototype.is_casting to support atb and charge
  215.  *         - Added Battle_Hud.prototype.cooldown_at,
  216.  *           Battle_Hud.prototype.cooldown_max_at,
  217.  *           Battle_Hud.prototype.is_cooling_down and
  218.  *           Battle_Hud.prototype.is_max_cooldown to support cooldown
  219.  *      2. (v1.01b+) The actor window isn't fully shown
  220.  *         - Reference tag: MOG_BattleHud_Actor_Window
  221.  *         - Removed Scene_Battle.prototype.update_patb_window_positions to
  222.  *           let MOG_BattleHud handle the actor window position
  223.  *      3. (v1.02b+)The original status window will be shown when the current
  224.  *         inputable actor becomes not inputable
  225.  *         - Reference tag: MOG_BattleHud_StopShowingStatusWindow
  226.  *         - Extended Scene_Battle.prototype.close_patb_selection_windows to
  227.  *           stop showing the status window upon the aforementioned event
  228.  *    # Yanfly Engine Plugins - Battle Engine Core:
  229.  *      1. All battler actions are recreated upon starting actor inputs
  230.  *         - Reference tag: YEP_BattleEngineCore_StopRecreateAction
  231.  *         - Stopped calling BattleManager.createActions when patb's effective
  232.  *      2. Valid actions don't execute at all
  233.  *         - Reference tag: YEP_BattleEngineCore_HandleNewPhases
  234.  *         - Extended BattleManager.can_update_patb_process to handle new
  235.  *           phases added by Yanfly Engine Plugins - Battle Engine Core
  236.  *      3. The battler's atb's reset right after executing 1 action already
  237.  *         - Reference tag: YEP_BattleEngineCore_StopAllActsEnd
  238.  *         - Stopped calling Game_Battler.prototype.on_all_patb_acts_end when
  239.  *           the battler still has actions
  240.  *      4. Skills/Items targeting all/random allies/enemies are confirmed
  241.  *         before the target selection's complete
  242.  *         - Reference tag: YEP_BattleEngineCore_StopConfirmAllRandomSelection
  243.  *         - Removed all Game_Action.prototype.confirm_patb_item contents
  244.  *         - (v1.00c+) Stopped this fix when Select Help Window is false
  245.  *      5. Right now wait_cond_code full and force run atb are still
  246.  *         functioning as act
  247.  *         - Due to BattleManager.can_update_patb_process to handle new phases
  248.  *           added by Yanfly Engine Plugins - Battle Engine Core
  249.  *      6. (v1.00e+) Subsequent actions of an all-selection one all wrongly
  250.  *         mark all party/troop members
  251.  *         - Reference tag: YEP_BattleEngineCore_StopWrongAllSelections
  252.  *         - Extended Scene_Battle.prototype.select_next_patb_command to stop
  253.  *           marking actions as all selections
  254.  *      7. (v1.03b+) The sprite of the currently inputable actor will return
  255.  *         to its home position when any action performs its finish sequence
  256.  *         - Reference tag: YEP_BattleEngineCore_StopInputableActorReturnHome
  257.  *         - Extended Game_Battler.prototype.spriteReturnHome to disable this
  258.  *           function for the currently inputable actor
  259.  *      8. (v1.03c+) The target help window remains when the actor's dead
  260.  *         - Reference tag: YEP_BattleEngineCore_CloseInvalidTargetHelpWindow
  261.  *         - Added Window_Help.prototype.deselect and extended
  262.  *           Scene_Battle.prototype.patb_selection_windows to close the stale
  263.  *           help window
  264.  *      9. (v1.03d+) The skill/item target help window doesn't show
  265.  *         - Reference tag: YEP_BattleEngineCore_ShowHelpWindow
  266.  *         - Extended commandSkill, commandItem, selectActorSelection and
  267.  *           selectActorSelection to explicitly open the help window
  268.  *      10. (v1.03d+) The selection and help window lost info after refresh
  269.  *         - Reference tag: YEP_BattleEngineCore_UpdateSelectionHelpWindow
  270.  *         - Extended refresh_patb_windows to reselect the selection windows
  271.  *           and update their respective help windows
  272.  *      11. (v1.03e+) The <= patb reset: val> notetag always reset the ATB
  273.  *          value to 0
  274.  *          - Reference tag: YEP_BattleEngineCore_StopSubjectOnAllActsEnd
  275.  *          - Extended BattleManager.endAction to stop calling onAllActionsEnd
  276.  *            twice for the action execution subject
  277.  *      12. (v1.03f+) The visuals of action sequences of actor sprites will be
  278.  *          reset when there are other inputable actors
  279.  *          - Reference tag: YEP_BattleEngineCore_StopRefreshBattlerMotion
  280.  *          - Rewritten Game_Battler.prototype.requestMotionRefresh to stop
  281.  *            refreshing the motions of battler sprites when executing the
  282.  *            action sequences
  283.  *============================================================================
  284.  */
  285.  
  286. "use strict";
  287. var DoubleX_RMMV = DoubleX_RMMV || {};
  288. DoubleX_RMMV["PATB Compatibility"] = "v1.04a";
  289.  
  290. /*============================================================================
  291.  *    ## Plugin Implementations
  292.  *       You need not edit this part as it's about how this plugin works
  293.  *----------------------------------------------------------------------------
  294.  *    # Plugin Support Info:
  295.  *      1. Prerequisites
  296.  *         - Basic knowledge of how DoubleX RMMV Popularized ATB and each
  297.  *           addressed plugin works
  298.  *         - Some Javascript coding proficiency to fully comprehend this
  299.  *           plugin
  300.  *      2. Function documentation
  301.  *         - The 1st part describes why this function's rewritten/extended for
  302.  *           rewritten/extended functions or what the function does for new
  303.  *           functions
  304.  *         - The 2nd part describes what the arguments of the function are
  305.  *         - The 3rd part informs which version rewritten, extended or created
  306.  *           this function
  307.  *         - The 4th part informs whether the function's rewritten or new
  308.  *         - The 5th part informs whether the function's a real or potential
  309.  *           hotspot
  310.  *         - The 6th part describes how this function works for new functions
  311.  *           only, and describes the parts added, removed or rewritten for
  312.  *           rewritten or extended functions only
  313.  *         Example:
  314.  * /*----------------------------------------------------------------------
  315.  *  *    Why rewrite/extended/What this function does
  316.  *  *----------------------------------------------------------------------*/
  317. /* // arguments: What these arguments are
  318.  * function_name = function(arguments) { // Version X+; Rewrite/New; Hotspot
  319.  *     // Added/Removed/Rewritten to do something/How this function works
  320.  *     function_name_code;
  321.  *     //
  322.  * } // function_name
  323.  *----------------------------------------------------------------------------*/
  324.  
  325. if (DoubleX_RMMV["PATB Core"]) {
  326.  
  327. /*----------------------------------------------------------------------------*/
  328.  
  329. if (Imported.YEP_BattleEngineCore) {
  330.  
  331. /*----------------------------------------------------------------------------
  332.  *    # Edit class: BattleManager
  333.  *----------------------------------------------------------------------------*/
  334.  
  335.  /*----------------------------------------------------------------------------
  336.   *    (v1.03e+)New public instance variables
  337.   *----------------------------------------------------------------------------*/
  338.  Object.defineProperties(BattleManager, {
  339.      // Whether onAllActionsEnd is called by BattleManager.endAction
  340.      "is_end_patb_act": { get: function() {
  341.          return this._is_end_patb_act;
  342.      }, configurable: true }
  343.  });
  344.  
  345. BattleManager.initMembersPatbCompatibility = BattleManager.initMembers;
  346. BattleManager.initMembers = function() { // v1.03a+
  347.     this.initMembersPatbCompatibility();
  348.     // Added to setup the mapping from the action sequence tag to their handlers
  349.     this.init_patb_act_sequences();
  350.     // YEP_BattleEngineCore_ActionSequences
  351. }; // BattleManager.initMembers
  352.  
  353. BattleManager.endActionPatbCompatibility = BattleManager.endAction;
  354. BattleManager.endAction = function() { // v1.03e+
  355.     // Added to stop calling onAllActionsEnd for the action execution subject
  356.     if ($gameSystem.is_patb()) { this._is_end_patb_act = true; }
  357.     // YEP_BattleEngineCore_StopSubjectOnAllActsEnd
  358.     BattleManager.endActionPatbCompatibility();
  359.     this._is_end_patb_act = false;
  360. }; // BattleManager.endAction
  361.  
  362. BattleManager.processActionSequencePatbCompatibility =
  363. BattleManager.processActionSequence;
  364. BattleManager.processActionSequence = function(actionName, actionArgs) {
  365. // v1.03a+
  366.     // Added to process new action sequences mimicking patb plugin calls
  367.     if (this.is_patb_act_sequence(actionName)) {
  368.         return this.process_patb_act_sequence(actionName, actionArgs);
  369.     }
  370.     // YEP_BattleEngineCore_ActionSequences
  371.     return this.processActionSequencePatbCompatibility(actionName, actionArgs);
  372. }; // BattleManager.processActionSequence
  373.  
  374. BattleManager.createActionsPatbCompatibility = BattleManager.createActions;
  375. BattleManager.createActions = function() {
  376.     // Rewritten to stop recreating battler actions when starting actor inputs
  377.     if (!$gameSystem.is_patb()) { this.createActionsPatbCompatibility(); }
  378.     // YEP_BattleEngineCore_StopRecreateAction
  379. }; // BattleManager.createActions
  380.  
  381. BattleManager.can_update_patb_process_compatibility =
  382. BattleManager.can_update_patb_process;
  383. BattleManager.can_update_patb_process = function() { // Hotspot
  384.     // Added to let BattleManager.update handle all phases when executing action
  385.     if (this._phase === 'actionList' || this._phase === 'actionTargetList') {
  386.         this.update();
  387.         return false;
  388.     } else if (this._phase === 'phaseChange') {
  389.         this.update();
  390.         return false;
  391.     }
  392.     // YEP_BattleEngineCore_HandleNewPhases
  393.     return this.can_update_patb_process_compatibility();
  394. }; // BattleManager.can_update_patb_process
  395.  
  396. BattleManager.init_patb_act_sequences = function() { // v1.03a+; New
  397.     this._patb_act_sequences = {
  398.         // DoubleX RMMV Popularized ATB Core
  399.         'ATB VAL': 'process_patb_val_act_sequence',
  400.         'ATB VAL %': 'process_patb_val_percent_act_sequence',
  401.         'RESET ATB VAL': 'process_reset_patb_val_act_sequence',
  402.         'RESET ATB': 'process_reset_patb_act_sequence',
  403.         //
  404.         // DoubleX RMMV Popularized ATB Charge
  405.         'CHARGE VAL': 'process_patb_charge_val_act_sequence',
  406.         'CHARGE VAL %': 'process_patb_charge_val_percent_act_sequence',
  407.         //
  408.         // DoubleX RMMV Popularized ATB Cooldown
  409.         'COOLDOWN VAL': 'process_patb_cooldown_val_act_sequence',
  410.         'COOLDOWN VAL %': 'process_patb_cooldown_val_percent_act_sequence',
  411.         //
  412.         // DoubleX RMMV Popularized ATB Countdown
  413.         'COUNTDOWN CLOCK': 'process_patb_countdown_clock_act_sequence',
  414.         'COUNTDOWN FREEZE': 'process_patb_countdown_freeze_act_sequence',
  415.         //
  416.         // DoubleX RMMV Popularized ATB Delay
  417.         'DELAY FRAME': 'process_patb_delay_frame_act_sequence',
  418.         //
  419.         // DoubleX RMMV Popularized ATB Reset
  420.         'RESET VAL': 'process_patb_reset_val_act_sequence',
  421.         'RESET VAL %': 'process_patb_reset_val_percent_act_sequence'
  422.         //
  423.     };
  424.     this._patb_act_sequence_regex = {
  425.         // DoubleX RMMV Popularized ATB Core
  426.         'ATB VAL': / *(.+) +(\d+) */i,
  427.         'ATB VAL %': / *(.+) +(\d+) */i,
  428.         'RESET ATB VAL': /.*/i,
  429.         'RESET ATB': /.*/i,
  430.         //
  431.         // DoubleX RMMV Popularized ATB Charge
  432.         'CHARGE VAL': / *(.+) +(\d+) */i,
  433.         'CHARGE VAL %': / *(.+) +(\d+) */i,
  434.         //
  435.         // DoubleX RMMV Popularized ATB Cooldown
  436.         'COOLDOWN VAL': / *(.+) +(\d+) */i,
  437.         'COOLDOWN VAL %': / *(.+) +(\d+) */i,
  438.         //
  439.         // DoubleX RMMV Popularized ATB Countdown
  440.         'COUNTDOWN CLOCK': / *(.+) +(\d+) +(\d+) */i,
  441.         'COUNTDOWN FREEZE': / *(\w+) +(\d+) */i,
  442.         //
  443.         // DoubleX RMMV Popularized ATB Delay
  444.         'DELAY FRAME': / *(.+) +(\d+) */i,
  445.         //
  446.         // DoubleX RMMV Popularized ATB Reset
  447.         'RESET VAL': / *(.+) +(\d+) */i,
  448.         'RESET VAL %': / *(.+) +(\d+) */i
  449.         //
  450.     };
  451. }; // BattleManager.init_patb_act_sequences
  452.  
  453. BattleManager.is_patb_act_sequence = function(actionName) { // v1.03a+; New
  454.     return Object.keys(this._patb_act_sequences).indexOf(actionName) >= 0;
  455. }; // BattleManager.processActionSequence
  456.  
  457. BattleManager.process_patb_act_sequence = function(actionName, actionArgs) {
  458. // v1.03a+; New
  459.     if (!$gameSystem.is_patb()) { return true; }
  460.     var targets = this.makeActionTargets(actionArgs[0]);
  461.     if (targets.length <= 0) { return true; };
  462.     var cmd = actionArgs[1];
  463.     if (cmd && !cmd.match(this._patb_act_sequence_regex[actionName])) {
  464.         return true;
  465.     }
  466.     return this[this._patb_act_sequences[actionName]](targets, cmd);
  467. }; // BattleManager.process_patb_act_sequence
  468.  
  469. BattleManager.process_patb_val_act_sequence = function(targets) {
  470. // v1.03a+; New
  471.     var operator = RegExp.$1, val = +RegExp.$2 * 1.0;
  472.     targets.forEach(function(target) {
  473.         if (this.is_patb_charge(target)) { target.reset_patb(); }
  474.         var atb = target.patb_val.atb;
  475.         target.patb_val.atb = target.operate_patb_notes(atb, operator, val);
  476.     }, this);
  477.     return true;
  478. }; // BattleManager.process_patb_val_act_sequence
  479.  
  480. BattleManager.process_patb_val_percent_act_sequence = function(targets) {
  481. // v1.03a+; New
  482.     var operator = RegExp.$1, temp = +RegExp.$2;
  483.     targets.forEach(function(target) {
  484.         if (this.is_patb_charge(target)) { target.reset_patb(); }
  485.         var val = temp * target.max_patb_val / 100.0, atb = target.patb_val.atb;
  486.         target.patb_val.atb = target.operate_patb_notes(atb, operator, val);
  487.     }, this);
  488.     return true;
  489. }; // BattleManager.process_patb_val_percent_act_sequence
  490.  
  491. BattleManager.process_reset_patb_val_act_sequence = function(targets) {
  492. // v1.03a+; New
  493.     targets.forEach(function(target) { target.reset_patb_val(); }, this);
  494.     return true;
  495. }; // BattleManager.process_reset_patb_val_act_sequence
  496.  
  497. BattleManager.process_reset_patb_act_sequence = function(targets) {
  498. // v1.03a+; New
  499.     targets.forEach(function(target) { target.reset_patb(); }, this);
  500.     return true;
  501. }; // BattleManager.process_reset_patb_act_sequence
  502.  
  503. BattleManager.process_patb_charge_val_act_sequence = function(targets) {
  504. // v1.03a+; New
  505.     if (!DoubleX_RMMV["PATB Charge"]) { return true; }
  506.     var operator = RegExp.$1, val = +RegExp.$2 * 1.0;
  507.     targets.filter(this.is_patb_charge, this).forEach(function(target) {
  508.         var charge = target.patb_val.charge;
  509.         target.patb_val.charge =
  510.                 target.operate_patb_notes(charge, operator, val);
  511.     }, this);
  512.     return true;
  513. }; // BattleManager.process_patb_charge_val_act_sequence
  514.  
  515. BattleManager.process_patb_charge_val_percent_act_sequence = function(targets) {
  516. // v1.03a+; New
  517.     if (!DoubleX_RMMV["PATB Charge"]) { return true; }
  518.     var operator = RegExp.$1, temp = +RegExp.$2;
  519.     targets.filter(this.is_patb_charge, this).forEach(function(target) {
  520.         var val = temp * target.max_patb_val / 100.0;
  521.         var charge = target.patb_val.charge;
  522.         target.patb_val.charge =
  523.                 target.operate_patb_notes(charge, operator, val);
  524.     }, this);
  525.     return true;
  526. }; // BattleManager.process_patb_charge_val_percent_act_sequence
  527.  
  528. BattleManager.is_patb_charge = function(target) { // v1.03a+; New
  529.     if (this.is_patb_cooldown(target)) { return false; }
  530.     return DoubleX_RMMV["PATB Charge"] && target.is_patb_charge();
  531. }; // BattleManager.is_patb_charge
  532.  
  533. BattleManager.process_patb_cooldown_val_act_sequence = function(targets) {
  534. // v1.03a+; New
  535.     if (!DoubleX_RMMV["PATB Cooldown"]) { return true; }
  536.     var operator = RegExp.$1, val = +RegExp.$2 * 1.0;
  537.     targets.filter(this.is_patb_cooldown, this).forEach(function(target) {
  538.         var cooldown = target.patb_val.cooldown;
  539.         target.patb_val.cooldown =
  540.                 target.operate_patb_notes(cooldown, operator, val);
  541.     }, this);
  542.     return true;
  543. }; // BattleManager.process_patb_cooldown_val_act_sequence
  544.  
  545. BattleManager.process_patb_cooldown_val_percent_act_sequence = function(targets) {
  546. // v1.03a+; New
  547.     if (!DoubleX_RMMV["PATB Cooldown"]) { return true; }
  548.     var operator = RegExp.$1, temp = +RegExp.$2;
  549.     targets.filter(this.is_patb_cooldown, this).forEach(function(target) {
  550.         var val = temp * target.max_patb_val / 100.0;
  551.         var cooldown = target.patb_val.cooldown;
  552.         target.patb_val.cooldown =
  553.                 target.operate_patb_notes(cooldown, operator, val);
  554.     }, this);
  555.     return true;
  556. }; // BattleManager.process_patb_cooldown_val_percent_act_sequence
  557.  
  558. BattleManager.is_patb_cooldown = function(target) { // v1.03a+; New
  559.     return target.is_patb_cooldown();
  560. }; // BattleManager.is_patb_cooldown
  561.  
  562. BattleManager.process_patb_countdown_clock_act_sequence = function(targets) {
  563. // v1.03a+; New
  564.     if (!DoubleX_RMMV["PATB Countdown"]) { return true; }
  565.     var operator = RegExp.$1, val = +RegExp.$2, state_id = +RegExp.$3;
  566.     // Separating the filter function would cause make it too hard for learners
  567.     targets.filter(function(target) {
  568.         return target.isStateAdded(state_id);
  569.     }, this).forEach(function(target) {
  570.         var clock = target.patb_countdown_clock[state_id];
  571.         var new_clock = target.operate_patb_notes(clock, operator, val);;
  572.         target.patb_countdown_clock[state_id] = new_clock;
  573.     }, this);
  574.     //
  575.     return true;
  576. }; // BattleManager.process_patb_countdown_clock_act_sequence
  577.  
  578. BattleManager.process_patb_countdown_freeze_act_sequence = function(targets) {
  579. // v1.03a+; New
  580.     if (!DoubleX_RMMV["PATB Countdown"]) { return true; }
  581.     var is_freeze = RegExp.$1 === "true", state_id = +RegExp.$2;
  582.     // Separating the filter function would cause make it too hard for learners
  583.     targets.filter(function(target) {
  584.         return target.isStateAdded(state_id);
  585.     }, this).forEach(function(target) {
  586.         target.patb_countdown_freeze[state_id] = is_freeze;
  587.     }, this);
  588.     //
  589.     return true;
  590. }; // BattleManager.process_patb_countdown_freeze_act_sequence
  591.  
  592. BattleManager.process_patb_delay_frame_act_sequence = function(targets) {
  593. // v1.03a+; New
  594.     if (!DoubleX_RMMV["PATB Delay"]) { return true; }
  595.     var operator = RegExp.$1, val = +RegExp.$2;
  596.     // Restricting delay to its intended scope would make this sequence useless
  597.     targets.forEach(function(target) {
  598.         var delay = target.patb_delay;
  599.         target.patb_delay = target.operate_patb_notes(delay, operator, val);
  600.     }, this);
  601.     //
  602.     return true;
  603. }; // BattleManager.process_patb_delay_frame_act_sequence
  604.  
  605. BattleManager.process_patb_reset_val_act_sequence = function(targets) {
  606. // v1.03a+; New
  607.     if (!DoubleX_RMMV["PATB Reset"]) { return true; }
  608.     var operator = RegExp.$1, val = +RegExp.$2 * 1.0;
  609.     targets.forEach(function(target) {
  610.         var reset = target.patb_reset_val;
  611.         target.patb_reset_val = target.operate_patb_notes(reset, operator, val);
  612.     }, this);
  613.     return true;
  614. }; // BattleManager.process_patb_reset_val_act_sequence
  615.  
  616. BattleManager.process_patb_reset_val_percent_act_sequence = function(targets) {
  617. // v1.03a+; New
  618.     if (!DoubleX_RMMV["PATB Reset"]) { return true; }
  619.     var operator = RegExp.$1, temp = +RegExp.$2;
  620.     targets.forEach(function(target) {
  621.         var val = temp * target.max_patb_val / 100.0;
  622.         var reset = target.patb_reset_val;
  623.         target.patb_reset_val = target.operate_patb_notes(reset, operator, val);
  624.     }, this);
  625.     return true;
  626. }; // BattleManager.process_patb_reset_val_percent_act_sequence
  627.  
  628. /*----------------------------------------------------------------------------
  629.  *    # Edit class: Game_Battler
  630.  *----------------------------------------------------------------------------*/
  631.  
  632. Game_Battler.prototype.requestMotionRefresh = function() { // v1.03f+; Rewrite
  633.     var deadMotion = this.deadMotion();
  634.     if (this.isDead() && this._motionType !== deadMotion) {
  635.       this.requestMotion(deadMotion);
  636.     }
  637.     if (this.isDead() && this._motionType === deadMotion) { return; }
  638.     if (this._motionType === 'victory') { return; }
  639.     if (this._motionType === 'escape' && !BattleManager.isInputting()) {
  640.         return;
  641.     } else if (this._motionType === 'guard' && !BattleManager.isInputting()) {
  642.         return;
  643.     }
  644.     this.clearMotion();
  645.     // Rewritten to stop refreshing motion when executing action sequences
  646.     if (this.battler() && BattleManager.isInputting() && (!$gameSystem.is_patb() || BattleManager._phase !== "actionList" && BattleManager._phase !== "actionTargetList")) {
  647.       this.battler().refreshMotion();
  648.     }
  649.     // YEP_BattleEngineCore_StopRefreshBattlerMotion
  650. }; // Game_Battler.prototype.requestMotionRefresh
  651.  
  652. Game_Battler.prototype.spriteReturnHomeComnpatibility =
  653. Game_Battler.prototype.spriteReturnHome;
  654. Game_Battler.prototype.spriteReturnHome = function() { // v1.03b+
  655.     // Added to stop returning home for the sprite of the currently inpuable one
  656.     if ($gameSystem.is_patb() && BattleManager.actor() === this) { return; }
  657.     // YEP_BattleEngineCore_StopInputableActorReturnHome
  658.     this.spriteReturnHomeComnpatibility();
  659. }; // Game_Battler.prototype.spriteReturnHome
  660.  
  661. Game_Battler.prototype.on_all_patb_acts_end_comnpatibility =
  662. Game_Battler.prototype.on_all_patb_acts_end;
  663. Game_Battler.prototype.on_all_patb_acts_end = function() {
  664.     // Added to stop resetting the battler's atb when there's still actions
  665.     if (this.currentAction() || BattleManager.is_end_patb_act) { return; }
  666.     // YEP_BattleEngineCore_StopAllActsEnd
  667.     this.on_all_patb_acts_end_comnpatibility();
  668. }; // Game_Battler.prototype.on_all_patb_acts_end
  669.  
  670. /*----------------------------------------------------------------------------
  671.  *    # (v1.03c+)Edit class: Window_Help
  672.  *----------------------------------------------------------------------------*/
  673.  
  674. // Added to let the help window call the deselect method
  675. Window_Help.prototype.deselect = Window_Help.prototype.deselect || function() {};
  676. // YEP_BattleEngineCore_CloseInvalidTargetHelpWindow
  677.  
  678. /*----------------------------------------------------------------------------
  679.  *    # (v1.04a)Edit class: Window_Patb_Bar
  680.  *----------------------------------------------------------------------------*/
  681.  
  682. // Don't check if animated sideview enemies are on as it's a general problem
  683. Window_Patb_Bar.prototype.updateBarCompatibility =
  684. Window_Patb_Bar.prototype.updateBar;
  685. Window_Patb_Bar.prototype.updateBar = function() { // Hotspot
  686.     this.updateBarCompatibility();
  687.     // Added to mirror the ATB bar again if its parent's mirrored
  688.     if (this.visible) { Sprite_StateIcon.prototype.updateMirror.call(this); }
  689.     // YEP_X_AnimatedSVEnemies_UnmirrorMirroredATBBars
  690. }; // Window_Patb_Bar.prototype.updateBar
  691. // Fixes like this might cause minor performance issues on low-end mobiles
  692.  
  693. /*----------------------------------------------------------------------------
  694.  *    # (v1.03c+)Edit class: Scene_Battle
  695.  *----------------------------------------------------------------------------*/
  696.  
  697.  [
  698.      "commandSkill",
  699.      "commandItem",
  700.      "selectActorSelection",
  701.      "selectEnemySelection"
  702.  ].forEach(function(func) {
  703.      Scene_Battle.prototype[func + "PatbCompatibility"] =
  704.      Scene_Battle.prototype[func];
  705.      Scene_Battle.prototype[func] = function() {
  706.          this[func + "PatbCompatibility"]();
  707.          // Added to ensure that the target help window will be shown and active
  708.          this._helpWindow.open();
  709.          // YEP_BattleEngineCore_ShowHelpWindow
  710.      }; // Scene_Battle.prototype[func]
  711.  });
  712.  
  713.  Scene_Battle.prototype.refresh_patb_windows_comnpatibility =
  714.  Scene_Battle.prototype.refresh_patb_windows;
  715.  Scene_Battle.prototype.refresh_patb_windows = function() { // New
  716.      this.refresh_patb_windows_comnpatibility();
  717.      // Added to refresh the target help window as well
  718.      [this._actorWindow, this._enemyWindow].forEach(function(window) {
  719.        if (!window.visible) { return; }
  720.        window.reselect();
  721.        window.updateHelp();
  722.      }, this);
  723.      // YEP_BattleEngineCore_UpdateSelectionHelpWindow
  724.  }; // Scene_Battle.prototype.refresh_patb_windows
  725.  
  726. Scene_Battle.prototype.patb_selection_windows_comnpatibility =
  727. Scene_Battle.prototype.patb_selection_windows;
  728. Scene_Battle.prototype.patb_selection_windows = function() { // v1.03c+
  729.     // Edited to close the target help window as well
  730.     return this.patb_selection_windows_comnpatibility().concat(
  731.             [this._helpWindow]);
  732.     // YEP_BattleEngineCore_CloseInvalidTargetHelpWindow
  733. }; // Scene_Battle.prototype.patb_selection_windows
  734.  
  735. if (Imported.YEP_X_SelectionControl) {
  736.  
  737. /*----------------------------------------------------------------------------
  738.  *    # (v1.02b+)Edit class: Window_BattleStatus
  739.  *----------------------------------------------------------------------------*/
  740.  
  741. /*----------------------------------------------------------------------------
  742.  *    New public instance variable
  743.  *----------------------------------------------------------------------------*/
  744. // The index without being influenced by YEP_X_SelectionControl
  745. Object.defineProperty(Window_BattleStatus.prototype, "patb_index", {
  746.     get: function() { /* Hotspot */ return this._patb_index; },
  747.     configurable: true
  748. });
  749.  
  750. /*----------------------------------------------------------------------------
  751.  *    Uses a new variable to store the index that are not from target windows
  752.  *----------------------------------------------------------------------------*/
  753. Window_BattleStatus.prototype.select = function(index) { // New
  754.     Window_Selectable.prototype.select.call(this, index);
  755.     if (!$gameTemp.is_patb_selecting_targets) { this._patb_index = index; }
  756. }; // Window_BattleStatus.prototype.select
  757.  
  758. /*----------------------------------------------------------------------------
  759.  *    # (v1.02b+)Edit class: Window_BattleEnemy
  760.  *----------------------------------------------------------------------------*/
  761.  
  762. Window_BattleEnemy.prototype.hidePatbCompatibility =
  763. Window_BattleEnemy.prototype.hide;
  764. Window_BattleEnemy.prototype.hide = function() {
  765.     // Added to ensure the new index won't be influenced by selecting targets
  766.     $gameTemp.is_patb_selecting_targets = true;
  767.     // YEP_X_SelectionControl_NewStatusWindowIndex
  768.     Window_BattleEnemy.prototype.hidePatbCompatibility.call(this);
  769.     // Added to ensure the new index will be influenced by everything else
  770.     $gameTemp.is_patb_selecting_targets = false;
  771.     // YEP_X_SelectionControl_NewStatusWindowIndex
  772. }; // Window_BattleEnemy.prototype.hide
  773.  
  774. Window_BattleEnemy.prototype.selectPatbCompatibility =
  775. Window_BattleEnemy.prototype.select;
  776. Window_BattleEnemy.prototype.select = function(index) {
  777.     // Added to ensure the new index won't be influenced by selecting targets
  778.     $gameTemp.is_patb_selecting_targets = true;
  779.     // YEP_X_SelectionControl_NewStatusWindowIndex
  780.     Window_BattleEnemy.prototype.selectPatbCompatibility.call(this, index);
  781.     // Added to ensure the new index will be influenced by everything else
  782.     $gameTemp.is_patb_selecting_targets = false;
  783.     // YEP_X_SelectionControl_NewStatusWindowIndex
  784. }; // Window_BattleEnemy.prototype.select
  785.  
  786. /*----------------------------------------------------------------------------
  787.  *    # (v1.00e+)Edit class: Scene_Battle
  788.  *----------------------------------------------------------------------------*/
  789.  
  790. // actor_indices: The indices of all currently inputable actors
  791. Scene_Battle.prototype.update_patb_actor_selection = function() {
  792. // v1.02b+; Rewrite; Hotspot
  793.     var actor_indices = BattleManager.inputable_patb_actor_indices();
  794.     // Rewritten to use the index that are not changed by YEP_X_SelectionControl
  795.     var index = this._statusWindow.patb_index;
  796.     // YEP_X_SelectionControl_NewStatusWindowIndex
  797.     if (actor_indices.indexOf(index) >= 0) { return; }
  798.     // Deactivates the active input windows that should be no longer active
  799.     if (index >= 0) { return this.close_patb_selection_windows(); }
  800.     if (this._partyCommandWindow.active) {
  801.         if (actor_indices.length <= 0) {
  802.             this.close_patb_window(this._partyCommandWindow);
  803.         }
  804.         return;
  805.     }
  806.     //
  807.     if (actor_indices.length <= 0) { return; }
  808.     BattleManager.changeActor(actor_indices[0], 'waiting');
  809.     this.startActorCommandSelection();
  810. }; // Scene_Battle.prototype.update_patb_actor_selection
  811.  
  812. Scene_Battle.prototype.select_next_patb_command_comnpatibility =
  813. Scene_Battle.prototype.select_next_patb_command;
  814. Scene_Battle.prototype.select_next_patb_command = function() { // v1.00b+
  815.     this.select_next_patb_command_comnpatibility();
  816.     // Added to ensure that subsequent actions won't be marked as all selections
  817.     BattleManager.stopAllSelection();
  818.     // YEP_BattleEngineCore_StopWrongAllSelections
  819. }; // Scene_Battle.prototype.select_next_patb_command
  820.  
  821. Scene_Battle.prototype.close_patb_selection_windows_comnpatibility =
  822. Scene_Battle.prototype.close_patb_selection_windows;
  823. Scene_Battle.prototype.close_patb_selection_windows = function() { // v1.02a+
  824.     // Added to save the last active status before stopping it from being closed
  825.     var is_enemy_window_active = this._enemyWindow.active;
  826.     // YEP_X_SelectionControl_StopUnlockingEnemyWindow
  827.     this.close_patb_selection_windows_comnpatibility();
  828.     // Added to load the last active status after stopping it from being closed
  829.     if (is_enemy_window_active) this._enemyWindow.activate();
  830.     // YEP_X_SelectionControl_StopUnlockingEnemyWindow
  831. }; // Scene_Battle.prototype.close_patb_selection_windows
  832.  
  833. } // if (Imported.YEP_X_SelectionControl)
  834.  
  835. if (DoubleX_RMMV["PATB Hotkey"]) {
  836.  
  837. /*----------------------------------------------------------------------------
  838.  *    # (v1.00b+)Edit class: Window_ActorCommand.
  839.  *----------------------------------------------------------------------------*/
  840.  
  841. Window_ActorCommand.prototype.processTouch = function() { // New; Hotspot
  842.     this.process_patb_hotkey_touch();
  843.     Window_Selectable.prototype.processTouch.call(this);
  844. }; // Window_ActorCommand.prototype.processTouch
  845.  
  846. Window_ActorCommand.prototype.process_patb_hotkey_touch = function() {
  847. // New; Hotspot
  848.     if (!this.isOpenAndActive() || !$gameSystem.is_patb()) { return; }
  849.     this.process_patb_hotkey_touch_select();
  850.     this.process_patb_hotkey_touch_trigger();
  851. }; // Window_ActorCommand.prototype.process_patb_hotkey_touch
  852.  
  853. Window_ActorCommand.prototype.process_patb_hotkey_touch_select = function() {
  854. // New; Hotspot
  855.     if (!Yanfly.Param.BECSelectMouseOver) { return; }
  856.     var index = this.getMouseOverActor();
  857.     if (index < 0) { return; }
  858.     var mem = $gameParty.battleMembers()[index];
  859.     if (mem.isSelected()) { return; }
  860.     SoundManager.playCursor();
  861.     $gameParty.select(mem);
  862. }; // Window_ActorCommand.prototype.process_patb_hotkey_touch_select
  863.  
  864. Window_ActorCommand.prototype.process_patb_hotkey_touch_trigger = function() {
  865. // New; Hotspot
  866.     if (!eval(Yanfly.Param.BECActorSelect)) { return; }
  867.     if (!TouchInput.isTriggered() || this.isTouchedInsideFrame()) { return; }
  868.     var i = this.getClickedActor();
  869.     if (i < 0) { return; }
  870.     return this.callHandler($gameSystem.patb["hotkey_actor_" + i.toString()]);
  871. }; // Window_ActorCommand.prototype.process_patb_hotkey_touch_trigger
  872.  
  873. Window_ActorCommand.prototype.getClickedActor =
  874. Window_BattleActor.prototype.getClickedActor;
  875.  
  876. Window_ActorCommand.prototype.isClickedActor =
  877. Window_BattleActor.prototype.isClickedActor;
  878.  
  879. Window_ActorCommand.prototype.getMouseOverActor =
  880. Window_BattleActor.prototype.getMouseOverActor;
  881.  
  882. Window_ActorCommand.prototype.isMouseOverActor =
  883. Window_BattleActor.prototype.isMouseOverActor;
  884.  
  885. } // if (DoubleX_RMMV["PATB Hotkey"])
  886.  
  887. } // if (Imported.YEP_BattleEngineCore)
  888.  
  889. if (Imported.MOG_BattleHud) {
  890.  
  891. /*----------------------------------------------------------------------------
  892.  *    # (v1.01a+)Edit class: Battle_Hud
  893.  *----------------------------------------------------------------------------*/
  894.  
  895. Battle_Hud.prototype.update_at = function() {
  896.     if (this._at_meter) {
  897.         if (!this.at === -1) { return this._at_meter.visible = false; }
  898.         this._at_meter.visible = true;
  899.         if(!this._at_flow[0]) {
  900.             // Rewritten to update the cooldown atb bars as well
  901.             if (this.is_casting()) {
  902.                 if (this.is_max_cast()) {
  903.                     return this.refresh_at_meter(this._at_meter, this.cast_at(), this.cast_max_at(), 3);
  904.                 }
  905.                 return this.refresh_at_meter(this._at_meter, this.cast_at(), this.cast_max_at(), 2);
  906.             } else if (this.is_cooling_down()) {
  907.                 if (this.is_max_cooldown()) {
  908.                     return this.refresh_at_meter(this._at_meter, this.cooldown_at(), this.cooldown_max_at(), 3);
  909.                 }
  910.                 return this.refresh_at_meter(this._at_meter, this.cooldown_at(), this.cooldown_max_at(), 2);
  911.             } else if (this.is_max_at()) {
  912.                 return this.refresh_at_meter(this._at_meter, this.at(), this.max_at(), 1);
  913.             }
  914.             // MOG_BattleHud_PATB_Data
  915.             return this.refresh_at_meter(this._at_meter, this.at(), this.max_at(), 0);
  916.         }
  917.         // Rewritten to update the cooldown atb bars as well
  918.         if (this.is_casting()) {
  919.             if (this.is_max_cast()) {
  920.                 this.refresh_at_meter_flow(this._at_meter, this.cast_at(), this.cast_max_at(), 3, this._at_flow[1]);
  921.             } else {
  922.                 this.refresh_at_meter_flow(this._at_meter, this.cast_at(), this.cast_max_at(), 2, this._at_flow[1]);
  923.             }
  924.         } else if (this.is_cooling_down()) {
  925.             if (this.is_max_cooldown()) {
  926.                 this.refresh_at_meter_flow(this._at_meter, this.cooldown_at(), this.cooldown_max_at(), 3, this._at_flow[1]);
  927.             } else {
  928.                 this.refresh_at_meter_flow(this._at_meter, this.cooldown_at(), this.cooldown_max_at(), 2, this._at_flow[1]);
  929.             }
  930.         } else if (this.is_max_at()) {
  931.             this.refresh_at_meter_flow(this._at_meter, this.at(), this.max_at(), 1, this._at_flow[1]);
  932.         } else {
  933.             this.refresh_at_meter_flow(this._at_meter, this.at(), this.max_at(), 0, this._at_flow[1]);
  934.         }
  935.         // MOG_BattleHud_PATB_Data
  936.         this._at_flow[1] += 1.5;
  937.         if (this._at_flow[1] > this._at_flow[3]) { this._at_flow[1] = 0; }
  938.     }
  939. }; // Battle_Hud.prototype.update_at
  940.  
  941. Battle_Hud.prototype.at_patb_compatibility = Battle_Hud.prototype.at;
  942. Battle_Hud.prototype.at = function() {
  943.     // Added to use the ATB value from PATB only if it's active
  944.     if ($gameSystem.is_patb()) { return this._battler.patb_val.atb; }
  945.     // MOG_BattleHud_PATB_Data
  946.     return this.at_patb_compatibility();
  947. }; // Battle_Hud.prototype.at
  948.  
  949. Battle_Hud.prototype.max_at_patb_compatibility = Battle_Hud.prototype.max_at;
  950. Battle_Hud.prototype.max_at = function() {
  951.     // Added to use the ATB value from PATB only if it's active
  952.     if ($gameSystem.is_patb()) { return this._battler._max_patb_val; }
  953.     // MOG_BattleHud_PATB_Data
  954.     return this.max_at_patb_compatibility();
  955. }; // Battle_Hud.prototype.max_at
  956.  
  957. Battle_Hud.prototype.cast_at_patb_compatibility = Battle_Hud.prototype.cast_at;
  958. Battle_Hud.prototype.cast_at = function() {
  959.     // Added to use the ATB value from PATB only if it's active
  960.     if ($gameSystem.is_patb()) {
  961.         if (!DoubleX_RMMV["PATB Charge"]) { return 0; }
  962.         return this._battler.patb_val.charge;
  963.     }
  964.     // MOG_BattleHud_PATB_Data
  965.     return this.cast_at_patb_compatibility();
  966. }; // Battle_Hud.prototype.cast_at
  967.  
  968. Battle_Hud.prototype.cast_max_at_patb_compatibility =
  969.         Battle_Hud.prototype.cast_max_at;
  970. Battle_Hud.prototype.cast_max_at = function() {
  971.     // Added to use the ATB value from PATB only if it's active
  972.     if ($gameSystem.is_patb()) { return this._battler._max_patb_val; }
  973.     // MOG_BattleHud_PATB_Data
  974.     return this.cast_max_at_patb_compatibility();
  975. }; // Battle_Hud.prototype.cast_max_at
  976.  
  977. Battle_Hud.prototype.is_casting_patb_compatibility =
  978.         Battle_Hud.prototype.is_casting;
  979. Battle_Hud.prototype.is_casting = function() {
  980.     // Added to use the ATB value from PATB only if it's active
  981.     if ($gameSystem.is_patb()) {
  982.         if (!DoubleX_RMMV["PATB Charge"]) { return false; }
  983.         return this._battler.is_patb_charge();
  984.     }
  985.     // MOG_BattleHud_PATB_Data
  986.     return this.is_casting_patb_compatibility();
  987. }; // Battle_Hud.prototype.is_casting
  988.  
  989. Battle_Hud.prototype.cooldown_at = function() { // New; Hotspot
  990.     if (!$gameSystem.is_patb() || !DoubleX_RMMV["PATB Cooldown"]) { return 0; }
  991.     return this._battler.patb_val.cooldown;
  992. }; // Battle_Hud.prototype.cooldown_at
  993.  
  994. Battle_Hud.prototype.cooldown_max_at = function() { // New; Hotspot
  995.     return $gameSystem.is_patb() ? this._battler._max_patb_val : 1;
  996. }; // Battle_Hud.prototype.cooldown_max_at
  997.  
  998. Battle_Hud.prototype.is_cooling_down = function() { // New; Hotspot
  999.     if ($gameSystem.is_patb() && DoubleX_RMMV["PATB Cooldown"]) {
  1000.         return this._battler.is_patb_cooldown();
  1001.     }
  1002.     return false;
  1003. }; // Battle_Hud.prototype.is_cooling_down
  1004.  
  1005. Battle_Hud.prototype.is_max_cooldown = function() { // New; Hotspot
  1006.     return this.cooldown_at() >= this.cooldown_max_at();
  1007. }; // Battle_Hud.prototype.is_max_cooldown
  1008.  
  1009. /*----------------------------------------------------------------------------
  1010.  *    # (v1.01b+)Edit class: Scene_Battle
  1011.  *----------------------------------------------------------------------------*/
  1012.  
  1013. Scene_Battle.prototype.update_patb_window_positions = function() { // Rewrite
  1014.     // Removed to let MOG_BattleHud handle the actor window positions
  1015.     // MOG_BattleHud_Actor_Window
  1016. }; // Scene_Battle.prototype.update_patb_window_positions
  1017.  
  1018. Scene_Battle.prototype.close_patb_selection_windows_comnpatibility2 =
  1019. Scene_Battle.prototype.close_patb_selection_windows;
  1020. Scene_Battle.prototype.close_patb_selection_windows = function() { // v1.02b+
  1021.     this.close_patb_selection_windows_comnpatibility2();
  1022.     // Added to stop showing the status window
  1023.     this._statusWindow.close();
  1024.     this._statusWindow.hide();
  1025.     // MOG_BattleHud_StopShowingStatusWindow
  1026. }; // Scene_Battle.prototype.close_patb_selection_windows
  1027.  
  1028. } // if (Imported.MOG_BattleHud)
  1029.  
  1030. /*----------------------------------------------------------------------------*/
  1031.  
  1032. } else {
  1033.     alert("To use PATB Compatibility, place it below all other PATB plugins.");
  1034. }
  1035.  
  1036. /*============================================================================*/
RAW Paste Data Copied