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

Project1

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

[已经解决] YEP_BattleEngineCore插件战斗信息问题

[复制链接]

Lv4.逐梦者

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

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

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

x
本帖最后由 347780682 于 2016-3-11 21:49 编辑

使用BattleEngineCore插件之后战斗信息就变成这样了





我想让他还原成这样,该怎么改?




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

Lv1.梦旅人

梦石
0
星屑
230
在线时间
174 小时
注册时间
2016-2-24
帖子
107
2
发表于 2016-3-11 23:51:53 | 只看该作者
插件参数里最后一项LOG下面全部改成true

评分

参与人数 1星屑 +166 收起 理由
余烬之中 + 166 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

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

GMT+8, 2024-12-24 03:17

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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