设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2897|回复: 0
打印 上一主题 下一主题

[已经过期] YEP_BattleEngineCore的问题

[复制链接]

Lv4.逐梦者

梦石
0
星屑
6422
在线时间
1557 小时
注册时间
2011-6-14
帖子
520
跳转到指定楼层
1
发表于 2016-4-22 13:31:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本来是连击多少次就显示多少次动画,使用YEP_BattleEngineCore后变成了连击N次只显示一次动画,求解 怎么改回去

JAVASCRIPT 代码复制
  1. //=============================================================================
  2. // Yanfly Engine Plugins - Battle Engine Core
  3. // YEP_BattleEngineCore.js
  4. //=============================================================================
  5.  
  6. var Imported = Imported || {};
  7. Imported.YEP_BattleEngineCore = true;
  8.  
  9. var Yanfly = Yanfly || {};
  10. Yanfly.BEC = Yanfly.BEC || {};
  11.  
  12. //=============================================================================
  13. /*:
  14.  * @plugindesc v1.35 Have more control over the flow of the battle system
  15.  * with this plugin and alter various aspects to your liking.
  16.  * @author Yanfly Engine Plugins
  17.  *
  18.  * @param ---General---
  19.  * @default
  20.  *
  21.  * @param Action Speed
  22.  * @desc This is the formula used for an action's base speed.
  23.  * Default: agi + Math.randomInt(Math.floor(5 + agi / 4))
  24.  * @default agi
  25.  *
  26.  * @param Default System
  27.  * @desc This is the default battle system your game uses.
  28.  * Default: dtb
  29.  * @default dtb
  30.  *
  31.  * @param ---Escape---
  32.  * @default
  33.  *
  34.  * @param Escape Ratio
  35.  * @desc This is the formula used to determine escape success.
  36.  * Default: 0.5 * $gameParty.agility() / $gameTroop.agility()
  37.  * @default 0.5 * $gameParty.agility() / $gameTroop.agility()
  38.  *
  39.  * @param Fail Escape Boost
  40.  * @desc Each time the player fails escape, increase the success
  41.  * rate by this much. Default: 0.1
  42.  * @default 0.1
  43.  *
  44.  * @param ---Animation---
  45.  * @default
  46.  *
  47.  * @param Animation Base Delay
  48.  * @desc This sets the base delay in between animations.
  49.  * Default: 8
  50.  * @default 0
  51.  *
  52.  * @param Animation Next Delay
  53.  * @desc This sets the sequential delay in between animations.
  54.  * Default: 12
  55.  * @default 0
  56.  *
  57.  * @param Certain Hit Animation
  58.  * @desc Default animation to play for certain hit skills.
  59.  * Use 0 if you wish for no animation.
  60.  * @default 120
  61.  *
  62.  * @param Physical Animation
  63.  * @desc Default animation to play for physical skills.
  64.  * Use 0 if you wish for no animation.
  65.  * @default 52
  66.  *
  67.  * @param Magical Animation
  68.  * @desc Default animation to play for magical skills.
  69.  * Use 0 if you wish for no animation.
  70.  * @default 51
  71.  *
  72.  * @param Enemy Attack Animation
  73.  * @desc This is the default attack animation played by enemies.
  74.  * Default: 0
  75.  * @default 39
  76.  *
  77.  * @param Reflect Animation
  78.  * @desc The animation used when magic attacks are reflected.
  79.  * @default 42
  80.  *
  81.  * @param Motion Waiting
  82.  * @desc Play animations after performing an action or during?
  83.  * During - false     After - true     Default: false
  84.  * @default false
  85.  *
  86.  * @param ---Frontview---
  87.  * @default
  88.  *
  89.  * @param Front Position X
  90.  * @desc This formula determines the actor's home X position.
  91.  * Default: 0
  92.  * @default Graphics.boxWidth / 8 + Graphics.boxWidth / 4 * index
  93.  *
  94.  * @param Front Position Y
  95.  * @desc This formula determines the actor's home Y position.
  96.  * Default: 0
  97.  * @default Graphics.boxHeight - 180
  98.  *
  99.  * @param Front Actor Sprite
  100.  * @desc Show the actor battle sprite in frontview?
  101.  * NO - false     YES - true     Default - false
  102.  * @default false
  103.  *
  104.  * @param Front Sprite Priority
  105.  * @desc Give actor sprites the priority of always being on top?
  106.  * 0 - Normal   1 - Actors on Top   2 - Enemies on Top
  107.  * @default 1
  108.  *
  109.  * @param ---Sideview---
  110.  * @default
  111.  *
  112.  * @param Home Position X
  113.  * @desc This formula determines the actor's home X position.
  114.  * Default: 600 + index * 32
  115.  * @default screenWidth - 16 - (maxSize + 2) * 32 + index * 32
  116.  *
  117.  * @param Home Position Y
  118.  * @desc This formula determines the actor's home Y position.
  119.  * Default: 280 + index * 48
  120.  * @default screenHeight - statusHeight - maxSize * 48 + (index+1) * 48 - 32
  121.  *
  122.  * @param Side Sprite Priority
  123.  * @desc Give actor sprites the priority of always being on top?
  124.  * 0 - Normal   1 - Actors on Top   2 - Enemies on Top
  125.  * @default 1
  126.  *
  127.  * @param ---Sprites---
  128.  * @default
  129.  *
  130.  * @param Default X Anchor
  131.  * @desc Default value used for your sprites's X Anchor.
  132.  * Default: 0.5
  133.  * @default 0.5
  134.  *
  135.  * @param Default Y Anchor
  136.  * @desc Default value used for your sprites's Y Anchor.
  137.  * Default: 1.0
  138.  * @default 1.0
  139.  *
  140.  * @param Step Distance
  141.  * @desc This is the distance a unit steps forward for actions.
  142.  * Default: 48
  143.  * @default 48
  144.  *
  145.  * @param Flinch Distance
  146.  * @desc In sideview, when a unit takes damage or dodges, it will
  147.  * flinch a certain distance in pixels.
  148.  * @default 12
  149.  *
  150.  * @param Show Shadows
  151.  * @desc Do you wish to have shadows appear under actors?
  152.  * NO - false     YES - true
  153.  * @default true
  154.  *
  155.  * @param ---Damage Popups---
  156.  * @default
  157.  *
  158.  * @param Popup Duration
  159.  * @desc Adjusts how many frames a popup will stay visible for.
  160.  * Default: 90
  161.  * @default 128
  162.  *
  163.  * @param Newest Popup Bottom
  164.  * @desc Places the newest popup at the bottom of a group.
  165.  * NO - false     YES - true
  166.  * @default true
  167.  *
  168.  * @param Popup Overlap Rate
  169.  * @desc When multiple damage popups appear, they cover each other.
  170.  * Use this to change the buffer rate amount for each sprite.
  171.  * @default 0.9
  172.  *
  173.  * @param Critical Popup
  174.  * @desc Adjusts the popup's flashing color for critical hits.
  175.  * Default: 255, 0, 0, 160
  176.  * @default 255, 0, 0, 160
  177.  *
  178.  * @param Critical Duration
  179.  * @desc How many frames the flashing will remain for a critical.
  180.  * Default: 60
  181.  * @default 60
  182.  *
  183.  * @param ---Tick-Settings---
  184.  * @default
  185.  *
  186.  * @param Timed States
  187.  * @desc If the battle system is Tick-based, use time instead of
  188.  * turns for states? NO - false   YES - true
  189.  * @default false
  190.  *
  191.  * @param Timed Buffs
  192.  * @desc If the battle system is Tick-based, use time instead of
  193.  * turns for buffs? NO - false   YES - true
  194.  * @default false
  195.  *
  196.  * @param Turn Time
  197.  * @desc How many ticks must past to equal 1 turn?
  198.  * @default 100
  199.  *
  200.  * @param AI Self Turns
  201.  * @desc Set AI to be based on their own individual turns?
  202.  * NO - false     YES - true
  203.  * @default true
  204.  *
  205.  * @param ---Window Settings---
  206.  * @default
  207.  *
  208.  * @param Lower Windows
  209.  * @desc Places the skill and item windows at the screen's bottom.
  210.  * OFF - false     ON - true
  211.  * @default true
  212.  *
  213.  * @param Window Rows
  214.  * @desc For lower windows, how many rows of items do you wish for
  215.  * the windows to display?
  216.  * @default 4
  217.  *
  218.  * @param Command Window Rows
  219.  * @desc Sets the number of rows for each command window to display.
  220.  * Default: 4
  221.  * @default 4
  222.  *
  223.  * @param Command Alignment
  224.  * @desc Sets the text alignment for the Party/Actor Commands.
  225.  * Default: left
  226.  * @default center
  227.  *
  228.  * @param Start Actor Command
  229.  * @desc Starts turn with the Actor Command Window instead of Party.
  230.  * OFF - false     ON - true
  231.  * @default true
  232.  *
  233.  * @param Current Max
  234.  * @desc Display the entire current / max value of HP/MP?
  235.  * NO - false     YES - true     Default: true
  236.  * @default false
  237.  *
  238.  * @param ---Selection Help---
  239.  * @default
  240.  *
  241.  * @param Mouse Over
  242.  * @desc Allows you to mouse over the enemies to auto-select them.
  243.  * OFF - false     ON - true
  244.  * @default true
  245.  *
  246.  * @param Select Help Window
  247.  * @desc When selecting actors and enemies, show the help window?
  248.  * NO - false     YES - true
  249.  * @default true
  250.  *
  251.  * @param User Help Text
  252.  * @desc The singular form of 'User' used in a help window.
  253.  * @default User
  254.  *
  255.  * @param Ally Help Text
  256.  * @desc The singular form of 'Ally' used in a help window.
  257.  * @default Ally
  258.  *
  259.  * @param Allies Help Text
  260.  * @desc The plural form of 'Allies' used in a help window.
  261.  * @default Allies
  262.  *
  263.  * @param Enemy Help Text
  264.  * @desc The singular form of 'Enemy' used in a help window.
  265.  * @default Enemy
  266.  *
  267.  * @param Enemies Help Text
  268.  * @desc The plural form of 'Enemy' used in a help window.
  269.  * @default Enemies
  270.  *
  271.  * @param All Help Text
  272.  * @desc When selecting a entire group of targets.
  273.  * %1 - Target Group (Allies or Enemies)
  274.  * @default All %1
  275.  *
  276.  * @param Random Help Text
  277.  * @desc When selecting a random selection of targets.
  278.  * %1 - Target Group (Allies or Enemies)     %2 - Number
  279.  * @default %2 Random %1
  280.  *
  281.  * @param ---Enemy Select---
  282.  * @default
  283.  *
  284.  * @param Visual Enemy Select
  285.  * @desc Replaces the enemy selection screen with a more visual one.
  286.  * OFF - false     ON - true
  287.  * @default true
  288.  *
  289.  * @param Show Enemy Name
  290.  * @desc Show enemy names with Visual Enemy Select.
  291.  * OFF - false     ON - true
  292.  * @default true
  293.  *
  294.  * @param Show Select Box
  295.  * @desc Show a selection box when selecting enemies.
  296.  * OFF - false     ON - true
  297.  * @default false
  298.  *
  299.  * @param Enemy Font Size
  300.  * @desc Changes the font size used to display enemy names.
  301.  * Default: 28
  302.  * @default 20
  303.  *
  304.  * @param Enemy Auto Select
  305.  * @desc Changes what enemy is automatically selected at first.
  306.  * LEFT - 0     RIGHT - this.furthestRight()
  307.  * @default this.furthestRight()
  308.  *
  309.  * @param ---Actor Select---
  310.  * @default
  311.  *
  312.  * @param Visual Actor Select
  313.  * @desc Allows you to click the actor on screen to select it.
  314.  * OFF - false     ON - true
  315.  * @default true
  316.  *
  317.  * @param ---Battle Log---
  318.  * @default
  319.  *
  320.  * @param Show Emerge Text
  321.  * @desc Shows the battle start text for enemies appearing.
  322.  * OFF - false     ON - true
  323.  * @default false
  324.  *
  325.  * @param Show Pre-Emptive Text
  326.  * @desc Shows the text for getting a pre-emptive attack.
  327.  * OFF - false     ON - true
  328.  * @default true
  329.  *
  330.  * @param Show Surprise Text
  331.  * @desc Shows the text for getting a surprise attack.
  332.  * OFF - false     ON - true
  333.  * @default true
  334.  *
  335.  * @param Optimize Speed
  336.  * @desc Cuts log base line process to optimize the battle speed.
  337.  * OFF - false     ON - true
  338.  * @default true
  339.  *
  340.  * @param Show Action Text
  341.  * @desc Displays full action text or a simplified version of it.
  342.  * SIMPLE - false     FULL - true
  343.  * @default false
  344.  *
  345.  * @param Show State Text
  346.  * @desc Shows all text regarding states.
  347.  * OFF - false     ON - true
  348.  * @default false
  349.  *
  350.  * @param Show Buff Text
  351.  * @desc Shows all text regarding buffs.
  352.  * OFF - false     ON - true
  353.  * @default false
  354.  *
  355.  * @param Show Counter Text
  356.  * @desc Shows text regarding counter attacks.
  357.  * OFF - false     ON - true
  358.  * @default true
  359.  *
  360.  * @param Show Reflect Text
  361.  * @desc Shows text regarding reflected spells.
  362.  * OFF - false     ON - true
  363.  * @default true
  364.  *
  365.  * @param Show Substitute Text
  366.  * @desc Shows text regarding substituted damage.
  367.  * OFF - false     ON - true
  368.  * @default true
  369.  *
  370.  * @param Show Fail Text
  371.  * @desc Shows text regarding failed attacks.
  372.  * OFF - false     ON - true
  373.  * @default false
  374.  *
  375.  * @param Show Critical Text
  376.  * @desc Shows text regarding critical hits.
  377.  * OFF - false     ON - true
  378.  * @default false
  379.  *
  380.  * @param Show Miss Text
  381.  * @desc Shows text regarding missed attacks.
  382.  * OFF - false     ON - true
  383.  * @default false
  384.  *
  385.  * @param Show Evasion Text
  386.  * @desc Shows text regarding evaded attacks.
  387.  * OFF - false     ON - true
  388.  * @default false
  389.  *
  390.  * @param Show HP Text
  391.  * @desc Shows text regarding HP damage or heals.
  392.  * OFF - false     ON - true
  393.  * @default false
  394.  *
  395.  * @param Show MP Text
  396.  * @desc Shows text regarding MP damage or heals.
  397.  * OFF - false     ON - true
  398.  * @default false
  399.  *
  400.  * @param Show TP Text
  401.  * @desc Shows text regarding TP damage or heals.
  402.  * OFF - false     ON - true
  403.  * @default false
  404.  *
  405.  * @help
  406.  * ============================================================================
  407.  * Introduction
  408.  * ============================================================================
  409.  *
  410.  * This plugin alters the various aspects of the default battle system,
  411.  * allowing it to be more streamlined like most modern RPG's and less clunky
  412.  * like older RPG's. This ranges from choosing what text will appear in the
  413.  * battle log window at the top and how it will be displayed.
  414.  *
  415.  * ============================================================================
  416.  * Battle Messages
  417.  * ============================================================================
  418.  *
  419.  * When changing "Terms" and the "Messages" that appear in battle, inserting
  420.  * the following tag anywhere in the message will cause the message to center
  421.  * itself in the battle log.
  422.  *
  423.  *   <CENTER>
  424.  *   This tag must be all caps in order for the battle log window to recognize
  425.  *   it as an instruction to center the displayed battle text message.
  426.  *
  427.  * There are a couple of notetags you can use to change the way certain skills
  428.  * and items will show up incase you don't want a name like 'Harold's Attack'
  429.  * to appear in the name.
  430.  *
  431.  * Skill and Item Notetags:
  432.  *
  433.  *   <Display Text: x>
  434.  *   This will change the text displayed to x.
  435.  *
  436.  *   <Display Icon: x>
  437.  *   This will change the icon displayed to x.
  438.  *
  439.  * ============================================================================
  440.  * Battle Windows
  441.  * ============================================================================
  442.  *
  443.  * There's various options to adjust the window settings found in the battle
  444.  * system to make navigating the battle system more intuitive. Such options
  445.  * include starting the turns with the Actor Command Window instead of the
  446.  * Party Command Window (the Fight/Escape Window). The Party Command Window is
  447.  * still accessible but only by pressing cancel on the first actor's window.
  448.  *
  449.  * ============================================================================
  450.  * Battle Order
  451.  * ============================================================================
  452.  *
  453.  * The battle turn order is also fixed, too. This way, any battlers that Have
  454.  * their AGI value changed over the course of battle will reflect those changes
  455.  * during the current turn rather than the following turn. The action speed
  456.  * calculation can also be adjusted and finetuned to have the random factor of
  457.  * its speed calculation formula removed, too, making AGI actually worthwhile
  458.  * as a tactical parameter.
  459.  *
  460.  * Skill and Item Notetag:
  461.  *   <speed: +x>
  462.  *   <speed: -x>
  463.  *   This lets you break past the editor's limit of -2000 and 2000 allowing you
  464.  *   to set the speed of your actions with more control.
  465.  *
  466.  * ============================================================================
  467.  * Multiple Hits
  468.  * ============================================================================
  469.  *
  470.  * Multi-hit action will no longer end prematurely if the target dies midway
  471.  * through the action. This is done through toggling immortal states. To make
  472.  * use of feature, make sure your database has an Immortal State somewhere. If
  473.  * you do not wish to use this feature, set the Parameter for Immortal State ID
  474.  * to 0 instead.
  475.  *
  476.  * ============================================================================
  477.  * Popup Revamp
  478.  * ============================================================================
  479.  *
  480.  * Although the damage popups may still look the same as the default ones from
  481.  * MV, the process in which they're created is now different to streamline the
  482.  * damage popup process. Before, popups would only appear one a time with a
  483.  * frame's different at minimum in order for them to show. Now, any actions
  484.  * that occur at the same frame will now all show popups at the same frame,
  485.  * making for smoother and less clunky damage popups.
  486.  *
  487.  * ============================================================================
  488.  * Common Events
  489.  * ============================================================================
  490.  *
  491.  * Common Events will now occur at the end of each action regardless of whether
  492.  * or not the enemy party is still alive. With proper placing of the action
  493.  * sequence tags, you can make the skill's common event occur in the middle of
  494.  * an action, too. However, keep in mind if you force an action in the middle
  495.  * of another action, the remainder of the former action's sequence list will
  496.  * become null and void in favor of the new forced action.
  497.  *
  498.  * ============================================================================
  499.  * Casting Animations
  500.  * ============================================================================
  501.  *
  502.  * Casting Animations help provide visual hints for players either by letting
  503.  * them know which battler is going to perform an action or what type of skill
  504.  * that action will be. This plugin enables skills to have casting animations
  505.  * that can be modified universally or customized for each individual skill.
  506.  *
  507.  * Skill Notetag:
  508.  *   <Cast Animation: x>
  509.  *   Sets the skill's cast animation to animation ID x. Setting x to zero will
  510.  *   cause the skill to not have any animaton at all.
  511.  *
  512.  * ============================================================================
  513.  * Changing Battle Systems
  514.  * ============================================================================
  515.  *
  516.  * While the player is not in battle, you can change the battle system using a
  517.  * Plugin Command. With only this plugin, there is only one battle system
  518.  * included: the default battle system.
  519.  *
  520.  * Plugin Command:
  521.  *   setBattleSys DTB      Sets battle system to Default Turn Battle.
  522.  *
  523.  * Other future plugins may include other battle systems that may utilize the
  524.  * Battle Engine Core.
  525.  *
  526.  * ============================================================================
  527.  * Sideview Actions
  528.  * ============================================================================
  529.  *
  530.  * In RPG Maker MV's default battle system, both the sideview and the frontview
  531.  * settings do not display counterattacks, reflected magic attacks, nor any
  532.  * case of substituting for battle members. The Battle Engine Core provides
  533.  * games that are using the sideview settings small amounts of animations to
  534.  * relay information to the player in a more visual sense.
  535.  *
  536.  * Magic Reflection will also display a reflection animation to indicate the
  537.  * battler has reflection properties. This animation can be changed in the
  538.  * parameters, but certain actors, classes, enemies, weapons, armors, and
  539.  * states can display a unique kind of animation for reflection if desired.
  540.  *
  541.  * Actor, Class, Enemy, Weapon, Armor, and State Notetag:
  542.  *   <Reflect Animation ID: x>
  543.  *   Changes the user's reflect animation to x. This will take priority in the
  544.  *   following order: Actor, Class, Enemy, Weapon, Armor, State, Default.
  545.  *
  546.  * Sometimes, you don't want your enemies to be able to move. Or you don't want
  547.  * certain actors to be able to move. They're just stationary for whatever
  548.  * reason. To accomplish that, you can use this notetag to forbid the battler
  549.  * from moving.
  550.  *
  551.  * Actor, Class, Enemy, Weapon, Armor, and State Notetag:
  552.  *   <Sprite Cannot Move>
  553.  *   Prevents the battler's sprite from moving. This will take priority in the
  554.  *   following order: Actor, Class, Enemy, Weapon, Armor, and State. If an
  555.  *   enemy is unable to move when it performs an action, it will flash white as
  556.  *   if it normally does in front view.
  557.  *
  558.  * ============================================================================
  559.  * Custom Sideview Battler Anchor
  560.  * ============================================================================
  561.  *
  562.  * Sideview battlers are generally centered horizontally, and grounded at their
  563.  * feet. However, not all sideview battler spritesheets work this way. In the
  564.  * event you have a sideview battler that doesn't conform to those standards,
  565.  * you can 'anchor' them a different way.
  566.  *
  567.  * Actor, Class, Weapon, Armor, State Notetags:
  568.  *   <Anchor X: y.z>
  569.  *   <Anchor Y: y.z>
  570.  *   This sets the anchor location for the actor's sideview battler at y.z.
  571.  *   By default, the X anchor is 0.5 while the Y anchor is 1.0. If you want
  572.  *   the X anchor to be a bit more to the left, make it less than 0.5. Make it
  573.  *   more than 0.5 to make the X anchor more towards the right. To raise the
  574.  *   Y anchor, set the number value to less than 1.0. Keep adjusting until you
  575.  *   find that perfect anchor setting.
  576.  *
  577.  * If an anchor has multiple traits that yield different anchors, it will be
  578.  * used in a priority list akin to this order:
  579.  *
  580.  *   States
  581.  *   Weapons
  582.  *   Armors
  583.  *   Class
  584.  *   Actor
  585.  *   Default
  586.  *
  587.  * The higher it is on the priority list, the higher its priority.
  588.  *
  589.  * ============================================================================
  590.  * Enemy Attack Animation
  591.  * ============================================================================
  592.  *
  593.  * To give your enemies unique attack animations, you can use this notetag:
  594.  *
  595.  * Enemy Notetag:
  596.  *   <Attack Animation: x>
  597.  *   Replace x with the ID of the battle animation you wish to set as the
  598.  *   enemy's default attack animation.
  599.  *
  600.  * ============================================================================
  601.  * Automatic State Removal Conditions
  602.  * ============================================================================
  603.  *
  604.  * By default, RPG Maker MV's battle system has automatic state removal under
  605.  * three different conditions: none, action end, turn end.
  606.  *
  607.  * None and Turn End are working as intended. However, Action End, however, had
  608.  * the states removed at the start of the battler's action rather than the end.
  609.  * This is changed and updated to occur only at the end of a battler's action.
  610.  *
  611.  * Two more automatic conditions are now added: Action Start and Turn Start.
  612.  * These can be added and implemented using the following notetags:
  613.  *
  614.  * State Notetags:
  615.  *   <Action Start: x>
  616.  *   <Action Start: x to y>
  617.  *   This will cause this state to update its turns remaining at the start of
  618.  *   an action. x is the number of turns it will last. If you use x to y, upon
  619.  *   applying the state, the state will be removed a random number of turns
  620.  *   from x to y.
  621.  *
  622.  *   <Turn Start: x>
  623.  *   <Turn Start: x to y>
  624.  *   This will cause the state to update its turns remaining at the start of a
  625.  *   battle turn. x is the number of turns it will last. If you use x to y,
  626.  *   upon applying the state, the state will be removed a random number of
  627.  *   turns from x to y.
  628.  *
  629.  * States with Action End have a unique trait to them where if the caster of
  630.  * the state is the current active battler (subject) and if the state is then
  631.  * applied on the user itself, they will gain a 'free turn'. The 'free turn' is
  632.  * to mitigate the user from losing 1 duration of the turn since with an Action
  633.  * End timing, they would lose the benefit of being under the state for that
  634.  * turn's timing.
  635.  *
  636.  * ============================================================================
  637.  * Action Sequences
  638.  * ============================================================================
  639.  *
  640.  * The Yanfly Engine Plugins - Battle Engine Core includes the capability of
  641.  * using custom action sequences. Action sequences are basic instructions for
  642.  * the game to creating a customized skill both visually and mechanically.
  643.  * The Battle Engine Core, however, will only include the most basic of action
  644.  * sequences so the instructions on how to create a custom action sequence will
  645.  * be included in the Help file on future extension plugins for this plugin.
  646.  *
  647.  * ============================================================================
  648.  * Changelog
  649.  * ============================================================================
  650.  *
  651.  * Verison 1.35:
  652.  * - Scopes that target a dead ally will automatically target the first dead
  653.  * ally now. Scopes that target all dead allies will lock onto the first dead
  654.  * ally. This will hopefully provide less confusion amongst playing.
  655.  *
  656.  * Version 1.34a:
  657.  * - Fixed a bug where 'NOT FOCUS' targets were not including dead members.
  658.  * - Fixed a bug where using NOT FOCUS would cause dead targets to be visible.
  659.  *
  660.  * Version 1.33:
  661.  * - Updated for RPG Maker MV version 1.1.0.
  662.  *
  663.  * Version 1.32d:
  664.  * - Fixed a bug that caused a crash when an actor died.
  665.  * - Added a motion engine to be used for future plugins.
  666.  * - Preparation for a future plugin.
  667.  * - <Anchor X: y.z> and <Anchor Y: y.z> notetags for actors are now extended
  668.  * to actors, classes, weapons, armors, and states.
  669.  * - Added <Display Text: x> and <Display Icon: x> notetags for skills and
  670.  * items. These notetags will alter the display name shown and icon shown
  671.  * respectively while performing a skill.
  672.  * - Switched Magic Reflect checking order with Counterattack checking order.
  673.  * This is to give priority to reflected actions over countered actions.
  674.  *
  675.  * Version 1.31b:
  676.  * - States with Action End now have a unique trait to them where if the caster
  677.  * of the state is the current active battler (subject) and if the state is
  678.  * then applied on the user itself, they will gain a 'free turn'. The 'free
  679.  * turn' is to mitigate the user from losing 1 duration of the turn since with
  680.  * an Action End timing, they would lose the benefit of being under the state
  681.  * for that turn's timing.
  682.  * - Added failsafes for Free Turns in case other plugins have overwritten the
  683.  * on battle start functions.
  684.  * - Added a compatibility update to Animated SV Enemies for dead motion.
  685.  *
  686.  * Version 1.30:
  687.  * - Optimization update.
  688.  * - Fixed a bug that prevented added state effects be unable to apply if they
  689.  * are an added Death state.
  690.  * - Battlelog lines are now able to display text codes.
  691.  *
  692.  * Version 1.29:
  693.  * - Fixed a bug with the 'else if' action sequences not working in the right
  694.  * order of sequence conditions.
  695.  *
  696.  * Version 1.28d:
  697.  * - Fixed a bug if instant casting a skill that would make an opponent battler
  698.  * to force an action to end incorrectly. Thanks to DoubleX for the fix.
  699.  * - Fixed a bug with mouse over not working properly.
  700.  * - Fixed a bug regarding forced actions that will cause the battle to freeze
  701.  * if the forced action causes the main active subject to leave the battle.
  702.  * - Fixed a bug with timed states not updating their turns properly.
  703.  * - Changed priority of IF action sequences to higher to no longer interfere
  704.  * other action sequences.
  705.  *
  706.  * Version 1.27:
  707.  * - Mechanic change. This will only affect those using turn-based state timing
  708.  * mechanics. Turn End state updates are now shifted from Turn End to occur at
  709.  * Regeneration timing to have a more synchronized aspect. The timings are very
  710.  * close so there's next to no notice in difference. Buff turn updates are also
  711.  * moved to the regeneration timing, too.
  712.  *
  713.  * Version 1.26:
  714.  * - Added 'Mouse Over' parameter to Selection Help. This parameter enables
  715.  * mouse users to simply hover over the enemy to select them rather than having
  716.  * to click an enemy twice to select them.
  717.  *
  718.  * Version 1.25f:
  719.  * - Added failsafes for Forced Action queues.
  720.  * - Added 'Show Select Box' parameter when selecting enemies.
  721.  * - Fixed a bug that caused End Turn events to not function properly.
  722.  * - Battle animations, by default, are positioned relative to the base bitmap
  723.  * for its target sprite. However, actor sprites do not have a base bitmap and
  724.  * therefore, battle animations, regardless of position, will always target the
  725.  * actor sprite's feet. This update now gives actor sprites a base bitmap.
  726.  * - Readjusted sprite width and sprite height calculations.
  727.  * - Added a failsafe for when no sideview actor graphics are used.
  728.  *
  729.  * Version 1.24:
  730.  * - Implemented a Forced Action queue list. This means if a Forced Action
  731.  * takes place in the middle of an action, the action will resume after the
  732.  * forced action finishes rather than cancels it out like MV does.
  733.  *
  734.  * Version 1.23:
  735.  * - Fixed a bug that didn't regenerate HP/MP/TP properly for tick-based.
  736.  *
  737.  * Version 1.22:
  738.  * - Fixed a bug within MV that caused Forced Actions at Turn End to prompt and
  739.  * trigger all turn-end related activities (such as regeneration and state turn
  740.  * updating).
  741.  * - Made a mechanic change so that Action Start and Action End state turns do
  742.  * not update their turns through forced actions.
  743.  *
  744.  * Version 1.21:
  745.  * - Fixed a bug where states Action End weren't going down properly with DTB.
  746.  *
  747.  * Version 1.20:
  748.  * - Fixed a bug where revived actors using instant cast aren't properly set to
  749.  * use actions immediately.
  750.  *
  751.  * Version 1.19:
  752.  * - Added <Attack Animation: x> notetag for enemies.
  753.  * - Added 'AI Self Turns' for Tick-Based Battles. Enemies can now have their
  754.  * A.I. revolve around their own individual turns rather than the battle's.
  755.  * - Mechanic change for states. Following suit with the change to Action End
  756.  * removal, there are now two more conditions added: Action Start, Turn Start.
  757.  * - Added <Action Start: x>, <Action Start: x to y>, <Turn Start: x>, and
  758.  * <Turn Start: x to y> notetags for automatic state removal.
  759.  *
  760.  * Version 1.18:
  761.  * - Fixed a bug with irregular targeting scopes.
  762.  * - Fixed an MV-related bug with Recover All event not refreshing battlers.
  763.  *
  764.  * Version 1.17b:
  765.  * - Fixed a bug with action end states to remove multiple at once.
  766.  * - Fixed a visual error with flinching sprites.
  767.  * - Added 'Current Max' parameter to change HP current/max display in battle.
  768.  * - Mechanic change for states that update on Action End to end at the end of
  769.  * a battler's turn instead of at the start.
  770.  * - Began preparations for another battle system.
  771.  *
  772.  * Version 1.16:
  773.  * - Fixed an issue with mirrored enemies having mirrored state icons.
  774.  *
  775.  * Version 1.15a:
  776.  * - Fixed a bug revolving the status window not updating.
  777.  * - Updated default home position formula to better fit other party sizes.
  778.  * New Home Position X:
  779.  *   screenWidth - 16 - (maxSize + 2) * 32 + index * 32
  780.  * New Home Position Y:
  781.  *   screenHeight - statusHeight - maxSize * 48 + (index+1) * 48 - 16
  782.  *
  783.  * Version 1.14:
  784.  * - Fixed a bug with Forced Actions locking out the battle.
  785.  * - New mechanic: For tick-based battle systems, states with action-end will
  786.  * go down in turns based on how many actions took place for the actor instead.
  787.  * Previously, they were indistinguishable from states with Turn End removal.
  788.  * - New mechanic: Using Instant Skills/Items from YEP_InstantCast.js will also
  789.  * cause states with action-end to go down in turns upon using actions.
  790.  *
  791.  * Version 1.13a:
  792.  * - Fixed a bug that made battlebacks disappear.
  793.  * - Reworked visual enemy selection.
  794.  * - Victory phase doesn't immediately display level up changes in battle
  795.  * status window.
  796.  * - Fixed a bug with the visual enemy select showing dead enemy names.
  797.  *
  798.  * Version 1.12b:
  799.  * - If the Battle HUD has been hidden for whatever reason during the victory
  800.  * sequence, it will be returned.
  801.  * - Added <speed: +x> and <speed: -x> notetags to break past editor limits.
  802.  * - Added new conditions where the battle won't end until all action sequences
  803.  * have been fulfilled.
  804.  *
  805.  * Version 1.11:
  806.  * - Fixed a bug that didn't show HP/MP Regeneration.
  807.  *
  808.  * Version 1.10:
  809.  * - Removed immortal state dependancy. Immortality is now its own setting.
  810.  * - Added more abbreviated variables for action speed calculation.
  811.  * - Fixed a bug where all-scope attacks would reveal Appear-Halfway enemies.
  812.  * - Fixed a bug where the battle wouldn't end if the final enemy was killed
  813.  * by state damage.
  814.  *
  815.  * Version 1.09:
  816.  * - Fixed a undefined actor bug for refreshing the status window.
  817.  * - Added 'Show Shadows' parameter to the plugin settings.
  818.  * - Reworked the default action sequences so that forced actions do not appear
  819.  * on top of each other and party-heal animations occur simultaneously.
  820.  *
  821.  * Version 1.08:
  822.  * - Fixed a bug where battlers gaining HP/MP in the damage formula for
  823.  * themselves wouldn't trigger popups.
  824.  * - Fixed a bug where if the party failed to escape from battle, states that
  825.  * would be removed by battle still get removed. *Fixed by Emjenoeg*
  826.  * - Fixed a bug where instant death skills didn't work.
  827.  * - Changed Sprite Priority settings to decide whether actors, enemies, or
  828.  * neither would always be on top.
  829.  *
  830.  * Version 1.07:
  831.  * - Optimized status window to refresh at a minimum.
  832.  * - Set up frame work for future plugins:
  833.  * - Added 'Escape Ratio' and 'Fail Escape Boost' to parameters to allow users
  834.  * to set the escape ratio they want.
  835.  * - Added 'Front Sprite Priority' and 'Side Sprite Priority' to parameters to
  836.  * dictate if actor sprites are always on top.
  837.  * - Added 'Tick-Settings' category for tick-based battle systems.
  838.  *
  839.  * Version 1.06:
  840.  * - Fixed a bug that causes dead actors at the start of battle to not spawn.
  841.  * - Fixed a bug where the help window on an empty slot would show the
  842.  * previous skill's message.
  843.  *
  844.  * Version 1.05:
  845.  * - Added new target typing: Character X, which allows you to select
  846.  * specifically the actor with an actor ID of X if he/she/it is in the party.
  847.  * - Fixed a bug that prevented Miss and Evade popups from showing.
  848.  *
  849.  * Version 1.04:
  850.  * - Fixed a bug where popups didn't show under certain animation types.
  851.  * - Fixed certain battler motions from not refreshing correctly.
  852.  * - Actions with no scope will not trigger the confirmation selection window.
  853.  *
  854.  * Version 1.03:
  855.  * - Added 'Wait for Effect' action sequence.
  856.  * - Actions now wait for effects (such as collapsing) to be done before
  857.  * continuing on with battle or to end battle.
  858.  *
  859.  * Version 1.02:
  860.  * - Fixed a bug where the help window would retain descriptions on no skills.
  861.  * - Synched up weapons with actor sprites so they would occur simultaneously.
  862.  * - Fixed an issue where requesting certain motions from enemies that don't
  863.  * exist would cause them to crash.
  864.  *
  865.  * Version 1.01:
  866.  * - Skills and items that affect both HP and MP will now show popups for both.
  867.  *
  868.  * Version 1.00:
  869.  * - Finished plugin!
  870.  */
  871. //=============================================================================
  872.  
  873. //=============================================================================
  874. // Parameter Variables
  875. //=============================================================================
  876.  
  877. Yanfly.Parameters = PluginManager.parameters('YEP_BattleEngineCore');
  878. Yanfly.Param = Yanfly.Param || {};
  879.  
  880. Yanfly.Param.BECSystem = String(Yanfly.Parameters['Default System']);
  881. Yanfly.Param.BECEscRatio = String(Yanfly.Parameters['Escape Ratio']);
  882. Yanfly.Param.BECEscFail = String(Yanfly.Parameters['Fail Escape Boost']);
  883. Yanfly.Param.CastCertHit = Number(Yanfly.Parameters['Certain Hit Animation']);
  884. Yanfly.Param.CastPhysical = Number(Yanfly.Parameters['Physical Animation']);
  885. Yanfly.Param.CastMagical = Number(Yanfly.Parameters['Magical Animation']);
  886. Yanfly.Param.EnemyAtkAni = Number(Yanfly.Parameters['Enemy Attack Animation']);
  887. Yanfly.Param.BECOptSpeed = String(Yanfly.Parameters['Optimize Speed']);
  888. Yanfly.Param.BECEmergeText = String(Yanfly.Parameters['Show Emerge Text']);
  889. Yanfly.Param.BECPreEmpText = String(Yanfly.Parameters['Show Pre-Emptive Text']);
  890. Yanfly.Param.BECSurpText = String(Yanfly.Parameters['Show Surprise Text']);
  891. Yanfly.Param.BECPopupOverlap = String(Yanfly.Parameters['Popup Overlap Rate']);
  892. Yanfly.Param.BECNewPopBottom = String(Yanfly.Parameters['Newest Popup Bottom']);
  893. Yanfly.Param.BECStartActCmd = String(Yanfly.Parameters['Start Actor Command']);
  894. Yanfly.Param.BECCurMax = eval(String(Yanfly.Parameters['Current Max']));
  895. Yanfly.Param.BECSelectHelp = String(Yanfly.Parameters['Select Help Window']);
  896. Yanfly.Param.BECHelpUserTx = String(Yanfly.Parameters['User Help Text']);
  897. Yanfly.Param.BECHelpAllyTx = String(Yanfly.Parameters['Ally Help Text']);
  898. Yanfly.Param.BECHelpAlliesTx = String(Yanfly.Parameters['Allies Help Text']);
  899. Yanfly.Param.BECHelpEnemyTx = String(Yanfly.Parameters['Enemy Help Text']);
  900. Yanfly.Param.BECHelpEnemiesTx = String(Yanfly.Parameters['Enemies Help Text']);
  901. Yanfly.Param.BECHelpAllTx = String(Yanfly.Parameters['All Help Text']);
  902. Yanfly.Param.BECHelpRandTx = String(Yanfly.Parameters['Random Help Text']);
  903. Yanfly.Param.BECFrontPosX = String(Yanfly.Parameters['Front Position X']);
  904. Yanfly.Param.BECFrontPosY = String(Yanfly.Parameters['Front Position Y']);
  905. Yanfly.Param.BECFrontSprite = String(Yanfly.Parameters['Front Actor Sprite']);
  906. Yanfly.Param.BECFrSpPrio = String(Yanfly.Parameters['Front Sprite Priority']);
  907. Yanfly.Param.BECHomePosX = String(Yanfly.Parameters['Home Position X']);
  908. Yanfly.Param.BECHomePosY = String(Yanfly.Parameters['Home Position Y']);
  909. Yanfly.Param.BECSideSpPrio = String(Yanfly.Parameters['Side Sprite Priority']);
  910. Yanfly.Param.BECAnchorX = Number(Yanfly.Parameters['Default X Anchor']);
  911. Yanfly.Param.BECAnchorY = Number(Yanfly.Parameters['Default Y Anchor']);
  912. Yanfly.Param.BECStepDist = Number(Yanfly.Parameters['Step Distance']);
  913. Yanfly.Param.BECFlinchDist = Number(Yanfly.Parameters['Flinch Distance']);
  914. Yanfly.Param.BECShowShadows = String(Yanfly.Parameters['Show Shadows']);
  915. Yanfly.Param.BECPopupDur = String(Yanfly.Parameters['Popup Duration']);
  916. Yanfly.Param.BECCritPopup = String(Yanfly.Parameters['Critical Popup']);
  917. Yanfly.Param.BECCritDur = String(Yanfly.Parameters['Critical Duration']);
  918. Yanfly.Param.BECActionSpeed = String(Yanfly.Parameters['Action Speed']);
  919. Yanfly.Param.BECReflectAni = Number(Yanfly.Parameters['Reflect Animation']);
  920. Yanfly.Param.BECMotionWait = String(Yanfly.Parameters['Motion Waiting']);
  921. Yanfly.Param.BECTimeStates = String(Yanfly.Parameters['Timed States']);
  922. Yanfly.Param.BECTimeBuffs = String(Yanfly.Parameters['Timed Buffs']);
  923. Yanfly.Param.BECTurnTime = Number(Yanfly.Parameters['Turn Time']);
  924. Yanfly.Param.BECAISelfTurn = eval(String(Yanfly.Parameters['AI Self Turns']));
  925. Yanfly.Param.BECLowerWindows = String(Yanfly.Parameters['Lower Windows']);
  926. Yanfly.Param.BECSelectMouseOver = eval(String(Yanfly.Parameters['Mouse Over']));
  927. Yanfly.Param.BECEnemySelect = String(Yanfly.Parameters['Visual Enemy Select']);
  928. Yanfly.Param.BECActorSelect = String(Yanfly.Parameters['Visual Actor Select']);
  929. Yanfly.Param.BECWindowRows = String(Yanfly.Parameters['Window Rows']);
  930. Yanfly.Param.BECEnemyFontSize = Number(Yanfly.Parameters['Enemy Font Size']);
  931. Yanfly.Param.BECShowEnemyName = String(Yanfly.Parameters['Show Enemy Name']);
  932. Yanfly.Param.BECShowSelectBox = String(Yanfly.Parameters['Show Select Box']);
  933. Yanfly.Param.BECEnemyAutoSel = String(Yanfly.Parameters['Enemy Auto Select']);
  934. Yanfly.Param.BECCommandAlign = String(Yanfly.Parameters['Command Alignment']);
  935. Yanfly.Param.BECCommandRows = String(Yanfly.Parameters['Command Window Rows']);
  936. Yanfly.Param.BECAniBaseDel = String(Yanfly.Parameters['Animation Base Delay']);
  937. Yanfly.Param.BECAniNextDel = String(Yanfly.Parameters['Animation Next Delay']);
  938. Yanfly.Param.BECFullActText = String(Yanfly.Parameters['Show Action Text']);
  939. Yanfly.Param.BECShowCntText = String(Yanfly.Parameters['Show Counter Text']);
  940. Yanfly.Param.BECShowRflText = String(Yanfly.Parameters['Show Reflect Text']);
  941. Yanfly.Param.BECShowSubText = String(Yanfly.Parameters['Show Substitute Text']);
  942. Yanfly.Param.BECShowFailText = String(Yanfly.Parameters['Show Fail Text']);
  943. Yanfly.Param.BECShowCritText = String(Yanfly.Parameters['Show Critical Text']);
  944. Yanfly.Param.BECShowMissText = String(Yanfly.Parameters['Show Miss Text']);
  945. Yanfly.Param.BECShowEvaText = String(Yanfly.Parameters['Show Evasion Text']);
  946. Yanfly.Param.BECShowHpText = String(Yanfly.Parameters['Show HP Text']);
  947. Yanfly.Param.BECShowMpText = String(Yanfly.Parameters['Show MP Text']);
  948. Yanfly.Param.BECShowTpText = String(Yanfly.Parameters['Show TP Text']);
  949. Yanfly.Param.BECShowStateText = String(Yanfly.Parameters['Show State Text']);
  950. Yanfly.Param.BECShowBuffText = String(Yanfly.Parameters['Show Buff Text']);
  951.  
  952. //=============================================================================
  953. // DataManager
  954. //=============================================================================
  955.  
  956. Yanfly.BEC.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  957. DataManager.isDatabaseLoaded = function() {
  958.   if (!Yanfly.BEC.DataManager_isDatabaseLoaded.call(this)) return false;
  959.   if (!Yanfly._loaded_YEP_BattleEngineCore) {
  960.     this.processMELODYNotetags($dataSkills);
  961.     this.processMELODYNotetags($dataItems);
  962.     this.processBECNotetags1($dataSkills);
  963.     this.processBECNotetags2($dataSkills);
  964.     this.processBECNotetags2($dataItems);
  965.     this.processBECNotetags3($dataEnemies);
  966.     this.processBECNotetags4($dataActors);
  967.     this.processBECNotetags4($dataClasses);
  968.     this.processBECNotetags4($dataWeapons);
  969.     this.processBECNotetags4($dataArmors);
  970.     this.processBECNotetags4($dataEnemies);
  971.     this.processBECNotetags4($dataStates);
  972.     this.processBECNotetags5($dataActors, true);
  973.     this.processBECNotetags5($dataClasses, false);
  974.     this.processBECNotetags5($dataWeapons, false);
  975.     this.processBECNotetags5($dataArmors, false);
  976.     this.processBECNotetags5($dataStates, false);
  977.     this.processBECNotetags6($dataStates);
  978.     Yanfly._loaded_YEP_BattleEngineCore = true;
  979.   }
  980.   return true;
  981. };
  982.  
  983. DataManager.processMELODYNotetags = function(group) {
  984.   for (var n = 1; n < group.length; n++) {
  985.     var obj = group[n];
  986.     if (obj.actionsMade) continue;
  987.     obj.actionsMade = true;
  988.     var notedata = obj.note.split(/[\r\n]+/);
  989.  
  990.     var actionType = 0;
  991.     this.setDefaultActions(obj);
  992.  
  993.     for (var i = 0; i < notedata.length; i++) {
  994.       var line = notedata[i];
  995.       if (line.match(/<(?:SETUP ACTION|setup)>/i)) {
  996.         actionType = 1;
  997.         obj.setupActions = [];
  998.       } else if (line.match(/<\/(?:SETUP ACTION|setup)>/i)) {
  999.         var actionType = 0;
  1000.       } else if (line.match(/<(?:WHOLE ACTION|whole)>/i)) {
  1001.         actionType = 2;
  1002.         obj.wholeActions = [];
  1003.       } else if (line.match(/<\/(?:WHOLE ACTION|whole)>/i)) {
  1004.         var actionType = 0;
  1005.       } else if (line.match(/<(?:TARGET ACTION|target)>/i)) {
  1006.         actionType = 3;
  1007.         obj.targetActions = [];
  1008.       } else if (line.match(/<\/(?:TARGET ACTION|target)>/i)) {
  1009.         var actionType = 0;
  1010.       } else if (line.match(/<(?:FOLLOW ACTION|follow)>/i)) {
  1011.         actionType = 4;
  1012.         obj.followActions = [];
  1013.       } else if (line.match(/<\/(?:FOLLOW ACTION|follow)>/i)) {
  1014.         var actionType = 0;
  1015.       } else if (line.match(/<(?:FINISH ACTION|finish)>/i)) {
  1016.         actionType = 5;
  1017.         obj.finishActions = [];
  1018.       } else if (line.match(/<\/(?:FINISH ACTION|finish)>/i)) {
  1019.         var actionType = 0;
  1020.       } else {
  1021.         this.convertSequenceLine(obj, line, actionType);
  1022.       }
  1023.     }
  1024.   }
  1025. };
  1026.  
  1027. Yanfly.BEC.DefaultActionSetup = [
  1028.     ['CLEAR BATTLE LOG'],
  1029.     ['DISPLAY ACTION'],
  1030.     ['IMMORTAL', ['TARGETS', 'TRUE']],
  1031.     ['PERFORM START'],
  1032.     ['WAIT FOR MOVEMENT'],
  1033.     ['CAST ANIMATION'],
  1034.     ['WAIT FOR ANIMATION']
  1035. ];
  1036. Yanfly.BEC.DefaultActionWhole = [
  1037.     ['PERFORM ACTION'],
  1038. ];
  1039. Yanfly.BEC.DefaultActionTarget = [
  1040.     ['PERFORM ACTION'],
  1041. ];
  1042. if (eval(Yanfly.Param.BECMotionWait)) {
  1043.   Yanfly.BEC.DefaultActionWhole.push(['MOTION WAIT', ['USER']]);
  1044.   Yanfly.BEC.DefaultActionTarget.push(['MOTION WAIT', ['USER']]);
  1045. } else {
  1046.   Yanfly.BEC.DefaultActionWhole.push(['WAIT', [10]]);
  1047.   Yanfly.BEC.DefaultActionTarget.push(['WAIT', [10]]);
  1048. };
  1049. Yanfly.BEC.DefaultActionWhole.push(['ACTION ANIMATION']);
  1050. Yanfly.BEC.DefaultActionWhole.push(['WAIT FOR ANIMATION']);
  1051. Yanfly.BEC.DefaultActionTarget.push(['ACTION ANIMATION']);
  1052. Yanfly.BEC.DefaultActionTarget.push(['WAIT FOR ANIMATION']);
  1053. Yanfly.BEC.DefaultActionFollow = [
  1054. ];
  1055. Yanfly.BEC.DefaultActionFinish = [
  1056.     ['IMMORTAL', ['TARGETS', 'FALSE']],
  1057.     ['WAIT FOR NEW LINE'],
  1058.     ['CLEAR BATTLE LOG'],
  1059.     ['PERFORM FINISH'],
  1060.     ['WAIT FOR MOVEMENT'],
  1061.     ['WAIT FOR EFFECT'],
  1062.     ['ACTION COMMON EVENT'],
  1063. ];
  1064. DataManager.setDefaultActions = function(obj) {
  1065.     obj.setupActions = Yanfly.BEC.DefaultActionSetup.slice();
  1066.     if (this.isWholeAction(obj)) {
  1067.       obj.wholeActions = Yanfly.BEC.DefaultActionWhole.slice();
  1068.       this.addActionEffects(obj, obj.wholeActions);
  1069.       obj.targetActions = [];
  1070.     } else {
  1071.       obj.wholeActions = [];
  1072.       obj.targetActions = Yanfly.BEC.DefaultActionTarget.slice();
  1073.       this.addActionEffects(obj, obj.targetActions);
  1074.     }
  1075.     obj.followActions = Yanfly.BEC.DefaultActionFollow.slice();
  1076.     obj.finishActions = Yanfly.BEC.DefaultActionFinish.slice();
  1077. };
  1078.  
  1079. DataManager.isWholeAction = function(obj) {
  1080.   if (obj.animationId > 0 && $dataAnimations[obj.animationId]) {
  1081.     var animation = $dataAnimations[obj.animationId];
  1082.     if (animation.position === 3) return true;
  1083.     if (animation.position !== 3 && [2, 8, 10].contains(obj.scope)) return true;
  1084.   }
  1085.   return false;
  1086. };
  1087.  
  1088. DataManager.addActionEffects = function(obj, array) {
  1089.     for (;;) {
  1090.       array[array.length] = ['ACTION EFFECT'];
  1091.       array[array.length] = ['DEATH BREAK'];
  1092.       obj.repeats -= 1;
  1093.       if (obj.repeats <= 0) break;
  1094.       array[array.length] = ['WAIT', [8]];
  1095.     }
  1096.     obj.repeats = 1;
  1097. };
  1098.  
  1099. Yanfly.BEC.SeqType6 =
  1100.   /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i;
  1101. Yanfly.BEC.SeqType5 =
  1102.   /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i;
  1103. Yanfly.BEC.SeqType4 =
  1104.   /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i;
  1105. Yanfly.BEC.SeqType3 =
  1106.   /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*)/i;
  1107. Yanfly.BEC.SeqType2 =
  1108.   /[ ]*(.*):[ ](.*),[ ](.*)/i;
  1109. Yanfly.BEC.SeqType1 =
  1110.   /[ ]*(.*):[ ](.*)/i;
  1111. Yanfly.BEC.SeqType0 =
  1112.   /[ ]*(.*)/i;
  1113. DataManager.convertSequenceLine = function(obj, line, actionType) {
  1114.   if (actionType <= 0 || actionType > 5) return;
  1115.   Yanfly.BEC.SeqType;
  1116.   var seqArgs;
  1117.   if (line.match(Yanfly.BEC.SeqType6)) {
  1118.     Yanfly.BEC.SeqType = RegExp.$1;
  1119.     seqArgs =
  1120.       [RegExp.$2, RegExp.$3, RegExp.$4, RegExp.$5, RegExp.$6, RegExp.$7];
  1121.   } else if (line.match(Yanfly.BEC.SeqType5)) {
  1122.     Yanfly.BEC.SeqType = RegExp.$1;
  1123.     seqArgs = [RegExp.$2, RegExp.$3, RegExp.$4, RegExp.$5, RegExp.$6];
  1124.   } else if (line.match(Yanfly.BEC.SeqType4)) {
  1125.     Yanfly.BEC.SeqType = RegExp.$1;
  1126.     seqArgs = [RegExp.$2, RegExp.$3, RegExp.$4, RegExp.$5];
  1127.   } else if (line.match(Yanfly.BEC.SeqType3)) {
  1128.     Yanfly.BEC.SeqType = RegExp.$1;
  1129.     seqArgs = [RegExp.$2, RegExp.$3, RegExp.$4];
  1130.   } else if (line.match(Yanfly.BEC.SeqType2)) {
  1131.     Yanfly.BEC.SeqType = RegExp.$1;
  1132.     seqArgs = [RegExp.$2, RegExp.$3];
  1133.   } else if (line.match(Yanfly.BEC.SeqType1)) {
  1134.     Yanfly.BEC.SeqType = RegExp.$1;
  1135.     seqArgs = [RegExp.$2];
  1136.   } else if (line.match(Yanfly.BEC.SeqType0)) {
  1137.     Yanfly.BEC.SeqType = RegExp.$1;
  1138.     seqArgs = [];
  1139.   } else {
  1140.     return;
  1141.   }
  1142.   var array = [Yanfly.BEC.SeqType, seqArgs];
  1143.   if (actionType === 1) obj.setupActions[obj.setupActions.length] = array;
  1144.   if (actionType === 2) obj.wholeActions[obj.wholeActions.length] = array;
  1145.   if (actionType === 3) obj.targetActions[obj.targetActions.length] = array;
  1146.   if (actionType === 4) obj.followActions[obj.followActions.length] = array;
  1147.   if (actionType === 5) obj.finishActions[obj.finishActions.length] = array;
  1148. };
  1149.  
  1150. DataManager.processBECNotetags1 = function(group) {
  1151.   var note1 = /<(?:CAST ANIMATION|cast ani):[ ](\d+)>/i;
  1152.   for (var n = 1; n < group.length; n++) {
  1153.     var obj = group[n];
  1154.     var notedata = obj.note.split(/[\r\n]+/);
  1155.  
  1156.     obj.castAnimation = 0;
  1157.     if (obj.hitType === 0) obj.castAnimation = Yanfly.Param.CastCertHit;
  1158.     if (obj.hitType === 1) obj.castAnimation = Yanfly.Param.CastPhysical;
  1159.     if (obj.hitType === 2) obj.castAnimation = Yanfly.Param.CastMagical;
  1160.  
  1161.     for (var i = 0; i < notedata.length; i++) {
  1162.       var line = notedata[i];
  1163.       if (line.match(note1)) {
  1164.         obj.castAnimation = parseInt(RegExp.$1);
  1165.       }
  1166.     }
  1167.   }
  1168. };
  1169.  
  1170. DataManager.processBECNotetags2 = function(group) {
  1171.   var note1 = /<(?:ACTION COPY):[ ](.*):[ ]*(\d+)>/i;
  1172.   var note2 = /<(?:SPEED):[ ]([\+\-]\d+)>/i;
  1173.   var note3 = /<(?:DISPLAY NAME|DISPLAY TEXT):[ ](.*)>/i;
  1174.   var note4 = /<(?:DISPLAY ICON):[ ](\d+)>/i;
  1175.   for (var n = 1; n < group.length; n++) {
  1176.     var obj = group[n];
  1177.     var notedata = obj.note.split(/[\r\n]+/);
  1178.  
  1179.     obj.battleDisplayText = obj.name;
  1180.     obj.battleDisplayIcon = obj.iconIndex;
  1181.  
  1182.     for (var i = 0; i < notedata.length; i++) {
  1183.       var line = notedata[i];
  1184.       if (line.match(note1)) {
  1185.         var text = String(RegExp.$1).toUpperCase();
  1186.         var target;
  1187.         if (['I', 'ITEM'].contains(text)) {
  1188.           target = $dataItems[parseInt(RegExp.$2)];
  1189.         } else if (['S', 'SKILL'].contains(text)) {
  1190.           target = $dataSkills[parseInt(RegExp.$2)];
  1191.         }
  1192.         if (target) {
  1193.           obj.setupActions = target.setupActions.slice();
  1194.           obj.wholeActions = target.wholeActions.slice();
  1195.           obj.targetActions = target.targetActions.slice();
  1196.           obj.followActions = target.followActions.slice();
  1197.           obj.finishActions = target.finishActions.slice();
  1198.         }
  1199.       } else if (line.match(note2)) {
  1200.         obj.speed = parseInt(RegExp.$1);
  1201.       } else if (line.match(note3)) {
  1202.         obj.battleDisplayText = String(RegExp.$1);
  1203.       } else if (line.match(note4)) {
  1204.         obj.battleDisplayIcon = parseInt(RegExp.$1);
  1205.       }
  1206.     }
  1207.   }
  1208. };
  1209.  
  1210. DataManager.processBECNotetags3 = function(group) {
  1211.   var note1 = /<(?:ATTACK ANIMATION|attack ani):[ ](\d+)>/i;
  1212.   for (var n = 1; n < group.length; n++) {
  1213.     var obj = group[n];
  1214.     var notedata = obj.note.split(/[\r\n]+/);
  1215.  
  1216.     obj.attackAnimationId = Yanfly.Param.EnemyAtkAni;
  1217.  
  1218.     for (var i = 0; i < notedata.length; i++) {
  1219.       var line = notedata[i];
  1220.       if (line.match(note1)) {
  1221.         obj.attackAnimationId = parseInt(RegExp.$1);
  1222.       }
  1223.     }
  1224.   }
  1225. };
  1226.  
  1227. DataManager.processBECNotetags4 = function(group) {
  1228.   var note1 = /<(?:REFLECT ANIMATION|reflect ani):[ ](\d+)>/i;
  1229.   for (var n = 1; n < group.length; n++) {
  1230.     var obj = group[n];
  1231.     var notedata = obj.note.split(/[\r\n]+/);
  1232.  
  1233.     obj.reflectAnimationId = 0;
  1234.     obj.spriteCannotMove = false;
  1235.  
  1236.     for (var i = 0; i < notedata.length; i++) {
  1237.       var line = notedata[i];
  1238.       if (line.match(note1)) {
  1239.         obj.reflectAnimationId = parseInt(RegExp.$1);
  1240.       } else if (line.match(/<(?:SPRITE CANNOT MOVE)>/i)) {
  1241.         obj.spriteCannotMove = true;
  1242.       }
  1243.     }
  1244.   }
  1245. };
  1246.  
  1247. DataManager.processBECNotetags5 = function(group, isActor) {
  1248.   for (var n = 1; n < group.length; n++) {
  1249.     var obj = group[n];
  1250.     var notedata = obj.note.split(/[\r\n]+/);
  1251.  
  1252.     if (isActor) {
  1253.       obj.anchorX = Yanfly.Param.BECAnchorX;
  1254.       obj.anchorY = Yanfly.Param.BECAnchorY;
  1255.     }
  1256.  
  1257.     for (var i = 0; i < notedata.length; i++) {
  1258.       var line = notedata[i];
  1259.       if (line.match(/<(?:ANCHOR X):[ ](\d+)[.](\d+)>/i)) {
  1260.         obj.anchorX = eval(String(RegExp.$1) + '.' + String(RegExp.$2));
  1261.       } else if (line.match(/<(?:ANCHOR Y):[ ](\d+)[.](\d+)>/i)) {
  1262.         obj.anchorY = eval(String(RegExp.$1) + '.' + String(RegExp.$2));
  1263.       }
  1264.     }
  1265.   }
  1266. };
  1267.  
  1268. DataManager.processBECNotetags6 = function(group) {
  1269.   var note1a = /<(?:ACTION START):[ ](\d+)>/i;
  1270.   var note1b = /<(?:ACTION START):[ ](\d+)[ ](?:THROUGH|to)[ ](\d+)>/i;
  1271.   var note2a = /<(?:TURN START):[ ](\d+)>/i;
  1272.   var note2b = /<(?:TURN START):[ ](\d+)[ ](?:THROUGH|to)[ ](\d+)>/i;
  1273.   for (var n = 1; n < group.length; n++) {
  1274.     var obj = group[n];
  1275.     var notedata = obj.note.split(/[\r\n]+/);
  1276.  
  1277.     for (var i = 0; i < notedata.length; i++) {
  1278.       var line = notedata[i];
  1279.       if (line.match(note1a)) {
  1280.         var turns = parseInt(RegExp.$1);
  1281.         obj.autoRemovalTiming = 3;
  1282.         obj.maxTurns = turns;
  1283.         obj.minTurns = turns;
  1284.       } else if (line.match(note1b)) {
  1285.         var turns1 = parseInt(RegExp.$1);
  1286.         var turns2 = parseInt(RegExp.$2);
  1287.         obj.autoRemovalTiming = 3;
  1288.         obj.maxTurns = turns1;
  1289.         obj.minTurns = turns2;
  1290.       } else if (line.match(note2a)) {
  1291.         var turns = parseInt(RegExp.$1);
  1292.         obj.autoRemovalTiming = 4;
  1293.         obj.maxTurns = turns;
  1294.         obj.minTurns = turns;
  1295.       } else if (line.match(note2b)) {
  1296.         var turns1 = parseInt(RegExp.$1);
  1297.         var turns2 = parseInt(RegExp.$2);
  1298.         obj.autoRemovalTiming = 4;
  1299.         obj.maxTurns = turns1;
  1300.         obj.minTurns = turns2;
  1301.       }
  1302.     }
  1303.   }
  1304. };
  1305.  
  1306. //=============================================================================
  1307. // TouchInput
  1308. //=============================================================================
  1309.  
  1310. Yanfly.BEC.TouchInput_onMouseMove = TouchInput._onMouseMove;
  1311. TouchInput._onMouseMove = function(event) {
  1312.     Yanfly.BEC.TouchInput_onMouseMove.call(this, event);
  1313.     this._mouseOverX = Graphics.pageToCanvasX(event.pageX);
  1314.     this._mouseOverY = Graphics.pageToCanvasY(event.pageY);
  1315. };
  1316.  
  1317. //=============================================================================
  1318. // BattleManager
  1319. //=============================================================================
  1320.  
  1321. Yanfly.BEC.BattleManager_initMembers = BattleManager.initMembers;
  1322. BattleManager.initMembers = function() {
  1323.     Yanfly.BEC.BattleManager_initMembers.call(this);
  1324.     this._forceSelection = false;
  1325.     this._allSelection = false;
  1326.     this._victoryPhase = false;
  1327.     this._forceActionQueue = [];
  1328. };
  1329.  
  1330. BattleManager.isBattleSystem = function(value) {
  1331.     return value.toLowerCase() === $gameSystem.getBattleSystem();
  1332. };
  1333.  
  1334. BattleManager.isDTB = function() {
  1335.     return this.isBattleSystem('dtb');
  1336. };
  1337.  
  1338. BattleManager.isTurnBased = function() {
  1339.     if (this.isDTB()) return true;
  1340.     return false;
  1341. };
  1342.  
  1343. BattleManager.isTickBased = function() {
  1344.     return !this.isTurnBased();
  1345. };
  1346.  
  1347. BattleManager.tickRate = function() {
  1348.     return 1;
  1349. };
  1350.  
  1351. BattleManager.forceSelection = function() {
  1352.     this._forceSelection = true;
  1353. };
  1354.  
  1355. BattleManager.isForceSelection = function() {
  1356.     return this._forceSelection;
  1357. };
  1358.  
  1359. BattleManager.resetSelection = function() {
  1360.     this._forceSelection = false;
  1361. };
  1362.  
  1363. BattleManager.startAllSelection = function() {
  1364.     this._allSelection = true;
  1365. };
  1366.  
  1367. BattleManager.isAllSelection = function() {
  1368.      return this._allSelection && BattleManager.isInputting();
  1369. };
  1370.  
  1371. BattleManager.stopAllSelection = function() {
  1372.     this._allSelection = false;
  1373. };
  1374.  
  1375. Yanfly.BEC.BattleManager_makeEscapeRatio = BattleManager.makeEscapeRatio;
  1376. BattleManager.makeEscapeRatio = function() {
  1377.     if (this.isDTB()) {
  1378.       this._escapeRatio = eval(Yanfly.Param.BECEscRatio);
  1379.       this._escapeFailBoost = eval(Yanfly.Param.BECEscFail);
  1380.     } else {
  1381.       this._escapeFailBoost = 0.1;
  1382.       Yanfly.BEC.BattleManager_makeEscapeRatio.call(this);
  1383.     }
  1384. };
  1385.  
  1386. BattleManager.timeBasedStates = function() {
  1387.     if (!$gameParty.inBattle()) return false;
  1388.     if (this.isTurnBased()) return false;
  1389.     if (this._timeBasedStates !== undefined) return this._timeBasedStates;
  1390.     this._timeBasedStates = eval(Yanfly.Param.BECTimeStates);
  1391.     return this._timeBasedStates;
  1392. };
  1393.  
  1394. BattleManager.timeBasedBuffs = function() {
  1395.     if (!$gameParty.inBattle()) return false;
  1396.     if (this.isTurnBased()) return false;
  1397.     if (this._timeBasedBuffs !== undefined) return this._timeBasedBuffs;
  1398.     this._timeBasedBuffs = eval(Yanfly.Param.BECTimeBuffs);
  1399.     return this._timeBasedBuffs;
  1400. };
  1401.  
  1402. BattleManager.displayStartMessages = function() {
  1403.     if (eval(Yanfly.Param.BECEmergeText)) {
  1404.       $gameTroop.enemyNames().forEach(function(name) {
  1405.           $gameMessage.add(TextManager.emerge.format(name));
  1406.       });
  1407.     }
  1408.     if (this._preemptive && eval(Yanfly.Param.BECPreEmpText)) {
  1409.         $gameMessage.add(TextManager.preemptive.format($gameParty.name()));
  1410.     } else if (this._surprise && eval(Yanfly.Param.BECSurpText)) {
  1411.         $gameMessage.add(TextManager.surprise.format($gameParty.name()));
  1412.     }
  1413. };
  1414.  
  1415. BattleManager.registerSprite = function(battler, sprite) {
  1416.   if (!this._registeredSprites) this._registeredSprites = {};
  1417.   if (battler.isActor()) var id = 100000 + battler.actorId();
  1418.   if (battler.isEnemy()) var id = 200000 + battler.index();
  1419.   this._registeredSprites[id] = sprite;
  1420. };
  1421.  
  1422. BattleManager.getSprite = function(battler) {
  1423.   if (!this._registeredSprites) this._registeredSprites = {};
  1424.   if (battler.isActor()) var id = 100000 + battler.actorId();
  1425.   if (battler.isEnemy()) var id = 200000 + battler.index();
  1426.   return this._registeredSprites[id];
  1427. };
  1428.  
  1429. BattleManager.setSpritePriority = function() {
  1430.     if ($gameSystem.isSideView()) {
  1431.       this._spritePriority = eval(Yanfly.Param.BECSideSpPrio);
  1432.     } else {
  1433.       this._spritePriority = eval(Yanfly.Param.BECFrontSprite);
  1434.     }
  1435.     if (this._spritePriority === false) this._spritePriority = 0;
  1436.     if (this._spritePriority === true) this._spritePriority = 1;
  1437. };
  1438.  
  1439. BattleManager.getSpritePriority = function() {
  1440.     if (!this._spritePriority) this.setSpritePriority();
  1441.     return this._spritePriority;
  1442. };
  1443.  
  1444. BattleManager.changeActor = function(newActorIndex, lastActorActionState) {
  1445.     var lastActor = this.actor();
  1446.     this._actorIndex = newActorIndex;
  1447.     var newActor = this.actor();
  1448.     if (lastActor) {
  1449.         lastActor.setActionState(lastActorActionState);
  1450.         lastActor.spriteReturnHome();
  1451.     }
  1452.     if (newActor) {
  1453.         newActor.setActionState('inputting');
  1454.         newActor.spriteStepForward();
  1455.     }
  1456. };
  1457.  
  1458. BattleManager.createActions = function() {
  1459.     $gameParty.createActions();
  1460.     $gameTroop.createActions();
  1461. };
  1462.  
  1463. BattleManager.clearInputtingAction = function() {
  1464.     if (this.inputtingAction()) this.inputtingAction().clear();
  1465. };
  1466.  
  1467. Yanfly.BEC.BattleManager_checkBattleEnd = BattleManager.checkBattleEnd;
  1468. BattleManager.checkBattleEnd = function() {
  1469.     if (this._phase === 'actionList') return false;
  1470.     if (this._phase === 'actionTargetList') return false;
  1471.     if (this._phase === 'action') return false;
  1472.     if (this._phase === 'phaseChange') return false;
  1473.     if ($gameTroop.isEventRunning()) return false;
  1474.     return Yanfly.BEC.BattleManager_checkBattleEnd.call(this);
  1475. };
  1476.  
  1477. Yanfly.BEC.BattleManager_processTurn = BattleManager.processTurn;
  1478. BattleManager.processTurn = function() {
  1479.     this._processTurn = true;
  1480.     Yanfly.BEC.BattleManager_processTurn.call(this);
  1481.     this._processTurn = false;
  1482. };
  1483.  
  1484. Yanfly.BEC.BattleManager_processVictory = BattleManager.processVictory;
  1485. BattleManager.processVictory = function() {
  1486.     this._logWindow.clear();
  1487.     this._victoryPhase = true;
  1488.     if (this._windowLayer) this._windowLayer.x = 0;
  1489.     Yanfly.BEC.BattleManager_processVictory.call(this);
  1490. };
  1491.  
  1492. BattleManager.processEscape = function() {
  1493.     $gameParty.performEscape();
  1494.     SoundManager.playEscape();
  1495.     var success = this._preemptive ? true : (Math.random() < this._escapeRatio);
  1496.     if (success) {
  1497.         $gameParty.performEscapeSuccess();
  1498.         this.displayEscapeSuccessMessage();
  1499.         this._escaped = true;
  1500.         this.processAbort();
  1501.     } else {
  1502.         this.displayEscapeFailureMessage();
  1503.         this._escapeRatio += this._escapeFailBoost;
  1504.         $gameParty.clearActions();
  1505.         this.startTurn();
  1506.     }
  1507.     return success;
  1508. };
  1509.  
  1510. Yanfly.BEC.BattleManager_processAbort = BattleManager.processAbort;
  1511. BattleManager.processAbort = function() {
  1512.     $gameParty.removeBattleStates();
  1513.     Yanfly.BEC.BattleManager_processAbort.call(this);
  1514. };
  1515.  
  1516. BattleManager.startTurn = function() {
  1517.     this._enteredEndPhase = false;
  1518.     this._phase = 'turn';
  1519.     this.clearActor();
  1520.     $gameTroop.increaseTurn();
  1521.     $gameParty.onTurnStart();
  1522.     $gameTroop.onTurnStart();
  1523.     this._performedBattlers = [];
  1524.     this.makeActionOrders();
  1525.     $gameParty.requestMotionRefresh();
  1526.     this._logWindow.startTurn();
  1527.     this._subject = this.getNextSubject();
  1528. };
  1529.  
  1530. Yanfly.BEC.BattleManager_endTurn = BattleManager.endTurn;
  1531. BattleManager.endTurn = function() {
  1532.     if (this.isTurnBased() && this._spriteset.isPopupPlaying()) return;
  1533.     if (this.isTurnBased() && this._enteredEndPhase) {
  1534.       this._phase = 'turnEnd';
  1535.       this._preemptive = false;
  1536.       this._surprise = false;
  1537.       return;
  1538.     }
  1539.     this._enteredEndPhase = true;
  1540.     Yanfly.BEC.BattleManager_endTurn.call(this);
  1541. };
  1542.  
  1543. BattleManager.getNextSubject = function() {
  1544.     if ($gameTroop.turnCount() <= 0) return;
  1545.     this._performedBattlers = this._performedBattlers || [];
  1546.     this.makeActionOrders();
  1547.     for (;;) {
  1548.         var battlerArray = [];
  1549.         for (var i = 0; i < this._actionBattlers.length; ++i) {
  1550.           var obj = this._actionBattlers[i];
  1551.           if (!this._performedBattlers.contains(obj)) battlerArray.push(obj);
  1552.         }
  1553.         this._actionBattlers = battlerArray;
  1554.         var battler = this._actionBattlers.shift();
  1555.         if (!battler) return null;
  1556.         if (battler.isBattleMember() && battler.isAlive()) {
  1557.             this._performedBattlers.push(battler);
  1558.             return battler;
  1559.         }
  1560.     }
  1561. };
  1562.  
  1563. BattleManager.update = function() {
  1564.     if (!this.isBusy() && !this.updateEvent()) {
  1565.         switch (this._phase) {
  1566.         case 'start':
  1567.             this.startInput();
  1568.             break;
  1569.         case 'turn':
  1570.             this.updateTurn();
  1571.             break;
  1572.         case 'action':
  1573.             this.updateAction();
  1574.             break;
  1575.         case 'phaseChange':
  1576.             this.updatePhase();
  1577.             break;
  1578.         case 'actionList':
  1579.             this.updateActionList()
  1580.             break;
  1581.         case 'actionTargetList':
  1582.             this.updateActionTargetList()
  1583.             break;
  1584.         case 'turnEnd':
  1585.             this.updateTurnEnd();
  1586.             break;
  1587.         case 'battleEnd':
  1588.             this.updateBattleEnd();
  1589.             break;
  1590.         }
  1591.     }
  1592. };
  1593.  
  1594. BattleManager.updateEvent = function() {
  1595.     if (this._processingForcedAction) return false;
  1596.     switch (this._phase) {
  1597.     case 'start':
  1598.     case 'turn':
  1599.     case 'turnEnd':
  1600.     case 'actionList':
  1601.     case 'actionTargetList':
  1602.       if (this.isActionForced()) {
  1603.         this.processForcedAction();
  1604.         return true;
  1605.       } else {
  1606.         return this.updateEventMain();
  1607.       }
  1608.     }
  1609.     return this.checkAbort();
  1610. };
  1611.  
  1612. Yanfly.BEC.BattleManager_forceAction = BattleManager.forceAction;
  1613. BattleManager.forceAction = function(battler) {
  1614.     this.createForceActionFailSafes();
  1615.     this.savePreForceActionSettings();
  1616.     Yanfly.BEC.BattleManager_forceAction.call(this, battler);
  1617. };
  1618.  
  1619. BattleManager.createForceActionFailSafes = function() {
  1620.     this._actionList = this._actionList || [];
  1621.     this._targets = this._targets || [];
  1622.     this._allTargets = this._allTargets || [];
  1623.     this._individualTargets = this._individualTargets || [];
  1624.     this._phaseSteps = this._phaseSteps || [];
  1625.     this._conditionFlags = this._conditionFlags || [];
  1626.     this._trueFlags = this._trueFlags || [];
  1627. };
  1628.  
  1629. BattleManager.savePreForceActionSettings = function() {
  1630.     var settings = this.setPreForceActionSettings();
  1631.     this._forceActionQueue.push(settings);
  1632. };
  1633.  
  1634. BattleManager.setPreForceActionSettings = function() {
  1635.     return {
  1636.       subject: this._subject,
  1637.       action: JsonEx.makeDeepCopy(this._action),
  1638.       actionList: JsonEx.makeDeepCopy(this._actionList),
  1639.       targets: this._targets.slice(),
  1640.       allTargets: this._allTargets.slice(),
  1641.       indTargets: this._individualTargets.slice(),
  1642.       phaseSteps: JsonEx.makeDeepCopy(this._phaseSteps),
  1643.       returnPhase: this._returnPhase,
  1644.       phase: this._phase,
  1645.       conditionFlags: JsonEx.makeDeepCopy(this._conditionFlags),
  1646.       trueFlags: JsonEx.makeDeepCopy(this._trueFlags)
  1647.     }
  1648. };
  1649.  
  1650. BattleManager.loadPreForceActionSettings = function() {
  1651.     var settings = this._forceActionQueue[0];
  1652.     if (settings) {
  1653.       this._forceActionQueue.shift();
  1654.       this.resetPreForceActionSettings(settings);
  1655.       return this._subject && this._subject.isAppeared();
  1656.     } else {
  1657.       return false;
  1658.     }   
  1659. };
  1660.  
  1661. BattleManager.resetPreForceActionSettings = function(settings) {
  1662.     this._subject = settings['subject'];
  1663.     this._action = settings['action'];
  1664.     this._actionList = settings['actionList'];
  1665.     this._targets = settings['targets'];
  1666.     this._allTargets = settings['allTargets'];
  1667.     this._individualTargets = settings['indTargets'];
  1668.     this._phaseSteps = settings['phaseSteps'];
  1669.     this._returnPhase = settings['returnPhase'];
  1670.     this._conditionFlags = settings['conditionFlags'];
  1671.     this._trueFlags = settings['trueFlags'];
  1672.     this._phase = settings['phase'];   
  1673. };
  1674.  
  1675. Yanfly.BEC.BattleManager_processForcedAction =
  1676.     BattleManager.processForcedAction;
  1677. BattleManager.processForcedAction = function() {
  1678.     if (this._actionForcedBattler) {
  1679.       this._preForcePhase = this._phase;
  1680.       this._processingForcedAction = true;
  1681.     }
  1682.     Yanfly.BEC.BattleManager_processForcedAction.call(this);
  1683. };
  1684.  
  1685. BattleManager.setTargets = function(array) {
  1686.     this._targets = [];
  1687.     var max = array.length;
  1688.     for (var i = 0; i < max; ++i) {
  1689.       var target = array[i];
  1690.       if (target) this._targets.push(target);
  1691.     }
  1692. };
  1693.  
  1694. BattleManager.updateAction = function() {
  1695.     var target = this._targets.shift();
  1696.     if (target) {
  1697.         this.invokeAction(this._subject, target);
  1698.     } else {
  1699.         if (this._returnPhase === 'target') {
  1700.           this.setTargets([this._individualTargets[0]]);
  1701.           this._phase = 'actionTargetList';
  1702.         } else {
  1703.           this.setTargets(this._allTargets.slice());
  1704.           this._phase = 'actionList';
  1705.         }
  1706.     }
  1707. };
  1708.  
  1709. BattleManager.invokeAction = function(subject, target) {
  1710.   if (!eval(Yanfly.Param.BECOptSpeed))  this._logWindow.push('pushBaseLine');
  1711.   var normal = true;
  1712.   if (Math.random() < this._action.itemMrf(target)) {
  1713.     this.invokeMagicReflection(subject, target);
  1714.   } else if (Math.random() < this._action.itemCnt(target)) {
  1715.     this.invokeCounterAttack(subject, target);
  1716.   } else {
  1717.     this.invokeNormalAction(subject, target);
  1718.   }
  1719.   subject.setLastTarget(target);
  1720.   if (!eval(Yanfly.Param.BECOptSpeed)) this._logWindow.push('popBaseLine');
  1721. };
  1722.  
  1723. BattleManager.invokeCounterAttack = function(subject, target) {
  1724.     var action = new Game_Action(target);
  1725.     this._logWindow.displayCounter(target);
  1726.     action.setAttack();
  1727.     action.apply(subject);
  1728.     this._logWindow.displayActionResults(subject, subject);
  1729.     if (subject.isDead()) subject.performCollapse();
  1730. };
  1731.  
  1732. Yanfly.BEC.BattleManager_invokeMagicReflection =
  1733.     BattleManager.invokeMagicReflection;
  1734. BattleManager.invokeMagicReflection = function(subject, target) {
  1735.     Yanfly.BEC.BattleManager_invokeMagicReflection.call(this, subject, target);
  1736.     if (subject.isDead()) subject.performCollapse();
  1737. };
  1738.  
  1739. BattleManager.updatePhase = function() {
  1740.     var phase = this._phaseSteps.shift();
  1741.     if (phase) this.createPhaseChanges();
  1742.     switch (phase) {
  1743.     case 'setup':
  1744.       this.createSetupActions();
  1745.       break;
  1746.     case 'whole':
  1747.       this.createWholeActions();
  1748.       break;
  1749.     case 'target':
  1750.       this.createTargetActions();
  1751.       break;
  1752.     case 'follow':
  1753.       this.createFollowActions();
  1754.       break;
  1755.     case 'finish':
  1756.       this.createFinishActions();
  1757.       break;
  1758.     default:
  1759.       this.endAction();
  1760.       break;
  1761.     }
  1762. };
  1763.  
  1764. BattleManager.createPhaseChanges = function() {
  1765.     this._phase = 'actionList';
  1766.     this.setTargets(this._allTargets.slice());
  1767.     this._conditionFlags = [];
  1768.     this._trueFlags = [];
  1769. };
  1770.  
  1771. BattleManager.createSetupActions = function() {
  1772.     $gameTemp.clearActionSequenceSettings();
  1773.     this._returnPhase = 'setup';
  1774.     this._actionList = this._action.item().setupActions.slice();
  1775. };
  1776.  
  1777. BattleManager.createWholeActions = function() {
  1778.     this._returnPhase = 'whole';
  1779.     this._actionList = this._action.item().wholeActions.slice();
  1780. };
  1781.  
  1782. BattleManager.createTargetActions = function() {
  1783.     this._returnPhase = 'target';
  1784.     this._phase = 'actionTargetList';
  1785.     this.setTargets([this._individualTargets[0]]);
  1786.     this._actionList = this._action.item().targetActions.slice();
  1787. };
  1788.  
  1789. BattleManager.createFollowActions = function() {
  1790.     this._returnPhase = 'follow';
  1791.     this._actionList = this._action.item().followActions.slice();
  1792. };
  1793.  
  1794. BattleManager.createFinishActions = function() {
  1795.     this._returnPhase = 'finish';
  1796.     this._actionList = this._action.item().finishActions.slice();
  1797. };
  1798.  
  1799. Yanfly.BEC.BattleManager_endAction = BattleManager.endAction;
  1800. BattleManager.endAction = function() {
  1801.     if (this._processingForcedAction) {
  1802.       this._phase = this._preForcePhase;
  1803.     }
  1804.     this._processingForcedAction = false;
  1805.     if (this._subject) this._subject.onAllActionsEnd();
  1806.     if (this.loadPreForceActionSettings()) return;
  1807.     Yanfly.BEC.BattleManager_endAction.call(this);
  1808. };
  1809.  
  1810. BattleManager.updateActionList = function() {
  1811.     for (;;) {
  1812.       this._actSeq = this._actionList.shift();
  1813.       if (this._actSeq) {
  1814.         if (!this.actionConditionsMet(this._actSeq)) continue;
  1815.         var seqName = this._actSeq[0].toUpperCase();
  1816.         if (!this.processActionSequenceCheck(seqName, this._actSeq[1])) {
  1817.           break;
  1818.         }
  1819.       } else {
  1820.         this._phase = 'phaseChange';
  1821.         break;
  1822.       }
  1823.     }
  1824. };
  1825.  
  1826. BattleManager.updateActionTargetList = function() {
  1827.     for (;;) {
  1828.       this._actSeq = this._actionList.shift();
  1829.       if (this._actSeq) {
  1830.         if (!this.actionConditionsMet(this._actSeq)) continue;
  1831.         var seqName = this._actSeq[0].toUpperCase();
  1832.         if (!this.processActionSequenceCheck(seqName, this._actSeq[1])) {
  1833.           break;
  1834.         }
  1835.       } else if (this._individualTargets.length > 0) {
  1836.         this._individualTargets.shift();
  1837.         if (this._individualTargets.length > 0) {
  1838.           this.setTargets([this._individualTargets[0]]);
  1839.           this._actionList = this._action.item().targetActions.slice();
  1840.         } else {
  1841.           this._phase = 'phaseChange';
  1842.           break;
  1843.         }
  1844.       } else {
  1845.         this._phase = 'phaseChange';
  1846.         break;
  1847.       }
  1848.     }
  1849. };
  1850.  
  1851. BattleManager.updateActionTargetList = function() {
  1852.     for (;;) {
  1853.       this._actSeq = this._actionList.shift();
  1854.       if (this._actSeq) {
  1855.         if (!this.actionConditionsMet(this._actSeq)) continue;
  1856.         var seqName = this._actSeq[0].toUpperCase();
  1857.         if (!this.processActionSequenceCheck(seqName, this._actSeq[1])) {
  1858.           break;
  1859.         }
  1860.       } else if (this._individualTargets.length > 0) {
  1861.         this._individualTargets.shift();
  1862.         if (this._individualTargets.length > 0) {
  1863.           this.setTargets([this._individualTargets[0]]);
  1864.           this._actionList = this._action.item().targetActions.slice();
  1865.         } else {
  1866.           this._phase = 'phaseChange';
  1867.           break;
  1868.         }
  1869.       } else {
  1870.         this._phase = 'phaseChange';
  1871.         break;
  1872.       }
  1873.     }
  1874. };
  1875.  
  1876. BattleManager.startAction = function() {
  1877.     var subject = this._subject;
  1878.     var action = subject.currentAction();
  1879.     this._action = action;
  1880.     var targets = action.makeTargets();
  1881.     this.setTargets(targets);
  1882.     this._allTargets = targets.slice();
  1883.     this._individualTargets = targets.slice();
  1884.     this._phase = 'phaseChange';
  1885.     this._phaseSteps = ['setup', 'whole', 'target', 'follow', 'finish'];
  1886.     this._returnPhase = '';
  1887.     this._actionList = [];
  1888.     subject.useItem(this._action.item());
  1889.     this._action.applyGlobal();
  1890.     this._logWindow.startAction(this._subject, this._action, this._targets);
  1891. };
  1892.  
  1893. BattleManager.processActionSequenceCheck = function(actionName, actionArgs) {
  1894.     // IF condition
  1895.     if (actionName.match(/IF[ ](.*)/i)) {
  1896.       return this.actionIfConditions(actionName, actionArgs);
  1897.     }
  1898.     return this.processActionSequence(actionName, actionArgs)
  1899. };
  1900.  
  1901. BattleManager.processActionSequence = function(actionName, actionArgs) {
  1902.     // NO ACTION
  1903.     if (actionName === '') {
  1904.       return true;
  1905.     }
  1906.     // ACTION ANIMATION
  1907.     if (actionName === 'ACTION ANIMATION') {
  1908.       return this.actionActionAnimation(actionArgs);
  1909.     }
  1910.     // ACTION EFFECT
  1911.     if (actionName === 'ACTION COMMON EVENT') {
  1912.       return this.actionActionCommonEvent();
  1913.     }
  1914.     // ACTION EFFECT
  1915.     if (actionName === 'ACTION EFFECT') {
  1916.       return this.actionActionEffect(actionArgs);
  1917.     }
  1918.     // ANI WAIT: frames
  1919.     if (['ANI WAIT', 'ANIWAIT', 'ANIMATION WAIT'].contains(actionName)) {
  1920.       return this.actionAniWait(actionArgs[0]);
  1921.     }
  1922.     // CAST ANIMATION
  1923.     if (actionName === 'CAST ANIMATION') {
  1924.       return this.actionCastAnimation();
  1925.     }
  1926.     // CLEAR BATTLE LOG
  1927.     if (actionName === 'CLEAR BATTLE LOG') {
  1928.       return this.actionClearBattleLog();
  1929.     }
  1930.     // DEATH BREAK
  1931.     if (actionName === 'DEATH BREAK') {
  1932.       return this.actionDeathBreak();
  1933.     }
  1934.     // DISPLAY ACTION
  1935.     if (actionName === 'DISPLAY ACTION') {
  1936.       return this.actionDisplayAction();
  1937.     }
  1938.     // IMMORTAL: targets, true/false
  1939.     if (actionName === 'IMMORTAL') {
  1940.       return this.actionImmortal(actionArgs);
  1941.     }
  1942.     // MOTION WAIT
  1943.     if (actionName === 'MOTION WAIT') {
  1944.       return this.actionMotionWait(actionArgs);
  1945.     }
  1946.     // PERFORM ACTION
  1947.     if (actionName === 'PERFORM ACTION') {
  1948.       return this.actionPerformAction();
  1949.     }
  1950.     // PERFORM FINISH
  1951.     if (actionName === 'PERFORM FINISH') {
  1952.       return this.actionPerformFinish();
  1953.     }
  1954.     // PERFORM START
  1955.     if (actionName === 'PERFORM START') {
  1956.       return this.actionPerformStart();
  1957.     }
  1958.     // WAIT: frames
  1959.     if (actionName === 'WAIT') {
  1960.       return this.actionWait(actionArgs[0]);
  1961.     }
  1962.     // WAIT FOR ANIMATION
  1963.     if (actionName === 'WAIT FOR ANIMATION') {
  1964.       return this.actionWaitForAnimation();
  1965.     }
  1966.     // WAIT FOR EFFECT
  1967.     if (actionName === 'WAIT FOR EFFECT') {
  1968.       return this.actionWaitForEffect();
  1969.     }
  1970.     // WAIT FOR MOVEMENT
  1971.     if (actionName === 'WAIT FOR MOVEMENT') {
  1972.       return this.actionWaitForMovement();
  1973.     }
  1974.     // WAIT FOR NEW LINE
  1975.     if (actionName === 'WAIT FOR NEW LINE') {
  1976.       return this.actionWaitForNewLine();
  1977.     }
  1978.     // WAIT FOR POPUPS
  1979.     if (actionName === 'WAIT FOR POPUPS') {
  1980.       return this.actionWaitForPopups();
  1981.     }
  1982.     return false;
  1983. };
  1984.  
  1985. BattleManager.makeActionTargets = function(string) {
  1986.     var targets = []
  1987.     string = string.toUpperCase()
  1988.     if (['SUBJECT', 'USER'].contains(string)) {
  1989.       return [this._subject];
  1990.     }
  1991.     if (['TARGET', 'TARGETS'].contains(string)) {
  1992.       var group = this._targets;
  1993.       for (var i = 0; i < group.length; ++i) {
  1994.         var target = group[i];
  1995.         if (target) targets.push(target);
  1996.       }
  1997.       return targets;
  1998.     }
  1999.     if (['ACTORS', 'EXISTING ACTORS', 'ALIVE ACTORS'].contains(string)) {
  2000.       var group = $gameParty.aliveMembers();
  2001.       for (var i = 0; i < group.length; ++i) {
  2002.         var target = group[i];
  2003.         if (target) targets.push(target);
  2004.       }
  2005.       return targets;
  2006.     }
  2007.     if (['ACTORS ALL', 'ALL ACTORS', 'PARTY'].contains(string)) {
  2008.       var group = $gameParty.battleMembers();
  2009.       for (var i = 0; i < group.length; ++i) {
  2010.         var target = group[i];
  2011.         if (target) targets.push(target);
  2012.       }
  2013.       return targets;
  2014.     }
  2015.     if (['DEAD ACTORS', 'DEAD ACTOR'].contains(string)) {
  2016.       var group = $gameParty.deadMembers();
  2017.       for (var i = 0; i < group.length; ++i) {
  2018.         var target = group[i];
  2019.         if (target) targets.push(target);
  2020.       }
  2021.       return targets;
  2022.     }
  2023.     if (['ACTORS NOT USER', 'ACTORS NOT SUBJECT'].contains(string)) {
  2024.       var group = $gameParty.aliveMembers();
  2025.       for (var i = 0; i < group.length; ++i) {
  2026.         var target = group[i];
  2027.         if (target && target !== this._subject) targets.push(target);
  2028.       }
  2029.       return targets;
  2030.     }
  2031.     if (['ENEMIES', 'EXISTING ENEMIES', 'ALIVE ENEMIES', 'TROOP',
  2032.     'TROOPS'].contains(string)) {
  2033.       var group = $gameTroop.aliveMembers();
  2034.       for (var i = 0; i < group.length; ++i) {
  2035.         var target = group[i];
  2036.         if (target) targets.push(target);
  2037.       }
  2038.       return targets;
  2039.     }
  2040.     if (['ENEMIES ALL', 'ALL ENEMIES'].contains(string)) {
  2041.       var group = $gameTroop.members();
  2042.       for (var i = 0; i < group.length; ++i) {
  2043.         var target = group[i];
  2044.         if (target) targets.push(target);
  2045.       }
  2046.       return targets;
  2047.     }
  2048.     if (['DEAD ENEMIES', 'DEAD ENEMY'].contains(string)) {
  2049.       var group = $gameTroop.deadMembers();
  2050.       for (var i = 0; i < group.length; ++i) {
  2051.         var target = group[i];
  2052.         if (target) targets.push(target);
  2053.       }
  2054.       return targets;
  2055.     }
  2056.     if (['ENEMIES NOT USER', 'ENEMIES NOT SUBJECT', 'TROOP NOT USER',
  2057.     'TROOP NOT SUBJECT'].contains(string)) {
  2058.       var group = $gameTroop.aliveMembers();
  2059.       for (var i = 0; i < group.length; ++i) {
  2060.         var target = group[i];
  2061.         if (target && target !== this._subject) targets.push(target);
  2062.       }
  2063.       return targets;
  2064.     }
  2065.     if (string.match(/ACTOR[ ](\d+)/i)) {
  2066.       var target = $gameParty.battleMembers()[parseInt(RegExp.$1)];
  2067.       if (target) return [target];
  2068.     }
  2069.     if (string.match(/ENEMY[ ](\d+)/i)) {
  2070.       var target = $gameTroop.members()[parseInt(RegExp.$1)];
  2071.       if (target) return [target];
  2072.     }
  2073.     if (['FRIEND', 'FRIENDS', 'ALLIES'].contains(string)) {
  2074.       var group = this._action.friendsUnit().aliveMembers();
  2075.       for (var i = 0; i < group.length; ++i) {
  2076.         var target = group[i];
  2077.         if (target) targets.push(target);
  2078.       }
  2079.       return targets;
  2080.     }
  2081.     if (['ALL FRIENDS', 'ALL ALLIES'].contains(string)) {
  2082.       var group = this._action.friendsUnit().members();
  2083.       for (var i = 0; i < group.length; ++i) {
  2084.         var target = group[i];
  2085.         if (target) targets.push(target);
  2086.       }
  2087.       return targets;
  2088.     }
  2089.     if (['DEAD FRIEND', 'DEAD FRIENDS', 'DEAD ALLIES'].contains(string)) {
  2090.       var group = this._action.friendsUnit().deadMembers();
  2091.       for (var i = 0; i < group.length; ++i) {
  2092.         var target = group[i];
  2093.         if (target) targets.push(target);
  2094.       }
  2095.       return targets;
  2096.     }
  2097.     if (['OPPONENT', 'OPPONENTS', 'RIVALS', 'FOES'].contains(string)) {
  2098.       var group = this._action.opponentsUnit().aliveMembers();
  2099.       for (var i = 0; i < group.length; ++i) {
  2100.         var target = group[i];
  2101.         if (target) targets.push(target);
  2102.       }
  2103.       return targets;
  2104.     }
  2105.     if (['ALL OPPONENTS', 'ALL RIVALS', 'ALL FOES'].contains(string)) {
  2106.       var group = this._action.opponentsUnit().members();
  2107.       for (var i = 0; i < group.length; ++i) {
  2108.         var target = group[i];
  2109.         if (target) targets.push(target);
  2110.       }
  2111.       return targets;
  2112.     }
  2113.     if (['DEAD OPPONENT', 'DEAD OPPONENTS', 'DEAD RIVALS',
  2114.     'DEAD FOES'].contains(string)) {
  2115.       var group = this._action.opponentsUnit().deadMembers();
  2116.       for (var i = 0; i < group.length; ++i) {
  2117.         var target = group[i];
  2118.         if (target) targets.push(target);
  2119.       }
  2120.       return targets;
  2121.     }
  2122.     if (['FRIENDS NOT USER', 'ALLIES NOT USER'].contains(string)) {
  2123.       var group = this._action.friendsUnit().aliveMembers();
  2124.       for (var i = 0; i < group.length; ++i) {
  2125.         var target = group[i];
  2126.         if (target && target !== this._subject) targets.push(target);
  2127.       }
  2128.       return targets;
  2129.     }
  2130.     if (string.match(/(?:FRIEND|ALLY)[ ](\d+)/i)) {
  2131.       var target = this._action.friendsUnit().members()[parseInt(RegExp.$1)];
  2132.       if (target) return [target];
  2133.     }
  2134.     if (string.match(/(?:OPPONENT|FOE|RIVAL)[ ](\d+)/i)) {
  2135.       var target = this._action.opponentsUnit().members()[parseInt(RegExp.$1)]
  2136.       if (target) return [target];
  2137.     }
  2138.     if (['ALL ALIVE'].contains(string)) {
  2139.       var group = this._action.friendsUnit().aliveMembers();
  2140.       group = group.concat(this._action.opponentsUnit().aliveMembers());
  2141.       for (var i = 0; i < group.length; ++i) {
  2142.         var target = group[i];
  2143.         if (target) targets.push(target);
  2144.       }
  2145.       return targets;
  2146.     }
  2147.     if (['ALL MEMBERS'].contains(string)) {
  2148.       var group = this._action.friendsUnit().members();
  2149.       group = group.concat(this._action.opponentsUnit().members());
  2150.       for (var i = 0; i < group.length; ++i) {
  2151.         var target = group[i];
  2152.         if (target) targets.push(target);
  2153.       }
  2154.       return targets;
  2155.     }
  2156.     if (['ALL DEAD'].contains(string)) {
  2157.       var group = this._action.friendsUnit().deadMembers();
  2158.       group = group.concat(this._action.opponentsUnit().deadMembers());
  2159.       for (var i = 0; i < group.length; ++i) {
  2160.         var target = group[i];
  2161.         if (target) targets.push(target);
  2162.       }
  2163.       return targets;
  2164.     }
  2165.     if (['ALL NOT USER'].contains(string)) {
  2166.       var group = this._action.friendsUnit().aliveMembers();
  2167.       group = group.concat(this._action.opponentsUnit().aliveMembers());
  2168.       for (var i = 0; i < group.length; ++i) {
  2169.         var target = group[i];
  2170.         if (target && target !== this._subject) targets.push(target);
  2171.       }
  2172.       return targets;
  2173.     }
  2174.     if (['FOCUS', 'PARTICIPANTS'].contains(string)) {
  2175.       var group = this._targets;
  2176.       for (var i = 0; i < group.length; ++i) {
  2177.         var target = group[i];
  2178.         if (target) targets.push(target);
  2179.       }
  2180.       if (!targets.contains(this._subject)) targets.push(this._subject);
  2181.       return targets;
  2182.     }
  2183.     if (['NOT FOCUS', 'NONPARTICIPANTS'].contains(string)) {
  2184.       var group = this._action.friendsUnit().members();
  2185.       group = group.concat(this._action.opponentsUnit().members());
  2186.       for (var i = 0; i < group.length; ++i) {
  2187.         var target = group[i];
  2188.         if (target) {
  2189.           if (target === this._subject) continue;
  2190.           if (this._targets.contains(target)) continue;
  2191.  
  2192.           if (target.isDead()) {
  2193.                   if (Imported.YEP_X_AnimatedSVEnemies && target.isEnemy()) {
  2194.                           if (target.hasSVBattler() && !target.sideviewCollapse()) {
  2195.                                   // Ignore
  2196.                           } else {
  2197.                                   continue;
  2198.                           }
  2199.                   } else {
  2200.                           continue;
  2201.                   }
  2202.           }
  2203.  
  2204.           targets.push(target);
  2205.         }
  2206.       }
  2207.       return targets;
  2208.     }
  2209.     if (string.match(/(?:CHAR|CHARA|CHARACTER)[ ](\d+)/i)) {
  2210.       var actorId = parseInt(RegExp.$1);
  2211.       var actor = $gameActors.actor(actorId);
  2212.       if (actor && $gameParty.battleMembers().contains(actor)) {
  2213.         return [actor];
  2214.       }
  2215.     }
  2216.     if ('FIRST' === string.toUpperCase()) {
  2217.       return [this._targets[0]];
  2218.     }
  2219.     return targets;
  2220. };
  2221.  
  2222. BattleManager.actionConditionsMet = function(actSeq) {
  2223.     var ci = this._conditionFlags.length - 1;
  2224.     var actionName = actSeq[0];
  2225.     var actionArgs = actSeq[1];
  2226.     var subject = this._subject;
  2227.     var user = this._subject;
  2228.     var target = this._targets[0];
  2229.     var targets = this._targets;
  2230.     var action = this._action;
  2231.     var item = this._action.item();
  2232.     if (actionName.match(/ELSE[ ]IF[ ](.*)/i)) {
  2233.       if (this._conditionFlags.length <= 0) return false;
  2234.       if (this._conditionFlags[ci]) {
  2235.         this._conditionFlags[ci] = false;
  2236.         this._trueFlags[ci] = true;
  2237.       } else if (!this._conditionFlags[ci] && !this._trueFlags[ci]) {
  2238.         var text = String(RegExp.$1);
  2239.         this._conditionFlags[ci] = eval('(' + text + ')');
  2240.         this._trueFlags[ci] = eval('(' + text + ')');
  2241.       }
  2242.       return false;
  2243.     } else if (actionName.match(/ELSE[ ]*(.*)/i)) {
  2244.       if (this._conditionFlags.length <= 0) return false;
  2245.       if (this._conditionFlags[ci]) {
  2246.         this._conditionFlags[ci] = false;
  2247.         this._trueFlags[ci] = true;
  2248.       } else if (!this._conditionFlags[ci] && !this._trueFlags[ci]) {
  2249.         this._conditionFlags[ci] = true;
  2250.         this._trueFlags[ci] = true;
  2251.       }
  2252.       return false;
  2253.     } else if (actionName.toUpperCase() === 'END') {
  2254.       if (this._conditionFlags.length <= 0) return false;
  2255.       this._conditionFlags.pop();
  2256.       this._trueFlags.pop();
  2257.       return false;
  2258.     }
  2259.     if (this._conditionFlags.length > 0) return this._conditionFlags[ci];
  2260.     return true
  2261. };
  2262.  
  2263. BattleManager.actionActionAnimation = function(actionArgs) {
  2264.     if (actionArgs && actionArgs[0]) {
  2265.       var targets = this.makeActionTargets(actionArgs[0]);
  2266.     } else {
  2267.       var targets = this._targets;
  2268.     }
  2269.     var mirror = false;
  2270.     if (actionArgs && actionArgs[1]) {
  2271.       if (actionArgs[1].toUpperCase() === 'MIRROR') mirror = true;
  2272.     }
  2273.     var subject = this._subject;
  2274.     var group = targets.filter(Yanfly.Util.onlyUnique);
  2275.     var aniId = this._action.item().animationId;
  2276.     if (aniId < 0) {
  2277.       if (mirror) {
  2278.         this._logWindow.showActorAtkAniMirror(subject, group);
  2279.       } else {
  2280.         this._logWindow.showAttackAnimation(subject, group);
  2281.       }
  2282.     } else {
  2283.       this._logWindow.showNormalAnimation(group, aniId, mirror);
  2284.     }
  2285.     return true;
  2286. };
  2287.  
  2288. BattleManager.actionActionCommonEvent = function() {
  2289.     this._action.item().effects.forEach(function(effect) {
  2290.         if (effect.code === Game_Action.EFFECT_COMMON_EVENT) {
  2291.             $gameTemp.reserveCommonEvent(effect.dataId);
  2292.         }
  2293.     }, this);
  2294.     return false;
  2295. };
  2296.  
  2297. BattleManager.actionActionEffect = function(actionArgs) {
  2298.     if (actionArgs && actionArgs[0]) {
  2299.       var targets = this.makeActionTargets(actionArgs[0]);
  2300.     } else {
  2301.       var targets = this._targets;
  2302.     }
  2303.     targets.forEach(function(target) {
  2304.       if (target !== undefined) {
  2305.         var alreadyDead = target.isDead();
  2306.         this.invokeAction(this._subject, target);
  2307.         if (target.isDead() && !alreadyDead) {
  2308.             target.performCollapse();
  2309.         }
  2310.       }
  2311.     }, this);
  2312.     return true;
  2313. };
  2314.  
  2315. BattleManager.actionAniWait = function(frames) {
  2316.     frames *= Yanfly.Param.AnimationRate || 4;
  2317.     this._logWindow._waitCount = parseInt(frames);
  2318.     return false;
  2319. };
  2320.  
  2321. BattleManager.actionCastAnimation = function() {
  2322.   if (!$gameSystem.isSideView() && this._subject.isActor()) return true;
  2323.   if (!this._action.isAttack() && !this._action.isGuard() &&
  2324.   this._action.isSkill()) {
  2325.     if (this._action.item().castAnimation > 0) {
  2326.       var ani = $dataAnimations[this._action.item().castAnimation]
  2327.       this._logWindow.showAnimation(this._subject, [this._subject],
  2328.         this._action.item().castAnimation);
  2329.     }
  2330.   }
  2331.   return true;
  2332. };
  2333.  
  2334.  
  2335. BattleManager.actionClearBattleLog = function() {
  2336.     this._logWindow.clear();
  2337.     return false;
  2338. };
  2339.  
  2340. BattleManager.actionDeathBreak = function() {
  2341.     if (this._subject.isDead() || this._subject.hp <= 0) {
  2342.       this._targets = [];
  2343.       this._actionList = [];
  2344.       this._individualTargets = [];
  2345.       this._phase = 'phaseChange';
  2346.       return false;
  2347.     }
  2348.     return true;
  2349. };
  2350.  
  2351. BattleManager.actionDisplayAction = function() {
  2352.     this._logWindow.displayAction(this._subject, this._action.item());
  2353.     return false;
  2354. };
  2355.  
  2356. BattleManager.actionIfConditions = function(actionName, actionArgs) {
  2357.   var subject = this._subject;
  2358.   var user = this._subject;
  2359.   var target = this._targets[0];
  2360.   var targets = this._targets;
  2361.   var action = this._action;
  2362.   var item = this._action.item();
  2363.   var actionName = this._actSeq[0];
  2364.   if (actionName.match(/IF[ ](.*)/i)) {
  2365.     var text = String(RegExp.$1);
  2366.     this._conditionFlags.push(eval(text));
  2367.     this._trueFlags.push(false);
  2368.     var ci = this._conditionFlags.length;
  2369.   }
  2370.   return true;
  2371. };
  2372.  
  2373. BattleManager.actionImmortal = function(actionArgs) {
  2374.     var targets =
  2375.       this.makeActionTargets(actionArgs[0]).filter(Yanfly.Util.onlyUnique);
  2376.     var value = eval(String(actionArgs[1]).toLowerCase());
  2377.     targets.forEach(function (target) {
  2378.       if (value) {
  2379.         target.addImmortal();
  2380.       } else {
  2381.         var alreadyDead = target.isDead();
  2382.         target.removeImmortal();
  2383.       }
  2384.     }, this);
  2385.     return true;
  2386. };
  2387.  
  2388. BattleManager.actionMotionWait = function(actionArgs) {
  2389.     var targets = this.makeActionTargets(actionArgs[0]);
  2390.     if (targets[0].isActor() && targets[0].isSpriteVisible()) {
  2391.       this._logWindow._waitCount += 12;
  2392.       return false;
  2393.     }
  2394.     return true;
  2395. };
  2396.  
  2397. BattleManager.actionPerformAction = function() {
  2398.     this._logWindow.performAction(this._subject, this._action);
  2399.     if (this._subject.isActor() && this._subject.isSpriteVisible) {
  2400.       this._logWindow._waitCount += 20;
  2401.       return false;
  2402.     }
  2403.     return true;
  2404. };
  2405.  
  2406. BattleManager.actionPerformFinish = function() {
  2407.     this._logWindow.performActionEnd(this._subject);
  2408.     $gameParty.aliveMembers().forEach(function(member) {
  2409.       member.spriteReturnHome();
  2410.     });
  2411.     $gameTroop.aliveMembers().forEach(function(member) {
  2412.       member.spriteReturnHome();
  2413.     });
  2414.     return true;
  2415. };
  2416.  
  2417. BattleManager.actionPerformStart = function() {
  2418.     this._logWindow.performActionStart(this._subject, this._action);
  2419.     return true;
  2420. };
  2421.  
  2422. BattleManager.actionWait = function(frames) {
  2423.     this._logWindow._waitCount = parseInt(frames);
  2424.     return false;
  2425. };
  2426.  
  2427. BattleManager.actionWaitForAnimation = function() {
  2428.     this._logWindow.waitForAnimation();
  2429.     return false;
  2430. };
  2431.  
  2432. BattleManager.actionWaitForEffect = function() {
  2433.     this._logWindow.waitForEffect();
  2434.     return false;
  2435. };
  2436.  
  2437. BattleManager.actionWaitForMovement = function() {
  2438.     this._logWindow.waitForMovement();
  2439.     return false;
  2440. };
  2441.  
  2442. BattleManager.actionWaitForNewLine = function() {
  2443.     this._logWindow.waitForNewLine();
  2444.     return false;
  2445. };
  2446.  
  2447. BattleManager.actionWaitForPopups = function() {
  2448.     this._logWindow.waitForPopups();
  2449.     return false;
  2450. };
  2451.  
  2452. //=============================================================================
  2453. // Sprite_Battler
  2454. //=============================================================================
  2455.  
  2456. Yanfly.BEC.Sprite_Battler_initialize = Sprite_Battler.prototype.initialize;
  2457. Sprite_Battler.prototype.initialize = function(battler) {
  2458.     this.preSpriteInitialize(battler);
  2459.     Yanfly.BEC.Sprite_Battler_initialize.call(this, battler);
  2460. };
  2461.  
  2462. Sprite_Battler.prototype.preSpriteInitialize = function(battler) {
  2463. };
  2464.  
  2465. Yanfly.BEC.Sprite_Battler_update = Sprite_Battler.prototype.update;
  2466. Sprite_Battler.prototype.update = function() {
  2467.     Yanfly.BEC.Sprite_Battler_update.call(this);
  2468.     if (this._postSpriteInitialized) return;
  2469.     this.postSpriteInitialize();
  2470. };
  2471.  
  2472. Sprite_Battler.prototype.postSpriteInitialize = function() {
  2473.     this._postSpriteInitialized = true;
  2474. };
  2475.  
  2476. Yanfly.BEC.Sprite_Battler_initMembers = Sprite_Battler.prototype.initMembers;
  2477. Sprite_Battler.prototype.initMembers = function() {
  2478.     Yanfly.BEC.Sprite_Battler_initMembers.call(this);
  2479.     this.adjustAnchor();
  2480.     this.setZ();
  2481. };
  2482.  
  2483. Sprite_Battler.prototype.adjustAnchor = function() {
  2484.     this.anchor.x = 0.5;
  2485.     this.anchor.y = 1.0;
  2486. };
  2487.  
  2488. Sprite_Battler.prototype.setZ = function() {
  2489.     this.z = 1;
  2490. };
  2491.  
  2492. Sprite_Battler.prototype.setupDamagePopup = function() {
  2493.     if (this._battler.isDamagePopupRequested()) {
  2494.       if (this._battler.isSpriteVisible()) {
  2495.         var sprite = new Sprite_Damage();
  2496.         sprite.x = this.x + this.damageOffsetX();
  2497.         sprite.y = this.y + this.damageOffsetY();
  2498.         sprite.setup(this._battler);
  2499.         this.pushDamageSprite(sprite);
  2500.         BattleManager._spriteset.addChild(sprite);
  2501.         this._battler.clearResult();
  2502.       }
  2503.     } else {
  2504.       this._battler.clearDamagePopup();
  2505.     }
  2506. };
  2507.  
  2508. Sprite_Battler.prototype.pushDamageSprite = function(sprite) {
  2509.     var heightBuffer = eval(Yanfly.Param.BECPopupOverlap);
  2510.     if (eval(Yanfly.Param.BECNewPopBottom)) {
  2511.       this._damages.push(sprite);
  2512.       this._damages.forEach(function(spr) {
  2513.         for (var i = 0; i < spr.children.length; i++) {
  2514.           childSprite = spr.children[i];
  2515.           childSprite.anchor.y += heightBuffer;
  2516.         }
  2517.       }, this);
  2518.     } else {
  2519.       this._damages.push(sprite);
  2520.       heightBuffer *= this._damages.length
  2521.       for (var i = 0; i < sprite.children.length; i++) {
  2522.         childSprite = sprite.children[i];
  2523.         childSprite.anchor.y += heightBuffer;
  2524.       }
  2525.     }
  2526. };
  2527.  
  2528. Yanfly.BEC.Sprite_Battler_setBattler = Sprite_Battler.prototype.setBattler;
  2529. Sprite_Battler.prototype.setBattler = function(battler) {
  2530.     Yanfly.BEC.Sprite_Battler_setBattler.call(this, battler);
  2531.     if (battler) battler.setBattler(this);
  2532. };
  2533.  
  2534. Yanfly.BEC.Sprite_Battler_startMove = Sprite_Battler.prototype.startMove;
  2535. Sprite_Battler.prototype.startMove = function(x, y, duration) {
  2536.     if (this._battler && !this._battler.spriteCanMove()) return;
  2537.     Yanfly.BEC.Sprite_Battler_startMove.call(this, x, y, duration);
  2538. };
  2539.  
  2540. Sprite_Battler.prototype.stepForward = function() {
  2541.     this.startMove(Yanfly.Param.BECStepDist, 0, 12);
  2542. };
  2543.  
  2544. Sprite_Battler.prototype.stepBack = function() {
  2545.     this.startMove(0, 0, 12);
  2546. };
  2547.  
  2548. Sprite_Battler.prototype.stepFlinch = function() {
  2549.     var flinchX = this.x - this._homeX - Yanfly.Param.BECFlinchDist;
  2550.     var flinchY = this.y - this._homeY;
  2551.     this.startMove(flinchX, flinchY, 6);
  2552. };
  2553.  
  2554. Sprite_Battler.prototype.stepSubBack = function() {
  2555.     var backX = -1 * this.width / 2;
  2556.     this.startMove(backX, 0, 6);
  2557. };
  2558.  
  2559. Sprite_Battler.prototype.stepToSubstitute = function(focus) {
  2560.     var target = focus.battler();
  2561.     var targetX = (this.x - this._homeX) + (target._homeX - this._homeX);
  2562.     var targetY = (this.y - this._homeY) + (target._homeY - this._homeY);;
  2563.     if (focus.isActor()) targetX -= this._mainSprite.width / 2;
  2564.     if (focus.isEnemy()) targetX += this.width / 2;
  2565.     this.startMove(targetX, targetY, 1);
  2566. };
  2567.  
  2568. Sprite_Battler.prototype.startMotion = function(motionType) {
  2569. };
  2570.  
  2571. Sprite_Battler.prototype.forceMotion = function(motionType) {
  2572. };
  2573.  
  2574. Sprite_Battler.prototype.refreshMotion = function() {
  2575. };
  2576.  
  2577. Sprite_Battler.prototype.startActionMotion = function() {
  2578. };
  2579.  
  2580. Sprite_Battler.prototype.moveForward = function(distance, frames) {
  2581.     distance = parseInt(distance);
  2582.     frames = parseInt(frames);
  2583.     if (this._battler.isActor()) distance *= -1;
  2584.     var moveX = this.x - this._homeX + distance;
  2585.     var moveY = this.y - this._homeY;
  2586.     this.startMove(moveX, moveY, frames);
  2587. };
  2588.  
  2589. Sprite_Battler.prototype.moveToPoint = function(pointX, pointY, frames) {
  2590.     pointX = parseInt(pointX);
  2591.     pointY = parseInt(pointY);
  2592.     var targetX = pointX - this._homeX;
  2593.     var targetY = pointY - this._homeY;
  2594.     this.startMove(targetX, targetY, frames);
  2595. };
  2596.  
  2597. Sprite_Battler.prototype.setMirror = function(value) {
  2598.     if (this.scale.x > 0 && value) this.scale.x *= -1;
  2599.     if (this.scale.x < 0 && !value) this.scale.x *= -1;
  2600. };
  2601.  
  2602. Sprite_Battler.prototype.isPopupPlaying = function() {
  2603.     if (this._damages.length > 0) {
  2604.       for (var i = 0; i < this._damages.length; ++i) {
  2605.         return this._damages[i].isPlaying();
  2606.       }
  2607.     }
  2608.     return false;
  2609. };
  2610.  
  2611. //=============================================================================
  2612. // Sprite_Actor
  2613. //=============================================================================
  2614.  
  2615. Sprite_Actor.prototype.preSpriteInitialize = function(battler) {
  2616.     Sprite_Battler.prototype.preSpriteInitialize.call(this, battler);
  2617. };
  2618.  
  2619. Sprite_Actor.prototype.postSpriteInitialize = function() {
  2620.     Sprite_Battler.prototype.postSpriteInitialize.call(this);
  2621. };
  2622.  
  2623. Yanfly.BEC.Sprite_Actor_updateShadow = Sprite_Actor.prototype.updateShadow;
  2624. Sprite_Actor.prototype.updateShadow = function() {
  2625.     if (this._hideShadows === undefined) {
  2626.       this._hideShadows = eval(Yanfly.Param.BECShowShadows);
  2627.     }
  2628.     if (!this._hideShadows) return this._shadowSprite.visible = false;
  2629.     Yanfly.BEC.Sprite_Actor_updateShadow.call(this);
  2630. };
  2631.  
  2632. Sprite_Actor.prototype.setActorHome = function(index) {
  2633.     var screenWidth = Graphics.boxWidth;
  2634.     var screenHeight = Graphics.boxHeight;
  2635.     var maxSize = $gameParty.maxBattleMembers();
  2636.     var partySize = $gameParty.battleMembers().length;
  2637.     var statusHeight = eval(Yanfly.Param.BECCommandRows);
  2638.     statusHeight *= Window_Base.prototype.lineHeight.call(this);
  2639.     statusHeight += Window_Base.prototype.standardPadding.call(this) * 2;
  2640.     if ($gameSystem.isSideView()) {
  2641.       var homeX = eval(Yanfly.Param.BECHomePosX);
  2642.       var homeY = eval(Yanfly.Param.BECHomePosY);
  2643.     } else {
  2644.       var homeX = eval(Yanfly.Param.BECFrontPosX);
  2645.       var homeY = eval(Yanfly.Param.BECFrontPosY);
  2646.     }
  2647.     this._checkAliveStatus = false;
  2648.     if ($gameParty.battleMembers()[index]) {
  2649.       var actor = $gameParty.battleMembers()[index];
  2650.       if (actor.isAlive()) this._checkAliveStatus = true;
  2651.     }
  2652.     this.setHome(homeX, homeY);
  2653.     this.moveToStartPosition();
  2654. };
  2655.  
  2656. Sprite_Actor.prototype.moveToStartPosition = function() {
  2657.     if (BattleManager._bypassMoveToStartLocation) return;
  2658.     if ($gameSystem.isSideView() && this._checkAliveStatus) {
  2659.       this.startMove(300, 0, 0);
  2660.     }
  2661. };
  2662.  
  2663. Sprite_Actor.prototype.setupMotion = function() {
  2664. };
  2665.  
  2666. Sprite_Actor.prototype.forceMotion = function(motionType) {
  2667.     var newMotion = Sprite_Actor.MOTIONS[motionType];
  2668.     this._motion = newMotion;
  2669.     this._motionCount = 0;
  2670.     this._pattern = 0;
  2671. };
  2672.  
  2673. Sprite_Actor.prototype.updateTargetPosition = function() {
  2674. };
  2675.  
  2676. Sprite_Actor.prototype.updateMotion = function() {
  2677.     this.updateMotionCount();
  2678. };
  2679.  
  2680. Sprite_Actor.prototype.onMoveEnd = function() {
  2681.     Sprite_Battler.prototype.onMoveEnd.call(this);
  2682. };
  2683.  
  2684. Sprite_Actor.prototype.stepForward = function() {
  2685.     this.startMove(-Yanfly.Param.BECStepDist, 0, 12);
  2686. };
  2687.  
  2688. Sprite_Actor.prototype.stepFlinch = function() {
  2689.     var flinchX = this.x - this._homeX + Yanfly.Param.BECFlinchDist;
  2690.     var flinchY = this.y - this._homeY;
  2691.     this.startMove(flinchX, flinchY, 6);
  2692. };
  2693.  
  2694. Sprite_Actor.prototype.stepSubBack = function() {
  2695.     var backX = this._mainSprite.width / 2;
  2696.     this.startMove(backX, 0, 6);
  2697. };
  2698.  
  2699. Yanfly.BEC.Sprite_Actor_updateBitmap = Sprite_Actor.prototype.updateBitmap;
  2700. Sprite_Actor.prototype.updateBitmap = function() {
  2701.     var name = this._actor.battlerName();
  2702.     var needUpdate = false;
  2703.     if (this._battlerName !== name) needUpdate = true;
  2704.     Yanfly.BEC.Sprite_Actor_updateBitmap.call(this);
  2705.     if (needUpdate) this.adjustAnchor();
  2706. };
  2707.  
  2708. Sprite_Actor.prototype.adjustAnchor = function() {
  2709.     if (!this._mainSprite) return;
  2710.     this._mainSprite.anchor.x = this._actor.anchorX();
  2711.     this._mainSprite.anchor.y = this._actor.anchorY();
  2712. };
  2713.  
  2714. Yanfly.BEC.Sprite_Actor_updateFrame = Sprite_Actor.prototype.updateFrame;
  2715. Sprite_Actor.prototype.updateFrame = function() {
  2716.     Yanfly.BEC.Sprite_Actor_updateFrame.call(this);
  2717.     if (!this._mainSprite) return;
  2718.     if (!this._mainSprite.bitmap) return;
  2719.     if (this._mainSprite.bitmap.width > 0 && !this.bitmap) {
  2720.       var sw = this._mainSprite.bitmap.width / 9;
  2721.       var sh = this._mainSprite.bitmap.height / 6;
  2722.       this.bitmap = new Bitmap(sw, sh);
  2723.     }
  2724. };
  2725.  
  2726. Yanfly.BEC.Sprite_Actor_refreshMotion = Sprite_Actor.prototype.refreshMotion;
  2727. Sprite_Actor.prototype.refreshMotion = function() {
  2728.     var actor = this._actor;
  2729.     if (!actor) return;
  2730.     var motionGuard = Sprite_Actor.MOTIONS['guard'];
  2731.     if (this._motion === motionGuard && !BattleManager.isInputting()) return;
  2732.     var stateMotion = actor.stateMotionIndex();
  2733.     if (actor.isInputting() || actor.isActing()) {
  2734.       this.startMotion(actor.idleMotion());
  2735.     } else if (stateMotion === 3) {
  2736.       this.startMotion(actor.deadMotion());
  2737.     } else if (stateMotion === 2) {
  2738.       this.startMotion(actor.sleepMotion());
  2739.     } else if (actor.isChanting()) {
  2740.       this.startMotion(actor.chantMotion());
  2741.     } else if (actor.isGuard() || actor.isGuardWaiting()) {
  2742.       this.startMotion(actor.guardMotion());
  2743.     } else if (stateMotion === 1) {
  2744.       this.startMotion(actor.abnormalMotion());
  2745.     } else if (actor.isDying()) {
  2746.       this.startMotion(actor.dyingMotion());
  2747.     } else if (actor.isUndecided()) {
  2748.       this.startMotion(actor.idleMotion());
  2749.     } else {
  2750.       this.startMotion(actor.waitMotion());
  2751.     }
  2752. };
  2753.  
  2754. //=============================================================================
  2755. // Sprite_Enemy
  2756. //=============================================================================
  2757.  
  2758. Sprite_Enemy.prototype.preSpriteInitialize = function(battler) {
  2759.     Sprite_Battler.prototype.preSpriteInitialize.call(this, battler);
  2760.     this._visualSelect = eval(Yanfly.Param.BECEnemySelect);
  2761.     if (this._visualSelect) this.createVisualSelectWindow();
  2762. };
  2763.  
  2764. Yanfly.BEC.Sprite_Enemy_update = Sprite_Enemy.prototype.update;
  2765. Sprite_Enemy.prototype.update = function() {
  2766.     Yanfly.BEC.Sprite_Enemy_update.call(this);
  2767.     this.addVisualSelectWindow();
  2768. };
  2769.  
  2770. Sprite_Enemy.prototype.addVisualSelectWindow = function() {
  2771.     if (!this._visualSelect) return;
  2772.     if (this._addedVisualSelect) return;
  2773.     if (!SceneManager._scene) return;
  2774.     var scene = SceneManager._scene;
  2775.     if (!scene._windowLayer) return;
  2776.     this._addedVisualSelect = true;
  2777.     scene.addChild(this._visualSelectWindow);
  2778. };
  2779.  
  2780. Sprite_Enemy.prototype.createVisualSelectWindow = function() {
  2781.     this._visualSelectWindow = new Window_EnemyVisualSelect();
  2782. };
  2783.  
  2784. Yanfly.BEC.Sprite_Enemy_setBattler = Sprite_Enemy.prototype.setBattler;
  2785. Sprite_Enemy.prototype.setBattler = function(battler) {
  2786.     Yanfly.BEC.Sprite_Enemy_setBattler.call(this, battler);
  2787.     if (this._visualSelectWindow) this._visualSelectWindow.setBattler(battler);
  2788. };
  2789.  
  2790. //=============================================================================
  2791. // Sprite_Weapon
  2792. //=============================================================================
  2793.  
  2794. Yanfly.BEC.Sprite_Weapon_setup = Sprite_Weapon.prototype.setup;
  2795. Sprite_Weapon.prototype.setup = function(weaponImageId) {
  2796.     Yanfly.BEC.Sprite_Weapon_setup.call(this, weaponImageId);
  2797.     this._animationCount -= 1; // Synch with sprite
  2798. };
  2799.  
  2800. //=============================================================================
  2801. // Sprite_Damage
  2802. //=============================================================================
  2803.  
  2804. Yanfly.BEC.Sprite_Damage_initialize = Sprite_Damage.prototype.initialize;
  2805. Sprite_Damage.prototype.initialize = function() {
  2806.     Yanfly.BEC.Sprite_Damage_initialize.call(this);
  2807.     this._duration = eval(Yanfly.Param.BECPopupDur);
  2808. };
  2809.  
  2810. Sprite_Damage.prototype.setup = function(target) {
  2811.     var result = target.shiftDamagePopup();
  2812.     if (result.missed || result.evaded) {
  2813.       this.createMiss();
  2814.     } else if (result.hpAffected) {
  2815.       this.createDigits(0, result.hpDamage);
  2816.     } else if (target.isAlive() && result.mpDamage !== 0) {
  2817.       this.createDigits(2, result.mpDamage);
  2818.     }
  2819.     if (result.critical) {
  2820.       this.setupCriticalEffect();
  2821.     }
  2822. };
  2823.  
  2824. Sprite_Damage.prototype.setupCriticalEffect = function() {
  2825.     this._flashColor = eval('[' + Yanfly.Param.BECCritPopup + ']');
  2826.     this._flashDuration = eval(Yanfly.Param.BECCritDur);
  2827. };
  2828.  
  2829. //=============================================================================
  2830. // Sprite_StateIcon
  2831. //=============================================================================
  2832.  
  2833. Yanfly.BEC.Sprite_StateIcon_update = Sprite_StateIcon.prototype.update;
  2834. Sprite_StateIcon.prototype.update = function() {
  2835.     Yanfly.BEC.Sprite_StateIcon_update.call(this);
  2836.     this.updateMirror();
  2837. };
  2838.  
  2839. Sprite_StateIcon.prototype.updateMirror = function() {
  2840.     if (this.parent.scale.x < 0) this.scale.x = -1 * Math.abs(this.scale.x);
  2841.     if (this.parent.scale.x > 0) this.scale.x = Math.abs(this.scale.x);
  2842. };
  2843.  
  2844. //=============================================================================
  2845. // Sprite_StateOverlay
  2846. //=============================================================================
  2847.  
  2848. Yanfly.BEC.Sprite_StateOverlay_update = Sprite_StateOverlay.prototype.update;
  2849. Sprite_StateOverlay.prototype.update = function() {
  2850.     Yanfly.BEC.Sprite_StateOverlay_update.call(this);
  2851.     this.updateMirror();
  2852. };
  2853.  
  2854. Sprite_StateOverlay.prototype.updateMirror = function() {
  2855.     if (this.parent.scale.x < 0) this.scale.x = -1 * Math.abs(this.scale.x);
  2856.     if (this.parent.scale.x > 0) this.scale.x = Math.abs(this.scale.x);
  2857. };
  2858.  
  2859. //=============================================================================
  2860. // Spriteset_Battle
  2861. //=============================================================================
  2862.  
  2863. Spriteset_Battle.prototype.isBusy = function() {
  2864.     return false;
  2865. };
  2866.  
  2867. Yanfly.BEC.Spriteset_Battle_update = Spriteset_Battle.prototype.update;
  2868. Spriteset_Battle.prototype.update = function() {
  2869.     Yanfly.BEC.Spriteset_Battle_update.call(this);
  2870.     this.updateZCoordinates();
  2871. };
  2872.  
  2873. Spriteset_Battle.prototype.updateZCoordinates = function() {
  2874.     this._battleField.children.sort(this.battleFieldDepthCompare);
  2875. };
  2876.  
  2877. Spriteset_Battle.prototype.battleFieldDepthCompare = function(a, b) {
  2878.     if (a.tilePosition && !b.tilePosition) return -1;
  2879.     if (b.tilePosition && !a.tilePosition) return 1;
  2880.     var priority = BattleManager.getSpritePriority();
  2881.     if (a._battler && b._battler && priority !== 0) {
  2882.       if (priority === 1) {
  2883.         if (a._battler.isActor() && b._battler.isEnemy()) return 1;
  2884.         if (a._battler.isEnemy() && b._battler.isActor()) return -1;
  2885.       } else if (priority === 2) {
  2886.         if (a._battler.isActor() && b._battler.isEnemy()) return -1;
  2887.         if (a._battler.isEnemy() && b._battler.isActor()) return 1;
  2888.       }
  2889.     }
  2890.     if (a.z < b.z) return -1;
  2891.     if (a.z > b.z) return 1;
  2892.     if (a.y < b.y) return -1;
  2893.     if (a.y > b.y) return 1;
  2894.     return 0;
  2895. };
  2896.  
  2897. Spriteset_Battle.prototype.isPopupPlaying = function() {
  2898.     return this.battlerSprites().some(function(sprite) {
  2899.         return sprite.isPopupPlaying();
  2900.     });
  2901. };
  2902.  
  2903. //=============================================================================
  2904. // Game_Temp
  2905. //=============================================================================
  2906.  
  2907. Game_Temp.prototype.clearActionSequenceSettings = function() {
  2908. };
  2909.  
  2910. //=============================================================================
  2911. // Game_System
  2912. //=============================================================================
  2913.  
  2914. Yanfly.BEC.Game_System_initialize = Game_System.prototype.initialize;
  2915. Game_System.prototype.initialize = function() {
  2916.     Yanfly.BEC.Game_System_initialize.call(this);
  2917.     this.initBattleSystem();
  2918. };
  2919.  
  2920. Game_System.prototype.initBattleSystem = function() {
  2921.     this._battleSystem = Yanfly.Param.BECSystem.toLowerCase();
  2922. };
  2923.  
  2924. Game_System.prototype.getBattleSystem = function() {
  2925.     if (this._battleSystem === undefined) this.initBattleSystem();
  2926.     return this._battleSystem;
  2927. };
  2928.  
  2929. Game_System.prototype.setBattleSystem = function(type) {
  2930.     this._battleSystem = type.toLowerCase();
  2931. };
  2932.  
  2933. //=============================================================================
  2934. // Game_Interpreter
  2935. //=============================================================================
  2936.  
  2937. Yanfly.BEC.Game_Interpreter_pluginCommand =
  2938.     Game_Interpreter.prototype.pluginCommand;
  2939. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  2940.     Yanfly.BEC.Game_Interpreter_pluginCommand.call(this, command, args);
  2941.     if (command === 'setBattleSys' && !$gameParty.inBattle()) {
  2942.       this.setBattleSystem(args[0]);
  2943.     }
  2944. };
  2945.  
  2946. Game_Interpreter.prototype.setBattleSystem = function(value) {
  2947.     $gameSystem.setBattleSystem(value);
  2948. };
  2949.  
  2950. //=============================================================================
  2951. // Game_Action
  2952. //=============================================================================
  2953.  
  2954. Game_Action.prototype.speed = function() {
  2955.     var user = this.subject(); var a = user;
  2956.     var maxhp = user.mhp; var mhp = user.mhp; var hp = user.hp;
  2957.     var maxmp = user.mmp; var mmp = user.mmp; var mp = user.mp;
  2958.     var maxtp = user.maxTp(); var mtp = user.maxTp(); var tp = user.tp;
  2959.     var atk = user.atk; var def = user.def; var mat = user.mat;
  2960.     var int = user.mat; var mdf = user.mdf; var res = user.res;
  2961.     var agi = user.agi; var luk = user.luk;
  2962.     var speed = eval(Yanfly.Param.BECActionSpeed);
  2963.     if (this.item()) speed += this.item().speed;
  2964.     if (this.isAttack()) speed += this.subject().attackSpeed();
  2965.     return speed;
  2966. };
  2967.  
  2968. Yanfly.BEC.Game_Action_apply = Game_Action.prototype.apply;
  2969. Game_Action.prototype.apply = function(target) {
  2970.     target._result = null;
  2971.     target._result = new Game_ActionResult();
  2972.     this.subject()._result = null;
  2973.     this.subject()._result = new Game_ActionResult();
  2974.     Yanfly.BEC.Game_Action_apply.call(this, target);
  2975.     if ($gameParty.inBattle()) {
  2976.       target.startDamagePopup();
  2977.       target.performResultEffects();
  2978.       if (target !== this.subject()) this.subject().startDamagePopup();
  2979.     }
  2980. };
  2981.  
  2982. Game_Action.prototype.itemEffectAddAttackState = function(target, effect) {
  2983.     this.subject().attackStates().forEach(function(stateId) {
  2984.         var chance = effect.value1;
  2985.         chance *= target.stateRate(stateId);
  2986.         chance *= this.subject().attackStatesRate(stateId);
  2987.         chance *= this.lukEffectRate(target);
  2988.         if (Math.random() < chance) {
  2989.             if (stateId === target.deathStateId()) {
  2990.               if (target.isImmortal()) target.removeImmortal();
  2991.             }
  2992.             target.addState(stateId);
  2993.             this.makeSuccess(target);
  2994.         }
  2995.     }.bind(this), target);
  2996. };
  2997.  
  2998. Game_Action.prototype.itemEffectAddNormalState = function(target, effect) {
  2999.     var stateId = effect.dataId;
  3000.     var chance = effect.value1;
  3001.     if (!this.isCertainHit()) {
  3002.       chance *= target.stateRate(stateId);
  3003.       chance *= this.lukEffectRate(target);
  3004.     }
  3005.     if (Math.random() < chance) {
  3006.       if (stateId === target.deathStateId()) {
  3007.         if (target.isImmortal()) target.removeImmortal();
  3008.       }
  3009.       target.addState(stateId);
  3010.       this.makeSuccess(target);
  3011.     }
  3012. };
  3013.  
  3014. Yanfly.BEC.Game_Action_applyGlobal = Game_Action.prototype.applyGlobal;
  3015. Game_Action.prototype.applyGlobal = function() {
  3016.     if ($gameParty.inBattle()) return;
  3017.     Yanfly.BEC.Game_Action_applyGlobal.call(this);
  3018. };
  3019.  
  3020. Yanfly.BEC.Game_Action_needsSelection = Game_Action.prototype.needsSelection;
  3021. Game_Action.prototype.needsSelection = function() {
  3022.     if ($gameParty.inBattle() && this.item().scope === 0) return false;
  3023.     if ($gameParty.inBattle() && BattleManager.isForceSelection()) return true;
  3024.     return Yanfly.BEC.Game_Action_needsSelection.call(this);
  3025. };
  3026.  
  3027. //=============================================================================
  3028. // Game_BattlerBase
  3029. //=============================================================================
  3030.  
  3031. Yanfly.BEC.Game_BattlerBase_recoverAll = Game_BattlerBase.prototype.recoverAll;
  3032. Game_BattlerBase.prototype.recoverAll = function() {
  3033.     Yanfly.BEC.Game_BattlerBase_recoverAll.call(this);
  3034.     this.refresh();
  3035.     if ($gameParty.inBattle()) this.forceMotionRefresh();
  3036. };
  3037.  
  3038. Game_BattlerBase.prototype.requestStatusRefresh = function() {
  3039.     this._statusRefreshRequested = true;
  3040. };
  3041.  
  3042. Game_BattlerBase.prototype.isStatusRefreshRequested = function() {
  3043.     return this._statusRefreshRequested;
  3044. };
  3045.  
  3046. Game_BattlerBase.prototype.completetStatusRefreshRequest = function() {
  3047.     this._statusRefreshRequested = false;
  3048. };
  3049.  
  3050. Game_BattlerBase.prototype.updateStateTicks = function() {
  3051.     var needRefresh = false;
  3052.     for (var i = 0; i < this._states.length; ++i) {
  3053.       var stateId = this._states[i];
  3054.       var state = $dataStates[stateId];
  3055.       if (!state) continue;
  3056.       if (state.autoRemovalTiming !== 2) continue;
  3057.       if (!this._stateTurns[stateId]) continue;
  3058.       var value = BattleManager.tickRate() / Yanfly.Param.BECTurnTime;
  3059.       var shown1 = Math.ceil(this._stateTurns[stateId]);
  3060.       this._stateTurns[stateId] -= value;
  3061.       var shown2 = Math.ceil(this._stateTurns[stateId]);
  3062.       if (shown1 !== shown2) needRefresh = true;
  3063.       if (this._stateTurns[stateId] <= 0) this.removeState(stateId);
  3064.     }
  3065.     if (needRefresh) this.refresh();
  3066. };
  3067.  
  3068. Game_BattlerBase.prototype.isBypassUpdateTurns = function() {
  3069.     if ($gameTroop.isEventRunning()) return true;
  3070.     return false;
  3071. };
  3072.  
  3073. Game_BattlerBase.prototype.updateStateTurns = function() {
  3074.     this.updateStateTurnEnd();
  3075. };
  3076.  
  3077. Game_BattlerBase.prototype.updateStateTurnTiming = function(timing) {
  3078.     if (this.isBypassUpdateTurns()) return;
  3079.     var statesRemoved = [];
  3080.     this._freeStateTurn = this._freeStateTurn || [];
  3081.     for (var i = 0; i < this._states.length; ++i) {
  3082.       var stateId = this._states[i];
  3083.       var state = $dataStates[stateId];
  3084.       if (!state) continue;
  3085.       if (state.autoRemovalTiming !== timing) continue;
  3086.       if (!this._stateTurns[stateId]) continue;
  3087.       if (this._freeStateTurn.contains(stateId)) {
  3088.         var index = this._freeStateTurn.indexOf(stateId);
  3089.         this._freeStateTurn.splice(index, 1);
  3090.       } else {
  3091.         this._stateTurns[stateId] -= 1;
  3092.       }
  3093.       if (this._stateTurns[stateId] <= 0) statesRemoved.push(stateId);
  3094.     }
  3095.     for (var i = 0; i < statesRemoved.length; ++i) {
  3096.       var stateId = statesRemoved[i];
  3097.       this.removeState(stateId);
  3098.     }
  3099. };
  3100.  
  3101. Game_BattlerBase.prototype.updateStateActionStart = function() {
  3102.     this.updateStateTurnTiming(3);
  3103. };
  3104.  
  3105. Game_BattlerBase.prototype.updateStateActionEnd = function() {
  3106.     this.updateStateTurnTiming(1);
  3107. };
  3108.  
  3109. Game_BattlerBase.prototype.updateStateTurnStart = function() {
  3110.     this.updateStateTurnTiming(4);
  3111. };
  3112.  
  3113. Game_BattlerBase.prototype.updateStateTurnEnd = function() {
  3114.     this.updateStateTurnTiming(2);
  3115. };
  3116.  
  3117. Game_BattlerBase.prototype.updateBuffTicks = function() {
  3118.     var needRefresh = false;
  3119.     for (var i = 0; i < this._buffTurns.length; i++) {
  3120.       if (this._buffTurns[i] <= 0) continue;
  3121.       var value = BattleManager.tickRate() / Yanfly.Param.BECTurnTime;
  3122.       var shown1 = Math.ceil(this._buffTurns[i]);
  3123.       this._buffTurns[i] -= value;
  3124.       var shown2 = Math.ceil(this._buffTurns[i]);
  3125.       if (shown1 !== shown2) needRefresh = true;
  3126.       if (this._buffTurns[i] <= 0) this.removeBuff(i);
  3127.     }
  3128.     if (needRefresh) this.refresh();
  3129. };
  3130.  
  3131. Game_BattlerBase.prototype.timedTick = function() {
  3132.     return 1 * BattleManager.tickRate();
  3133. };
  3134.  
  3135. Yanfly.BEC.Game_BattlerBase_isStateResist =
  3136.     Game_BattlerBase.prototype.isStateResist;
  3137. Game_BattlerBase.prototype.isStateResist = function(stateId) {
  3138.     if (stateId === this.deathStateId() && this.isImmortal()) return true;
  3139.     return Yanfly.BEC.Game_BattlerBase_isStateResist.call(this, stateId);
  3140. };
  3141.  
  3142. Game_BattlerBase.prototype.isImmortal = function() {
  3143.     return this._immortalState;
  3144. };
  3145.  
  3146. Yanfly.BEC.Game_BattlerBase_paySkillCost =
  3147.     Game_BattlerBase.prototype.paySkillCost;
  3148. Game_BattlerBase.prototype.paySkillCost = function(skill) {
  3149.     this.requestStatusRefresh();
  3150.     Yanfly.BEC.Game_BattlerBase_paySkillCost.call(this, skill);
  3151. };
  3152.  
  3153. //=============================================================================
  3154. // Game_Battler
  3155. //=============================================================================
  3156.  
  3157. Yanfly.BEC.Game_Battler_useItem = Game_Battler.prototype.useItem;
  3158. Game_Battler.prototype.useItem = function(item) {
  3159.     Yanfly.BEC.Game_Battler_useItem.call(this, item);
  3160.     if (!$gameParty.inBattle()) return;
  3161.     this.increaseSelfTurnCount();
  3162.     this.updateStateActionStart();
  3163. };
  3164.  
  3165. Yanfly.BEC.Game_Battler_onBattleStart = Game_Battler.prototype.onBattleStart;
  3166. Game_Battler.prototype.onBattleStart = function() {
  3167.     Yanfly.BEC.Game_Battler_onBattleStart.call(this);
  3168.     this._freeStateTurn = [];
  3169.     this._immortalState = false;
  3170.     this._selfTurnCount = 0;
  3171. };
  3172.  
  3173. Yanfly.BEC.Game_Battler_onBattleEnd = Game_Battler.prototype.onBattleEnd;
  3174. Game_Battler.prototype.onBattleEnd = function() {
  3175.     Yanfly.BEC.Game_Battler_onBattleEnd.call(this);
  3176.     this._freeStateTurn = [];
  3177.     this._immortalState = false;
  3178. };
  3179.  
  3180. Yanfly.BEC.Game_Battler_isSelected = Game_Battler.prototype.isSelected;
  3181. Game_Battler.prototype.isSelected = function() {
  3182.     if ($gameParty.inBattle() && BattleManager.isAllSelection()) {
  3183.       if (!this.isAppeared()) return false;
  3184.       var action = BattleManager.inputtingAction();
  3185.       if (action && action.item()) {
  3186.         if (this.isDead() && this.isEnemy()) return false;
  3187.         if (this.isDead() && this.isActor()) return action.isForDeadFriend();
  3188.         if (action.isForFriend() && this.isActor()) return true;
  3189.         if (action.isForOpponent() && this.isEnemy()) return true;
  3190.       }
  3191.     }
  3192.     return Yanfly.BEC.Game_Battler_isSelected.call(this);
  3193. };
  3194.  
  3195. Yanfly.BEC.Game_Battler_regenerateAll = Game_Battler.prototype.regenerateAll;
  3196. Game_Battler.prototype.regenerateAll = function() {
  3197.     var lifeState = this.isAlive();
  3198.     Yanfly.BEC.Game_Battler_regenerateAll.call(this);
  3199.     if (!BattleManager.timeBasedStates()) this.updateStateTurns();
  3200.     if (!BattleManager.timeBasedBuffs()) {
  3201.       this.updateBuffTurns();
  3202.       this.removeBuffsAuto();
  3203.     }
  3204.     if (this.isDead() && lifeState === true) {
  3205.       this.performCollapse();
  3206.     }
  3207.     if ($gameParty.inBattle()) this.startDamagePopup();
  3208. };
  3209.  
  3210. Game_Battler.prototype.addImmortal = function() {
  3211.     this._immortalState = true;
  3212. };
  3213.  
  3214. Game_Battler.prototype.removeImmortal = function() {
  3215.     var alreadyDead = this.isDead();
  3216.     this._immortalState = false;
  3217.     this.refresh();
  3218.     if (this.isDead() && !alreadyDead) this.performCollapse();
  3219. };
  3220.  
  3221. Yanfly.BEC.Game_Battler_removeState = Game_Battler.prototype.removeState;
  3222. Game_Battler.prototype.removeState = function(stateId) {
  3223.     Yanfly.BEC.Game_Battler_removeState.call(this, stateId);
  3224. };
  3225.  
  3226. Game_Battler.prototype.clearDamagePopup = function() {
  3227.     this._damagePopup = [];
  3228. };
  3229.  
  3230. Game_Battler.prototype.isDamagePopupRequested = function() {
  3231.     if (!this._damagePopup) this.clearDamagePopup();
  3232.     return this._damagePopup.length > 0;
  3233. };
  3234.  
  3235. Game_Battler.prototype.startDamagePopup = function() {
  3236.     var result = this.result();
  3237.     if (result.missed || result.evaded) {
  3238.       var copyResult = JsonEx.makeDeepCopy(result);
  3239.       copyResult.hpAffected = false;
  3240.       copyResult.mpDamage = 0;
  3241.       this._damagePopup.push(copyResult);
  3242.     }
  3243.     if (result.hpAffected) {
  3244.       var copyResult = JsonEx.makeDeepCopy(result);
  3245.       copyResult.mpDamage = 0;
  3246.       this._damagePopup.push(copyResult);
  3247.     }
  3248.     if (result.mpDamage !== 0) {
  3249.       var copyResult = JsonEx.makeDeepCopy(result);
  3250.       copyResult.hpAffected = false;
  3251.       this._damagePopup.push(copyResult);
  3252.     }
  3253. };
  3254.  
  3255. Game_Battler.prototype.shiftDamagePopup = function() {
  3256.     if (!this._damagePopup) this.clearDamagePopup();
  3257.     return this._damagePopup.shift();
  3258. };
  3259.  
  3260. Yanfly.BEC.Game_Battler_performCollapse =
  3261.     Game_Battler.prototype.performCollapse;
  3262. Game_Battler.prototype.performCollapse = function() {
  3263.     Yanfly.BEC.Game_Battler_performCollapse.call(this);
  3264.     if ($gameParty.inBattle()) this.forceMotion(this.deadMotion());
  3265. };
  3266.  
  3267. Game_Battler.prototype.performResultEffects = function() {
  3268.     var result = this.result();
  3269.     if (result.missed && result.physical) this.performMiss();
  3270.     if (result.evaded) {
  3271.       if (result.physical) {
  3272.         this.performEvasion();
  3273.       } else {
  3274.         this.performMagicEvasion();
  3275.       }
  3276.     }
  3277.     if (result.hpAffected) {
  3278.       if (result.hpDamage > 0 && !result.drain) {
  3279.         this.performDamage();
  3280.       }
  3281.       if (result.hpDamage < 0) {
  3282.         this.performRecovery();
  3283.       }
  3284.     }
  3285.     if (this.isAlive() && result.mpDamage !== 0 && result.mpDamage < 0) {
  3286.       this.performRecovery();
  3287.     }
  3288.     if (this.isAlive() && result.tpDamage !== 0 && result.tpDamage < 0) {
  3289.       this.performRecovery();
  3290.     }
  3291. };
  3292.  
  3293. Yanfly.BEC.Game_Battler_performDamage =
  3294.   Game_Battler.prototype.performDamage;
  3295. Game_Battler.prototype.performDamage = function() {
  3296.     Yanfly.BEC.Game_Battler_performDamage.call(this);
  3297.     this.performFlinch();
  3298. };
  3299.  
  3300. Yanfly.BEC.Game_Battler_performMiss = Game_Battler.prototype.performMiss;
  3301. Game_Battler.prototype.performMiss = function() {
  3302.     Yanfly.BEC.Game_Battler_performMiss.call(this);
  3303.     this.performFlinch();
  3304. };
  3305.  
  3306. Yanfly.BEC.Game_Battler_performEvasion =
  3307.     Game_Battler.prototype.performEvasion;
  3308. Game_Battler.prototype.performEvasion = function() {
  3309.     Yanfly.BEC.Game_Battler_performEvasion.call(this);
  3310.     this.performFlinch();
  3311. };
  3312.  
  3313. Yanfly.BEC.Game_Battler_performMagicEvasion =
  3314.     Game_Battler.prototype.performMagicEvasion;
  3315. Game_Battler.prototype.performMagicEvasion = function() {
  3316.     Yanfly.BEC.Game_Battler_performMagicEvasion.call(this);
  3317.     this.performFlinch();
  3318. };
  3319.  
  3320. Game_Battler.prototype.performFlinch = function() {
  3321.     if (this._flinched || !$gameSystem.isSideView()) return;
  3322.     this._flinched = true;
  3323.     this.spriteStepFlinch();
  3324. };
  3325.  
  3326. Yanfly.BEC.Game_Battler_performReflection =
  3327.     Game_Battler.prototype.performReflection;
  3328. Game_Battler.prototype.performReflection = function() {
  3329.     Yanfly.BEC.Game_Battler_performReflection.call(this);
  3330.     if (!$gameSystem.isSideView() && this.isActor()) return;
  3331.     var animationId = this.reflectAnimationId();
  3332.     var mirror = this.isActor();
  3333.     this.startAnimation(animationId, mirror, 0);
  3334. };
  3335.  
  3336. Yanfly.BEC.Game_Battler_performSubstitute =
  3337.     Game_Battler.prototype.performSubstitute;
  3338. Game_Battler.prototype.performSubstitute = function(target) {
  3339.     Yanfly.BEC.Game_Battler_performSubstitute.call(this, target);
  3340.     if (!$gameSystem.isSideView()) return;
  3341.     this._flinched = true;
  3342.     if (BattleManager._action.isForAll()) {
  3343.       this.spriteStepForward();
  3344.       target.spriteStepSubBack();
  3345.     } else {
  3346.       this.spriteStepToSubstitute(target);
  3347.       target.spriteStepSubBack();
  3348.     }
  3349. };
  3350.  
  3351. Game_Battler.prototype.setBattler = function(sprite) {
  3352.     BattleManager.registerSprite(this, sprite);
  3353. };
  3354.  
  3355. Game_Battler.prototype.battler = function() {
  3356.     return BattleManager.getSprite(this);
  3357. };
  3358.  
  3359. Game_Battler.prototype.requestMotion = function(motionType) {
  3360.     this._motionType = motionType;
  3361.     if (this.battler()) {
  3362.       this.battler().startMotion(motionType);
  3363.     }
  3364. };
  3365.  
  3366. Game_Battler.prototype.forceMotion = function(motionType) {
  3367.     this._motionType = motionType;
  3368.     if (this.battler()) {
  3369.       this.battler().forceMotion(motionType);
  3370.     }
  3371. };
  3372.  
  3373. Game_Battler.prototype.startWeaponAnimation = function(weaponImageId) {
  3374.     this._weaponImageId = weaponImageId;
  3375.     if (this.battler()) {
  3376.       this.battler().setupWeaponAnimation();
  3377.     }
  3378. };
  3379.  
  3380. Game_Battler.prototype.performActionStart = function(action) {
  3381.     if (!action.isGuard()) {
  3382.         this.setActionState('acting');
  3383.         this.spriteStepForward();
  3384.     }
  3385. };
  3386.  
  3387. Yanfly.BEC.Game_Battler_performActionEnd =
  3388.     Game_Battler.prototype.performActionEnd;
  3389. Game_Battler.prototype.performActionEnd = function() {
  3390.     Yanfly.BEC.Game_Battler_performActionEnd.call(this);
  3391.     this.spriteReturnHome();
  3392. };
  3393.  
  3394. Game_Battler.prototype.spriteStepForward = function() {
  3395.     if ($gameSystem.isSideView() && this.battler()) {
  3396.       this.battler().stepForward();
  3397.     }
  3398. };
  3399.  
  3400. Game_Battler.prototype.spriteStepBack = function() {
  3401.     if ($gameSystem.isSideView() && this.battler()) {
  3402.       this.battler().stepBack();
  3403.     }
  3404. };
  3405.  
  3406. Game_Battler.prototype.spriteStepSubBack = function() {
  3407.     if ($gameSystem.isSideView() && this.battler()) {
  3408.       this.battler().stepSubBack();
  3409.     }
  3410. };
  3411.  
  3412. Game_Battler.prototype.spriteStepToSubstitute = function(target) {
  3413.     if ($gameSystem.isSideView() && this.battler()) {
  3414.       this.battler().stepToSubstitute(target);
  3415.     }
  3416. };
  3417.  
  3418. Game_Battler.prototype.spriteStepFlinch = function() {
  3419.     if ($gameSystem.isSideView() && this.battler()) {
  3420.       this.battler().stepFlinch();
  3421.     }
  3422. };
  3423.  
  3424. Game_Battler.prototype.spriteReturnHome = function() {
  3425.     if ($gameSystem.isSideView() && this.battler()) {
  3426.       this._flinched = false;
  3427.       this.spriteFaceForward();
  3428.       this.battler().stepBack();
  3429.       if (this.numActions() <= 0) {
  3430.         this.setActionState('undecided');
  3431.       }
  3432.       this.battler().refreshMotion();
  3433.     }
  3434. };
  3435.  
  3436. Game_Battler.prototype.reflectAnimationId = function() {
  3437.     for (var i = 0; i < this.states().length; ++i) {
  3438.       var state = this.states()[i];
  3439.       if (state.reflectAnimationId > 0) return state.reflectAnimationId;
  3440.     }
  3441.     return Yanfly.Param.BECReflectAni;
  3442. };
  3443.  
  3444. Game_Battler.prototype.spriteCanMove = function() {
  3445.     if (!$gameSystem.isSideView()) return false;
  3446.     for (var i = 0; i < this.states().length; ++i) {
  3447.       var state = this.states()[i];
  3448.       if (state.spriteCannotMove) return false;
  3449.     }
  3450.     return this.canMove();
  3451. };
  3452.  
  3453. Game_Battler.prototype.spritePosX = function() {
  3454.     if ($gameSystem.isSideView() && this.battler()) {
  3455.       return this.battler().x;
  3456.     } else if (this.battler()) {
  3457.       return this.battler().x;
  3458.     } else {
  3459.       return 0;
  3460.     }
  3461. };
  3462.  
  3463. Game_Battler.prototype.spritePosY = function() {
  3464.     if ($gameSystem.isSideView() && this.battler()) {
  3465.       return this.battler().y;
  3466.     } else if (this.battler()) {
  3467.       return this.battler().y;
  3468.     } else {
  3469.       return 0;
  3470.     }
  3471. };
  3472.  
  3473. Game_Battler.prototype.spriteWidth = function() {
  3474.     if ($gameSystem.isSideView() && this.battler() && this.battler().bitmap) {
  3475.       return this.battler().bitmap.width;
  3476.     } else if (this.battler()) {
  3477.       return this.battler().bitmap.width;
  3478.     } else {
  3479.       return 1;
  3480.     }
  3481. };
  3482.  
  3483. Game_Battler.prototype.spriteHeight = function() {
  3484.     if ($gameSystem.isSideView() && this.battler() && this.battler().bitmap) {
  3485.       return this.battler().bitmap.height;
  3486.     } else if (this.battler()) {
  3487.       return this.battler().bitmap.height;
  3488.     } else {
  3489.       return 1;
  3490.     }
  3491. };
  3492.  
  3493. Game_Battler.prototype.anchorX = function() {
  3494.     return Yanfly.Param.BECAnchorX;
  3495. };
  3496.  
  3497. Game_Battler.prototype.anchorY = function() {
  3498.     return Yanfly.Param.BECAnchorY;
  3499. };
  3500.  
  3501. Game_Battler.prototype.spriteHomeX = function() {
  3502.     if ($gameSystem.isSideView() && this.battler()) {
  3503.       return this.battler()._homeX;
  3504.     } else {
  3505.       return 0;
  3506.     }
  3507. };
  3508.  
  3509. Game_Battler.prototype.spriteHomeY = function() {
  3510.     if ($gameSystem.isSideView() && this.battler()) {
  3511.       return this.battler()._homeY;
  3512.     } else {
  3513.       return 0;
  3514.     }
  3515. };
  3516.  
  3517. Game_Battler.prototype.setMirror = function(value) {
  3518.     if ($gameSystem.isSideView() && this.battler() && this.spriteCanMove()) {
  3519.       this.battler().setMirror(value);
  3520.     }
  3521. };
  3522.  
  3523. Game_Battler.prototype.spriteFaceForward = function() {
  3524.     this.setMirror(false);
  3525. };
  3526.  
  3527. Game_Battler.prototype.spriteFaceBackward = function() {
  3528.     this.setMirror(true);
  3529. };
  3530.  
  3531. Game_Battler.prototype.spriteFacePoint = function(pointX, pointY) {
  3532.     if (this.spritePosX() > pointX) {
  3533.       this.spriteFaceBackward();
  3534.     } else {
  3535.       this.spriteFaceForward();
  3536.     }
  3537. };
  3538.  
  3539. Game_Battler.prototype.spriteFaceAwayPoint = function(pointX, pointY) {
  3540.     if (this.spritePosX() > pointX) {
  3541.       this.spriteFaceForward();
  3542.     } else {
  3543.       this.spriteFaceBackward();
  3544.     }
  3545. };
  3546.  
  3547. Game_Battler.prototype.spriteFaceTarget = function(target) {
  3548.     if (!target) return;
  3549.     var pointX = target.spritePosX();
  3550.     var pointY = target.spritePosY();
  3551.     this.spriteFacePoint(pointX, pointY);
  3552. };
  3553.  
  3554. Game_Battler.prototype.spriteFaceAwayTarget = function(target) {
  3555.     if (!target) return;
  3556.     var pointX = target.spritePosX();
  3557.     var pointY = target.spritePosY();
  3558.     this.spriteFaceAwayPoint(pointX, pointY);
  3559. };
  3560.  
  3561. Game_Battler.prototype.spriteFaceHome = function() {
  3562.     var pointX = this.spriteHomeX();
  3563.     var pointY = this.spriteHomeY();
  3564.     this.spriteFacePoint(pointX, pointY);
  3565. };
  3566.  
  3567. Game_Battler.prototype.spriteFaceAwayHome = function() {
  3568.     var pointX = target.spriteHomeX();
  3569.     var pointY = target.spriteHomeY();
  3570.     this.spriteFaceAwayPoint(pointX, pointY);
  3571. };
  3572.  
  3573. Game_Battler.prototype.attackMotion = function() {
  3574.     return 'thrust';
  3575. };
  3576.  
  3577. Game_Battler.prototype.performAttack = function() {
  3578. };
  3579.  
  3580. Game_Battler.prototype.forceMotionRefresh = function() {
  3581.     if (!$gameParty.inBattle()) return;
  3582.     if (this.battler()) this.battler().refreshMotion();
  3583. };
  3584.  
  3585. Game_Battler.prototype.requestMotionRefresh = function() {
  3586.     var deadMotion = this.deadMotion();
  3587.     if (this.isDead() && this._motionType !== deadMotion) {
  3588.       this.requestMotion(deadMotion);
  3589.     }
  3590.     if (this.isDead() && this._motionType === deadMotion) return;
  3591.     if (this._motionType === 'victory') return;
  3592.     if (this._motionType === 'escape' && !BattleManager.isInputting()) return;
  3593.     if (this._motionType === 'guard' && !BattleManager.isInputting()) return;
  3594.     this.clearMotion();
  3595.     if (this.battler() && BattleManager.isInputting()) {
  3596.       this.battler().refreshMotion();
  3597.     }
  3598. };
  3599.  
  3600. Game_Battler.prototype.onTurnStart = function() {
  3601.     this.updateStateTurnStart();
  3602. };
  3603.  
  3604. Game_Battler.prototype.onTurnEnd = function() {
  3605.     this.clearResult();
  3606.     if (BattleManager.isTurnBased()) {
  3607.       this.regenerateAll();
  3608.     } else if (BattleManager.isTickBased() && !BattleManager.isTurnEnd()) {
  3609.       this.regenerateAll();
  3610.     }
  3611.     this.removeStatesAuto(2);
  3612. };
  3613.  
  3614. Yanfly.BEC.Game_Battler_onAllActionsEnd =
  3615.     Game_Battler.prototype.onAllActionsEnd;
  3616. Game_Battler.prototype.onAllActionsEnd = function() {
  3617.     Yanfly.BEC.Game_Battler_onAllActionsEnd.call(this);
  3618.     if (!BattleManager._processTurn) this.updateStateActionEnd();
  3619. };
  3620.  
  3621. Game_Battler.prototype.updateTick = function() {
  3622.     if (BattleManager.timeBasedStates()) this.updateStateTicks();
  3623.     if (BattleManager.timeBasedBuffs()) this.updateBuffTicks();
  3624. };
  3625.  
  3626. Game_Battler.prototype.increaseSelfTurnCount = function() {
  3627.     if (this._selfTurnCount === undefined) this._selfTurnCount = 0;
  3628.     this._selfTurnCount += 1;
  3629. };
  3630.  
  3631. Game_Battler.prototype.turnCount = function() {
  3632.     if (BattleManager.isTurnBased()) return $gameTroop.turnCount();
  3633.     if (BattleManager.isTickBased() && Yanfly.Param.BECAISelfTurn) {
  3634.       return this._selfTurnCount;
  3635.     }
  3636.     return $gameTroop.turnCount();
  3637. };
  3638.  
  3639. Game_Battler.prototype.createActions = function() {
  3640.     if (this.currentAction()) return;
  3641.     this.makeActions();
  3642. };
  3643.  
  3644. Yanfly.BEC.Game_Battler_addState = Game_Battler.prototype.addState;
  3645. Game_Battler.prototype.addState = function(stateId) {
  3646.     Yanfly.BEC.Game_Battler_addState.call(this, stateId);
  3647.     if (this.canAddStateFreeTurn(stateId)) this.setStateFreeTurn(stateId);
  3648. };
  3649.  
  3650. Game_Battler.prototype.canAddStateFreeTurn = function(stateId) {
  3651.     if (!$gameParty.inBattle()) return false;
  3652.     if (!this.isStateAffected(stateId)) return false;
  3653.     if (BattleManager._subject !== this) return false;
  3654.     if ($dataStates[stateId].autoRemovalTiming !== 1) return false;
  3655.     return true;
  3656. };
  3657.  
  3658. Game_Battler.prototype.setStateFreeTurn = function(stateId) {
  3659.     this._freeStateTurn = this._freeStateTurn || [];
  3660.     this._freeStateTurn.push(stateId);
  3661. };
  3662.  
  3663. Game_Battler.prototype.idleMotion = function() {
  3664.     return 'walk';
  3665. };
  3666.  
  3667. Game_Battler.prototype.deadMotion = function() {
  3668.     return 'dead';
  3669. };
  3670.  
  3671. Game_Battler.prototype.sleepMotion = function() {
  3672.     return 'sleep';
  3673. };
  3674.  
  3675. Game_Battler.prototype.chantMotion = function() {
  3676.     return 'chant';
  3677. };
  3678.  
  3679. Game_Battler.prototype.guardMotion = function() {
  3680.     return 'guard';
  3681. };
  3682.  
  3683. Game_Battler.prototype.abnormalMotion = function() {
  3684.     return 'abnormal';
  3685. };
  3686.  
  3687. Game_Battler.prototype.dyingMotion = function() {
  3688.     return 'dying';
  3689. };
  3690.  
  3691. Game_Battler.prototype.waitMotion = function() {
  3692.     return 'wait';
  3693. };
  3694.  
  3695. //=============================================================================
  3696. // Game_Actor
  3697. //=============================================================================
  3698.  
  3699. Yanfly.BEC.Game_Actor_refresh = Game_Actor.prototype.refresh;
  3700. Game_Actor.prototype.refresh = function() {
  3701.     this._anchorX = undefined;
  3702.     this._anchorY = undefined;
  3703.     Yanfly.BEC.Game_Actor_refresh.call(this);
  3704.     if ($gameParty.inBattle()) this.requestStatusRefresh();
  3705. };
  3706.  
  3707. Game_Actor.prototype.isSpriteVisible = function() {
  3708.     if ($gameSystem.isSideView()) return true;
  3709.     return eval(Yanfly.Param.BECFrontSprite);
  3710. };
  3711.  
  3712. Game_Actor.prototype.reflectAnimationId = function() {
  3713.     if (this.actor().reflectAnimationId > 0) {
  3714.       return this.actor().reflectAnimationId;
  3715.     }
  3716.     if (this.currentClass().reflectAnimationId > 0) {
  3717.       return this.currentClass().reflectAnimationId;
  3718.     }
  3719.     for (var i = 0; i < this.equips().length; ++i) {
  3720.       var equip = this.equips()[i];
  3721.       if (equip && equip.reflectAnimationId > 0) {
  3722.         return equip.reflectAnimationId;
  3723.       }
  3724.     }
  3725.     return Game_Battler.prototype.reflectAnimationId.call(this);
  3726. };
  3727.  
  3728. Game_Actor.prototype.spriteCanMove = function() {
  3729.     if (this.actor().spriteCannotMove) return false;
  3730.     if (this.currentClass().spriteCannotMove) return false;
  3731.     for (var i = 0; i < this.equips().length; ++i) {
  3732.       var equip = this.equips()[i];
  3733.       if (equip && equip.spriteCannotMove) return false;
  3734.     }
  3735.     return Game_Battler.prototype.spriteCanMove.call(this);
  3736. };
  3737.  
  3738. Game_Actor.prototype.spriteWidth = function() {
  3739.     if ($gameSystem.isSideView() && this.battler()) {
  3740.       return this.battler()._mainSprite.width;
  3741.     } else {
  3742.       return 1;
  3743.     }
  3744. };
  3745.  
  3746. Game_Actor.prototype.spriteHeight = function() {
  3747.     if ($gameSystem.isSideView() && this.battler()) {
  3748.       return this.battler()._mainSprite.height;
  3749.     } else {
  3750.       return 1;
  3751.     }
  3752. };
  3753.  
  3754. Game_Actor.prototype.anchorX = function() {
  3755.     if (this._anchorX !== undefined) return this._anchorX;
  3756.     var length = this.states().length;
  3757.     for (var i = 0; i < length; ++i) {
  3758.       var obj = this.states()[i];
  3759.       if (obj && obj.anchorX !== undefined) {
  3760.         this._anchorX = obj.anchorX;
  3761.         return this._anchorX;
  3762.       }
  3763.     }
  3764.     length = this.equips().length;
  3765.     for (var i = 0; i < length; ++i) {
  3766.       var obj = this.equips()[i];
  3767.       if (obj && obj.anchorX !== undefined) {
  3768.         this._anchorX = obj.anchorX;
  3769.         return this._anchorX;
  3770.       }
  3771.     }
  3772.     if (this.currentClass().anchorX !== undefined) {
  3773.       this._anchorX = this.currentClass().anchorX;
  3774.       return this._anchorX;
  3775.     }
  3776.     this._anchorX = this.actor().anchorX;
  3777.     return this._anchorX;
  3778. };
  3779.  
  3780. Game_Actor.prototype.anchorY = function() {
  3781.     if (this._anchorY !== undefined) return this._anchorY;
  3782.     var length = this.states().length;
  3783.     for (var i = 0; i < length; ++i) {
  3784.       var obj = this.states()[i];
  3785.       if (obj && obj.anchorY !== undefined) {
  3786.         this._anchorY = obj.anchorY;
  3787.         return this._anchorY;
  3788.       }
  3789.     }
  3790.     length = this.equips().length;
  3791.     for (var i = 0; i < length; ++i) {
  3792.       var obj = this.equips()[i];
  3793.       if (obj && obj.anchorY !== undefined) {
  3794.         this._anchorY = obj.anchorY;
  3795.         return this._anchorY;
  3796.       }
  3797.     }
  3798.     if (this.currentClass().anchorY !== undefined) {
  3799.       this._anchorY = this.currentClass().anchorY;
  3800.       return this._anchorY;
  3801.     }
  3802.     this._anchorY = this.actor().anchorY;
  3803.     return this._anchorY;
  3804. };
  3805.  
  3806. Game_Actor.prototype.spriteFacePoint = function(pointX, pointY) {
  3807.     if (this.spritePosX() > pointX) {
  3808.       this.spriteFaceForward();
  3809.     } else {
  3810.       this.spriteFaceBackward();
  3811.     }
  3812. };
  3813.  
  3814. Game_Actor.prototype.spriteFaceAwayPoint = function(pointX, pointY) {
  3815.     if (this.spritePosX() > pointX) {
  3816.       this.spriteFaceBackward();
  3817.     } else {
  3818.       this.spriteFaceForward();
  3819.     }
  3820. };
  3821.  
  3822. Game_Actor.prototype.performAttack = function() {
  3823.     var weapons = this.weapons();
  3824.     var wtypeId = weapons[0] ? weapons[0].wtypeId : 0;
  3825.     var attackMotion = $dataSystem.attackMotions[wtypeId];
  3826.     if (attackMotion) {
  3827.       if (attackMotion.type === 0) {
  3828.         this.forceMotion('thrust');
  3829.       } else if (attackMotion.type === 1) {
  3830.         this.forceMotion('swing');
  3831.       } else if (attackMotion.type === 2) {
  3832.         this.forceMotion('missile');
  3833.       }
  3834.       this.startWeaponAnimation(attackMotion.weaponImageId);
  3835.     }
  3836. };
  3837.  
  3838. Game_Actor.prototype.attackMotion = function() {
  3839.     var weapons = this.weapons();
  3840.     var wtypeId = weapons[0] ? weapons[0].wtypeId : 0;
  3841.     var attackMotion = $dataSystem.attackMotions[wtypeId];
  3842.     if (attackMotion) {
  3843.       if (attackMotion.type === 0) {
  3844.         return 'thrust';
  3845.       } else if (attackMotion.type === 1) {
  3846.         return 'swing';
  3847.       } else if (attackMotion.type === 2) {
  3848.         return 'missile';
  3849.       }
  3850.     };
  3851.     return 'thrust';
  3852. };
  3853.  
  3854. Game_Actor.prototype.performEscapeSuccess = function() {
  3855.     if (this.battler()) {
  3856.       this.performEscape();
  3857.       this.battler().startMove(300, 0, 60);
  3858.     }
  3859. };
  3860.  
  3861. //=============================================================================
  3862. // Game_Enemy
  3863. //=============================================================================
  3864.  
  3865. Game_Enemy.prototype.performActionStart = function(action) {
  3866.     Game_Battler.prototype.performActionStart.call(this, action);
  3867.     if (!$gameSystem.isSideView() || !this.spriteCanMove()) {
  3868.       this.requestEffect('whiten');
  3869.     }
  3870. };
  3871.  
  3872. Yanfly.BEC.Game_Enemy_performDamage = Game_Enemy.prototype.performDamage;
  3873. Game_Enemy.prototype.performDamage = function() {
  3874.     if ($gameSystem.isSideView()) {
  3875.       Game_Battler.prototype.performDamage.call(this);
  3876.       SoundManager.playEnemyDamage();
  3877.     } else {
  3878.       Yanfly.BEC.Game_Enemy_performDamage.call(this);
  3879.     }
  3880. };
  3881.  
  3882. Game_Enemy.prototype.attackAnimationId = function() {
  3883.     return this.enemy().attackAnimationId;
  3884. };
  3885.  
  3886. Game_Enemy.prototype.reflectAnimationId = function() {
  3887.     if (this.enemy().reflectAnimationId > 0) {
  3888.       return this.enemy().reflectAnimationId;
  3889.     }
  3890.     return Game_Battler.prototype.reflectAnimationId.call(this);
  3891. };
  3892.  
  3893. Game_Enemy.prototype.spriteCanMove = function() {
  3894.     if (this.enemy().spriteCannotMove) return false;
  3895.     return Game_Battler.prototype.spriteCanMove.call(this);
  3896. };
  3897.  
  3898. Game_Enemy.prototype.meetsTurnCondition = function(param1, param2) {
  3899.     var n = this.turnCount();
  3900.     if (param2 === 0) {
  3901.         return n === param1;
  3902.     } else {
  3903.         return n > 0 && n >= param1 && n % param2 === param1 % param2;
  3904.     }
  3905. };
  3906.  
  3907. //=============================================================================
  3908. // Game_Unit
  3909. //=============================================================================
  3910.  
  3911. Game_Unit.prototype.createActions = function() {
  3912.     var max = this.members().length;
  3913.     for (var i = 0; i < max; ++i) {
  3914.       var member = this.members()[i];
  3915.       if (member) member.createActions();
  3916.     }
  3917. };
  3918.  
  3919. Game_Unit.prototype.requestMotionRefresh = function() {
  3920.     var max = this.members().length;
  3921.     for (var i = 0; i < max; ++i) {
  3922.       var member = this.members()[i];
  3923.       if (member) member.requestMotionRefresh();
  3924.     }
  3925. };
  3926.  
  3927. Game_Unit.prototype.onTurnStart = function() {
  3928.     var max = this.members().length;
  3929.     for (var i = 0; i < max; ++i) {
  3930.       var member = this.members()[i];
  3931.       if (member) member.onTurnStart();
  3932.     }
  3933. };
  3934.  
  3935. Game_Unit.prototype.updateTick = function() {
  3936.     var max = this.members().length;
  3937.     for (var i = 0; i < max; ++i) {
  3938.       var member = this.members()[i];
  3939.       if (member) member.updateTick();
  3940.     }
  3941. };
  3942.  
  3943. //=============================================================================
  3944. // Game_Party
  3945. //=============================================================================
  3946.  
  3947. Game_Party.prototype.performEscapeSuccess = function() {
  3948.     for (var i = 0; i < this.members().length; ++i) {
  3949.       var member = this.members()[i];
  3950.       if (member) member.performEscapeSuccess();
  3951.     }
  3952. };
  3953.  
  3954. //=============================================================================
  3955. // Scene_Battle
  3956. //=============================================================================
  3957.  
  3958. Yanfly.BEC.Scene_Battle_update = Scene_Battle.prototype.update;
  3959. Scene_Battle.prototype.update = function() {
  3960.     Yanfly.BEC.Scene_Battle_update.call(this);
  3961.     this.updateStatusWindowRequests();
  3962. };
  3963.  
  3964. Scene_Battle.prototype.updateStatusWindowRequests = function() {
  3965.     if (!this._statusWindow) return;
  3966.     if (this._statusWindow.isClosed()) return;
  3967.     this._statusWindow.updateStatusRequests();
  3968. };
  3969.  
  3970. Yanfly.BEC.Scene_Battle_createSkillWindow =
  3971.     Scene_Battle.prototype.createSkillWindow;
  3972. Scene_Battle.prototype.createSkillWindow = function() {
  3973.     Yanfly.BEC.Scene_Battle_createSkillWindow.call(this);
  3974.     if (eval(Yanfly.Param.BECLowerWindows)) {
  3975.       this.adjustLowerWindow(this._skillWindow);
  3976.     }
  3977. };
  3978.  
  3979. Yanfly.BEC.Scene_Battle_createItemWindow =
  3980.     Scene_Battle.prototype.createItemWindow;
  3981. Scene_Battle.prototype.createItemWindow = function() {
  3982.     Yanfly.BEC.Scene_Battle_createItemWindow.call(this);
  3983.     if (eval(Yanfly.Param.BECLowerWindows)) {
  3984.       this.adjustLowerWindow(this._itemWindow);
  3985.     }
  3986. };
  3987.  
  3988. Yanfly.BEC.Scene_Battle_createActorWindow =
  3989.     Scene_Battle.prototype.createActorWindow;
  3990. Scene_Battle.prototype.createActorWindow = function() {
  3991.     Yanfly.BEC.Scene_Battle_createActorWindow.call(this);
  3992.     this._actorWindow.x = Graphics.boxWidth - this._actorWindow.width;
  3993.     if (eval(Yanfly.Param.BECSelectHelp)) {
  3994.       this._actorWindow.setHelpWindow(this._helpWindow);
  3995.     }
  3996. };
  3997.  
  3998. Yanfly.BEC.Scene_Battle_createEnemyWindow =
  3999.     Scene_Battle.prototype.createEnemyWindow;
  4000. Scene_Battle.prototype.createEnemyWindow = function() {
  4001.     Yanfly.BEC.Scene_Battle_createEnemyWindow.call(this);
  4002.     if (eval(Yanfly.Param.BECSelectHelp)) {
  4003.       this._enemyWindow.setHelpWindow(this._helpWindow);
  4004.     }
  4005. };
  4006.  
  4007. Scene_Battle.prototype.adjustLowerWindow = function(win) {
  4008.     win.height = win.fittingHeight(eval(Yanfly.Param.BECWindowRows));
  4009.     win.y = Graphics.boxHeight - win.height;
  4010. };
  4011.  
  4012. Yanfly.BEC.Scene_Battle_startPartyCommandSelection =
  4013.     Scene_Battle.prototype.startPartyCommandSelection;
  4014. Scene_Battle.prototype.startPartyCommandSelection = function() {
  4015.     if (this.isStartActorCommand()) {
  4016.       this.selectNextCommand();
  4017.     } else {
  4018.       Yanfly.BEC.Scene_Battle_startPartyCommandSelection.call(this);
  4019.     }
  4020. };
  4021.  
  4022. Scene_Battle.prototype.isStartActorCommand = function() {
  4023.     if (this._isStartActorCommand === undefined) {
  4024.       this._isStartActorCommand = eval(Yanfly.Param.BECStartActCmd)
  4025.     }
  4026.     return this._isStartActorCommand;
  4027. };
  4028.  
  4029. Yanfly.BEC.Scene_Battle_selectPreviousCommand =
  4030.     Scene_Battle.prototype.selectPreviousCommand;
  4031. Scene_Battle.prototype.selectPreviousCommand = function() {
  4032.     if (this.isStartActorCommand()) {
  4033.       BattleManager.selectPreviousCommand();
  4034.       if (BattleManager.isInputting() && BattleManager.actor()) {
  4035.         this.startActorCommandSelection();
  4036.       } else {
  4037.         Yanfly.BEC.Scene_Battle_startPartyCommandSelection.call(this);
  4038.       }
  4039.     } else {
  4040.       Yanfly.BEC.Scene_Battle_selectPreviousCommand.call(this);
  4041.     }
  4042. };
  4043.  
  4044. Yanfly.BEC.Scene_Battle_selectNextCommand =
  4045.     Scene_Battle.prototype.selectNextCommand;
  4046. Scene_Battle.prototype.selectNextCommand = function() {
  4047.     Yanfly.BEC.Scene_Battle_selectNextCommand.call(this);
  4048.     this._helpWindow.clear();
  4049.     BattleManager.stopAllSelection();
  4050. };
  4051.  
  4052. Yanfly.BEC.Scene_Battle_commandSkill = Scene_Battle.prototype.commandSkill;
  4053. Scene_Battle.prototype.commandSkill = function() {
  4054.     this._helpWindow.clear();
  4055.     Yanfly.BEC.Scene_Battle_commandSkill.call(this);
  4056. };
  4057.  
  4058. Yanfly.BEC.Scene_Battle_commandItem = Scene_Battle.prototype.commandItem;
  4059. Scene_Battle.prototype.commandItem = function() {
  4060.     this._helpWindow.clear();
  4061.     Yanfly.BEC.Scene_Battle_commandItem.call(this);
  4062. };
  4063.  
  4064. Yanfly.BEC.Scene_Battle_startActorCommandSelection =
  4065.     Scene_Battle.prototype.startActorCommandSelection;
  4066. Scene_Battle.prototype.startActorCommandSelection = function() {
  4067.     BattleManager.createActions();
  4068.     Yanfly.BEC.Scene_Battle_startActorCommandSelection.call(this);
  4069.     this._statusWindow.refresh();
  4070. };
  4071.  
  4072. Yanfly.BEC.Scene_Battle_selectActorSelection =
  4073.     Scene_Battle.prototype.selectActorSelection;
  4074. Scene_Battle.prototype.selectActorSelection = function() {
  4075.     if (eval(Yanfly.Param.BECSelectHelp)) this._helpWindow.show();
  4076.     this._helpWindow.clear();
  4077.     Yanfly.BEC.Scene_Battle_selectActorSelection.call(this);
  4078.     this._actorWindow.autoSelect();
  4079. };
  4080.  
  4081. Yanfly.BEC.Scene_Battle_onActorCancel = Scene_Battle.prototype.onActorCancel;
  4082. Scene_Battle.prototype.onActorCancel = function() {
  4083.     if (eval(Yanfly.Param.BECSelectHelp)) this._helpWindow.hide();
  4084.     this._helpWindow.clear();
  4085.     Yanfly.BEC.Scene_Battle_onActorCancel.call(this);
  4086.     BattleManager.stopAllSelection();
  4087.     BattleManager.clearInputtingAction();
  4088. };
  4089.  
  4090. Yanfly.BEC.Scene_Battle_selectEnemySelection =
  4091.     Scene_Battle.prototype.selectEnemySelection;
  4092. Scene_Battle.prototype.selectEnemySelection = function() {
  4093.     if (eval(Yanfly.Param.BECSelectHelp)) this._helpWindow.show();
  4094.     this._helpWindow.clear();
  4095.     Yanfly.BEC.Scene_Battle_selectEnemySelection.call(this);
  4096.     this._enemyWindow.autoSelect();
  4097. };
  4098.  
  4099. Yanfly.BEC.Scene_Battle_onEnemyCancel = Scene_Battle.prototype.onEnemyCancel;
  4100. Scene_Battle.prototype.onEnemyCancel = function() {
  4101.     if (eval(Yanfly.Param.BECSelectHelp)) this._helpWindow.hide();
  4102.     this._helpWindow.clear();
  4103.     Yanfly.BEC.Scene_Battle_onEnemyCancel.call(this);
  4104.     BattleManager.stopAllSelection();
  4105.     BattleManager.clearInputtingAction();
  4106. };
  4107.  
  4108. Yanfly.BEC.Scene_Battle_onSelectAction = Scene_Battle.prototype.onSelectAction;
  4109. Scene_Battle.prototype.onSelectAction = function() {
  4110.     if (eval(Yanfly.Param.BECSelectHelp)) BattleManager.forceSelection();
  4111.     this._helpWindow.clear();
  4112.     Yanfly.BEC.Scene_Battle_onSelectAction.call(this);
  4113.     if (eval(Yanfly.Param.BECSelectHelp)) BattleManager.resetSelection();
  4114. };
  4115.  
  4116. Yanfly.BEC.Scene_Battle_onSkillOk =
  4117.     Scene_Battle.prototype.onSkillOk;
  4118. Scene_Battle.prototype.onSkillOk = function() {
  4119.     this._helpWindow.clear();
  4120.     Yanfly.BEC.Scene_Battle_onSkillOk.call(this);
  4121. };
  4122.  
  4123. Yanfly.BEC.Scene_Battle_onSkillCancel =
  4124.     Scene_Battle.prototype.onSkillCancel;
  4125. Scene_Battle.prototype.onSkillCancel = function() {
  4126.     this._helpWindow.clear();
  4127.     Yanfly.BEC.Scene_Battle_onSkillCancel.call(this);
  4128.     BattleManager.clearInputtingAction();
  4129. };
  4130.  
  4131. Yanfly.BEC.Scene_Battle_onItemOk =
  4132.     Scene_Battle.prototype.onItemOk;
  4133. Scene_Battle.prototype.onItemOk = function() {
  4134.     this._helpWindow.clear();
  4135.     Yanfly.BEC.Scene_Battle_onItemOk.call(this);
  4136. };
  4137.  
  4138. Yanfly.BEC.Scene_Battle_onItemCancel =
  4139.     Scene_Battle.prototype.onItemCancel;
  4140. Scene_Battle.prototype.onItemCancel = function() {
  4141.     this._helpWindow.clear();
  4142.     Yanfly.BEC.Scene_Battle_onItemCancel.call(this);
  4143.     BattleManager.clearInputtingAction();
  4144. };
  4145.  
  4146. //=============================================================================
  4147. // Window_Selectable
  4148. //=============================================================================
  4149.  
  4150. Yanfly.BEC.Window_Selectable_isCursorMovable =
  4151.     Window_Selectable.prototype.isCursorMovable;
  4152. Window_Selectable.prototype.isCursorMovable = function() {
  4153.     if (this._inputLock) return false;
  4154.     return Yanfly.BEC.Window_Selectable_isCursorMovable.call(this);
  4155. };
  4156.  
  4157. //=============================================================================
  4158. // Window_Help
  4159. //=============================================================================
  4160.  
  4161. Yanfly.BEC.Window_Help_clear = Window_Help.prototype.clear;
  4162. Window_Help.prototype.clear = function() {
  4163.     Yanfly.BEC.Window_Help_clear.call(this);
  4164.     this.contents.clear();
  4165. };
  4166.  
  4167. Window_Help.prototype.setBattler = function(battler) {
  4168.     this.contents.clear();
  4169.     this.clear();
  4170.     if (!$gameParty.inBattle()) return;
  4171.     if (!battler) return;
  4172.     var action = BattleManager.inputtingAction();
  4173.     if (this.specialSelectionText(action)) {
  4174.       this.drawSpecialSelectionText(action);
  4175.     } else {
  4176.       this.drawBattler(battler);
  4177.     }
  4178. };
  4179.  
  4180. Window_Help.prototype.specialSelectionText = function(action) {
  4181.     BattleManager.resetSelection();
  4182.     if (!action) return false;
  4183.     return !action.needsSelection();
  4184. };
  4185.  
  4186. Window_Help.prototype.drawBattler = function(battler) {
  4187.     var text = battler.name();
  4188.     var wx = 0;
  4189.     var wy = (this.contents.height - this.lineHeight()) / 2;
  4190.     this.drawText(text, wx, wy, this.contents.width, 'center');
  4191. };
  4192.  
  4193. Window_Help.prototype.drawSpecialSelectionText = function(action) {
  4194.     var wx = 0;
  4195.     var wy = (this.contents.height - this.lineHeight()) / 2;
  4196.     var text = '';
  4197.     if (action.isForUser()) {
  4198.       text = Yanfly.Param.BECHelpUserTx;
  4199.     } else if (action.isForRandom()) {
  4200.       BattleManager.startAllSelection();
  4201.       var fmt = Yanfly.Param.BECHelpRandTx;
  4202.       if (action.isForOpponent() && action.numTargets() !== 1) {
  4203.         var target = Yanfly.Param.BECHelpEnemiesTx;
  4204.       } else if (action.isForOpponent() && action.numTargets() === 1) {
  4205.         var target = Yanfly.Param.BECHelpEnemyTx;
  4206.       } else if (action.isForFriend() && action.numTargets() !== 1) {
  4207.         var target = Yanfly.Param.BECHelpAlliesTx;
  4208.       } else {
  4209.         var target = Yanfly.Param.BECHelpAllyTx;
  4210.       }
  4211.       text = fmt.format(target, Yanfly.Util.toGroup(action.numTargets()));
  4212.     } else if (action.isForAll()) {
  4213.       BattleManager.startAllSelection();
  4214.       var fmt = Yanfly.Param.BECHelpAllTx;
  4215.       if (action.isForOpponent()) {
  4216.         var target = Yanfly.Param.BECHelpEnemiesTx;
  4217.       } else {
  4218.         var target = Yanfly.Param.BECHelpAlliesTx;
  4219.       }
  4220.       text = fmt.format(target);
  4221.     }
  4222.     this.drawText(text, wx, wy, this.contents.width, 'center');
  4223. };
  4224.  
  4225. //=============================================================================
  4226. // Window_BattleActor
  4227. //=============================================================================
  4228.  
  4229. Window_BattleActor.prototype.autoSelect = function() {
  4230.     var action = BattleManager.inputtingAction();
  4231.     if (!action) return;
  4232.     this._inputLock = false;
  4233.     this._selectDead = false;
  4234.     if (action.isForUser()) {
  4235.       this.select(BattleManager.actor().index());
  4236.       this._inputLock = true;
  4237.     } else if (action.isForDeadFriend()) {
  4238.       this._selectDead = true;
  4239.       this.autoSelectFirstDeadActor();
  4240.       if (action.isForAll()) this._inputLock = true;
  4241.     }
  4242. };
  4243.  
  4244. Window_BattleActor.prototype.autoSelectFirstDeadActor = function() {
  4245.     var length = $gameParty.members().length;
  4246.     for (var i = 0; i < length; ++i) {
  4247.       var member = $gameParty.members()[i];
  4248.       if (member && member.isDead()) return this.select(i);
  4249.     }
  4250. };
  4251.  
  4252. Window_BattleActor.prototype.isOkEnabled = function() {
  4253.     if (this._selectDead) return this.actor().isDead();
  4254.     return Window_Selectable.prototype.isOkEnabled.call(this);
  4255. };
  4256.  
  4257. Window_BattleActor.prototype.updateHelp = function() {
  4258.     if (!this._helpWindow) return;
  4259.     this._helpWindow.setBattler(this.actor());
  4260. };
  4261.  
  4262. Yanfly.BEC.Window_BattleActor_processTouch =
  4263.     Window_BattleActor.prototype.processTouch;
  4264. Window_BattleActor.prototype.processTouch = function() {
  4265.     if (eval(Yanfly.Param.BECActorSelect) && this.isOpenAndActive()) {
  4266.       if (TouchInput.isTriggered() && !this.isTouchedInsideFrame()) {
  4267.         if (this.getClickedActor() >= 0) {
  4268.           var index = this.getClickedActor();
  4269.           if (this.index() === index) {
  4270.             return this.processOk();
  4271.           } else {
  4272.             SoundManager.playCursor();
  4273.             return this.select(index);
  4274.           }
  4275.         }
  4276.       }
  4277.       if (TouchInput.isPressed() && !this.isTouchedInsideFrame()) {
  4278.         if (this.getClickedActor() >= 0) {
  4279.           var index = this.getClickedActor();
  4280.           if (this.index() !== index) {
  4281.             SoundManager.playCursor();
  4282.             return this.select(index);
  4283.           }
  4284.         }
  4285.       }
  4286.       if (Yanfly.Param.BECSelectMouseOver) {
  4287.         var index = this.getMouseOverActor();
  4288.         if (index >= 0 && this.index() !== index) {
  4289.           SoundManager.playCursor();
  4290.           return this.select(index);
  4291.         }
  4292.       }
  4293.     }
  4294.     Yanfly.BEC.Window_BattleActor_processTouch.call(this);
  4295. };
  4296.  
  4297. Window_BattleActor.prototype.getClickedActor = function() {
  4298.     for (var i = 0; i < $gameParty.battleMembers().length; ++i) {
  4299.       var actor = $gameParty.battleMembers().reverse()[i];
  4300.       if (!actor) continue;
  4301.       if (this.isClickedActor(actor)) {
  4302.         if (this._selectDead && !actor.isDead()) continue;
  4303.         if (this._inputLock && actor.index() !== this.index()) continue;
  4304.         return actor.index();
  4305.       }
  4306.     }
  4307.     return -1;
  4308. };
  4309.  
  4310. Window_BattleActor.prototype.isClickedActor = function(actor) {
  4311.     if (!actor) return false;
  4312.     if (!actor.isSpriteVisible()) return false;
  4313.     if (!actor.isAppeared()) return false;
  4314.     var x = TouchInput.x;
  4315.     var y = TouchInput.y;
  4316.     var rect = new Rectangle();
  4317.     rect.width = actor.spriteWidth();
  4318.     rect.height = actor.spriteHeight();
  4319.     rect.x = actor.spritePosX() - rect.width / 2;
  4320.     rect.y = actor.spritePosY() - rect.height;
  4321.     return (x >= rect.x && y >= rect.y && x < rect.x + rect.width &&
  4322.       y < rect.y + rect.height);
  4323. };
  4324.  
  4325. Window_BattleActor.prototype.getMouseOverActor = function() {
  4326.     for (var i = 0; i < $gameParty.battleMembers().length; ++i) {
  4327.       var actor = $gameParty.battleMembers().reverse()[i];
  4328.       if (!actor) continue;
  4329.       if (this.isMouseOverActor(actor)) {
  4330.         if (this._selectDead && !actor.isDead()) continue;
  4331.         if (this._inputLock && actor.index() !== this.index()) continue;
  4332.         return actor.index();
  4333.       }
  4334.     }
  4335.     return -1;
  4336. };
  4337.  
  4338. Window_BattleActor.prototype.isMouseOverActor = function(actor) {
  4339.     if (!actor) return false;
  4340.     if (!actor.isSpriteVisible()) return false;
  4341.     if (!actor.isAppeared()) return false;
  4342.     var x = TouchInput._mouseOverX;
  4343.     var y = TouchInput._mouseOverY;
  4344.     var rect = new Rectangle();
  4345.     rect.width = actor.spriteWidth();
  4346.     rect.height = actor.spriteHeight();
  4347.     rect.x = actor.spritePosX() - rect.width / 2;
  4348.     rect.y = actor.spritePosY() - rect.height;
  4349.     return (x >= rect.x && y >= rect.y && x < rect.x + rect.width &&
  4350.       y < rect.y + rect.height);
  4351. };
  4352.  
  4353. //=============================================================================
  4354. // Window_BattleEnemy
  4355. //=============================================================================
  4356.  
  4357. Yanfly.DisableWebGLMask = false;
  4358.  
  4359. Yanfly.BEC.Window_BattleEnemy_initialize =
  4360.     Window_BattleEnemy.prototype.initialize;
  4361. Window_BattleEnemy.prototype.initialize = function(x, y) {
  4362.     if (eval(Yanfly.Param.BECEnemySelect)) {
  4363.       x -= Graphics.boxWidth * 200;
  4364.       y -= Graphics.boxHeight * 200;
  4365.     };
  4366.     Yanfly.BEC.Window_BattleEnemy_initialize.call(this, x, y);
  4367. };
  4368.  
  4369. Yanfly.BEC.WindowLayer_webglMaskWindow =
  4370.     WindowLayer.prototype._webglMaskWindow;
  4371. WindowLayer.prototype._webglMaskWindow = function(renderSession, win) {
  4372.     if (win._ignoreMask) return;
  4373.     Yanfly.BEC.WindowLayer_webglMaskWindow.call(this, renderSession, win);
  4374. };
  4375.  
  4376. Yanfly.BEC.Window_BattleEnemy_maxCols =
  4377.     Window_BattleEnemy.prototype.maxCols;
  4378. Window_BattleEnemy.prototype.maxCols = function() {
  4379.     if (eval(Yanfly.Param.BECEnemySelect)) return this._enemies.length;
  4380.     return Yanfly.BEC.Window_BattleEnemy_maxCols.call(this);
  4381. };
  4382.  
  4383. Window_BattleEnemy.prototype.allowedTargets = function() {
  4384.     var targets = [];
  4385.     targets = targets.concat($gameTroop.aliveMembers());
  4386.     return targets;
  4387. };
  4388.  
  4389. Window_BattleEnemy.prototype.refresh = function() {
  4390.     this._enemies = this.allowedTargets();
  4391.     this.sortTargets();
  4392.     Window_Selectable.prototype.refresh.call(this);
  4393. };
  4394.  
  4395. Window_BattleEnemy.prototype.sortTargets = function() {
  4396.     this._enemies.sort(function(a, b) {
  4397.         if (a.spritePosX() == b.spritePosX()) {
  4398.           return a.spritePosY() - b.spritePosY();
  4399.         }
  4400.         return a.spritePosX() - b.spritePosX();
  4401.     });
  4402. };
  4403.  
  4404. Window_BattleEnemy.prototype.autoSelect = function() {
  4405.     var selectIndex = eval(Yanfly.Param.BECEnemyAutoSel);
  4406.     this.select(selectIndex);
  4407. };
  4408.  
  4409. Window_BattleEnemy.prototype.furthestRight = function() {
  4410.     return this.maxItems() - 1;
  4411. };
  4412.  
  4413. Window_BattleEnemy.prototype.updateHelp = function() {
  4414.     if (!this._helpWindow) return;
  4415.     this._helpWindow.setBattler(this.enemy());
  4416. };
  4417.  
  4418. Yanfly.BEC.Window_BattleEnemy_processTouch =
  4419.     Window_BattleEnemy.prototype.processTouch;
  4420. Window_BattleEnemy.prototype.processTouch = function() {
  4421.     if (eval(Yanfly.Param.BECEnemySelect) && this.isOpenAndActive()) {
  4422.       if (TouchInput.isTriggered() && !this.isTouchedInsideFrame()) {
  4423.         if (this.getClickedEnemy() >= 0) {
  4424.           var index = this.getClickedEnemy();
  4425.           if (this.index() === index) {
  4426.             return this.processOk();
  4427.           } else {
  4428.             SoundManager.playCursor();
  4429.             return this.select(index);
  4430.           }
  4431.         }
  4432.       }
  4433.       if (TouchInput.isPressed() && !this.isTouchedInsideFrame()) {
  4434.         if (this.getClickedEnemy() >= 0) {
  4435.           var index = this.getClickedEnemy();
  4436.           if (this.index() !== index) {
  4437.             SoundManager.playCursor();
  4438.             return this.select(index);
  4439.           }
  4440.         }
  4441.       }
  4442.       if (Yanfly.Param.BECSelectMouseOver) {
  4443.         var index = this.getMouseOverEnemy();
  4444.         if (index >= 0 && this.index() !== index) {
  4445.           SoundManager.playCursor();
  4446.           return this.select(index);
  4447.         }
  4448.       }
  4449.     };
  4450.     Yanfly.BEC.Window_BattleEnemy_processTouch.call(this);
  4451. };
  4452.  
  4453. Window_BattleEnemy.prototype.getClickedEnemy = function() {
  4454.     for (var i = 0; i < this._enemies.length; ++i) {
  4455.       var enemy = this._enemies[i];
  4456.       if (!enemy) continue;
  4457.       if (this.isClickedEnemy(enemy)) {
  4458.         if (this._selectDead && !enemy.isDead()) continue;
  4459.         var index = this._enemies.indexOf(enemy)
  4460.         if (this._inputLock && index !== this.index()) continue;
  4461.         return index;
  4462.       }
  4463.     }
  4464.     return -1;
  4465. };
  4466.  
  4467. Window_BattleEnemy.prototype.isClickedEnemy = function(enemy) {
  4468.     if (!enemy) return false;
  4469.     if (!enemy.isSpriteVisible()) return false;
  4470.     var x = TouchInput.x;
  4471.     var y = TouchInput.y;
  4472.     var rect = new Rectangle();
  4473.     rect.width = enemy.spriteWidth();
  4474.     rect.height = enemy.spriteHeight();
  4475.     rect.x = enemy.spritePosX() - rect.width / 2;
  4476.     rect.y = enemy.spritePosY() - rect.height;
  4477.     return (x >= rect.x && y >= rect.y && x < rect.x + rect.width &&
  4478.       y < rect.y + rect.height);
  4479. };
  4480.  
  4481. Window_BattleEnemy.prototype.getMouseOverEnemy = function() {
  4482.     for (var i = 0; i < this._enemies.length; ++i) {
  4483.       var enemy = this._enemies[i];
  4484.       if (!enemy) continue;
  4485.       if (this.isMouseOverEnemy(enemy)) {
  4486.         if (this._selectDead && !enemy.isDead()) continue;
  4487.         var index = this._enemies.indexOf(enemy)
  4488.         if (this._inputLock && index !== this.index()) continue;
  4489.         return index;
  4490.       }
  4491.     }
  4492.     return -1;
  4493. };
  4494.  
  4495. Window_BattleEnemy.prototype.isMouseOverEnemy = function(enemy) {
  4496.     if (!enemy) return false;
  4497.     if (!enemy.isSpriteVisible()) return false;
  4498.     var x = TouchInput._mouseOverX;
  4499.     var y = TouchInput._mouseOverY;
  4500.     var rect = new Rectangle();
  4501.     rect.width = enemy.spriteWidth();
  4502.     rect.height = enemy.spriteHeight();
  4503.     rect.x = enemy.spritePosX() - rect.width / 2;
  4504.     rect.y = enemy.spritePosY() - rect.height;
  4505.     return (x >= rect.x && y >= rect.y && x < rect.x + rect.width &&
  4506.       y < rect.y + rect.height);
  4507. };
  4508.  
  4509. //=============================================================================
  4510. // Window_EnemyVisualSelect
  4511. //=============================================================================
  4512.  
  4513. function Window_EnemyVisualSelect() {
  4514.     this.initialize.apply(this, arguments);
  4515. }
  4516.  
  4517. Window_EnemyVisualSelect.prototype = Object.create(Window_Base.prototype);
  4518. Window_EnemyVisualSelect.prototype.constructor = Window_EnemyVisualSelect;
  4519.  
  4520. Window_EnemyVisualSelect.prototype.initialize = function() {
  4521.     Window_Base.prototype.initialize.call(this, 0, 0, 1, 1);
  4522.     this._battler = null;
  4523.     this._battlerName = '';
  4524.     this._requestRefresh = false;
  4525.     this._showSelectCursor = eval(Yanfly.Param.BECShowSelectBox);
  4526.     this._showEnemyName = eval(Yanfly.Param.BECShowEnemyName);
  4527.     this.contentsOpacity = 0;
  4528.     this.opacity = 0;
  4529. };
  4530.  
  4531. Window_EnemyVisualSelect.prototype.setBattler = function(battler) {
  4532.     if (this._battler === battler) return;
  4533.     this._battler = battler;
  4534.     this._battlerName = battler.name();
  4535. };
  4536.  
  4537. Window_EnemyVisualSelect.prototype.update = function() {
  4538.     Window_Base.prototype.update.call(this);
  4539.     if (!this._battler) return;
  4540.     this.updateWindowAspects();
  4541. };
  4542.  
  4543. Window_EnemyVisualSelect.prototype.updateWindowAspects = function() {
  4544.     this.updateBattlerName();
  4545.     this.updateWindowSize();
  4546.     this.updateWindowPosition();
  4547.     this.updateOpacity();
  4548.     this.updateRefresh();
  4549.     this.updateCursor();
  4550. };
  4551.  
  4552. Window_EnemyVisualSelect.prototype.updateBattlerName = function() {
  4553.     if (this._battlerName !== this._battler.name())
  4554.     this._battlerName = this._battler.name();
  4555.     this._requestRefresh = true;
  4556. };
  4557.  
  4558. Window_EnemyVisualSelect.prototype.updateWindowSize = function() {
  4559.     var spriteWidth = this._battler.spriteWidth();
  4560.     this.contents.fontSize = Yanfly.Param.BECEnemyFontSize;
  4561.     var textWidth = this.textWidth(this._battler.name());
  4562.     textWidth += this.textPadding() * 2;
  4563.     var width = Math.max(spriteWidth, textWidth) + this.standardPadding() * 2;
  4564.     var height = this._battler.spriteHeight() + this.standardPadding() * 2;
  4565.     if (width === this.width && height === this.height) return;
  4566.     this.width = width;
  4567.     this.height = height;
  4568.     this.createContents();
  4569.     this._requestRefresh = true;
  4570.     this.makeWindowBoundaries();
  4571. };
  4572.  
  4573. Window_EnemyVisualSelect.prototype.makeWindowBoundaries = function() {
  4574.     if (!this._requestRefresh) return;
  4575.     this._minX = -1 * this.standardPadding();
  4576.     this._maxX = Graphics.boxWidth - this.width + this.standardPadding();
  4577.     this._minY = -1 * this.standardPadding();
  4578.     this._maxY = Graphics.boxHeight - this.height + this.standardPadding();
  4579.     this._maxY -= SceneManager._scene._statusWindow.height;
  4580. };
  4581.  
  4582. Window_EnemyVisualSelect.prototype.updateWindowPosition = function() {
  4583.     if (!this._battler) return;
  4584.     this.x = -1 * this.width / 2;
  4585.     this.y = -1 * this.height + this.standardPadding();
  4586.     this.x += this._battler.spritePosX();
  4587.     this.y += this._battler.spritePosY();
  4588.     this.x = this.x.clamp(this._minX, this._maxX);
  4589.     this.y = this.y.clamp(this._minY, this._maxY);
  4590. };
  4591.  
  4592. Window_EnemyVisualSelect.prototype.updateOpacity = function() {
  4593.     if (this.isShowWindow()) {
  4594.       this.contentsOpacity += 32;
  4595.     } else {
  4596.       this.contentsOpacity -= 32;
  4597.     }
  4598. };
  4599.  
  4600. Window_EnemyVisualSelect.prototype.isShowWindow = function() {
  4601.     var scene = SceneManager._scene;
  4602.     if (!scene._enemyWindow) return false;
  4603.     var enemyWindow = scene._enemyWindow;
  4604.     if (!enemyWindow.active) return false;
  4605.     if (!this._battler.isAppeared()) return false;
  4606.     if (this._battler.isDead()) {
  4607.       return enemyWindow._selectDead;
  4608.     }
  4609.     return enemyWindow._enemies.contains(this._battler);
  4610. };
  4611.  
  4612. Window_EnemyVisualSelect.prototype.updateCursor = function() {
  4613.     if (this.isShowCursor()) {
  4614.       var wy = this.contents.height - this.lineHeight();
  4615.       this.setCursorRect(0, wy, this.contents.width, this.lineHeight());
  4616.     } else {
  4617.       this.setCursorRect(0, 0, 0, 0);
  4618.     }
  4619. };
  4620.  
  4621. Window_EnemyVisualSelect.prototype.isShowCursor = function() {
  4622.     if (!this._showSelectCursor) return false;
  4623.     var scene = SceneManager._scene;
  4624.     if (!scene._enemyWindow) return false;
  4625.     var enemyWindow = scene._enemyWindow;
  4626.     if (!enemyWindow.active) return false;
  4627.     if (!this._battler.isAppeared()) return false;
  4628.     return this._battler.isSelected();
  4629. };
  4630.  
  4631. Window_EnemyVisualSelect.prototype.updateRefresh = function() {
  4632.     if (this._requestRefresh) this.refresh();
  4633. };
  4634.  
  4635. Window_EnemyVisualSelect.prototype.refresh = function() {
  4636.     this.contents.clear();
  4637.     if (!this._battler) return;
  4638.     if (!this._showEnemyName) return;
  4639.     if (this._battler.isHidden()) return;
  4640.     this._requestRefresh = false;
  4641.     this.contents.fontSize = Yanfly.Param.BECEnemyFontSize;
  4642.     var text = this._battler.name();
  4643.     var wy = this.contents.height - this.lineHeight();
  4644.     this.drawText(text, 0, wy, this.contents.width, 'center');
  4645. };
  4646.  
  4647. //=============================================================================
  4648. // Window_PartyCommand
  4649. //=============================================================================
  4650.  
  4651. Window_PartyCommand.prototype.itemTextAlign = function() {
  4652.     return Yanfly.Param.BECCommandAlign;
  4653. };
  4654.  
  4655. Window_PartyCommand.prototype.numVisibleRows = function() {
  4656.     return eval(Yanfly.Param.BECCommandRows);
  4657. };
  4658.  
  4659. //=============================================================================
  4660. // Window_ActorCommand
  4661. //=============================================================================
  4662.  
  4663. Window_ActorCommand.prototype.itemTextAlign = function() {
  4664.     return Yanfly.Param.BECCommandAlign;
  4665. };
  4666.  
  4667. Window_ActorCommand.prototype.numVisibleRows = function() {
  4668.     return eval(Yanfly.Param.BECCommandRows);
  4669. };
  4670.  
  4671. //=============================================================================
  4672. // Window_BattleStatus
  4673. //=============================================================================
  4674.  
  4675. Window_BattleStatus.prototype.numVisibleRows = function() {
  4676.     return eval(Yanfly.Param.BECCommandRows);
  4677. };
  4678.  
  4679. Window_BattleStatus.prototype.updateStatusRequests = function() {
  4680.     if (BattleManager._victoryPhase) return;
  4681.     for (var i = 0; i < $gameParty.battleMembers().length; ++i) {
  4682.       var actor = $gameParty.battleMembers()[i];
  4683.       if (!actor) continue;
  4684.       if (actor.isStatusRefreshRequested()) this.processStatusRefresh(i);
  4685.     }
  4686. };
  4687.  
  4688. Window_BattleStatus.prototype.processStatusRefresh = function(index) {
  4689.     var actor = $gameParty.battleMembers()[index];
  4690.     if (!actor) return;
  4691.     var rect = this.itemRect(index);
  4692.     this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
  4693.     this.drawItem(index);
  4694.     actor.completetStatusRefreshRequest();
  4695. };
  4696.  
  4697. if (!Yanfly.Param.BECCurMax) {
  4698.  
  4699. Window_BattleStatus.prototype.drawCurrentAndMax = function(current, max, x, y,
  4700.                                                    width, color1, color2) {
  4701.     var labelWidth = this.textWidth('HP');
  4702.     var valueWidth = this.textWidth(Yanfly.Util.toGroup(max));
  4703.     var slashWidth = this.textWidth('/');
  4704.     var x1 = x + width - valueWidth;
  4705.     this.changeTextColor(color1);
  4706.     this.drawText(Yanfly.Util.toGroup(current), x1, y, valueWidth, 'right');
  4707. };
  4708.  
  4709. }; // Yanfly.Param.BECCurMax
  4710.  
  4711. //=============================================================================
  4712. // Window_BattleLog
  4713. //=============================================================================
  4714.  
  4715. Yanfly.BEC.Window_BattleLog_isFastForward =
  4716.     Window_BattleLog.prototype.isFastForward;
  4717. Window_BattleLog.prototype.isFastForward = function() {
  4718.     if (eval(Yanfly.Param.BECOptSpeed)) return true;
  4719.     return Yanfly.BEC.Window_BattleLog_isFastForward.call(this);
  4720. };
  4721.  
  4722. Window_BattleLog.prototype.updateWaitCount = function() {
  4723.     if (this._waitCount > 0) {
  4724.         this._waitCount -= 1;
  4725.         if (this._waitCount < 0) {
  4726.             this._waitCount = 0;
  4727.         }
  4728.         return true;
  4729.     }
  4730.     return false;
  4731. };
  4732.  
  4733. Window_BattleLog.prototype.animationBaseDelay = function() {
  4734.     return eval(Yanfly.Param.BECAniBaseDel);
  4735. };
  4736.  
  4737. Window_BattleLog.prototype.animationNextDelay = function() {
  4738.     return eval(Yanfly.Param.BECAniNextDel);
  4739. };
  4740.  
  4741. Window_BattleLog.prototype.updateWaitMode = function() {
  4742.     var waiting = false;
  4743.     switch (this._waitMode) {
  4744.     case 'effect':
  4745.         waiting = this._spriteset.isEffecting();
  4746.         break;
  4747.     case 'movement':
  4748.         waiting = this._spriteset.isAnyoneMoving();
  4749.         break;
  4750.     case 'animation':
  4751.         waiting = this._spriteset.isAnimationPlaying();
  4752.         break;
  4753.     case 'popups':
  4754.         waiting = this._spriteset.isPopupPlaying();
  4755.         break;
  4756.     }
  4757.     if (!waiting) {
  4758.         this._waitMode = '';
  4759.     }
  4760.     return waiting;
  4761. };
  4762.  
  4763. Window_BattleLog.prototype.startAction = function(subject, action, targets) {
  4764. };
  4765.  
  4766. Window_BattleLog.prototype.endAction = function(subject) {
  4767. };
  4768.  
  4769. Window_BattleLog.prototype.waitForAnimation = function() {
  4770.     this.setWaitMode('animation');
  4771. };
  4772.  
  4773. Window_BattleLog.prototype.waitForEffect = function() {
  4774.     this.setWaitMode('effect');
  4775. };
  4776.  
  4777. Window_BattleLog.prototype.waitForPopups = function() {
  4778.     this.setWaitMode('popups');
  4779. };
  4780.  
  4781. Yanfly.BEC.Window_BattleLog_displayAction =
  4782.     Window_BattleLog.prototype.displayAction;
  4783. Window_BattleLog.prototype.displayAction = function(subject, item) {
  4784.     if (eval(Yanfly.Param.BECFullActText)) {
  4785.       Yanfly.BEC.Window_BattleLog_displayAction.call(this, subject, item);
  4786.     } else {
  4787.       this._actionIcon = this.displayIcon(item);
  4788.       var text = this.displayText(item);
  4789.       this.push('addText', '<SIMPLE>' + text);
  4790.       if (item.message2) {
  4791.         this.push('addText', '<CENTER>' + item.message2.format(text));
  4792.       }
  4793.     }
  4794. };
  4795.  
  4796. Window_BattleLog.prototype.displayIcon = function(item) {
  4797.     return item.battleDisplayIcon;
  4798. };
  4799.  
  4800. Window_BattleLog.prototype.displayText = function(item) {
  4801.     return item.battleDisplayText;
  4802. };
  4803.  
  4804. Yanfly.BEC.Window_BattleLog_displayActionResults =
  4805.     Window_BattleLog.prototype.displayActionResults;
  4806. Window_BattleLog.prototype.displayActionResults = function(subject, target) {
  4807.     if (eval(Yanfly.Param.BECOptSpeed)) {
  4808.       if (target.result().used) {
  4809.           this.displayCritical(target);
  4810.           this.displayDamage(target);
  4811.           this.displayAffectedStatus(target);
  4812.           this.displayFailure(target);
  4813.       }
  4814.     } else {
  4815.       Yanfly.BEC.Window_BattleLog_displayActionResults.call(this, subject,
  4816.           target);
  4817.     }
  4818.     if (target.isDead()) target.performCollapse();
  4819. };
  4820.  
  4821. Yanfly.BEC.Window_BattleLog_drawLineText =
  4822.     Window_BattleLog.prototype.drawLineText;
  4823. Window_BattleLog.prototype.drawLineText = function(index) {
  4824.     if (this._lines[index].match('<CENTER>')) {
  4825.       this.drawCenterLine(index);
  4826.     } else if (this._lines[index].match('<SIMPLE>')) {
  4827.       this.drawSimpleActionLine(index);
  4828.     } else {
  4829.       Yanfly.BEC.Window_BattleLog_drawLineText.call(this, index);
  4830.     }
  4831. };
  4832.  
  4833. Window_BattleLog.prototype.textWidthEx = function(text) {
  4834.     return this.drawTextEx(text, 0, this.contents.height);
  4835. };
  4836.  
  4837. Window_BattleLog.prototype.drawCenterLine = function(index) {
  4838.     var text = this._lines[index].replace('<CENTER>', '');
  4839.     var rect = this.itemRectForText(index);
  4840.     this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
  4841.     var tw = this.textWidthEx(text);
  4842.     var wx = rect.x + (rect.width - tw) / 2;
  4843.     this.drawTextEx(text, wx, rect.y);
  4844. };
  4845.  
  4846. Window_BattleLog.prototype.drawSimpleActionLine = function(index) {
  4847.     var text = this._lines[index].replace('<SIMPLE>', '');
  4848.     var rect = this.itemRectForText(index);
  4849.     this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
  4850.     if (this._actionIcon) {
  4851.       var tw = this.textWidth(text);
  4852.       var ix = (rect.width - tw) / 2 - 4;
  4853.       this.drawIcon(this._actionIcon, ix, rect.y + 2);
  4854.     }
  4855.     this.drawText(text, rect.x, rect.y, Graphics.boxWidth, 'center');
  4856. };
  4857.  
  4858. Window_BattleLog.prototype.displayCounter = function(target) {
  4859.     if (eval(Yanfly.Param.BECShowCntText)) {
  4860.       this.addText(TextManager.counterAttack.format(target.name()));
  4861.     }
  4862.     target.performCounter();
  4863.     this.showAttackAnimation(target, [BattleManager._subject]);
  4864.     this.waitForAnimation();
  4865. };
  4866.  
  4867. Window_BattleLog.prototype.displayReflection = function(target) {
  4868.     if (eval(Yanfly.Param.BECShowRflText)) {
  4869.       this.addText(TextManager.magicReflection.format(target.name()));
  4870.     }
  4871.     target.performReflection();
  4872.     var animationId = BattleManager._action.item().animationId;
  4873.     this.showNormalAnimation([BattleManager._subject], animationId);
  4874.     this.waitForAnimation();
  4875. };
  4876.  
  4877. Window_BattleLog.prototype.displaySubstitute = function(substitute, target) {
  4878.     if (eval(Yanfly.Param.BECShowSubText)) {
  4879.       var substName = substitute.name();
  4880.       this.addText(TextManager.substitute.format(substName, target.name()));
  4881.     }
  4882.     substitute.performSubstitute(target);
  4883. };
  4884.  
  4885. Yanfly.BEC.Window_BattleLog_displayFailure =
  4886.     Window_BattleLog.prototype.displayFailure;
  4887. Window_BattleLog.prototype.displayFailure = function(target) {
  4888.     if (!eval(Yanfly.Param.BECShowFailText)) return;
  4889.     Yanfly.BEC.Window_BattleLog_displayFailure.call(this, target);
  4890. };
  4891.  
  4892. Yanfly.BEC.Window_BattleLog_displayCritical =
  4893.     Window_BattleLog.prototype.displayCritical;
  4894. Window_BattleLog.prototype.displayCritical = function(target) {
  4895.     if (!eval(Yanfly.Param.BECShowCritText)) return;
  4896.     Yanfly.BEC.Window_BattleLog_displayCritical.call(this, target);
  4897. };
  4898.  
  4899. Yanfly.BEC.Window_BattleLog_displayMiss =
  4900.     Window_BattleLog.prototype.displayMiss;
  4901. Window_BattleLog.prototype.displayMiss = function(target) {
  4902.     if (!eval(Yanfly.Param.BECShowMissText)) return;
  4903.     Yanfly.BEC.Window_BattleLog_displayMiss.call(this, target);
  4904. };
  4905.  
  4906. Yanfly.BEC.Window_BattleLog_displayEvasion =
  4907.     Window_BattleLog.prototype.displayEvasion;
  4908. Window_BattleLog.prototype.displayEvasion = function(target) {
  4909.     if (!eval(Yanfly.Param.BECShowEvaText)) return;
  4910.     Yanfly.BEC.Window_BattleLog_displayEvasion.call(this, target);
  4911. };
  4912.  
  4913. Yanfly.BEC.Window_BattleLog_displayHpDamage =
  4914.     Window_BattleLog.prototype.displayHpDamage;
  4915. Window_BattleLog.prototype.displayHpDamage = function(target) {
  4916.     if (!eval(Yanfly.Param.BECShowHpText)) return;
  4917.     Yanfly.BEC.Window_BattleLog_displayHpDamage.call(this, target);
  4918. };
  4919.  
  4920. Yanfly.BEC.Window_BattleLog_displayMpDamage =
  4921.     Window_BattleLog.prototype.displayMpDamage;
  4922. Window_BattleLog.prototype.displayMpDamage = function(target) {
  4923.     if (!eval(Yanfly.Param.BECShowMpText)) return;
  4924.     Yanfly.BEC.Window_BattleLog_displayMpDamage.call(this, target);
  4925. };
  4926.  
  4927. Yanfly.BEC.Window_BattleLog_displayTpDamage =
  4928.     Window_BattleLog.prototype.displayTpDamage;
  4929. Window_BattleLog.prototype.displayTpDamage = function(target) {
  4930.     if (!eval(Yanfly.Param.BECShowTpText)) return;
  4931.     Yanfly.BEC.Window_BattleLog_displayTpDamage.call(this, target);
  4932. };
  4933.  
  4934. Yanfly.BEC.Window_BattleLog_displayCurrentState =
  4935.     Window_BattleLog.prototype.displayCurrentState;
  4936. Window_BattleLog.prototype.displayCurrentState = function(subject) {
  4937.     if (!eval(Yanfly.Param.BECShowStateText)) return;
  4938.     Yanfly.BEC.Window_BattleLog_displayCurrentState.call(this, subject);
  4939. };
  4940.  
  4941. Yanfly.BEC.Window_BattleLog_displayAddedStates =
  4942.     Window_BattleLog.prototype.displayAddedStates;
  4943. Window_BattleLog.prototype.displayAddedStates = function(target) {
  4944.     if (!eval(Yanfly.Param.BECShowStateText)) return;
  4945.     Yanfly.BEC.Window_BattleLog_displayAddedStates.call(this, target);
  4946. };
  4947.  
  4948. Yanfly.BEC.Window_BattleLog_displayRemovedStates =
  4949.     Window_BattleLog.prototype.displayRemovedStates;
  4950. Window_BattleLog.prototype.displayRemovedStates = function(target) {
  4951.     if (!eval(Yanfly.Param.BECShowStateText)) return;
  4952.     Yanfly.BEC.Window_BattleLog_displayRemovedStates.call(this, target);
  4953. };
  4954.  
  4955. Yanfly.BEC.Window_BattleLog_displayChangedBuffs =
  4956.     Window_BattleLog.prototype.displayChangedBuffs;
  4957. Window_BattleLog.prototype.displayChangedBuffs = function(target) {
  4958.     if (!eval(Yanfly.Param.BECShowBuffText)) return;
  4959.     Yanfly.BEC.Window_BattleLog_displayChangedBuffs.call(this, target);
  4960. };
  4961.  
  4962. Window_BattleLog.prototype.popupDamage = function(target) {
  4963. };
  4964.  
  4965. Yanfly.BEC.Window_BattleLog_showEnemyAttackAnimation =
  4966.     Window_BattleLog.prototype.showEnemyAttackAnimation;
  4967. Window_BattleLog.prototype.showEnemyAttackAnimation =
  4968. function(subject, targets) {
  4969.     if ($gameSystem.isSideView()) {
  4970.       this.showNormalAnimation(targets, subject.attackAnimationId(), false);
  4971.     } else {
  4972.       this.showNormalAnimation(targets, subject.attackAnimationId(), false);
  4973.       Yanfly.BEC.Window_BattleLog_showEnemyAttackAnimation.call(this, subject,
  4974.           targets);
  4975.     }
  4976. };
  4977.  
  4978. Window_BattleLog.prototype.showActorAtkAniMirror = function(subject, targets) {
  4979.     this.showNormalAnimation(targets, subject.attackAnimationId1(), true);
  4980.     this.showNormalAnimation(targets, subject.attackAnimationId2(), false);
  4981. };
  4982.  
  4983. //=============================================================================
  4984. // New Function
  4985. //=============================================================================
  4986.  
  4987. Yanfly.Util = Yanfly.Util || {};
  4988.  
  4989. if (!Yanfly.Util.toGroup) {
  4990.     Yanfly.Util.toGroup = function(inVal) {
  4991.         return inVal;
  4992.     }
  4993. };
  4994.  
  4995. Yanfly.Util.getRange = function(n, m) {
  4996.     var result = [];
  4997.     for (var i = n; i <= m; ++i) result.push(i);
  4998.     return result;
  4999. };
  5000.  
  5001. Yanfly.Util.onlyUnique = function(value, index, self) {
  5002.     return self.indexOf(value) === index;
  5003. };
  5004.  
  5005. //=============================================================================
  5006. // End of File
  5007. //=============================================================================
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-12-24 01:21

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表