查看: 2629|回复: 1

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

[复制链接]
梦石
0
星屑
6963
在线时间
1557 小时
注册时间
2011-6-14
回帖
425
发表于 2016-3-11 21:47:57 | 显示全部楼层 |阅读模式

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

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

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

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


`}~~9CJ`XJYV3}LX(@W]7YA.png


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


H5KUP[@T]IK[9N`FMXY6NO1.png

  1. //=============================================================================
  2. // Yanfly Engine Plugins - Battle Engine Core
  3. // YEP_BattleEngineCore.js
  4. //=============================================================================

  5. var Imported = Imported || {};
  6. Imported.YEP_BattleEngineCore = true;

  7. var Yanfly = Yanfly || {};
  8. Yanfly.BEC = Yanfly.BEC || {};

  9. //=============================================================================
  10. /*:
  11. * @plugindesc v1.33 Have more control over the flow of the battle system
  12. * with this plugin and alter various aspects to your liking.
  13. * @author Yanfly Engine Plugins
  14. *
  15. * @param ---General---
  16. * @default
  17. *
  18. * @param Action Speed
  19. * @desc This is the formula used for an action's base speed.
  20. * Default: agi + Math.randomInt(Math.floor(5 + agi / 4))
  21. * @default agi
  22. *
  23. * @param Default System
  24. * @desc This is the default battle system your game uses.
  25. * Default: dtb
  26. * @default dtb
  27. *
  28. * @param ---Escape---
  29. * @default
  30. *
  31. * @param Escape Ratio
  32. * @desc This is the formula used to determine escape success.
  33. * Default: 0.5 * $gameParty.agility() / $gameTroop.agility()
  34. * @default 0.5 * $gameParty.agility() / $gameTroop.agility()
  35. *
  36. * @param Fail Escape Boost
  37. * @desc Each time the player fails escape, increase the success
  38. * rate by this much. Default: 0.1
  39. * @default 0.1
  40. *
  41. * @param ---Animation---
  42. * @default
  43. *
  44. * @param Animation Base Delay
  45. * @desc This sets the base delay in between animations.
  46. * Default: 8
  47. * @default 0
  48. *
  49. * @param Animation Next Delay
  50. * @desc This sets the sequential delay in between animations.
  51. * Default: 12
  52. * @default 0
  53. *
  54. * @param Certain Hit Animation
  55. * @desc Default animation to play for certain hit skills.
  56. * Use 0 if you wish for no animation.
  57. * @default 120
  58. *
  59. * @param Physical Animation
  60. * @desc Default animation to play for physical skills.
  61. * Use 0 if you wish for no animation.
  62. * @default 52
  63. *
  64. * @param Magical Animation
  65. * @desc Default animation to play for magical skills.
  66. * Use 0 if you wish for no animation.
  67. * @default 51
  68. *
  69. * @param Enemy Attack Animation
  70. * @desc This is the default attack animation played by enemies.
  71. * Default: 0
  72. * @default 39
  73. *
  74. * @param Reflect Animation
  75. * @desc The animation used when magic attacks are reflected.
  76. * @default 42
  77. *
  78. * @param Motion Waiting
  79. * @desc Play animations after performing an action or during?
  80. * During - false     After - true     Default: false
  81. * @default false
  82. *
  83. * @param ---Frontview---
  84. * @default
  85. *
  86. * @param Front Position X
  87. * @desc This formula determines the actor's home X position.
  88. * Default: 0
  89. * @default Graphics.boxWidth / 8 + Graphics.boxWidth / 4 * index
  90. *
  91. * @param Front Position Y
  92. * @desc This formula determines the actor's home Y position.
  93. * Default: 0
  94. * @default Graphics.boxHeight - 180
  95. *
  96. * @param Front Actor Sprite
  97. * @desc Show the actor battle sprite in frontview?
  98. * NO - false     YES - true     Default - false
  99. * @default false
  100. *
  101. * @param Front Sprite Priority
  102. * @desc Give actor sprites the priority of always being on top?
  103. * 0 - Normal   1 - Actors on Top   2 - Enemies on Top
  104. * @default 1
  105. *
  106. * @param ---Sideview---
  107. * @default
  108. *
  109. * @param Home Position X
  110. * @desc This formula determines the actor's home X position.
  111. * Default: 600 + index * 32
  112. * @default screenWidth - 16 - (maxSize + 2) * 32 + index * 32
  113. *
  114. * @param Home Position Y
  115. * @desc This formula determines the actor's home Y position.
  116. * Default: 280 + index * 48
  117. * @default screenHeight - statusHeight - maxSize * 48 + (index+1) * 48 - 32
  118. *
  119. * @param Side Sprite Priority
  120. * @desc Give actor sprites the priority of always being on top?
  121. * 0 - Normal   1 - Actors on Top   2 - Enemies on Top
  122. * @default 1
  123. *
  124. * @param ---Sprites---
  125. * @default
  126. *
  127. * @param Default X Anchor
  128. * @desc Default value used for your sprites's X Anchor.
  129. * Default: 0.5
  130. * @default 0.5
  131. *
  132. * @param Default Y Anchor
  133. * @desc Default value used for your sprites's Y Anchor.
  134. * Default: 1.0
  135. * @default 1.0
  136. *
  137. * @param Step Distance
  138. * @desc This is the distance a unit steps forward for actions.
  139. * Default: 48
  140. * @default 48
  141. *
  142. * @param Flinch Distance
  143. * @desc In sideview, when a unit takes damage or dodges, it will
  144. * flinch a certain distance in pixels.
  145. * @default 12
  146. *
  147. * @param Show Shadows
  148. * @desc Do you wish to have shadows appear under actors?
  149. * NO - false     YES - true
  150. * @default true
  151. *
  152. * @param ---Damage Popups---
  153. * @default
  154. *
  155. * @param Popup Duration
  156. * @desc Adjusts how many frames a popup will stay visible for.
  157. * Default: 90
  158. * @default 128
  159. *
  160. * @param Newest Popup Bottom
  161. * @desc Places the newest popup at the bottom of a group.
  162. * NO - false     YES - true
  163. * @default true
  164. *
  165. * @param Popup Overlap Rate
  166. * @desc When multiple damage popups appear, they cover each other.
  167. * Use this to change the buffer rate amount for each sprite.
  168. * @default 0.9
  169. *
  170. * @param Critical Popup
  171. * @desc Adjusts the popup's flashing color for critical hits.
  172. * Default: 255, 0, 0, 160
  173. * @default 255, 0, 0, 160
  174. *
  175. * @param Critical Duration
  176. * @desc How many frames the flashing will remain for a critical.
  177. * Default: 60
  178. * @default 60
  179. *
  180. * @param ---Tick-Settings---
  181. * @default
  182. *
  183. * @param Timed States
  184. * @desc If the battle system is Tick-based, use time instead of
  185. * turns for states? NO - false   YES - true
  186. * @default false
  187. *
  188. * @param Timed Buffs
  189. * @desc If the battle system is Tick-based, use time instead of
  190. * turns for buffs? NO - false   YES - true
  191. * @default false
  192. *
  193. * @param Turn Time
  194. * @desc How many ticks must past to equal 1 turn?
  195. * @default 100
  196. *
  197. * @param AI Self Turns
  198. * @desc Set AI to be based on their own individual turns?
  199. * NO - false     YES - true
  200. * @default true
  201. *
  202. * @param ---Window Settings---
  203. * @default
  204. *
  205. * @param Lower Windows
  206. * @desc Places the skill and item windows at the screen's bottom.
  207. * OFF - false     ON - true
  208. * @default true
  209. *
  210. * @param Window Rows
  211. * @desc For lower windows, how many rows of items do you wish for
  212. * the windows to display?
  213. * @default 4
  214. *
  215. * @param Command Window Rows
  216. * @desc Sets the number of rows for each command window to display.
  217. * Default: 4
  218. * @default 4
  219. *
  220. * @param Command Alignment
  221. * @desc Sets the text alignment for the Party/Actor Commands.
  222. * Default: left
  223. * @default center
  224. *
  225. * @param Start Actor Command
  226. * @desc Starts turn with the Actor Command Window instead of Party.
  227. * OFF - false     ON - true
  228. * @default true
  229. *
  230. * @param Current Max
  231. * @desc Display the entire current / max value of HP/MP?
  232. * NO - false     YES - true     Default: true
  233. * @default false
  234. *
  235. * @param ---Selection Help---
  236. * @default
  237. *
  238. * @param Mouse Over
  239. * @desc Allows you to mouse over the enemies to auto-select them.
  240. * OFF - false     ON - true
  241. * @default true
  242. *
  243. * @param Select Help Window
  244. * @desc When selecting actors and enemies, show the help window?
  245. * NO - false     YES - true
  246. * @default true
  247. *
  248. * @param User Help Text
  249. * @desc The singular form of 'User' used in a help window.
  250. * @default User
  251. *
  252. * @param Ally Help Text
  253. * @desc The singular form of 'Ally' used in a help window.
  254. * @default Ally
  255. *
  256. * @param Allies Help Text
  257. * @desc The plural form of 'Allies' used in a help window.
  258. * @default Allies
  259. *
  260. * @param Enemy Help Text
  261. * @desc The singular form of 'Enemy' used in a help window.
  262. * @default Enemy
  263. *
  264. * @param Enemies Help Text
  265. * @desc The plural form of 'Enemy' used in a help window.
  266. * @default Enemies
  267. *
  268. * @param All Help Text
  269. * @desc When selecting a entire group of targets.
  270. * %1 - Target Group (Allies or Enemies)
  271. * @default All %1
  272. *
  273. * @param Random Help Text
  274. * @desc When selecting a random selection of targets.
  275. * %1 - Target Group (Allies or Enemies)     %2 - Number
  276. * @default %2 Random %1
  277. *
  278. * @param ---Enemy Select---
  279. * @default
  280. *
  281. * @param Visual Enemy Select
  282. * @desc Replaces the enemy selection screen with a more visual one.
  283. * OFF - false     ON - true
  284. * @default true
  285. *
  286. * @param Show Enemy Name
  287. * @desc Show enemy names with Visual Enemy Select.
  288. * OFF - false     ON - true
  289. * @default true
  290. *
  291. * @param Show Select Box
  292. * @desc Show a selection box when selecting enemies.
  293. * OFF - false     ON - true
  294. * @default false
  295. *
  296. * @param Enemy Font Size
  297. * @desc Changes the font size used to display enemy names.
  298. * Default: 28
  299. * @default 20
  300. *
  301. * @param Enemy Auto Select
  302. * @desc Changes what enemy is automatically selected at first.
  303. * LEFT - 0     RIGHT - this.furthestRight()
  304. * @default this.furthestRight()
  305. *
  306. * @param ---Actor Select---
  307. * @default
  308. *
  309. * @param Visual Actor Select
  310. * @desc Allows you to click the actor on screen to select it.
  311. * OFF - false     ON - true
  312. * @default true
  313. *
  314. * @param ---Battle Log---
  315. * @default
  316. *
  317. * @param Show Emerge Text
  318. * @desc Shows the battle start text for enemies appearing.
  319. * OFF - false     ON - true
  320. * @default false
  321. *
  322. * @param Show Pre-Emptive Text
  323. * @desc Shows the text for getting a pre-emptive attack.
  324. * OFF - false     ON - true
  325. * @default true
  326. *
  327. * @param Show Surprise Text
  328. * @desc Shows the text for getting a surprise attack.
  329. * OFF - false     ON - true
  330. * @default true
  331. *
  332. * @param Optimize Speed
  333. * @desc Cuts log base line process to optimize the battle speed.
  334. * OFF - false     ON - true
  335. * @default true
  336. *
  337. * @param Show Action Text
  338. * @desc Displays full action text or a simplified version of it.
  339. * SIMPLE - false     FULL - true
  340. * @default false
  341. *
  342. * @param Show State Text
  343. * @desc Shows all text regarding states.
  344. * OFF - false     ON - true
  345. * @default false
  346. *
  347. * @param Show Buff Text
  348. * @desc Shows all text regarding buffs.
  349. * OFF - false     ON - true
  350. * @default false
  351. *
  352. * @param Show Counter Text
  353. * @desc Shows text regarding counter attacks.
  354. * OFF - false     ON - true
  355. * @default true
  356. *
  357. * @param Show Reflect Text
  358. * @desc Shows text regarding reflected spells.
  359. * OFF - false     ON - true
  360. * @default true
  361. *
  362. * @param Show Substitute Text
  363. * @desc Shows text regarding substituted damage.
  364. * OFF - false     ON - true
  365. * @default true
  366. *
  367. * @param Show Fail Text
  368. * @desc Shows text regarding failed attacks.
  369. * OFF - false     ON - true
  370. * @default false
  371. *
  372. * @param Show Critical Text
  373. * @desc Shows text regarding critical hits.
  374. * OFF - false     ON - true
  375. * @default false
  376. *
  377. * @param Show Miss Text
  378. * @desc Shows text regarding missed attacks.
  379. * OFF - false     ON - true
  380. * @default false
  381. *
  382. * @param Show Evasion Text
  383. * @desc Shows text regarding evaded attacks.
  384. * OFF - false     ON - true
  385. * @default false
  386. *
  387. * @param Show HP Text
  388. * @desc Shows text regarding HP damage or heals.
  389. * OFF - false     ON - true
  390. * @default false
  391. *
  392. * @param Show MP Text
  393. * @desc Shows text regarding MP damage or heals.
  394. * OFF - false     ON - true
  395. * @default false
  396. *
  397. * @param Show TP Text
  398. * @desc Shows text regarding TP damage or heals.
  399. * OFF - false     ON - true
  400. * @default false
  401. *
  402. * @help
  403. * ============================================================================
  404. * Introduction
  405. * ============================================================================
  406. *
  407. * This plugin alters the various aspects of the default battle system,
  408. * allowing it to be more streamlined like most modern RPG's and less clunky
  409. * like older RPG's. This ranges from choosing what text will appear in the
  410. * battle log window at the top and how it will be displayed.
  411. *
  412. * ============================================================================
  413. * Battle Messages
  414. * ============================================================================
  415. *
  416. * When changing "Terms" and the "Messages" that appear in battle, inserting
  417. * the following tag anywhere in the message will cause the message to center
  418. * itself in the battle log.
  419. *
  420. *   <CENTER>
  421. *   This tag must be all caps in order for the battle log window to recognize
  422. *   it as an instruction to center the displayed battle text message.
  423. *
  424. * There are a couple of notetags you can use to change the way certain skills
  425. * and items will show up incase you don't want a name like 'Harold's Attack'
  426. * to appear in the name.
  427. *
  428. * Skill and Item Notetags:
  429. *
  430. *   <Display Text: x>
  431. *   This will change the text displayed to x.
  432. *
  433. *   <Display Icon: x>
  434. *   This will change the icon displayed to x.
  435. *
  436. * ============================================================================
  437. * Battle Windows
  438. * ============================================================================
  439. *
  440. * There's various options to adjust the window settings found in the battle
  441. * system to make navigating the battle system more intuitive. Such options
  442. * include starting the turns with the Actor Command Window instead of the
  443. * Party Command Window (the Fight/Escape Window). The Party Command Window is
  444. * still accessible but only by pressing cancel on the first actor's window.
  445. *
  446. * ============================================================================
  447. * Battle Order
  448. * ============================================================================
  449. *
  450. * The battle turn order is also fixed, too. This way, any battlers that Have
  451. * their AGI value changed over the course of battle will reflect those changes
  452. * during the current turn rather than the following turn. The action speed
  453. * calculation can also be adjusted and finetuned to have the random factor of
  454. * its speed calculation formula removed, too, making AGI actually worthwhile
  455. * as a tactical parameter.
  456. *
  457. * Skill and Item Notetag:
  458. *   <speed: +x>
  459. *   <speed: -x>
  460. *   This lets you break past the editor's limit of -2000 and 2000 allowing you
  461. *   to set the speed of your actions with more control.
  462. *
  463. * ============================================================================
  464. * Multiple Hits
  465. * ============================================================================
  466. *
  467. * Multi-hit action will no longer end prematurely if the target dies midway
  468. * through the action. This is done through toggling immortal states. To make
  469. * use of feature, make sure your database has an Immortal State somewhere. If
  470. * you do not wish to use this feature, set the Parameter for Immortal State ID
  471. * to 0 instead.
  472. *
  473. * ============================================================================
  474. * Popup Revamp
  475. * ============================================================================
  476. *
  477. * Although the damage popups may still look the same as the default ones from
  478. * MV, the process in which they're created is now different to streamline the
  479. * damage popup process. Before, popups would only appear one a time with a
  480. * frame's different at minimum in order for them to show. Now, any actions
  481. * that occur at the same frame will now all show popups at the same frame,
  482. * making for smoother and less clunky damage popups.
  483. *
  484. * ============================================================================
  485. * Common Events
  486. * ============================================================================
  487. *
  488. * Common Events will now occur at the end of each action regardless of whether
  489. * or not the enemy party is still alive. With proper placing of the action
  490. * sequence tags, you can make the skill's common event occur in the middle of
  491. * an action, too. However, keep in mind if you force an action in the middle
  492. * of another action, the remainder of the former action's sequence list will
  493. * become null and void in favor of the new forced action.
  494. *
  495. * ============================================================================
  496. * Casting Animations
  497. * ============================================================================
  498. *
  499. * Casting Animations help provide visual hints for players either by letting
  500. * them know which battler is going to perform an action or what type of skill
  501. * that action will be. This plugin enables skills to have casting animations
  502. * that can be modified universally or customized for each individual skill.
  503. *
  504. * Skill Notetag:
  505. *   <Cast Animation: x>
  506. *   Sets the skill's cast animation to animation ID x. Setting x to zero will
  507. *   cause the skill to not have any animaton at all.
  508. *
  509. * ============================================================================
  510. * Changing Battle Systems
  511. * ============================================================================
  512. *
  513. * While the player is not in battle, you can change the battle system using a
  514. * Plugin Command. With only this plugin, there is only one battle system
  515. * included: the default battle system.
  516. *
  517. * Plugin Command:
  518. *   setBattleSys DTB      Sets battle system to Default Turn Battle.
  519. *
  520. * Other future plugins may include other battle systems that may utilize the
  521. * Battle Engine Core.
  522. *
  523. * ============================================================================
  524. * Sideview Actions
  525. * ============================================================================
  526. *
  527. * In RPG Maker MV's default battle system, both the sideview and the frontview
  528. * settings do not display counterattacks, reflected magic attacks, nor any
  529. * case of substituting for battle members. The Battle Engine Core provides
  530. * games that are using the sideview settings small amounts of animations to
  531. * relay information to the player in a more visual sense.
  532. *
  533. * Magic Reflection will also display a reflection animation to indicate the
  534. * battler has reflection properties. This animation can be changed in the
  535. * parameters, but certain actors, classes, enemies, weapons, armors, and
  536. * states can display a unique kind of animation for reflection if desired.
  537. *
  538. * Actor, Class, Enemy, Weapon, Armor, and State Notetag:
  539. *   <Reflect Animation ID: x>
  540. *   Changes the user's reflect animation to x. This will take priority in the
  541. *   following order: Actor, Class, Enemy, Weapon, Armor, State, Default.
  542. *
  543. * Sometimes, you don't want your enemies to be able to move. Or you don't want
  544. * certain actors to be able to move. They're just stationary for whatever
  545. * reason. To accomplish that, you can use this notetag to forbid the battler
  546. * from moving.
  547. *
  548. * Actor, Class, Enemy, Weapon, Armor, and State Notetag:
  549. *   <Sprite Cannot Move>
  550. *   Prevents the battler's sprite from moving. This will take priority in the
  551. *   following order: Actor, Class, Enemy, Weapon, Armor, and State. If an
  552. *   enemy is unable to move when it performs an action, it will flash white as
  553. *   if it normally does in front view.
  554. *
  555. * ============================================================================
  556. * Custom Sideview Battler Anchor
  557. * ============================================================================
  558. *
  559. * Sideview battlers are generally centered horizontally, and grounded at their
  560. * feet. However, not all sideview battler spritesheets work this way. In the
  561. * event you have a sideview battler that doesn't conform to those standards,
  562. * you can 'anchor' them a different way.
  563. *
  564. * Actor, Class, Weapon, Armor, State Notetags:
  565. *   <Anchor X: y.z>
  566. *   <Anchor Y: y.z>
  567. *   This sets the anchor location for the actor's sideview battler at y.z.
  568. *   By default, the X anchor is 0.5 while the Y anchor is 1.0. If you want
  569. *   the X anchor to be a bit more to the left, make it less than 0.5. Make it
  570. *   more than 0.5 to make the X anchor more towards the right. To raise the
  571. *   Y anchor, set the number value to less than 1.0. Keep adjusting until you
  572. *   find that perfect anchor setting.
  573. *
  574. * If an anchor has multiple traits that yield different anchors, it will be
  575. * used in a priority list akin to this order:
  576. *
  577. *   States
  578. *   Weapons
  579. *   Armors
  580. *   Class
  581. *   Actor
  582. *   Default
  583. *
  584. * The higher it is on the priority list, the higher its priority.
  585. *
  586. * ============================================================================
  587. * Enemy Attack Animation
  588. * ============================================================================
  589. *
  590. * To give your enemies unique attack animations, you can use this notetag:
  591. *
  592. * Enemy Notetag:
  593. *   <Attack Animation: x>
  594. *   Replace x with the ID of the battle animation you wish to set as the
  595. *   enemy's default attack animation.
  596. *
  597. * ============================================================================
  598. * Automatic State Removal Conditions
  599. * ============================================================================
  600. *
  601. * By default, RPG Maker MV's battle system has automatic state removal under
  602. * three different conditions: none, action end, turn end.
  603. *
  604. * None and Turn End are working as intended. However, Action End, however, had
  605. * the states removed at the start of the battler's action rather than the end.
  606. * This is changed and updated to occur only at the end of a battler's action.
  607. *
  608. * Two more automatic conditions are now added: Action Start and Turn Start.
  609. * These can be added and implemented using the following notetags:
  610. *
  611. * State Notetags:
  612. *   <Action Start: x>
  613. *   <Action Start: x to y>
  614. *   This will cause this state to update its turns remaining at the start of
  615. *   an action. x is the number of turns it will last. If you use x to y, upon
  616. *   applying the state, the state will be removed a random number of turns
  617. *   from x to y.
  618. *
  619. *   <Turn Start: x>
  620. *   <Turn Start: x to y>
  621. *   This will cause the state to update its turns remaining at the start of a
  622. *   battle turn. x is the number of turns it will last. If you use x to y,
  623. *   upon applying the state, the state will be removed a random number of
  624. *   turns from x to y.
  625. *
  626. * States with Action End have a unique trait to them where if the caster of
  627. * the state is the current active battler (subject) and if the state is then
  628. * applied on the user itself, they will gain a 'free turn'. The 'free turn' is
  629. * to mitigate the user from losing 1 duration of the turn since with an Action
  630. * End timing, they would lose the benefit of being under the state for that
  631. * turn's timing.
  632. *
  633. * ============================================================================
  634. * Action Sequences
  635. * ============================================================================
  636. *
  637. * The Yanfly Engine Plugins - Battle Engine Core includes the capability of
  638. * using custom action sequences. Action sequences are basic instructions for
  639. * the game to creating a customized skill both visually and mechanically.
  640. * The Battle Engine Core, however, will only include the most basic of action
  641. * sequences so the instructions on how to create a custom action sequence will
  642. * be included in the Help file on future extension plugins for this plugin.
  643. *
  644. * ============================================================================
  645. * Changelog
  646. * ============================================================================
  647. *
  648. * Version 1.33:
  649. * - Updated for RPG Maker MV version 1.1.0.
  650. *
  651. * Version 1.32d:
  652. * - Fixed a bug that caused a crash when an actor died.
  653. * - Added a motion engine to be used for future plugins.
  654. * - Preparation for a future plugin.
  655. * - <Anchor X: y.z> and <Anchor Y: y.z> notetags for actors are now extended
  656. * to actors, classes, weapons, armors, and states.
  657. * - Added <Display Text: x> and <Display Icon: x> notetags for skills and
  658. * items. These notetags will alter the display name shown and icon shown
  659. * respectively while performing a skill.
  660. * - Switched Magic Reflect checking order with Counterattack checking order.
  661. * This is to give priority to reflected actions over countered actions.
  662. *
  663. * Version 1.31b:
  664. * - States with Action End now have a unique trait to them where if the caster
  665. * of the state is the current active battler (subject) and if the state is
  666. * then applied on the user itself, they will gain a 'free turn'. The 'free
  667. * turn' is to mitigate the user from losing 1 duration of the turn since with
  668. * an Action End timing, they would lose the benefit of being under the state
  669. * for that turn's timing.
  670. * - Added failsafes for Free Turns in case other plugins have overwritten the
  671. * on battle start functions.
  672. * - Added a compatibility update to Animated SV Enemies for dead motion.
  673. *
  674. * Version 1.30:
  675. * - Optimization update.
  676. * - Fixed a bug that prevented added state effects be unable to apply if they
  677. * are an added Death state.
  678. * - Battlelog lines are now able to display text codes.
  679. *
  680. * Version 1.29:
  681. * - Fixed a bug with the 'else if' action sequences not working in the right
  682. * order of sequence conditions.
  683. *
  684. * Version 1.28d:
  685. * - Fixed a bug if instant casting a skill that would make an opponent battler
  686. * to force an action to end incorrectly. Thanks to DoubleX for the fix.
  687. * - Fixed a bug with mouse over not working properly.
  688. * - Fixed a bug regarding forced actions that will cause the battle to freeze
  689. * if the forced action causes the main active subject to leave the battle.
  690. * - Fixed a bug with timed states not updating their turns properly.
  691. * - Changed priority of IF action sequences to higher to no longer interfere
  692. * other action sequences.
  693. *
  694. * Version 1.27:
  695. * - Mechanic change. This will only affect those using turn-based state timing
  696. * mechanics. Turn End state updates are now shifted from Turn End to occur at
  697. * Regeneration timing to have a more synchronized aspect. The timings are very
  698. * close so there's next to no notice in difference. Buff turn updates are also
  699. * moved to the regeneration timing, too.
  700. *
  701. * Version 1.26:
  702. * - Added 'Mouse Over' parameter to Selection Help. This parameter enables
  703. * mouse users to simply hover over the enemy to select them rather than having
  704. * to click an enemy twice to select them.
  705. *
  706. * Version 1.25f:
  707. * - Added failsafes for Forced Action queues.
  708. * - Added 'Show Select Box' parameter when selecting enemies.
  709. * - Fixed a bug that caused End Turn events to not function properly.
  710. * - Battle animations, by default, are positioned relative to the base bitmap
  711. * for its target sprite. However, actor sprites do not have a base bitmap and
  712. * therefore, battle animations, regardless of position, will always target the
  713. * actor sprite's feet. This update now gives actor sprites a base bitmap.
  714. * - Readjusted sprite width and sprite height calculations.
  715. * - Added a failsafe for when no sideview actor graphics are used.
  716. *
  717. * Version 1.24:
  718. * - Implemented a Forced Action queue list. This means if a Forced Action
  719. * takes place in the middle of an action, the action will resume after the
  720. * forced action finishes rather than cancels it out like MV does.
  721. *
  722. * Version 1.23:
  723. * - Fixed a bug that didn't regenerate HP/MP/TP properly for tick-based.
  724. *
  725. * Version 1.22:
  726. * - Fixed a bug within MV that caused Forced Actions at Turn End to prompt and
  727. * trigger all turn-end related activities (such as regeneration and state turn
  728. * updating).
  729. * - Made a mechanic change so that Action Start and Action End state turns do
  730. * not update their turns through forced actions.
  731. *
  732. * Version 1.21:
  733. * - Fixed a bug where states Action End weren't going down properly with DTB.
  734. *
  735. * Version 1.20:
  736. * - Fixed a bug where revived actors using instant cast aren't properly set to
  737. * use actions immediately.
  738. *
  739. * Version 1.19:
  740. * - Added <Attack Animation: x> notetag for enemies.
  741. * - Added 'AI Self Turns' for Tick-Based Battles. Enemies can now have their
  742. * A.I. revolve around their own individual turns rather than the battle's.
  743. * - Mechanic change for states. Following suit with the change to Action End
  744. * removal, there are now two more conditions added: Action Start, Turn Start.
  745. * - Added <Action Start: x>, <Action Start: x to y>, <Turn Start: x>, and
  746. * <Turn Start: x to y> notetags for automatic state removal.
  747. *
  748. * Version 1.18:
  749. * - Fixed a bug with irregular targeting scopes.
  750. * - Fixed an MV-related bug with Recover All event not refreshing battlers.
  751. *
  752. * Version 1.17b:
  753. * - Fixed a bug with action end states to remove multiple at once.
  754. * - Fixed a visual error with flinching sprites.
  755. * - Added 'Current Max' parameter to change HP current/max display in battle.
  756. * - Mechanic change for states that update on Action End to end at the end of
  757. * a battler's turn instead of at the start.
  758. * - Began preparations for another battle system.
  759. *
  760. * Version 1.16:
  761. * - Fixed an issue with mirrored enemies having mirrored state icons.
  762. *
  763. * Version 1.15a:
  764. * - Fixed a bug revolving the status window not updating.
  765. * - Updated default home position formula to better fit other party sizes.
  766. * New Home Position X:
  767. *   screenWidth - 16 - (maxSize + 2) * 32 + index * 32
  768. * New Home Position Y:
  769. *   screenHeight - statusHeight - maxSize * 48 + (index+1) * 48 - 16
  770. *
  771. * Version 1.14:
  772. * - Fixed a bug with Forced Actions locking out the battle.
  773. * - New mechanic: For tick-based battle systems, states with action-end will
  774. * go down in turns based on how many actions took place for the actor instead.
  775. * Previously, they were indistinguishable from states with Turn End removal.
  776. * - New mechanic: Using Instant Skills/Items from YEP_InstantCast.js will also
  777. * cause states with action-end to go down in turns upon using actions.
  778. *
  779. * Version 1.13a:
  780. * - Fixed a bug that made battlebacks disappear.
  781. * - Reworked visual enemy selection.
  782. * - Victory phase doesn't immediately display level up changes in battle
  783. * status window.
  784. * - Fixed a bug with the visual enemy select showing dead enemy names.
  785. *
  786. * Version 1.12b:
  787. * - If the Battle HUD has been hidden for whatever reason during the victory
  788. * sequence, it will be returned.
  789. * - Added <speed: +x> and <speed: -x> notetags to break past editor limits.
  790. * - Added new conditions where the battle won't end until all action sequences
  791. * have been fulfilled.
  792. *
  793. * Version 1.11:
  794. * - Fixed a bug that didn't show HP/MP Regeneration.
  795. *
  796. * Version 1.10:
  797. * - Removed immortal state dependancy. Immortality is now its own setting.
  798. * - Added more abbreviated variables for action speed calculation.
  799. * - Fixed a bug where all-scope attacks would reveal Appear-Halfway enemies.
  800. * - Fixed a bug where the battle wouldn't end if the final enemy was killed
  801. * by state damage.
  802. *
  803. * Version 1.09:
  804. * - Fixed a undefined actor bug for refreshing the status window.
  805. * - Added 'Show Shadows' parameter to the plugin settings.
  806. * - Reworked the default action sequences so that forced actions do not appear
  807. * on top of each other and party-heal animations occur simultaneously.
  808. *
  809. * Version 1.08:
  810. * - Fixed a bug where battlers gaining HP/MP in the damage formula for
  811. * themselves wouldn't trigger popups.
  812. * - Fixed a bug where if the party failed to escape from battle, states that
  813. * would be removed by battle still get removed. *Fixed by Emjenoeg*
  814. * - Fixed a bug where instant death skills didn't work.
  815. * - Changed Sprite Priority settings to decide whether actors, enemies, or
  816. * neither would always be on top.
  817. *
  818. * Version 1.07:
  819. * - Optimized status window to refresh at a minimum.
  820. * - Set up frame work for future plugins:
  821. * - Added 'Escape Ratio' and 'Fail Escape Boost' to parameters to allow users
  822. * to set the escape ratio they want.
  823. * - Added 'Front Sprite Priority' and 'Side Sprite Priority' to parameters to
  824. * dictate if actor sprites are always on top.
  825. * - Added 'Tick-Settings' category for tick-based battle systems.
  826. *
  827. * Version 1.06:
  828. * - Fixed a bug that causes dead actors at the start of battle to not spawn.
  829. * - Fixed a bug where the help window on an empty slot would show the
  830. * previous skill's message.
  831. *
  832. * Version 1.05:
  833. * - Added new target typing: Character X, which allows you to select
  834. * specifically the actor with an actor ID of X if he/she/it is in the party.
  835. * - Fixed a bug that prevented Miss and Evade popups from showing.
  836. *
  837. * Version 1.04:
  838. * - Fixed a bug where popups didn't show under certain animation types.
  839. * - Fixed certain battler motions from not refreshing correctly.
  840. * - Actions with no scope will not trigger the confirmation selection window.
  841. *
  842. * Version 1.03:
  843. * - Added 'Wait for Effect' action sequence.
  844. * - Actions now wait for effects (such as collapsing) to be done before
  845. * continuing on with battle or to end battle.
  846. *
  847. * Version 1.02:
  848. * - Fixed a bug where the help window would retain descriptions on no skills.
  849. * - Synched up weapons with actor sprites so they would occur simultaneously.
  850. * - Fixed an issue where requesting certain motions from enemies that don't
  851. * exist would cause them to crash.
  852. *
  853. * Version 1.01:
  854. * - Skills and items that affect both HP and MP will now show popups for both.
  855. *
  856. * Version 1.00:
  857. * - Finished plugin!
  858. */
  859. //=============================================================================

  860. //=============================================================================
  861. // Parameter Variables
  862. //=============================================================================

  863. Yanfly.Parameters = PluginManager.parameters('YEP_BattleEngineCore');
  864. Yanfly.Param = Yanfly.Param || {};

  865. Yanfly.Param.BECSystem = String(Yanfly.Parameters['Default System']);
  866. Yanfly.Param.BECEscRatio = String(Yanfly.Parameters['Escape Ratio']);
  867. Yanfly.Param.BECEscFail = String(Yanfly.Parameters['Fail Escape Boost']);
  868. Yanfly.Param.CastCertHit = Number(Yanfly.Parameters['Certain Hit Animation']);
  869. Yanfly.Param.CastPhysical = Number(Yanfly.Parameters['Physical Animation']);
  870. Yanfly.Param.CastMagical = Number(Yanfly.Parameters['Magical Animation']);
  871. Yanfly.Param.EnemyAtkAni = Number(Yanfly.Parameters['Enemy Attack Animation']);
  872. Yanfly.Param.BECOptSpeed = String(Yanfly.Parameters['Optimize Speed']);
  873. Yanfly.Param.BECEmergeText = String(Yanfly.Parameters['Show Emerge Text']);
  874. Yanfly.Param.BECPreEmpText = String(Yanfly.Parameters['Show Pre-Emptive Text']);
  875. Yanfly.Param.BECSurpText = String(Yanfly.Parameters['Show Surprise Text']);
  876. Yanfly.Param.BECPopupOverlap = String(Yanfly.Parameters['Popup Overlap Rate']);
  877. Yanfly.Param.BECNewPopBottom = String(Yanfly.Parameters['Newest Popup Bottom']);
  878. Yanfly.Param.BECStartActCmd = String(Yanfly.Parameters['Start Actor Command']);
  879. Yanfly.Param.BECCurMax = eval(String(Yanfly.Parameters['Current Max']));
  880. Yanfly.Param.BECSelectHelp = String(Yanfly.Parameters['Select Help Window']);
  881. Yanfly.Param.BECHelpUserTx = String(Yanfly.Parameters['User Help Text']);
  882. Yanfly.Param.BECHelpAllyTx = String(Yanfly.Parameters['Ally Help Text']);
  883. Yanfly.Param.BECHelpAlliesTx = String(Yanfly.Parameters['Allies Help Text']);
  884. Yanfly.Param.BECHelpEnemyTx = String(Yanfly.Parameters['Enemy Help Text']);
  885. Yanfly.Param.BECHelpEnemiesTx = String(Yanfly.Parameters['Enemies Help Text']);
  886. Yanfly.Param.BECHelpAllTx = String(Yanfly.Parameters['All Help Text']);
  887. Yanfly.Param.BECHelpRandTx = String(Yanfly.Parameters['Random Help Text']);
  888. Yanfly.Param.BECFrontPosX = String(Yanfly.Parameters['Front Position X']);
  889. Yanfly.Param.BECFrontPosY = String(Yanfly.Parameters['Front Position Y']);
  890. Yanfly.Param.BECFrontSprite = String(Yanfly.Parameters['Front Actor Sprite']);
  891. Yanfly.Param.BECFrSpPrio = String(Yanfly.Parameters['Front Sprite Priority']);
  892. Yanfly.Param.BECHomePosX = String(Yanfly.Parameters['Home Position X']);
  893. Yanfly.Param.BECHomePosY = String(Yanfly.Parameters['Home Position Y']);
  894. Yanfly.Param.BECSideSpPrio = String(Yanfly.Parameters['Side Sprite Priority']);
  895. Yanfly.Param.BECAnchorX = Number(Yanfly.Parameters['Default X Anchor']);
  896. Yanfly.Param.BECAnchorY = Number(Yanfly.Parameters['Default Y Anchor']);
  897. Yanfly.Param.BECStepDist = Number(Yanfly.Parameters['Step Distance']);
  898. Yanfly.Param.BECFlinchDist = Number(Yanfly.Parameters['Flinch Distance']);
  899. Yanfly.Param.BECShowShadows = String(Yanfly.Parameters['Show Shadows']);
  900. Yanfly.Param.BECPopupDur = String(Yanfly.Parameters['Popup Duration']);
  901. Yanfly.Param.BECCritPopup = String(Yanfly.Parameters['Critical Popup']);
  902. Yanfly.Param.BECCritDur = String(Yanfly.Parameters['Critical Duration']);
  903. Yanfly.Param.BECActionSpeed = String(Yanfly.Parameters['Action Speed']);
  904. Yanfly.Param.BECReflectAni = Number(Yanfly.Parameters['Reflect Animation']);
  905. Yanfly.Param.BECMotionWait = String(Yanfly.Parameters['Motion Waiting']);
  906. Yanfly.Param.BECTimeStates = String(Yanfly.Parameters['Timed States']);
  907. Yanfly.Param.BECTimeBuffs = String(Yanfly.Parameters['Timed Buffs']);
  908. Yanfly.Param.BECTurnTime = Number(Yanfly.Parameters['Turn Time']);
  909. Yanfly.Param.BECAISelfTurn = eval(String(Yanfly.Parameters['AI Self Turns']));
  910. Yanfly.Param.BECLowerWindows = String(Yanfly.Parameters['Lower Windows']);
  911. Yanfly.Param.BECSelectMouseOver = eval(String(Yanfly.Parameters['Mouse Over']));
  912. Yanfly.Param.BECEnemySelect = String(Yanfly.Parameters['Visual Enemy Select']);
  913. Yanfly.Param.BECActorSelect = String(Yanfly.Parameters['Visual Actor Select']);
  914. Yanfly.Param.BECWindowRows = String(Yanfly.Parameters['Window Rows']);
  915. Yanfly.Param.BECEnemyFontSize = Number(Yanfly.Parameters['Enemy Font Size']);
  916. Yanfly.Param.BECShowEnemyName = String(Yanfly.Parameters['Show Enemy Name']);
  917. Yanfly.Param.BECShowSelectBox = String(Yanfly.Parameters['Show Select Box']);
  918. Yanfly.Param.BECEnemyAutoSel = String(Yanfly.Parameters['Enemy Auto Select']);
  919. Yanfly.Param.BECCommandAlign = String(Yanfly.Parameters['Command Alignment']);
  920. Yanfly.Param.BECCommandRows = String(Yanfly.Parameters['Command Window Rows']);
  921. Yanfly.Param.BECAniBaseDel = String(Yanfly.Parameters['Animation Base Delay']);
  922. Yanfly.Param.BECAniNextDel = String(Yanfly.Parameters['Animation Next Delay']);
  923. Yanfly.Param.BECFullActText = String(Yanfly.Parameters['Show Action Text']);
  924. Yanfly.Param.BECShowCntText = String(Yanfly.Parameters['Show Counter Text']);
  925. Yanfly.Param.BECShowRflText = String(Yanfly.Parameters['Show Reflect Text']);
  926. Yanfly.Param.BECShowSubText = String(Yanfly.Parameters['Show Substitute Text']);
  927. Yanfly.Param.BECShowFailText = String(Yanfly.Parameters['Show Fail Text']);
  928. Yanfly.Param.BECShowCritText = String(Yanfly.Parameters['Show Critical Text']);
  929. Yanfly.Param.BECShowMissText = String(Yanfly.Parameters['Show Miss Text']);
  930. Yanfly.Param.BECShowEvaText = String(Yanfly.Parameters['Show Evasion Text']);
  931. Yanfly.Param.BECShowHpText = String(Yanfly.Parameters['Show HP Text']);
  932. Yanfly.Param.BECShowMpText = String(Yanfly.Parameters['Show MP Text']);
  933. Yanfly.Param.BECShowTpText = String(Yanfly.Parameters['Show TP Text']);
  934. Yanfly.Param.BECShowStateText = String(Yanfly.Parameters['Show State Text']);
  935. Yanfly.Param.BECShowBuffText = String(Yanfly.Parameters['Show Buff Text']);

  936. //=============================================================================
  937. // DataManager
  938. //=============================================================================

  939. Yanfly.BEC.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
  940. DataManager.isDatabaseLoaded = function() {
  941.   if (!Yanfly.BEC.DataManager_isDatabaseLoaded.call(this)) return false;
  942.   if (!Yanfly._loaded_YEP_BattleEngineCore) {
  943.     this.processMELODYNotetags($dataSkills);
  944.     this.processMELODYNotetags($dataItems);
  945.     this.processBECNotetags1($dataSkills);
  946.     this.processBECNotetags2($dataSkills);
  947.     this.processBECNotetags2($dataItems);
  948.     this.processBECNotetags3($dataEnemies);
  949.     this.processBECNotetags4($dataActors);
  950.     this.processBECNotetags4($dataClasses);
  951.     this.processBECNotetags4($dataWeapons);
  952.     this.processBECNotetags4($dataArmors);
  953.     this.processBECNotetags4($dataEnemies);
  954.     this.processBECNotetags4($dataStates);
  955.     this.processBECNotetags5($dataActors, true);
  956.     this.processBECNotetags5($dataClasses, false);
  957.     this.processBECNotetags5($dataWeapons, false);
  958.     this.processBECNotetags5($dataArmors, false);
  959.     this.processBECNotetags5($dataStates, false);
  960.     this.processBECNotetags6($dataStates);
  961.     Yanfly._loaded_YEP_BattleEngineCore = true;
  962.   }
  963.   return true;
  964. };

  965. DataManager.processMELODYNotetags = function(group) {
  966.   for (var n = 1; n < group.length; n++) {
  967.     var obj = group[n];
  968.     if (obj.actionsMade) continue;
  969.     obj.actionsMade = true;
  970.     var notedata = obj.note.split(/[\r\n]+/);

  971.     var actionType = 0;
  972.     this.setDefaultActions(obj);

  973.     for (var i = 0; i < notedata.length; i++) {
  974.       var line = notedata[i];
  975.       if (line.match(/<(?:SETUP ACTION|setup)>/i)) {
  976.         actionType = 1;
  977.         obj.setupActions = [];
  978.       } else if (line.match(/<\/(?:SETUP ACTION|setup)>/i)) {
  979.         var actionType = 0;
  980.       } else if (line.match(/<(?:WHOLE ACTION|whole)>/i)) {
  981.         actionType = 2;
  982.         obj.wholeActions = [];
  983.       } else if (line.match(/<\/(?:WHOLE ACTION|whole)>/i)) {
  984.         var actionType = 0;
  985.       } else if (line.match(/<(?:TARGET ACTION|target)>/i)) {
  986.         actionType = 3;
  987.         obj.targetActions = [];
  988.       } else if (line.match(/<\/(?:TARGET ACTION|target)>/i)) {
  989.         var actionType = 0;
  990.       } else if (line.match(/<(?:FOLLOW ACTION|follow)>/i)) {
  991.         actionType = 4;
  992.         obj.followActions = [];
  993.       } else if (line.match(/<\/(?:FOLLOW ACTION|follow)>/i)) {
  994.         var actionType = 0;
  995.       } else if (line.match(/<(?:FINISH ACTION|finish)>/i)) {
  996.         actionType = 5;
  997.         obj.finishActions = [];
  998.       } else if (line.match(/<\/(?:FINISH ACTION|finish)>/i)) {
  999.         var actionType = 0;
  1000.       } else {
  1001.         this.convertSequenceLine(obj, line, actionType);
  1002.       }
  1003.     }
  1004.   }
  1005. };

  1006. Yanfly.BEC.DefaultActionSetup = [
  1007.     ['CLEAR BATTLE LOG'],
  1008.     ['DISPLAY ACTION'],
  1009.     ['IMMORTAL', ['TARGETS', 'TRUE']],
  1010.     ['PERFORM START'],
  1011.     ['WAIT FOR MOVEMENT'],
  1012.     ['CAST ANIMATION'],
  1013.     ['WAIT FOR ANIMATION']
  1014. ];
  1015. Yanfly.BEC.DefaultActionWhole = [
  1016.     ['PERFORM ACTION'],
  1017. ];
  1018. Yanfly.BEC.DefaultActionTarget = [
  1019.     ['PERFORM ACTION'],
  1020. ];
  1021. if (eval(Yanfly.Param.BECMotionWait)) {
  1022.   Yanfly.BEC.DefaultActionWhole.push(['MOTION WAIT', ['USER']]);
  1023.   Yanfly.BEC.DefaultActionTarget.push(['MOTION WAIT', ['USER']]);
  1024. } else {
  1025.   Yanfly.BEC.DefaultActionWhole.push(['WAIT', [10]]);
  1026.   Yanfly.BEC.DefaultActionTarget.push(['WAIT', [10]]);
  1027. };
  1028. Yanfly.BEC.DefaultActionWhole.push(['ACTION ANIMATION']);
  1029. Yanfly.BEC.DefaultActionWhole.push(['WAIT FOR ANIMATION']);
  1030. Yanfly.BEC.DefaultActionTarget.push(['ACTION ANIMATION']);
  1031. Yanfly.BEC.DefaultActionTarget.push(['WAIT FOR ANIMATION']);
  1032. Yanfly.BEC.DefaultActionFollow = [
  1033. ];
  1034. Yanfly.BEC.DefaultActionFinish = [
  1035.     ['IMMORTAL', ['TARGETS', 'FALSE']],
  1036.     ['WAIT FOR NEW LINE'],
  1037.     ['CLEAR BATTLE LOG'],
  1038.     ['PERFORM FINISH'],
  1039.     ['WAIT FOR MOVEMENT'],
  1040.     ['WAIT FOR EFFECT'],
  1041.     ['ACTION COMMON EVENT'],
  1042. ];
  1043. DataManager.setDefaultActions = function(obj) {
  1044.     obj.setupActions = Yanfly.BEC.DefaultActionSetup.slice();
  1045.     if (this.isWholeAction(obj)) {
  1046.       obj.wholeActions = Yanfly.BEC.DefaultActionWhole.slice();
  1047.       this.addActionEffects(obj, obj.wholeActions);
  1048.       obj.targetActions = [];
  1049.     } else {
  1050.       obj.wholeActions = [];
  1051.       obj.targetActions = Yanfly.BEC.DefaultActionTarget.slice();
  1052.       this.addActionEffects(obj, obj.targetActions);
  1053.     }
  1054.     obj.followActions = Yanfly.BEC.DefaultActionFollow.slice();
  1055.     obj.finishActions = Yanfly.BEC.DefaultActionFinish.slice();
  1056. };

  1057. DataManager.isWholeAction = function(obj) {
  1058.   if (obj.animationId > 0 && $dataAnimations[obj.animationId]) {
  1059.     var animation = $dataAnimations[obj.animationId];
  1060.     if (animation.position === 3) return true;
  1061.     if (animation.position !== 3 && [2, 8, 10].contains(obj.scope)) return true;
  1062.   }
  1063.   return false;
  1064. };

  1065. DataManager.addActionEffects = function(obj, array) {
  1066.     for (;;) {
  1067.       array[array.length] = ['ACTION EFFECT'];
  1068.       array[array.length] = ['DEATH BREAK'];
  1069.       obj.repeats -= 1;
  1070.       if (obj.repeats <= 0) break;
  1071.       array[array.length] = ['WAIT', [8]];
  1072.     }
  1073.     obj.repeats = 1;
  1074. };

  1075. Yanfly.BEC.SeqType6 =
  1076.   /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i;
  1077. Yanfly.BEC.SeqType5 =
  1078.   /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i;
  1079. Yanfly.BEC.SeqType4 =
  1080.   /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*),[ ](.*)/i;
  1081. Yanfly.BEC.SeqType3 =
  1082.   /[ ]*(.*):[ ](.*),[ ](.*),[ ](.*)/i;
  1083. Yanfly.BEC.SeqType2 =
  1084.   /[ ]*(.*):[ ](.*),[ ](.*)/i;
  1085. Yanfly.BEC.SeqType1 =
  1086.   /[ ]*(.*):[ ](.*)/i;
  1087. Yanfly.BEC.SeqType0 =
  1088.   /[ ]*(.*)/i;
  1089. DataManager.convertSequenceLine = function(obj, line, actionType) {
  1090.   if (actionType <= 0 || actionType > 5) return;
  1091.   Yanfly.BEC.SeqType;
  1092.   var seqArgs;
  1093.   if (line.match(Yanfly.BEC.SeqType6)) {
  1094.     Yanfly.BEC.SeqType = RegExp.$1;
  1095.     seqArgs =
  1096.       [RegExp.$2, RegExp.$3, RegExp.$4, RegExp.$5, RegExp.$6, RegExp.$7];
  1097.   } else if (line.match(Yanfly.BEC.SeqType5)) {
  1098.     Yanfly.BEC.SeqType = RegExp.$1;
  1099.     seqArgs = [RegExp.$2, RegExp.$3, RegExp.$4, RegExp.$5, RegExp.$6];
  1100.   } else if (line.match(Yanfly.BEC.SeqType4)) {
  1101.     Yanfly.BEC.SeqType = RegExp.$1;
  1102.     seqArgs = [RegExp.$2, RegExp.$3, RegExp.$4, RegExp.$5];
  1103.   } else if (line.match(Yanfly.BEC.SeqType3)) {
  1104.     Yanfly.BEC.SeqType = RegExp.$1;
  1105.     seqArgs = [RegExp.$2, RegExp.$3, RegExp.$4];
  1106.   } else if (line.match(Yanfly.BEC.SeqType2)) {
  1107.     Yanfly.BEC.SeqType = RegExp.$1;
  1108.     seqArgs = [RegExp.$2, RegExp.$3];
  1109.   } else if (line.match(Yanfly.BEC.SeqType1)) {
  1110.     Yanfly.BEC.SeqType = RegExp.$1;
  1111.     seqArgs = [RegExp.$2];
  1112.   } else if (line.match(Yanfly.BEC.SeqType0)) {
  1113.     Yanfly.BEC.SeqType = RegExp.$1;
  1114.     seqArgs = [];
  1115.   } else {
  1116.     return;
  1117.   }
  1118.   var array = [Yanfly.BEC.SeqType, seqArgs];
  1119.   if (actionType === 1) obj.setupActions[obj.setupActions.length] = array;
  1120.   if (actionType === 2) obj.wholeActions[obj.wholeActions.length] = array;
  1121.   if (actionType === 3) obj.targetActions[obj.targetActions.length] = array;
  1122.   if (actionType === 4) obj.followActions[obj.followActions.length] = array;
  1123.   if (actionType === 5) obj.finishActions[obj.finishActions.length] = array;
  1124. };

  1125. DataManager.processBECNotetags1 = function(group) {
  1126.   var note1 = /<(?:CAST ANIMATION|cast ani):[ ](\d+)>/i;
  1127.   for (var n = 1; n < group.length; n++) {
  1128.     var obj = group[n];
  1129.     var notedata = obj.note.split(/[\r\n]+/);

  1130.     obj.castAnimation = 0;
  1131.     if (obj.hitType === 0) obj.castAnimation = Yanfly.Param.CastCertHit;
  1132.     if (obj.hitType === 1) obj.castAnimation = Yanfly.Param.CastPhysical;
  1133.     if (obj.hitType === 2) obj.castAnimation = Yanfly.Param.CastMagical;

  1134.     for (var i = 0; i < notedata.length; i++) {
  1135.       var line = notedata[i];
  1136.       if (line.match(note1)) {
  1137.         obj.castAnimation = parseInt(RegExp.$1);
  1138.       }
  1139.     }
  1140.   }
  1141. };

  1142. DataManager.processBECNotetags2 = function(group) {
  1143.   var note1 = /<(?:ACTION COPY):[ ](.*):[ ]*(\d+)>/i;
  1144.   var note2 = /<(?:SPEED):[ ]([\+\-]\d+)>/i;
  1145.   var note3 = /<(?:DISPLAY NAME|DISPLAY TEXT):[ ](.*)>/i;
  1146.   var note4 = /<(?:DISPLAY ICON):[ ](\d+)>/i;
  1147.   for (var n = 1; n < group.length; n++) {
  1148.     var obj = group[n];
  1149.     var notedata = obj.note.split(/[\r\n]+/);

  1150.     obj.battleDisplayText = obj.name;
  1151.     obj.battleDisplayIcon = obj.iconIndex;

  1152.     for (var i = 0; i < notedata.length; i++) {
  1153.       var line = notedata[i];
  1154.       if (line.match(note1)) {
  1155.         var text = String(RegExp.$1).toUpperCase();
  1156.         var target;
  1157.         if (['I', 'ITEM'].contains(text)) {
  1158.           target = $dataItems[parseInt(RegExp.$2)];
  1159.         } else if (['S', 'SKILL'].contains(text)) {
  1160.           target = $dataSkills[parseInt(RegExp.$2)];
  1161.         }
  1162.         if (target) {
  1163.           obj.setupActions = target.setupActions.slice();
  1164.           obj.wholeActions = target.wholeActions.slice();
  1165.           obj.targetActions = target.targetActions.slice();
  1166.           obj.followActions = target.followActions.slice();
  1167.           obj.finishActions = target.finishActions.slice();
  1168.         }
  1169.       } else if (line.match(note2)) {
  1170.         obj.speed = parseInt(RegExp.$1);
  1171.       } else if (line.match(note3)) {
  1172.         obj.battleDisplayText = String(RegExp.$1);
  1173.       } else if (line.match(note4)) {
  1174.         obj.battleDisplayIcon = parseInt(RegExp.$1);
  1175.       }
  1176.     }
  1177.   }
  1178. };

  1179. DataManager.processBECNotetags3 = function(group) {
  1180.   var note1 = /<(?:ATTACK ANIMATION|attack ani):[ ](\d+)>/i;
  1181.   for (var n = 1; n < group.length; n++) {
  1182.     var obj = group[n];
  1183.     var notedata = obj.note.split(/[\r\n]+/);

  1184.     obj.attackAnimationId = Yanfly.Param.EnemyAtkAni;

  1185.     for (var i = 0; i < notedata.length; i++) {
  1186.       var line = notedata[i];
  1187.       if (line.match(note1)) {
  1188.         obj.attackAnimationId = parseInt(RegExp.$1);
  1189.       }
  1190.     }
  1191.   }
  1192. };

  1193. DataManager.processBECNotetags4 = function(group) {
  1194.   var note1 = /<(?:REFLECT ANIMATION|reflect ani):[ ](\d+)>/i;
  1195.   for (var n = 1; n < group.length; n++) {
  1196.     var obj = group[n];
  1197.     var notedata = obj.note.split(/[\r\n]+/);

  1198.     obj.reflectAnimationId = 0;
  1199.     obj.spriteCannotMove = false;

  1200.     for (var i = 0; i < notedata.length; i++) {
  1201.       var line = notedata[i];
  1202.       if (line.match(note1)) {
  1203.         obj.reflectAnimationId = parseInt(RegExp.$1);
  1204.       } else if (line.match(/<(?:SPRITE CANNOT MOVE)>/i)) {
  1205.         obj.spriteCannotMove = true;
  1206.       }
  1207.     }
  1208.   }
  1209. };

  1210. DataManager.processBECNotetags5 = function(group, isActor) {
  1211.   for (var n = 1; n < group.length; n++) {
  1212.     var obj = group[n];
  1213.     var notedata = obj.note.split(/[\r\n]+/);

  1214.     if (isActor) {
  1215.       obj.anchorX = Yanfly.Param.BECAnchorX;
  1216.       obj.anchorY = Yanfly.Param.BECAnchorY;
  1217.     }

  1218.     for (var i = 0; i < notedata.length; i++) {
  1219.       var line = notedata[i];
  1220.       if (line.match(/<(?:ANCHOR X):[ ](\d+)[.](\d+)>/i)) {
  1221.         obj.anchorX = eval(String(RegExp.$1) + '.' + String(RegExp.$2));
  1222.       } else if (line.match(/<(?:ANCHOR Y):[ ](\d+)[.](\d+)>/i)) {
  1223.         obj.anchorY = eval(String(RegExp.$1) + '.' + String(RegExp.$2));
  1224.       }
  1225.     }
  1226.   }
  1227. };

  1228. DataManager.processBECNotetags6 = function(group) {
  1229.   var note1a = /<(?:ACTION START):[ ](\d+)>/i;
  1230.   var note1b = /<(?:ACTION START):[ ](\d+)[ ](?:THROUGH|to)[ ](\d+)>/i;
  1231.   var note2a = /<(?:TURN START):[ ](\d+)>/i;
  1232.   var note2b = /<(?:TURN START):[ ](\d+)[ ](?:THROUGH|to)[ ](\d+)>/i;
  1233.   for (var n = 1; n < group.length; n++) {
  1234.     var obj = group[n];
  1235.     var notedata = obj.note.split(/[\r\n]+/);

  1236.     for (var i = 0; i < notedata.length; i++) {
  1237.       var line = notedata[i];
  1238.       if (line.match(note1a)) {
  1239.         var turns = parseInt(RegExp.$1);
  1240.         obj.autoRemovalTiming = 3;
  1241.         obj.maxTurns = turns;
  1242.         obj.minTurns = turns;
  1243.       } else if (line.match(note1b)) {
  1244.         var turns1 = parseInt(RegExp.$1);
  1245.         var turns2 = parseInt(RegExp.$2);
  1246.         obj.autoRemovalTiming = 3;
  1247.         obj.maxTurns = turns1;
  1248.         obj.minTurns = turns2;
  1249.       } else if (line.match(note2a)) {
  1250.         var turns = parseInt(RegExp.$1);
  1251.         obj.autoRemovalTiming = 4;
  1252.         obj.maxTurns = turns;
  1253.         obj.minTurns = turns;
  1254.       } else if (line.match(note2b)) {
  1255.         var turns1 = parseInt(RegExp.$1);
  1256.         var turns2 = parseInt(RegExp.$2);
  1257.         obj.autoRemovalTiming = 4;
  1258.         obj.maxTurns = turns1;
  1259.         obj.minTurns = turns2;
  1260.       }
  1261.     }
  1262.   }
  1263. };

  1264. //=============================================================================
  1265. // TouchInput
  1266. //=============================================================================

  1267. Yanfly.BEC.TouchInput_onMouseMove = TouchInput._onMouseMove;
  1268. TouchInput._onMouseMove = function(event) {
  1269.     Yanfly.BEC.TouchInput_onMouseMove.call(this, event);
  1270.     this._mouseOverX = Graphics.pageToCanvasX(event.pageX);
  1271.     this._mouseOverY = Graphics.pageToCanvasY(event.pageY);
  1272. };

  1273. //=============================================================================
  1274. // BattleManager
  1275. //=============================================================================

  1276. Yanfly.BEC.BattleManager_initMembers = BattleManager.initMembers;
  1277. BattleManager.initMembers = function() {
  1278.     Yanfly.BEC.BattleManager_initMembers.call(this);
  1279.     this._forceSelection = false;
  1280.     this._allSelection = false;
  1281.     this._victoryPhase = false;
  1282.     this._forceActionQueue = [];
  1283. };

  1284. BattleManager.isBattleSystem = function(value) {
  1285.     return value.toLowerCase() === $gameSystem.getBattleSystem();
  1286. };

  1287. BattleManager.isDTB = function() {
  1288.     return this.isBattleSystem('dtb');
  1289. };

  1290. BattleManager.isTurnBased = function() {
  1291.     if (this.isDTB()) return true;
  1292.     return false;
  1293. };

  1294. BattleManager.isTickBased = function() {
  1295.     return !this.isTurnBased();
  1296. };

  1297. BattleManager.tickRate = function() {
  1298.     return 1;
  1299. };

  1300. BattleManager.forceSelection = function() {
  1301.     this._forceSelection = true;
  1302. };

  1303. BattleManager.isForceSelection = function() {
  1304.     return this._forceSelection;
  1305. };

  1306. BattleManager.resetSelection = function() {
  1307.     this._forceSelection = false;
  1308. };

  1309. BattleManager.startAllSelection = function() {
  1310.     this._allSelection = true;
  1311. };

  1312. BattleManager.isAllSelection = function() {
  1313.      return this._allSelection && BattleManager.isInputting();
  1314. };

  1315. BattleManager.stopAllSelection = function() {
  1316.     this._allSelection = false;
  1317. };

  1318. Yanfly.BEC.BattleManager_makeEscapeRatio = BattleManager.makeEscapeRatio;
  1319. BattleManager.makeEscapeRatio = function() {
  1320.     if (this.isDTB()) {
  1321.       this._escapeRatio = eval(Yanfly.Param.BECEscRatio);
  1322.       this._escapeFailBoost = eval(Yanfly.Param.BECEscFail);
  1323.     } else {
  1324.       this._escapeFailBoost = 0.1;
  1325.       Yanfly.BEC.BattleManager_makeEscapeRatio.call(this);
  1326.     }
  1327. };

  1328. BattleManager.timeBasedStates = function() {
  1329.     if (!$gameParty.inBattle()) return false;
  1330.     if (this.isTurnBased()) return false;
  1331.     if (this._timeBasedStates !== undefined) return this._timeBasedStates;
  1332.     this._timeBasedStates = eval(Yanfly.Param.BECTimeStates);
  1333.     return this._timeBasedStates;
  1334. };

  1335. BattleManager.timeBasedBuffs = function() {
  1336.     if (!$gameParty.inBattle()) return false;
  1337.     if (this.isTurnBased()) return false;
  1338.     if (this._timeBasedBuffs !== undefined) return this._timeBasedBuffs;
  1339.     this._timeBasedBuffs = eval(Yanfly.Param.BECTimeBuffs);
  1340.     return this._timeBasedBuffs;
  1341. };

  1342. BattleManager.displayStartMessages = function() {
  1343.     if (eval(Yanfly.Param.BECEmergeText)) {
  1344.       $gameTroop.enemyNames().forEach(function(name) {
  1345.           $gameMessage.add(TextManager.emerge.format(name));
  1346.       });
  1347.     }
  1348.     if (this._preemptive && eval(Yanfly.Param.BECPreEmpText)) {
  1349.         $gameMessage.add(TextManager.preemptive.format($gameParty.name()));
  1350.     } else if (this._surprise && eval(Yanfly.Param.BECSurpText)) {
  1351.         $gameMessage.add(TextManager.surprise.format($gameParty.name()));
  1352.     }
  1353. };

  1354. BattleManager.registerSprite = function(battler, sprite) {
  1355.   if (!this._registeredSprites) this._registeredSprites = {};
  1356.   if (battler.isActor()) var id = 100000 + battler.actorId();
  1357.   if (battler.isEnemy()) var id = 200000 + battler.index();
  1358.   this._registeredSprites[id] = sprite;
  1359. };

  1360. BattleManager.getSprite = function(battler) {
  1361.   if (!this._registeredSprites) this._registeredSprites = {};
  1362.   if (battler.isActor()) var id = 100000 + battler.actorId();
  1363.   if (battler.isEnemy()) var id = 200000 + battler.index();
  1364.   return this._registeredSprites[id];
  1365. };

  1366. BattleManager.setSpritePriority = function() {
  1367.     if ($gameSystem.isSideView()) {
  1368.       this._spritePriority = eval(Yanfly.Param.BECSideSpPrio);
  1369.     } else {
  1370.       this._spritePriority = eval(Yanfly.Param.BECFrontSprite);
  1371.     }
  1372.     if (this._spritePriority === false) this._spritePriority = 0;
  1373.     if (this._spritePriority === true) this._spritePriority = 1;
  1374. };

  1375. BattleManager.getSpritePriority = function() {
  1376.     if (!this._spritePriority) this.setSpritePriority();
  1377.     return this._spritePriority;
  1378. };

  1379. BattleManager.changeActor = function(newActorIndex, lastActorActionState) {
  1380.     var lastActor = this.actor();
  1381.     this._actorIndex = newActorIndex;
  1382.     var newActor = this.actor();
  1383.     if (lastActor) {
  1384.         lastActor.setActionState(lastActorActionState);
  1385.         lastActor.spriteReturnHome();
  1386.     }
  1387.     if (newActor) {
  1388.         newActor.setActionState('inputting');
  1389.         newActor.spriteStepForward();
  1390.     }
  1391. };

  1392. BattleManager.createActions = function() {
  1393.     $gameParty.createActions();
  1394.     $gameTroop.createActions();
  1395. };

  1396. BattleManager.clearInputtingAction = function() {
  1397.     if (this.inputtingAction()) this.inputtingAction().clear();
  1398. };

  1399. Yanfly.BEC.BattleManager_checkBattleEnd = BattleManager.checkBattleEnd;
  1400. BattleManager.checkBattleEnd = function() {
  1401.     if (this._phase === 'actionList') return false;
  1402.     if (this._phase === 'actionTargetList') return false;
  1403.     if (this._phase === 'action') return false;
  1404.     if (this._phase === 'phaseChange') return false;
  1405.     if ($gameTroop.isEventRunning()) return false;
  1406.     return Yanfly.BEC.BattleManager_checkBattleEnd.call(this);
  1407. };

  1408. Yanfly.BEC.BattleManager_processTurn = BattleManager.processTurn;
  1409. BattleManager.processTurn = function() {
  1410.     this._processTurn = true;
  1411.     Yanfly.BEC.BattleManager_processTurn.call(this);
  1412.     this._processTurn = false;
  1413. };

  1414. Yanfly.BEC.BattleManager_processVictory = BattleManager.processVictory;
  1415. BattleManager.processVictory = function() {
  1416.     this._logWindow.clear();
  1417.     this._victoryPhase = true;
  1418.     if (this._windowLayer) this._windowLayer.x = 0;
  1419.     Yanfly.BEC.BattleManager_processVictory.call(this);
  1420. };

  1421. BattleManager.processEscape = function() {
  1422.     $gameParty.performEscape();
  1423.     SoundManager.playEscape();
  1424.     var success = this._preemptive ? true : (Math.random() < this._escapeRatio);
  1425.     if (success) {
  1426.         $gameParty.performEscapeSuccess();
  1427.         this.displayEscapeSuccessMessage();
  1428.         this._escaped = true;
  1429.         this.processAbort();
  1430.     } else {
  1431.         this.displayEscapeFailureMessage();
  1432.         this._escapeRatio += this._escapeFailBoost;
  1433.         $gameParty.clearActions();
  1434.         this.startTurn();
  1435.     }
  1436.     return success;
  1437. };

  1438. Yanfly.BEC.BattleManager_processAbort = BattleManager.processAbort;
  1439. BattleManager.processAbort = function() {
  1440.     $gameParty.removeBattleStates();
  1441.     Yanfly.BEC.BattleManager_processAbort.call(this);
  1442. };

  1443. BattleManager.startTurn = function() {
  1444.     this._enteredEndPhase = false;
  1445.     this._phase = 'turn';
  1446.     this.clearActor();
  1447.     $gameTroop.increaseTurn();
  1448.     $gameParty.onTurnStart();
  1449.     $gameTroop.onTurnStart();
  1450.     this._performedBattlers = [];
  1451.     this.makeActionOrders();
  1452.     $gameParty.requestMotionRefresh();
  1453.     this._logWindow.startTurn();
  1454.     this._subject = this.getNextSubject();
  1455. };

  1456. Yanfly.BEC.BattleManager_endTurn = BattleManager.endTurn;
  1457. BattleManager.endTurn = function() {
  1458.     if (this.isTurnBased() && this._spriteset.isPopupPlaying()) return;
  1459.     if (this.isTurnBased() && this._enteredEndPhase) {
  1460.       this._phase = 'turnEnd';
  1461.       this._preemptive = false;
  1462.       this._surprise = false;
  1463.       return;
  1464.     }
  1465.     this._enteredEndPhase = true;
  1466.     Yanfly.BEC.BattleManager_endTurn.call(this);
  1467. };

  1468. BattleManager.getNextSubject = function() {
  1469.     if ($gameTroop.turnCount() <= 0) return;
  1470.     this._performedBattlers = this._performedBattlers || [];
  1471.     this.makeActionOrders();
  1472.     for (;;) {
  1473.         var battlerArray = [];
  1474.         for (var i = 0; i < this._actionBattlers.length; ++i) {
  1475.           var obj = this._actionBattlers[i];
  1476.           if (!this._performedBattlers.contains(obj)) battlerArray.push(obj);
  1477.         }
  1478.         this._actionBattlers = battlerArray;
  1479.         var battler = this._actionBattlers.shift();
  1480.         if (!battler) return null;
  1481.         if (battler.isBattleMember() && battler.isAlive()) {
  1482.             this._performedBattlers.push(battler);
  1483.             return battler;
  1484.         }
  1485.     }
  1486. };

  1487. BattleManager.update = function() {
  1488.     if (!this.isBusy() && !this.updateEvent()) {
  1489.         switch (this._phase) {
  1490.         case 'start':
  1491.             this.startInput();
  1492.             break;
  1493.         case 'turn':
  1494.             this.updateTurn();
  1495.             break;
  1496.         case 'action':
  1497.             this.updateAction();
  1498.             break;
  1499.         case 'phaseChange':
  1500.             this.updatePhase();
  1501.             break;
  1502.         case 'actionList':
  1503.             this.updateActionList()
  1504.             break;
  1505.         case 'actionTargetList':
  1506.             this.updateActionTargetList()
  1507.             break;
  1508.         case 'turnEnd':
  1509.             this.updateTurnEnd();
  1510.             break;
  1511.         case 'battleEnd':
  1512.             this.updateBattleEnd();
  1513.             break;
  1514.         }
  1515.     }
  1516. };

  1517. BattleManager.updateEvent = function() {
  1518.     if (this._processingForcedAction) return false;
  1519.     switch (this._phase) {
  1520.     case 'start':
  1521.     case 'turn':
  1522.     case 'turnEnd':
  1523.     case 'actionList':
  1524.     case 'actionTargetList':
  1525.       if (this.isActionForced()) {
  1526.         this.processForcedAction();
  1527.         return true;
  1528.       } else {
  1529.         return this.updateEventMain();
  1530.       }
  1531.     }
  1532.     return this.checkAbort();
  1533. };

  1534. Yanfly.BEC.BattleManager_forceAction = BattleManager.forceAction;
  1535. BattleManager.forceAction = function(battler) {
  1536.     this.createForceActionFailSafes();
  1537.     this.savePreForceActionSettings();
  1538.     Yanfly.BEC.BattleManager_forceAction.call(this, battler);
  1539. };

  1540. BattleManager.createForceActionFailSafes = function() {
  1541.     this._actionList = this._actionList || [];
  1542.     this._targets = this._targets || [];
  1543.     this._allTargets = this._allTargets || [];
  1544.     this._individualTargets = this._individualTargets || [];
  1545.     this._phaseSteps = this._phaseSteps || [];
  1546.     this._conditionFlags = this._conditionFlags || [];
  1547.     this._trueFlags = this._trueFlags || [];
  1548. };

  1549. BattleManager.savePreForceActionSettings = function() {
  1550.     var settings = this.setPreForceActionSettings();
  1551.     this._forceActionQueue.push(settings);
  1552. };

  1553. BattleManager.setPreForceActionSettings = function() {
  1554.     return {
  1555.       subject: this._subject,
  1556.       action: JsonEx.makeDeepCopy(this._action),
  1557.       actionList: JsonEx.makeDeepCopy(this._actionList),
  1558.       targets: this._targets.slice(),
  1559.       allTargets: this._allTargets.slice(),
  1560.       indTargets: this._individualTargets.slice(),
  1561.       phaseSteps: JsonEx.makeDeepCopy(this._phaseSteps),
  1562.       returnPhase: this._returnPhase,
  1563.       phase: this._phase,
  1564.       conditionFlags: JsonEx.makeDeepCopy(this._conditionFlags),
  1565.       trueFlags: JsonEx.makeDeepCopy(this._trueFlags)
  1566.     }
  1567. };

  1568. BattleManager.loadPreForceActionSettings = function() {
  1569.     var settings = this._forceActionQueue[0];
  1570.     if (settings) {
  1571.       this._forceActionQueue.shift();
  1572.       this.resetPreForceActionSettings(settings);
  1573.       return this._subject && this._subject.isAppeared();
  1574.     } else {
  1575.       return false;
  1576.     }   
  1577. };

  1578. BattleManager.resetPreForceActionSettings = function(settings) {
  1579.     this._subject = settings['subject'];
  1580.     this._action = settings['action'];
  1581.     this._actionList = settings['actionList'];
  1582.     this._targets = settings['targets'];
  1583.     this._allTargets = settings['allTargets'];
  1584.     this._individualTargets = settings['indTargets'];
  1585.     this._phaseSteps = settings['phaseSteps'];
  1586.     this._returnPhase = settings['returnPhase'];
  1587.     this._conditionFlags = settings['conditionFlags'];
  1588.     this._trueFlags = settings['trueFlags'];
  1589.     this._phase = settings['phase'];   
  1590. };

  1591. Yanfly.BEC.BattleManager_processForcedAction =
  1592.     BattleManager.processForcedAction;
  1593. BattleManager.processForcedAction = function() {
  1594.     if (this._actionForcedBattler) {
  1595.       this._preForcePhase = this._phase;
  1596.       this._processingForcedAction = true;
  1597.     }
  1598.     Yanfly.BEC.BattleManager_processForcedAction.call(this);
  1599. };

  1600. BattleManager.setTargets = function(array) {
  1601.     this._targets = [];
  1602.     var max = array.length;
  1603.     for (var i = 0; i < max; ++i) {
  1604.       var target = array[i];
  1605.       if (target) this._targets.push(target);
  1606.     }
  1607. };

  1608. BattleManager.updateAction = function() {
  1609.     var target = this._targets.shift();
  1610.     if (target) {
  1611.         this.invokeAction(this._subject, target);
  1612.     } else {
  1613.         if (this._returnPhase === 'target') {
  1614.           this.setTargets([this._individualTargets[0]]);
  1615.           this._phase = 'actionTargetList';
  1616.         } else {
  1617.           this.setTargets(this._allTargets.slice());
  1618.           this._phase = 'actionList';
  1619.         }
  1620.     }
  1621. };

  1622. BattleManager.invokeAction = function(subject, target) {
  1623.   if (!eval(Yanfly.Param.BECOptSpeed))  this._logWindow.push('pushBaseLine');
  1624.   var normal = true;
  1625.   if (Math.random() < this._action.itemMrf(target)) {
  1626.     this.invokeMagicReflection(subject, target);
  1627.   } else if (Math.random() < this._action.itemCnt(target)) {
  1628.     this.invokeCounterAttack(subject, target);
  1629.   } else {
  1630.     this.invokeNormalAction(subject, target);
  1631.   }
  1632.   subject.setLastTarget(target);
  1633.   if (!eval(Yanfly.Param.BECOptSpeed)) this._logWindow.push('popBaseLine');
  1634. };

  1635. BattleManager.invokeCounterAttack = function(subject, target) {
  1636.     var action = new Game_Action(target);
  1637.     this._logWindow.displayCounter(target);
  1638.     action.setAttack();
  1639.     action.apply(subject);
  1640.     this._logWindow.displayActionResults(subject, subject);
  1641.     if (subject.isDead()) subject.performCollapse();
  1642. };

  1643. Yanfly.BEC.BattleManager_invokeMagicReflection =
  1644.     BattleManager.invokeMagicReflection;
  1645. BattleManager.invokeMagicReflection = function(subject, target) {
  1646.     Yanfly.BEC.BattleManager_invokeMagicReflection.call(this, subject, target);
  1647.     if (subject.isDead()) subject.performCollapse();
  1648. };

  1649. BattleManager.updatePhase = function() {
  1650.     var phase = this._phaseSteps.shift();
  1651.     if (phase) this.createPhaseChanges();
  1652.     switch (phase) {
  1653.     case 'setup':
  1654.       this.createSetupActions();
  1655.       break;
  1656.     case 'whole':
  1657.       this.createWholeActions();
  1658.       break;
  1659.     case 'target':
  1660.       this.createTargetActions();
  1661.       break;
  1662.     case 'follow':
  1663.       this.createFollowActions();
  1664.       break;
  1665.     case 'finish':
  1666.       this.createFinishActions();
  1667.       break;
  1668.     default:
  1669.       this.endAction();
  1670.       break;
  1671.     }
  1672. };

  1673. BattleManager.createPhaseChanges = function() {
  1674.     this._phase = 'actionList';
  1675.     this.setTargets(this._allTargets.slice());
  1676.     this._conditionFlags = [];
  1677.     this._trueFlags = [];
  1678. };

  1679. BattleManager.createSetupActions = function() {
  1680.     $gameTemp.clearActionSequenceSettings();
  1681.     this._returnPhase = 'setup';
  1682.     this._actionList = this._action.item().setupActions.slice();
  1683. };

  1684. BattleManager.createWholeActions = function() {
  1685.     this._returnPhase = 'whole';
  1686.     this._actionList = this._action.item().wholeActions.slice();
  1687. };

  1688. BattleManager.createTargetActions = function() {
  1689.     this._returnPhase = 'target';
  1690.     this._phase = 'actionTargetList';
  1691.     this.setTargets([this._individualTargets[0]]);
  1692.     this._actionList = this._action.item().targetActions.slice();
  1693. };

  1694. BattleManager.createFollowActions = function() {
  1695.     this._returnPhase = 'follow';
  1696.     this._actionList = this._action.item().followActions.slice();
  1697. };

  1698. BattleManager.createFinishActions = function() {
  1699.     this._returnPhase = 'finish';
  1700.     this._actionList = this._action.item().finishActions.slice();
  1701. };

  1702. Yanfly.BEC.BattleManager_endAction = BattleManager.endAction;
  1703. BattleManager.endAction = function() {
  1704.     if (this._processingForcedAction) {
  1705.       this._phase = this._preForcePhase;
  1706.     }
  1707.     this._processingForcedAction = false;
  1708.     if (this._subject) this._subject.onAllActionsEnd();
  1709.     if (this.loadPreForceActionSettings()) return;
  1710.     Yanfly.BEC.BattleManager_endAction.call(this);
  1711. };

  1712. BattleManager.updateActionList = function() {
  1713.     for (;;) {
  1714.       this._actSeq = this._actionList.shift();
  1715.       if (this._actSeq) {
  1716.         if (!this.actionConditionsMet(this._actSeq)) continue;
  1717.         var seqName = this._actSeq[0].toUpperCase();
  1718.         if (!this.processActionSequenceCheck(seqName, this._actSeq[1])) {
  1719.           break;
  1720.         }
  1721.       } else {
  1722.         this._phase = 'phaseChange';
  1723.         break;
  1724.       }
  1725.     }
  1726. };

  1727. BattleManager.updateActionTargetList = function() {
  1728.     for (;;) {
  1729.       this._actSeq = this._actionList.shift();
  1730.       if (this._actSeq) {
  1731.         if (!this.actionConditionsMet(this._actSeq)) continue;
  1732.         var seqName = this._actSeq[0].toUpperCase();
  1733.         if (!this.processActionSequenceCheck(seqName, this._actSeq[1])) {
  1734.           break;
  1735.         }
  1736.       } else if (this._individualTargets.length > 0) {
  1737.         this._individualTargets.shift();
  1738.         if (this._individualTargets.length > 0) {
  1739.           this.setTargets([this._individualTargets[0]]);
  1740.           this._actionList = this._action.item().targetActions.slice();
  1741.         } else {
  1742.           this._phase = 'phaseChange';
  1743.           break;
  1744.         }
  1745.       } else {
  1746.         this._phase = 'phaseChange';
  1747.         break;
  1748.       }
  1749.     }
  1750. };

  1751. BattleManager.updateActionTargetList = function() {
  1752.     for (;;) {
  1753.       this._actSeq = this._actionList.shift();
  1754.       if (this._actSeq) {
  1755.         if (!this.actionConditionsMet(this._actSeq)) continue;
  1756.         var seqName = this._actSeq[0].toUpperCase();
  1757.         if (!this.processActionSequenceCheck(seqName, this._actSeq[1])) {
  1758.           break;
  1759.         }
  1760.       } else if (this._individualTargets.length > 0) {
  1761.         this._individualTargets.shift();
  1762.         if (this._individualTargets.length > 0) {
  1763.           this.setTargets([this._individualTargets[0]]);
  1764.           this._actionList = this._action.item().targetActions.slice();
  1765.         } else {
  1766.           this._phase = 'phaseChange';
  1767.           break;
  1768.         }
  1769.       } else {
  1770.         this._phase = 'phaseChange';
  1771.         break;
  1772.       }
  1773.     }
  1774. };

  1775. BattleManager.startAction = function() {
  1776.     var subject = this._subject;
  1777.     var action = subject.currentAction();
  1778.     this._action = action;
  1779.     var targets = action.makeTargets();
  1780.     this.setTargets(targets);
  1781.     this._allTargets = targets.slice();
  1782.     this._individualTargets = targets.slice();
  1783.     this._phase = 'phaseChange';
  1784.     this._phaseSteps = ['setup', 'whole', 'target', 'follow', 'finish'];
  1785.     this._returnPhase = '';
  1786.     this._actionList = [];
  1787.     subject.useItem(this._action.item());
  1788.     this._action.applyGlobal();
  1789.     this._logWindow.startAction(this._subject, this._action, this._targets);
  1790. };

  1791. BattleManager.processActionSequenceCheck = function(actionName, actionArgs) {
  1792.     // IF condition
  1793.     if (actionName.match(/IF[ ](.*)/i)) {
  1794.       return this.actionIfConditions(actionName, actionArgs);
  1795.     }
  1796.     return this.processActionSequence(actionName, actionArgs)
  1797. };

  1798. BattleManager.processActionSequence = function(actionName, actionArgs) {
  1799.     // NO ACTION
  1800.     if (actionName === '') {
  1801.       return true;
  1802.     }
  1803.     // ACTION ANIMATION
  1804.     if (actionName === 'ACTION ANIMATION') {
  1805.       return this.actionActionAnimation(actionArgs);
  1806.     }
  1807.     // ACTION EFFECT
  1808.     if (actionName === 'ACTION COMMON EVENT') {
  1809.       return this.actionActionCommonEvent();
  1810.     }
  1811.     // ACTION EFFECT
  1812.     if (actionName === 'ACTION EFFECT') {
  1813.       return this.actionActionEffect(actionArgs);
  1814.     }
  1815.     // ANI WAIT: frames
  1816.     if (['ANI WAIT', 'ANIWAIT', 'ANIMATION WAIT'].contains(actionName)) {
  1817.       return this.actionAniWait(actionArgs[0]);
  1818.     }
  1819.     // CAST ANIMATION
  1820.     if (actionName === 'CAST ANIMATION') {
  1821.       return this.actionCastAnimation();
  1822.     }
  1823.     // CLEAR BATTLE LOG
  1824.     if (actionName === 'CLEAR BATTLE LOG') {
  1825.       return this.actionClearBattleLog();
  1826.     }
  1827.     // DEATH BREAK
  1828.     if (actionName === 'DEATH BREAK') {
  1829.       return this.actionDeathBreak();
  1830.     }
  1831.     // DISPLAY ACTION
  1832.     if (actionName === 'DISPLAY ACTION') {
  1833.       return this.actionDisplayAction();
  1834.     }
  1835.     // IMMORTAL: targets, true/false
  1836.     if (actionName === 'IMMORTAL') {
  1837.       return this.actionImmortal(actionArgs);
  1838.     }
  1839.     // MOTION WAIT
  1840.     if (actionName === 'MOTION WAIT') {
  1841.       return this.actionMotionWait(actionArgs);
  1842.     }
  1843.     // PERFORM ACTION
  1844.     if (actionName === 'PERFORM ACTION') {
  1845.       return this.actionPerformAction();
  1846.     }
  1847.     // PERFORM FINISH
  1848.     if (actionName === 'PERFORM FINISH') {
  1849.       return this.actionPerformFinish();
  1850.     }
  1851.     // PERFORM START
  1852.     if (actionName === 'PERFORM START') {
  1853.       return this.actionPerformStart();
  1854.     }
  1855.     // WAIT: frames
  1856.     if (actionName === 'WAIT') {
  1857.       return this.actionWait(actionArgs[0]);
  1858.     }
  1859.     // WAIT FOR ANIMATION
  1860.     if (actionName === 'WAIT FOR ANIMATION') {
  1861.       return this.actionWaitForAnimation();
  1862.     }
  1863.     // WAIT FOR EFFECT
  1864.     if (actionName === 'WAIT FOR EFFECT') {
  1865.       return this.actionWaitForEffect();
  1866.     }
  1867.     // WAIT FOR MOVEMENT
  1868.     if (actionName === 'WAIT FOR MOVEMENT') {
  1869.       return this.actionWaitForMovement();
  1870.     }
  1871.     // WAIT FOR NEW LINE
  1872.     if (actionName === 'WAIT FOR NEW LINE') {
  1873.       return this.actionWaitForNewLine();
  1874.     }
  1875.     // WAIT FOR POPUPS
  1876.     if (actionName === 'WAIT FOR POPUPS') {
  1877.       return this.actionWaitForPopups();
  1878.     }
  1879.     return false;
  1880. };

  1881. BattleManager.makeActionTargets = function(string) {
  1882.     var targets = []
  1883.     string = string.toUpperCase()
  1884.     if (['SUBJECT', 'USER'].contains(string)) {
  1885.       return [this._subject];
  1886.     }
  1887.     if (['TARGET', 'TARGETS'].contains(string)) {
  1888.       var group = this._targets;
  1889.       for (var i = 0; i < group.length; ++i) {
  1890.         var target = group[i];
  1891.         if (target) targets.push(target);
  1892.       }
  1893.       return targets;
  1894.     }
  1895.     if (['ACTORS', 'EXISTING ACTORS', 'ALIVE ACTORS'].contains(string)) {
  1896.       var group = $gameParty.aliveMembers();
  1897.       for (var i = 0; i < group.length; ++i) {
  1898.         var target = group[i];
  1899.         if (target) targets.push(target);
  1900.       }
  1901.       return targets;
  1902.     }
  1903.     if (['ACTORS ALL', 'ALL ACTORS', 'PARTY'].contains(string)) {
  1904.       var group = $gameParty.battleMembers();
  1905.       for (var i = 0; i < group.length; ++i) {
  1906.         var target = group[i];
  1907.         if (target) targets.push(target);
  1908.       }
  1909.       return targets;
  1910.     }
  1911.     if (['DEAD ACTORS', 'DEAD ACTOR'].contains(string)) {
  1912.       var group = $gameParty.deadMembers();
  1913.       for (var i = 0; i < group.length; ++i) {
  1914.         var target = group[i];
  1915.         if (target) targets.push(target);
  1916.       }
  1917.       return targets;
  1918.     }
  1919.     if (['ACTORS NOT USER', 'ACTORS NOT SUBJECT'].contains(string)) {
  1920.       var group = $gameParty.aliveMembers();
  1921.       for (var i = 0; i < group.length; ++i) {
  1922.         var target = group[i];
  1923.         if (target && target !== this._subject) targets.push(target);
  1924.       }
  1925.       return targets;
  1926.     }
  1927.     if (['ENEMIES', 'EXISTING ENEMIES', 'ALIVE ENEMIES', 'TROOP',
  1928.     'TROOPS'].contains(string)) {
  1929.       var group = $gameTroop.aliveMembers();
  1930.       for (var i = 0; i < group.length; ++i) {
  1931.         var target = group[i];
  1932.         if (target) targets.push(target);
  1933.       }
  1934.       return targets;
  1935.     }
  1936.     if (['ENEMIES ALL', 'ALL ENEMIES'].contains(string)) {
  1937.       var group = $gameTroop.members();
  1938.       for (var i = 0; i < group.length; ++i) {
  1939.         var target = group[i];
  1940.         if (target) targets.push(target);
  1941.       }
  1942.       return targets;
  1943.     }
  1944.     if (['DEAD ENEMIES', 'DEAD ENEMY'].contains(string)) {
  1945.       var group = $gameTroop.deadMembers();
  1946.       for (var i = 0; i < group.length; ++i) {
  1947.         var target = group[i];
  1948.         if (target) targets.push(target);
  1949.       }
  1950.       return targets;
  1951.     }
  1952.     if (['ENEMIES NOT USER', 'ENEMIES NOT SUBJECT', 'TROOP NOT USER',
  1953.     'TROOP NOT SUBJECT'].contains(string)) {
  1954.       var group = $gameTroop.aliveMembers();
  1955.       for (var i = 0; i < group.length; ++i) {
  1956.         var target = group[i];
  1957.         if (target && target !== this._subject) targets.push(target);
  1958.       }
  1959.       return targets;
  1960.     }
  1961.     if (string.match(/ACTOR[ ](\d+)/i)) {
  1962.       var target = $gameParty.battleMembers()[parseInt(RegExp.$1)];
  1963.       if (target) return [target];
  1964.     }
  1965.     if (string.match(/ENEMY[ ](\d+)/i)) {
  1966.       var target = $gameTroop.members()[parseInt(RegExp.$1)];
  1967.       if (target) return [target];
  1968.     }
  1969.     if (['FRIEND', 'FRIENDS', 'ALLIES'].contains(string)) {
  1970.       var group = this._action.friendsUnit().aliveMembers();
  1971.       for (var i = 0; i < group.length; ++i) {
  1972.         var target = group[i];
  1973.         if (target) targets.push(target);
  1974.       }
  1975.       return targets;
  1976.     }
  1977.     if (['ALL FRIENDS', 'ALL ALLIES'].contains(string)) {
  1978.       var group = this._action.friendsUnit().members();
  1979.       for (var i = 0; i < group.length; ++i) {
  1980.         var target = group[i];
  1981.         if (target) targets.push(target);
  1982.       }
  1983.       return targets;
  1984.     }
  1985.     if (['DEAD FRIEND', 'DEAD FRIENDS', 'DEAD ALLIES'].contains(string)) {
  1986.       var group = this._action.friendsUnit().deadMembers();
  1987.       for (var i = 0; i < group.length; ++i) {
  1988.         var target = group[i];
  1989.         if (target) targets.push(target);
  1990.       }
  1991.       return targets;
  1992.     }
  1993.     if (['OPPONENT', 'OPPONENTS', 'RIVALS', 'FOES'].contains(string)) {
  1994.       var group = this._action.opponentsUnit().aliveMembers();
  1995.       for (var i = 0; i < group.length; ++i) {
  1996.         var target = group[i];
  1997.         if (target) targets.push(target);
  1998.       }
  1999.       return targets;
  2000.     }
  2001.     if (['ALL OPPONENTS', 'ALL RIVALS', 'ALL FOES'].contains(string)) {
  2002.       var group = this._action.opponentsUnit().members();
  2003.       for (var i = 0; i < group.length; ++i) {
  2004.         var target = group[i];
  2005.         if (target) targets.push(target);
  2006.       }
  2007.       return targets;
  2008.     }
  2009.     if (['DEAD OPPONENT', 'DEAD OPPONENTS', 'DEAD RIVALS',
  2010.     'DEAD FOES'].contains(string)) {
  2011.       var group = this._action.opponentsUnit().deadMembers();
  2012.       for (var i = 0; i < group.length; ++i) {
  2013.         var target = group[i];
  2014.         if (target) targets.push(target);
  2015.       }
  2016.       return targets;
  2017.     }
  2018.     if (['FRIENDS NOT USER', 'ALLIES NOT USER'].contains(string)) {
  2019.       var group = this._action.friendsUnit().aliveMembers();
  2020.       for (var i = 0; i < group.length; ++i) {
  2021.         var target = group[i];
  2022.         if (target && target !== this._subject) targets.push(target);
  2023.       }
  2024.       return targets;
  2025.     }
  2026.     if (string.match(/(?:FRIEND|ALLY)[ ](\d+)/i)) {
  2027.       var target = this._action.friendsUnit().members()[parseInt(RegExp.$1)];
  2028.       if (target) return [target];
  2029.     }
  2030.     if (string.match(/(?:OPPONENT|FOE|RIVAL)[ ](\d+)/i)) {
  2031.       var target = this._action.opponentsUnit().members()[parseInt(RegExp.$1)]
  2032.       if (target) return [target];
  2033.     }
  2034.     if (['ALL ALIVE'].contains(string)) {
  2035.       var group = this._action.friendsUnit().aliveMembers();
  2036.       group = group.concat(this._action.opponentsUnit().aliveMembers());
  2037.       for (var i = 0; i < group.length; ++i) {
  2038.         var target = group[i];
  2039.         if (target) targets.push(target);
  2040.       }
  2041.       return targets;
  2042.     }
  2043.     if (['ALL MEMBERS'].contains(string)) {
  2044.       var group = this._action.friendsUnit().members();
  2045.       group = group.concat(this._action.opponentsUnit().members());
  2046.       for (var i = 0; i < group.length; ++i) {
  2047.         var target = group[i];
  2048.         if (target) targets.push(target);
  2049.       }
  2050.       return targets;
  2051.     }
  2052.     if (['ALL DEAD'].contains(string)) {
  2053.       var group = this._action.friendsUnit().deadMembers();
  2054.       group = group.concat(this._action.opponentsUnit().deadMembers());
  2055.       for (var i = 0; i < group.length; ++i) {
  2056.         var target = group[i];
  2057.         if (target) targets.push(target);
  2058.       }
  2059.       return targets;
  2060.     }
  2061.     if (['ALL NOT USER'].contains(string)) {
  2062.       var group = this._action.friendsUnit().aliveMembers();
  2063.       group = group.concat(this._action.opponentsUnit().aliveMembers());
  2064.       for (var i = 0; i < group.length; ++i) {
  2065.         var target = group[i];
  2066.         if (target && target !== this._subject) targets.push(target);
  2067.       }
  2068.       return targets;
  2069.     }
  2070.     if (['FOCUS', 'PARTICIPANTS'].contains(string)) {
  2071.       var group = this._targets;
  2072.       for (var i = 0; i < group.length; ++i) {
  2073.         var target = group[i];
  2074.         if (target) targets.push(target);
  2075.       }
  2076.       if (!targets.contains(this._subject)) targets.push(this._subject);
  2077.       return targets;
  2078.     }
  2079.     if (['NOT FOCUS', 'NONPARTICIPANTS'].contains(string)) {
  2080.       var group = this._action.friendsUnit().aliveMembers();
  2081.       group = group.concat(this._action.opponentsUnit().aliveMembers());
  2082.       for (var i = 0; i < group.length; ++i) {
  2083.         var target = group[i];
  2084.         if (target) {
  2085.           if (target === this._subject) continue;
  2086.           if (this._targets.contains(target)) continue;
  2087.           targets.push(target);
  2088.         }
  2089.       }
  2090.       return targets;
  2091.     }
  2092.     if (string.match(/(?:CHAR|CHARA|CHARACTER)[ ](\d+)/i)) {
  2093.       var actorId = parseInt(RegExp.$1);
  2094.       var actor = $gameActors.actor(actorId);
  2095.       if (actor && $gameParty.battleMembers().contains(actor)) {
  2096.         return [actor];
  2097.       }
  2098.     }
  2099.     return targets;
  2100. };

  2101. BattleManager.actionConditionsMet = function(actSeq) {
  2102.     var ci = this._conditionFlags.length - 1;
  2103.     var actionName = actSeq[0];
  2104.     var actionArgs = actSeq[1];
  2105.     var subject = this._subject;
  2106.     var user = this._subject;
  2107.     var target = this._targets[0];
  2108.     var targets = this._targets;
  2109.     var action = this._action;
  2110.     var item = this._action.item();
  2111.     if (actionName.match(/ELSE[ ]IF[ ](.*)/i)) {
  2112.       if (this._conditionFlags.length <= 0) return false;
  2113.       if (this._conditionFlags[ci]) {
  2114.         this._conditionFlags[ci] = false;
  2115.         this._trueFlags[ci] = true;
  2116.       } else if (!this._conditionFlags[ci] && !this._trueFlags[ci]) {
  2117.         var text = String(RegExp.$1);
  2118.         this._conditionFlags[ci] = eval('(' + text + ')');
  2119.         this._trueFlags[ci] = eval('(' + text + ')');
  2120.       }
  2121.       return false;
  2122.     } else if (actionName.match(/ELSE[ ]*(.*)/i)) {
  2123.       if (this._conditionFlags.length <= 0) return false;
  2124.       if (this._conditionFlags[ci]) {
  2125.         this._conditionFlags[ci] = false;
  2126.         this._trueFlags[ci] = true;
  2127.       } else if (!this._conditionFlags[ci] && !this._trueFlags[ci]) {
  2128.         this._conditionFlags[ci] = true;
  2129.         this._trueFlags[ci] = true;
  2130.       }
  2131.       return false;
  2132.     } else if (actionName.toUpperCase() === 'END') {
  2133.       if (this._conditionFlags.length <= 0) return false;
  2134.       this._conditionFlags.pop();
  2135.       this._trueFlags.pop();
  2136.       return false;
  2137.     }
  2138.     if (this._conditionFlags.length > 0) return this._conditionFlags[ci];
  2139.     return true
  2140. };

  2141. BattleManager.actionActionAnimation = function(actionArgs) {
  2142.     if (actionArgs && actionArgs[0]) {
  2143.       var targets = this.makeActionTargets(actionArgs[0]);
  2144.     } else {
  2145.       var targets = this._targets;
  2146.     }
  2147.     var mirror = false;
  2148.     if (actionArgs && actionArgs[1]) {
  2149.       if (actionArgs[1].toUpperCase() === 'MIRROR') mirror = true;
  2150.     }
  2151.     var subject = this._subject;
  2152.     var group = targets.filter(Yanfly.Util.onlyUnique);
  2153.     var aniId = this._action.item().animationId;
  2154.     if (aniId < 0) {
  2155.       if (mirror) {
  2156.         this._logWindow.showActorAtkAniMirror(subject, group);
  2157.       } else {
  2158.         this._logWindow.showAttackAnimation(subject, group);
  2159.       }
  2160.     } else {
  2161.       this._logWindow.showNormalAnimation(group, aniId, mirror);
  2162.     }
  2163.     return true;
  2164. };

  2165. BattleManager.actionActionCommonEvent = function() {
  2166.     this._action.item().effects.forEach(function(effect) {
  2167.         if (effect.code === Game_Action.EFFECT_COMMON_EVENT) {
  2168.             $gameTemp.reserveCommonEvent(effect.dataId);
  2169.         }
  2170.     }, this);
  2171.     return false;
  2172. };

  2173. BattleManager.actionActionEffect = function(actionArgs) {
  2174.     if (actionArgs && actionArgs[0]) {
  2175.       var targets = this.makeActionTargets(actionArgs[0]);
  2176.     } else {
  2177.       var targets = this._targets;
  2178.     }
  2179.     targets.forEach(function(target) {
  2180.       if (target !== undefined) {
  2181.         var alreadyDead = target.isDead();
  2182.         this.invokeAction(this._subject, target);
  2183.         if (target.isDead() && !alreadyDead) {
  2184.             target.performCollapse();
  2185.         }
  2186.       }
  2187.     }, this);
  2188.     return true;
  2189. };

  2190. BattleManager.actionAniWait = function(frames) {
  2191.     frames *= Yanfly.Param.AnimationRate || 4;
  2192.     this._logWindow._waitCount = parseInt(frames);
  2193.     return false;
  2194. };

  2195. BattleManager.actionCastAnimation = function() {
  2196.   if (!$gameSystem.isSideView() && this._subject.isActor()) return true;
  2197.   if (!this._action.isAttack() && !this._action.isGuard() &&
  2198.   this._action.isSkill()) {
  2199.     if (this._action.item().castAnimation > 0) {
  2200.       var ani = $dataAnimations[this._action.item().castAnimation]
  2201.       this._logWindow.showAnimation(this._subject, [this._subject],
  2202.         this._action.item().castAnimation);
  2203.     }
  2204.   }
  2205.   return true;
  2206. };


  2207. BattleManager.actionClearBattleLog = function() {
  2208.     this._logWindow.clear();
  2209.     return false;
  2210. };

  2211. BattleManager.actionDeathBreak = function() {
  2212.     if (this._subject.isDead() || this._subject.hp <= 0) {
  2213.       this._targets = [];
  2214.       this._actionList = [];
  2215.       this._individualTargets = [];
  2216.       this._phase = 'phaseChange';
  2217.       return false;
  2218.     }
  2219.     return true;
  2220. };

  2221. BattleManager.actionDisplayAction = function() {
  2222.     this._logWindow.displayAction(this._subject, this._action.item());
  2223.     return false;
  2224. };

  2225. BattleManager.actionIfConditions = function(actionName, actionArgs) {
  2226.   var subject = this._subject;
  2227.   var user = this._subject;
  2228.   var target = this._targets[0];
  2229.   var targets = this._targets;
  2230.   var action = this._action;
  2231.   var item = this._action.item();
  2232.   var actionName = this._actSeq[0];
  2233.   if (actionName.match(/IF[ ](.*)/i)) {
  2234.     var text = String(RegExp.$1);
  2235.     this._conditionFlags.push(eval(text));
  2236.     this._trueFlags.push(false);
  2237.     var ci = this._conditionFlags.length;
  2238.   }
  2239.   return true;
  2240. };

  2241. BattleManager.actionImmortal = function(actionArgs) {
  2242.     var targets =
  2243.       this.makeActionTargets(actionArgs[0]).filter(Yanfly.Util.onlyUnique);
  2244.     var value = eval(String(actionArgs[1]).toLowerCase());
  2245.     targets.forEach(function (target) {
  2246.       if (value) {
  2247.         target.addImmortal();
  2248.       } else {
  2249.         var alreadyDead = target.isDead();
  2250.         target.removeImmortal();
  2251.       }
  2252.     }, this);
  2253.     return true;
  2254. };

  2255. BattleManager.actionMotionWait = function(actionArgs) {
  2256.     var targets = this.makeActionTargets(actionArgs[0]);
  2257.     if (targets[0].isActor() && targets[0].isSpriteVisible()) {
  2258.       this._logWindow._waitCount += 12;
  2259.       return false;
  2260.     }
  2261.     return true;
  2262. };

  2263. BattleManager.actionPerformAction = function() {
  2264.     this._logWindow.performAction(this._subject, this._action);
  2265.     if (this._subject.isActor() && this._subject.isSpriteVisible) {
  2266.       this._logWindow._waitCount += 20;
  2267.       return false;
  2268.     }
  2269.     return true;
  2270. };

  2271. BattleManager.actionPerformFinish = function() {
  2272.     this._logWindow.performActionEnd(this._subject);
  2273.     $gameParty.aliveMembers().forEach(function(member) {
  2274.       member.spriteReturnHome();
  2275.     });
  2276.     $gameTroop.aliveMembers().forEach(function(member) {
  2277.       member.spriteReturnHome();
  2278.     });
  2279.     return true;
  2280. };

  2281. BattleManager.actionPerformStart = function() {
  2282.     this._logWindow.performActionStart(this._subject, this._action);
  2283.     return true;
  2284. };

  2285. BattleManager.actionWait = function(frames) {
  2286.     this._logWindow._waitCount = parseInt(frames);
  2287.     return false;
  2288. };

  2289. BattleManager.actionWaitForAnimation = function() {
  2290.     this._logWindow.waitForAnimation();
  2291.     return false;
  2292. };

  2293. BattleManager.actionWaitForEffect = function() {
  2294.     this._logWindow.waitForEffect();
  2295.     return false;
  2296. };

  2297. BattleManager.actionWaitForMovement = function() {
  2298.     this._logWindow.waitForMovement();
  2299.     return false;
  2300. };

  2301. BattleManager.actionWaitForNewLine = function() {
  2302.     this._logWindow.waitForNewLine();
  2303.     return false;
  2304. };

  2305. BattleManager.actionWaitForPopups = function() {
  2306.     this._logWindow.waitForPopups();
  2307.     return false;
  2308. };

  2309. //=============================================================================
  2310. // Sprite_Battler
  2311. //=============================================================================

  2312. Yanfly.BEC.Sprite_Battler_initialize = Sprite_Battler.prototype.initialize;
  2313. Sprite_Battler.prototype.initialize = function(battler) {
  2314.     this.preSpriteInitialize(battler);
  2315.     Yanfly.BEC.Sprite_Battler_initialize.call(this, battler);
  2316. };

  2317. Sprite_Battler.prototype.preSpriteInitialize = function(battler) {
  2318. };

  2319. Yanfly.BEC.Sprite_Battler_update = Sprite_Battler.prototype.update;
  2320. Sprite_Battler.prototype.update = function() {
  2321.     Yanfly.BEC.Sprite_Battler_update.call(this);
  2322.     if (this._postSpriteInitialized) return;
  2323.     this.postSpriteInitialize();
  2324. };

  2325. Sprite_Battler.prototype.postSpriteInitialize = function() {
  2326.     this._postSpriteInitialized = true;
  2327. };

  2328. Yanfly.BEC.Sprite_Battler_initMembers = Sprite_Battler.prototype.initMembers;
  2329. Sprite_Battler.prototype.initMembers = function() {
  2330.     Yanfly.BEC.Sprite_Battler_initMembers.call(this);
  2331.     this.adjustAnchor();
  2332.     this.setZ();
  2333. };

  2334. Sprite_Battler.prototype.adjustAnchor = function() {
  2335.     this.anchor.x = 0.5;
  2336.     this.anchor.y = 1.0;
  2337. };

  2338. Sprite_Battler.prototype.setZ = function() {
  2339.     this.z = 1;
  2340. };

  2341. Sprite_Battler.prototype.setupDamagePopup = function() {
  2342.     if (this._battler.isDamagePopupRequested()) {
  2343.       if (this._battler.isSpriteVisible()) {
  2344.         var sprite = new Sprite_Damage();
  2345.         sprite.x = this.x + this.damageOffsetX();
  2346.         sprite.y = this.y + this.damageOffsetY();
  2347.         sprite.setup(this._battler);
  2348.         this.pushDamageSprite(sprite);
  2349.         BattleManager._spriteset.addChild(sprite);
  2350.         this._battler.clearResult();
  2351.       }
  2352.     } else {
  2353.       this._battler.clearDamagePopup();
  2354.     }
  2355. };

  2356. Sprite_Battler.prototype.pushDamageSprite = function(sprite) {
  2357.     var heightBuffer = eval(Yanfly.Param.BECPopupOverlap);
  2358.     if (eval(Yanfly.Param.BECNewPopBottom)) {
  2359.       this._damages.push(sprite);
  2360.       this._damages.forEach(function(spr) {
  2361.         for (var i = 0; i < spr.children.length; i++) {
  2362.           childSprite = spr.children[i];
  2363.           childSprite.anchor.y += heightBuffer;
  2364.         }
  2365.       }, this);
  2366.     } else {
  2367.       this._damages.push(sprite);
  2368.       heightBuffer *= this._damages.length
  2369.       for (var i = 0; i < sprite.children.length; i++) {
  2370.         childSprite = sprite.children[i];
  2371.         childSprite.anchor.y += heightBuffer;
  2372.       }
  2373.     }
  2374. };

  2375. Yanfly.BEC.Sprite_Battler_setBattler = Sprite_Battler.prototype.setBattler;
  2376. Sprite_Battler.prototype.setBattler = function(battler) {
  2377.     Yanfly.BEC.Sprite_Battler_setBattler.call(this, battler);
  2378.     if (battler) battler.setBattler(this);
  2379. };

  2380. Yanfly.BEC.Sprite_Battler_startMove = Sprite_Battler.prototype.startMove;
  2381. Sprite_Battler.prototype.startMove = function(x, y, duration) {
  2382.     if (this._battler && !this._battler.spriteCanMove()) return;
  2383.     Yanfly.BEC.Sprite_Battler_startMove.call(this, x, y, duration);
  2384. };

  2385. Sprite_Battler.prototype.stepForward = function() {
  2386.     this.startMove(Yanfly.Param.BECStepDist, 0, 12);
  2387. };

  2388. Sprite_Battler.prototype.stepBack = function() {
  2389.     this.startMove(0, 0, 12);
  2390. };

  2391. Sprite_Battler.prototype.stepFlinch = function() {
  2392.     var flinchX = this.x - this._homeX - Yanfly.Param.BECFlinchDist;
  2393.     var flinchY = this.y - this._homeY;
  2394.     this.startMove(flinchX, flinchY, 6);
  2395. };

  2396. Sprite_Battler.prototype.stepSubBack = function() {
  2397.     var backX = -1 * this.width / 2;
  2398.     this.startMove(backX, 0, 6);
  2399. };

  2400. Sprite_Battler.prototype.stepToSubstitute = function(focus) {
  2401.     var target = focus.battler();
  2402.     var targetX = (this.x - this._homeX) + (target._homeX - this._homeX);
  2403.     var targetY = (this.y - this._homeY) + (target._homeY - this._homeY);;
  2404.     if (focus.isActor()) targetX -= this._mainSprite.width / 2;
  2405.     if (focus.isEnemy()) targetX += this.width / 2;
  2406.     this.startMove(targetX, targetY, 1);
  2407. };

  2408. Sprite_Battler.prototype.startMotion = function(motionType) {
  2409. };

  2410. Sprite_Battler.prototype.forceMotion = function(motionType) {
  2411. };

  2412. Sprite_Battler.prototype.refreshMotion = function() {
  2413. };

  2414. Sprite_Battler.prototype.startActionMotion = function() {
  2415. };

  2416. Sprite_Battler.prototype.moveForward = function(distance, frames) {
  2417.     distance = parseInt(distance);
  2418.     frames = parseInt(frames);
  2419.     if (this._battler.isActor()) distance *= -1;
  2420.     var moveX = this.x - this._homeX + distance;
  2421.     var moveY = this.y - this._homeY;
  2422.     this.startMove(moveX, moveY, frames);
  2423. };

  2424. Sprite_Battler.prototype.moveToPoint = function(pointX, pointY, frames) {
  2425.     pointX = parseInt(pointX);
  2426.     pointY = parseInt(pointY);
  2427.     var targetX = pointX - this._homeX;
  2428.     var targetY = pointY - this._homeY;
  2429.     this.startMove(targetX, targetY, frames);
  2430. };

  2431. Sprite_Battler.prototype.setMirror = function(value) {
  2432.     if (this.scale.x > 0 && value) this.scale.x *= -1;
  2433.     if (this.scale.x < 0 && !value) this.scale.x *= -1;
  2434. };

  2435. Sprite_Battler.prototype.isPopupPlaying = function() {
  2436.     if (this._damages.length > 0) {
  2437.       for (var i = 0; i < this._damages.length; ++i) {
  2438.         return this._damages[i].isPlaying();
  2439.       }
  2440.     }
  2441.     return false;
  2442. };

  2443. //=============================================================================
  2444. // Sprite_Actor
  2445. //=============================================================================

  2446. Sprite_Actor.prototype.preSpriteInitialize = function(battler) {
  2447.     Sprite_Battler.prototype.preSpriteInitialize.call(this, battler);
  2448. };

  2449. Sprite_Actor.prototype.postSpriteInitialize = function() {
  2450.     Sprite_Battler.prototype.postSpriteInitialize.call(this);
  2451. };

  2452. Yanfly.BEC.Sprite_Actor_updateShadow = Sprite_Actor.prototype.updateShadow;
  2453. Sprite_Actor.prototype.updateShadow = function() {
  2454.     if (this._hideShadows === undefined) {
  2455.       this._hideShadows = eval(Yanfly.Param.BECShowShadows);
  2456.     }
  2457.     if (!this._hideShadows) return this._shadowSprite.visible = false;
  2458.     Yanfly.BEC.Sprite_Actor_updateShadow.call(this);
  2459. };

  2460. Sprite_Actor.prototype.setActorHome = function(index) {
  2461.     var screenWidth = Graphics.boxWidth;
  2462.     var screenHeight = Graphics.boxHeight;
  2463.     var maxSize = $gameParty.maxBattleMembers();
  2464.     var partySize = $gameParty.battleMembers().length;
  2465.     var statusHeight = eval(Yanfly.Param.BECCommandRows);
  2466.     statusHeight *= Window_Base.prototype.lineHeight.call(this);
  2467.     statusHeight += Window_Base.prototype.standardPadding.call(this) * 2;
  2468.     if ($gameSystem.isSideView()) {
  2469.       var homeX = eval(Yanfly.Param.BECHomePosX);
  2470.       var homeY = eval(Yanfly.Param.BECHomePosY);
  2471.     } else {
  2472.       var homeX = eval(Yanfly.Param.BECFrontPosX);
  2473.       var homeY = eval(Yanfly.Param.BECFrontPosY);
  2474.     }
  2475.     this._checkAliveStatus = false;
  2476.     if ($gameParty.battleMembers()[index]) {
  2477.       var actor = $gameParty.battleMembers()[index];
  2478.       if (actor.isAlive()) this._checkAliveStatus = true;
  2479.     }
  2480.     this.setHome(homeX, homeY);
  2481.     this.moveToStartPosition();
  2482. };

  2483. Sprite_Actor.prototype.moveToStartPosition = function() {
  2484.     if (BattleManager._bypassMoveToStartLocation) return;
  2485.     if ($gameSystem.isSideView() && this._checkAliveStatus) {
  2486.       this.startMove(300, 0, 0);
  2487.     }
  2488. };

  2489. Sprite_Actor.prototype.setupMotion = function() {
  2490. };

  2491. Sprite_Actor.prototype.forceMotion = function(motionType) {
  2492.     var newMotion = Sprite_Actor.MOTIONS[motionType];
  2493.     this._motion = newMotion;
  2494.     this._motionCount = 0;
  2495.     this._pattern = 0;
  2496. };

  2497. Sprite_Actor.prototype.updateTargetPosition = function() {
  2498. };

  2499. Sprite_Actor.prototype.updateMotion = function() {
  2500.     this.updateMotionCount();
  2501. };

  2502. Sprite_Actor.prototype.onMoveEnd = function() {
  2503.     Sprite_Battler.prototype.onMoveEnd.call(this);
  2504. };

  2505. Sprite_Actor.prototype.stepForward = function() {
  2506.     this.startMove(-Yanfly.Param.BECStepDist, 0, 12);
  2507. };

  2508. Sprite_Actor.prototype.stepFlinch = function() {
  2509.     var flinchX = this.x - this._homeX + Yanfly.Param.BECFlinchDist;
  2510.     var flinchY = this.y - this._homeY;
  2511.     this.startMove(flinchX, flinchY, 6);
  2512. };

  2513. Sprite_Actor.prototype.stepSubBack = function() {
  2514.     var backX = this._mainSprite.width / 2;
  2515.     this.startMove(backX, 0, 6);
  2516. };

  2517. Yanfly.BEC.Sprite_Actor_updateBitmap = Sprite_Actor.prototype.updateBitmap;
  2518. Sprite_Actor.prototype.updateBitmap = function() {
  2519.     var name = this._actor.battlerName();
  2520.     var needUpdate = false;
  2521.     if (this._battlerName !== name) needUpdate = true;
  2522.     Yanfly.BEC.Sprite_Actor_updateBitmap.call(this);
  2523.     if (needUpdate) this.adjustAnchor();
  2524. };

  2525. Sprite_Actor.prototype.adjustAnchor = function() {
  2526.     if (!this._mainSprite) return;
  2527.     this._mainSprite.anchor.x = this._actor.anchorX();
  2528.     this._mainSprite.anchor.y = this._actor.anchorY();
  2529. };

  2530. Yanfly.BEC.Sprite_Actor_updateFrame = Sprite_Actor.prototype.updateFrame;
  2531. Sprite_Actor.prototype.updateFrame = function() {
  2532.     Yanfly.BEC.Sprite_Actor_updateFrame.call(this);
  2533.     if (!this._mainSprite) return;
  2534.     if (!this._mainSprite.bitmap) return;
  2535.     if (this._mainSprite.bitmap.width > 0 && !this.bitmap) {
  2536.       var sw = this._mainSprite.bitmap.width / 9;
  2537.       var sh = this._mainSprite.bitmap.height / 6;
  2538.       this.bitmap = new Bitmap(sw, sh);
  2539.     }
  2540. };

  2541. Yanfly.BEC.Sprite_Actor_refreshMotion = Sprite_Actor.prototype.refreshMotion;
  2542. Sprite_Actor.prototype.refreshMotion = function() {
  2543.     var actor = this._actor;
  2544.     if (!actor) return;
  2545.     var motionGuard = Sprite_Actor.MOTIONS['guard'];
  2546.     if (this._motion === motionGuard && !BattleManager.isInputting()) return;
  2547.     var stateMotion = actor.stateMotionIndex();
  2548.     if (actor.isInputting() || actor.isActing()) {
  2549.       this.startMotion(actor.idleMotion());
  2550.     } else if (stateMotion === 3) {
  2551.       this.startMotion(actor.deadMotion());
  2552.     } else if (stateMotion === 2) {
  2553.       this.startMotion(actor.sleepMotion());
  2554.     } else if (actor.isChanting()) {
  2555.       this.startMotion(actor.chantMotion());
  2556.     } else if (actor.isGuard() || actor.isGuardWaiting()) {
  2557.       this.startMotion(actor.guardMotion());
  2558.     } else if (stateMotion === 1) {
  2559.       this.startMotion(actor.abnormalMotion());
  2560.     } else if (actor.isDying()) {
  2561.       this.startMotion(actor.dyingMotion());
  2562.     } else if (actor.isUndecided()) {
  2563.       this.startMotion(actor.idleMotion());
  2564.     } else {
  2565.       this.startMotion(actor.waitMotion());
  2566.     }
  2567. };

  2568. //=============================================================================
  2569. // Sprite_Enemy
  2570. //=============================================================================

  2571. Sprite_Enemy.prototype.preSpriteInitialize = function(battler) {
  2572.     Sprite_Battler.prototype.preSpriteInitialize.call(this, battler);
  2573.     this._visualSelect = eval(Yanfly.Param.BECEnemySelect);
  2574.     if (this._visualSelect) this.createVisualSelectWindow();
  2575. };

  2576. Yanfly.BEC.Sprite_Enemy_update = Sprite_Enemy.prototype.update;
  2577. Sprite_Enemy.prototype.update = function() {
  2578.     Yanfly.BEC.Sprite_Enemy_update.call(this);
  2579.     this.addVisualSelectWindow();
  2580. };

  2581. Sprite_Enemy.prototype.addVisualSelectWindow = function() {
  2582.     if (!this._visualSelect) return;
  2583.     if (this._addedVisualSelect) return;
  2584.     if (!SceneManager._scene) return;
  2585.     var scene = SceneManager._scene;
  2586.     if (!scene._windowLayer) return;
  2587.     this._addedVisualSelect = true;
  2588.     scene.addChild(this._visualSelectWindow);
  2589. };

  2590. Sprite_Enemy.prototype.createVisualSelectWindow = function() {
  2591.     this._visualSelectWindow = new Window_EnemyVisualSelect();
  2592. };

  2593. Yanfly.BEC.Sprite_Enemy_setBattler = Sprite_Enemy.prototype.setBattler;
  2594. Sprite_Enemy.prototype.setBattler = function(battler) {
  2595.     Yanfly.BEC.Sprite_Enemy_setBattler.call(this, battler);
  2596.     if (this._visualSelectWindow) this._visualSelectWindow.setBattler(battler);
  2597. };

  2598. //=============================================================================
  2599. // Sprite_Weapon
  2600. //=============================================================================

  2601. Yanfly.BEC.Sprite_Weapon_setup = Sprite_Weapon.prototype.setup;
  2602. Sprite_Weapon.prototype.setup = function(weaponImageId) {
  2603.     Yanfly.BEC.Sprite_Weapon_setup.call(this, weaponImageId);
  2604.     this._animationCount -= 1; // Synch with sprite
  2605. };

  2606. //=============================================================================
  2607. // Sprite_Damage
  2608. //=============================================================================

  2609. Yanfly.BEC.Sprite_Damage_initialize = Sprite_Damage.prototype.initialize;
  2610. Sprite_Damage.prototype.initialize = function() {
  2611.     Yanfly.BEC.Sprite_Damage_initialize.call(this);
  2612.     this._duration = eval(Yanfly.Param.BECPopupDur);
  2613. };

  2614. Sprite_Damage.prototype.setup = function(target) {
  2615.     var result = target.shiftDamagePopup();
  2616.     if (result.missed || result.evaded) {
  2617.       this.createMiss();
  2618.     } else if (result.hpAffected) {
  2619.       this.createDigits(0, result.hpDamage);
  2620.     } else if (target.isAlive() && result.mpDamage !== 0) {
  2621.       this.createDigits(2, result.mpDamage);
  2622.     }
  2623.     if (result.critical) {
  2624.       this.setupCriticalEffect();
  2625.     }
  2626. };

  2627. Sprite_Damage.prototype.setupCriticalEffect = function() {
  2628.     this._flashColor = eval('[' + Yanfly.Param.BECCritPopup + ']');
  2629.     this._flashDuration = eval(Yanfly.Param.BECCritDur);
  2630. };

  2631. //=============================================================================
  2632. // Sprite_StateIcon
  2633. //=============================================================================

  2634. Yanfly.BEC.Sprite_StateIcon_update = Sprite_StateIcon.prototype.update;
  2635. Sprite_StateIcon.prototype.update = function() {
  2636.     Yanfly.BEC.Sprite_StateIcon_update.call(this);
  2637.     this.updateMirror();
  2638. };

  2639. Sprite_StateIcon.prototype.updateMirror = function() {
  2640.     if (this.parent.scale.x < 0) this.scale.x = -1 * Math.abs(this.scale.x);
  2641.     if (this.parent.scale.x > 0) this.scale.x = Math.abs(this.scale.x);
  2642. };

  2643. //=============================================================================
  2644. // Sprite_StateOverlay
  2645. //=============================================================================

  2646. Yanfly.BEC.Sprite_StateOverlay_update = Sprite_StateOverlay.prototype.update;
  2647. Sprite_StateOverlay.prototype.update = function() {
  2648.     Yanfly.BEC.Sprite_StateOverlay_update.call(this);
  2649.     this.updateMirror();
  2650. };

  2651. Sprite_StateOverlay.prototype.updateMirror = function() {
  2652.     if (this.parent.scale.x < 0) this.scale.x = -1 * Math.abs(this.scale.x);
  2653.     if (this.parent.scale.x > 0) this.scale.x = Math.abs(this.scale.x);
  2654. };

  2655. //=============================================================================
  2656. // Spriteset_Battle
  2657. //=============================================================================

  2658. Spriteset_Battle.prototype.isBusy = function() {
  2659.     return false;
  2660. };

  2661. Yanfly.BEC.Spriteset_Battle_update = Spriteset_Battle.prototype.update;
  2662. Spriteset_Battle.prototype.update = function() {
  2663.     Yanfly.BEC.Spriteset_Battle_update.call(this);
  2664.     this.updateZCoordinates();
  2665. };

  2666. Spriteset_Battle.prototype.updateZCoordinates = function() {
  2667.     this._battleField.children.sort(this.battleFieldDepthCompare);
  2668. };

  2669. Spriteset_Battle.prototype.battleFieldDepthCompare = function(a, b) {
  2670.     if (a.tilePosition && !b.tilePosition) return -1;
  2671.     if (b.tilePosition && !a.tilePosition) return 1;
  2672.     var priority = BattleManager.getSpritePriority();
  2673.     if (a._battler && b._battler && priority !== 0) {
  2674.       if (priority === 1) {
  2675.         if (a._battler.isActor() && b._battler.isEnemy()) return 1;
  2676.         if (a._battler.isEnemy() && b._battler.isActor()) return -1;
  2677.       } else if (priority === 2) {
  2678.         if (a._battler.isActor() && b._battler.isEnemy()) return -1;
  2679.         if (a._battler.isEnemy() && b._battler.isActor()) return 1;
  2680.       }
  2681.     }
  2682.     if (a.z < b.z) return -1;
  2683.     if (a.z > b.z) return 1;
  2684.     if (a.y < b.y) return -1;
  2685.     if (a.y > b.y) return 1;
  2686.     return 0;
  2687. };

  2688. Spriteset_Battle.prototype.isPopupPlaying = function() {
  2689.     return this.battlerSprites().some(function(sprite) {
  2690.         return sprite.isPopupPlaying();
  2691.     });
  2692. };

  2693. //=============================================================================
  2694. // Game_Temp
  2695. //=============================================================================

  2696. Game_Temp.prototype.clearActionSequenceSettings = function() {
  2697. };

  2698. //=============================================================================
  2699. // Game_System
  2700. //=============================================================================

  2701. Yanfly.BEC.Game_System_initialize = Game_System.prototype.initialize;
  2702. Game_System.prototype.initialize = function() {
  2703.     Yanfly.BEC.Game_System_initialize.call(this);
  2704.     this.initBattleSystem();
  2705. };

  2706. Game_System.prototype.initBattleSystem = function() {
  2707.     this._battleSystem = Yanfly.Param.BECSystem.toLowerCase();
  2708. };

  2709. Game_System.prototype.getBattleSystem = function() {
  2710.     if (this._battleSystem === undefined) this.initBattleSystem();
  2711.     return this._battleSystem;
  2712. };

  2713. Game_System.prototype.setBattleSystem = function(type) {
  2714.     this._battleSystem = type.toLowerCase();
  2715. };

  2716. //=============================================================================
  2717. // Game_Interpreter
  2718. //=============================================================================

  2719. Yanfly.BEC.Game_Interpreter_pluginCommand =
  2720.     Game_Interpreter.prototype.pluginCommand;
  2721. Game_Interpreter.prototype.pluginCommand = function(command, args) {
  2722.     Yanfly.BEC.Game_Interpreter_pluginCommand.call(this, command, args);
  2723.     if (command === 'setBattleSys' && !$gameParty.inBattle()) {
  2724.       this.setBattleSystem(args[0]);
  2725.     }
  2726. };

  2727. Game_Interpreter.prototype.setBattleSystem = function(value) {
  2728.     $gameSystem.setBattleSystem(value);
  2729. };

  2730. //=============================================================================
  2731. // Game_Action
  2732. //=============================================================================

  2733. Game_Action.prototype.speed = function() {
  2734.     var user = this.subject(); var a = user;
  2735.     var maxhp = user.mhp; var mhp = user.mhp; var hp = user.hp;
  2736.     var maxmp = user.mmp; var mmp = user.mmp; var mp = user.mp;
  2737.     var maxtp = user.maxTp(); var mtp = user.maxTp(); var tp = user.tp;
  2738.     var atk = user.atk; var def = user.def; var mat = user.mat;
  2739.     var int = user.mat; var mdf = user.mdf; var res = user.res;
  2740.     var agi = user.agi; var luk = user.luk;
  2741.     var speed = eval(Yanfly.Param.BECActionSpeed);
  2742.     if (this.item()) speed += this.item().speed;
  2743.     if (this.isAttack()) speed += this.subject().attackSpeed();
  2744.     return speed;
  2745. };

  2746. Yanfly.BEC.Game_Action_apply = Game_Action.prototype.apply;
  2747. Game_Action.prototype.apply = function(target) {
  2748.     target._result = null;
  2749.     target._result = new Game_ActionResult();
  2750.     this.subject()._result = null;
  2751.     this.subject()._result = new Game_ActionResult();
  2752.     Yanfly.BEC.Game_Action_apply.call(this, target);
  2753.     if ($gameParty.inBattle()) {
  2754.       target.startDamagePopup();
  2755.       target.performResultEffects();
  2756.       if (target !== this.subject()) this.subject().startDamagePopup();
  2757.     }
  2758. };

  2759. Game_Action.prototype.itemEffectAddAttackState = function(target, effect) {
  2760.     this.subject().attackStates().forEach(function(stateId) {
  2761.         var chance = effect.value1;
  2762.         chance *= target.stateRate(stateId);
  2763.         chance *= this.subject().attackStatesRate(stateId);
  2764.         chance *= this.lukEffectRate(target);
  2765.         if (Math.random() < chance) {
  2766.             if (stateId === target.deathStateId()) {
  2767.               if (target.isImmortal()) target.removeImmortal();
  2768.             }
  2769.             target.addState(stateId);
  2770.             this.makeSuccess(target);
  2771.         }
  2772.     }.bind(this), target);
  2773. };

  2774. Game_Action.prototype.itemEffectAddNormalState = function(target, effect) {
  2775.     var stateId = effect.dataId;
  2776.     var chance = effect.value1;
  2777.     if (!this.isCertainHit()) {
  2778.       chance *= target.stateRate(stateId);
  2779.       chance *= this.lukEffectRate(target);
  2780.     }
  2781.     if (Math.random() < chance) {
  2782.       if (stateId === target.deathStateId()) {
  2783.         if (target.isImmortal()) target.removeImmortal();
  2784.       }
  2785.       target.addState(stateId);
  2786.       this.makeSuccess(target);
  2787.     }
  2788. };

  2789. Yanfly.BEC.Game_Action_applyGlobal = Game_Action.prototype.applyGlobal;
  2790. Game_Action.prototype.applyGlobal = function() {
  2791.     if ($gameParty.inBattle()) return;
  2792.     Yanfly.BEC.Game_Action_applyGlobal.call(this);
  2793. };

  2794. Yanfly.BEC.Game_Action_needsSelection = Game_Action.prototype.needsSelection;
  2795. Game_Action.prototype.needsSelection = function() {
  2796.     if ($gameParty.inBattle() && this.item().scope === 0) return false;
  2797.     if ($gameParty.inBattle() && BattleManager.isForceSelection()) return true;
  2798.     return Yanfly.BEC.Game_Action_needsSelection.call(this);
  2799. };

  2800. //=============================================================================
  2801. // Game_BattlerBase
  2802. //=============================================================================

  2803. Yanfly.BEC.Game_BattlerBase_recoverAll = Game_BattlerBase.prototype.recoverAll;
  2804. Game_BattlerBase.prototype.recoverAll = function() {
  2805.     Yanfly.BEC.Game_BattlerBase_recoverAll.call(this);
  2806.     this.refresh();
  2807.     if ($gameParty.inBattle()) this.forceMotionRefresh();
  2808. };

  2809. Game_BattlerBase.prototype.requestStatusRefresh = function() {
  2810.     this._statusRefreshRequested = true;
  2811. };

  2812. Game_BattlerBase.prototype.isStatusRefreshRequested = function() {
  2813.     return this._statusRefreshRequested;
  2814. };

  2815. Game_BattlerBase.prototype.completetStatusRefreshRequest = function() {
  2816.     this._statusRefreshRequested = false;
  2817. };

  2818. Game_BattlerBase.prototype.updateStateTicks = function() {
  2819.     var needRefresh = false;
  2820.     for (var i = 0; i < this._states.length; ++i) {
  2821.       var stateId = this._states[i];
  2822.       var state = $dataStates[stateId];
  2823.       if (!state) continue;
  2824.       if (state.autoRemovalTiming !== 2) continue;
  2825.       if (!this._stateTurns[stateId]) continue;
  2826.       var value = BattleManager.tickRate() / Yanfly.Param.BECTurnTime;
  2827.       var shown1 = Math.ceil(this._stateTurns[stateId]);
  2828.       this._stateTurns[stateId] -= value;
  2829.       var shown2 = Math.ceil(this._stateTurns[stateId]);
  2830.       if (shown1 !== shown2) needRefresh = true;
  2831.       if (this._stateTurns[stateId] <= 0) this.removeState(stateId);
  2832.     }
  2833.     if (needRefresh) this.refresh();
  2834. };

  2835. Game_BattlerBase.prototype.isBypassUpdateTurns = function() {
  2836.     if ($gameTroop.isEventRunning()) return true;
  2837.     return false;
  2838. };

  2839. Game_BattlerBase.prototype.updateStateTurns = function() {
  2840.     this.updateStateTurnEnd();
  2841. };

  2842. Game_BattlerBase.prototype.updateStateTurnTiming = function(timing) {
  2843.     if (this.isBypassUpdateTurns()) return;
  2844.     var statesRemoved = [];
  2845.     this._freeStateTurn = this._freeStateTurn || [];
  2846.     for (var i = 0; i < this._states.length; ++i) {
  2847.       var stateId = this._states[i];
  2848.       var state = $dataStates[stateId];
  2849.       if (!state) continue;
  2850.       if (state.autoRemovalTiming !== timing) continue;
  2851.       if (!this._stateTurns[stateId]) continue;
  2852.       if (this._freeStateTurn.contains(stateId)) {
  2853.         var index = this._freeStateTurn.indexOf(stateId);
  2854.         this._freeStateTurn.splice(index, 1);
  2855.       } else {
  2856.         this._stateTurns[stateId] -= 1;
  2857.       }
  2858.       if (this._stateTurns[stateId] <= 0) statesRemoved.push(stateId);
  2859.     }
  2860.     for (var i = 0; i < statesRemoved.length; ++i) {
  2861.       var stateId = statesRemoved[i];
  2862.       this.removeState(stateId);
  2863.     }
  2864. };

  2865. Game_BattlerBase.prototype.updateStateActionStart = function() {
  2866.     this.updateStateTurnTiming(3);
  2867. };

  2868. Game_BattlerBase.prototype.updateStateActionEnd = function() {
  2869.     this.updateStateTurnTiming(1);
  2870. };

  2871. Game_BattlerBase.prototype.updateStateTurnStart = function() {
  2872.     this.updateStateTurnTiming(4);
  2873. };

  2874. Game_BattlerBase.prototype.updateStateTurnEnd = function() {
  2875.     this.updateStateTurnTiming(2);
  2876. };

  2877. Game_BattlerBase.prototype.updateBuffTicks = function() {
  2878.     var needRefresh = false;
  2879.     for (var i = 0; i < this._buffTurns.length; i++) {
  2880.       if (this._buffTurns[i] <= 0) continue;
  2881.       var value = BattleManager.tickRate() / Yanfly.Param.BECTurnTime;
  2882.       var shown1 = Math.ceil(this._buffTurns[i]);
  2883.       this._buffTurns[i] -= value;
  2884.       var shown2 = Math.ceil(this._buffTurns[i]);
  2885.       if (shown1 !== shown2) needRefresh = true;
  2886.       if (this._buffTurns[i] <= 0) this.removeBuff(i);
  2887.     }
  2888.     if (needRefresh) this.refresh();
  2889. };

  2890. Game_BattlerBase.prototype.timedTick = function() {
  2891.     return 1 * BattleManager.tickRate();
  2892. };

  2893. Yanfly.BEC.Game_BattlerBase_isStateResist =
  2894.     Game_BattlerBase.prototype.isStateResist;
  2895. Game_BattlerBase.prototype.isStateResist = function(stateId) {
  2896.     if (stateId === this.deathStateId() && this.isImmortal()) return true;
  2897.     return Yanfly.BEC.Game_BattlerBase_isStateResist.call(this, stateId);
  2898. };

  2899. Game_BattlerBase.prototype.isImmortal = function() {
  2900.     return this._immortalState;
  2901. };

  2902. Yanfly.BEC.Game_BattlerBase_paySkillCost =
  2903.     Game_BattlerBase.prototype.paySkillCost;
  2904. Game_BattlerBase.prototype.paySkillCost = function(skill) {
  2905.     this.requestStatusRefresh();
  2906.     Yanfly.BEC.Game_BattlerBase_paySkillCost.call(this, skill);
  2907. };

  2908. //=============================================================================
  2909. // Game_Battler
  2910. //=============================================================================

  2911. Yanfly.BEC.Game_Battler_useItem = Game_Battler.prototype.useItem;
  2912. Game_Battler.prototype.useItem = function(item) {
  2913.     Yanfly.BEC.Game_Battler_useItem.call(this, item);
  2914.     if (!$gameParty.inBattle()) return;
  2915.     this.increaseSelfTurnCount();
  2916.     this.updateStateActionStart();
  2917. };

  2918. Yanfly.BEC.Game_Battler_onBattleStart = Game_Battler.prototype.onBattleStart;
  2919. Game_Battler.prototype.onBattleStart = function() {
  2920.     Yanfly.BEC.Game_Battler_onBattleStart.call(this);
  2921.     this._freeStateTurn = [];
  2922.     this._immortalState = false;
  2923.     this._selfTurnCount = 0;
  2924. };

  2925. Yanfly.BEC.Game_Battler_onBattleEnd = Game_Battler.prototype.onBattleEnd;
  2926. Game_Battler.prototype.onBattleEnd = function() {
  2927.     Yanfly.BEC.Game_Battler_onBattleEnd.call(this);
  2928.     this._freeStateTurn = [];
  2929.     this._immortalState = false;
  2930. };

  2931. Yanfly.BEC.Game_Battler_isSelected = Game_Battler.prototype.isSelected;
  2932. Game_Battler.prototype.isSelected = function() {
  2933.     if ($gameParty.inBattle() && BattleManager.isAllSelection()) {
  2934.       if (!this.isAppeared()) return false;
  2935.       var action = BattleManager.inputtingAction();
  2936.       if (action && action.item()) {
  2937.         if (this.isDead() && this.isEnemy()) return false;
  2938.         if (this.isDead() && this.isActor()) return action.isForDeadFriend();
  2939.         if (action.isForFriend() && this.isActor()) return true;
  2940.         if (action.isForOpponent() && this.isEnemy()) return true;
  2941.       }
  2942.     }
  2943.     return Yanfly.BEC.Game_Battler_isSelected.call(this);
  2944. };

  2945. Yanfly.BEC.Game_Battler_regenerateAll = Game_Battler.prototype.regenerateAll;
  2946. Game_Battler.prototype.regenerateAll = function() {
  2947.     var lifeState = this.isAlive();
  2948.     Yanfly.BEC.Game_Battler_regenerateAll.call(this);
  2949.     if (!BattleManager.timeBasedStates()) this.updateStateTurns();
  2950.     if (!BattleManager.timeBasedBuffs()) {
  2951.       this.updateBuffTurns();
  2952.       this.removeBuffsAuto();
  2953.     }
  2954.     if (this.isDead() && lifeState === true) {
  2955.       this.performCollapse();
  2956.     }
  2957.     if ($gameParty.inBattle()) this.startDamagePopup();
  2958. };

  2959. Game_Battler.prototype.addImmortal = function() {
  2960.     this._immortalState = true;
  2961. };

  2962. Game_Battler.prototype.removeImmortal = function() {
  2963.     var alreadyDead = this.isDead();
  2964.     this._immortalState = false;
  2965.     this.refresh();
  2966.     if (this.isDead() && !alreadyDead) this.performCollapse();
  2967. };

  2968. Yanfly.BEC.Game_Battler_removeState = Game_Battler.prototype.removeState;
  2969. Game_Battler.prototype.removeState = function(stateId) {
  2970.     Yanfly.BEC.Game_Battler_removeState.call(this, stateId);
  2971. };

  2972. Game_Battler.prototype.clearDamagePopup = function() {
  2973.     this._damagePopup = [];
  2974. };

  2975. Game_Battler.prototype.isDamagePopupRequested = function() {
  2976.     if (!this._damagePopup) this.clearDamagePopup();
  2977.     return this._damagePopup.length > 0;
  2978. };

  2979. Game_Battler.prototype.startDamagePopup = function() {
  2980.     var result = this.result();
  2981.     if (result.missed || result.evaded) {
  2982.       var copyResult = JsonEx.makeDeepCopy(result);
  2983.       copyResult.hpAffected = false;
  2984.       copyResult.mpDamage = 0;
  2985.       this._damagePopup.push(copyResult);
  2986.     }
  2987.     if (result.hpAffected) {
  2988.       var copyResult = JsonEx.makeDeepCopy(result);
  2989.       copyResult.mpDamage = 0;
  2990.       this._damagePopup.push(copyResult);
  2991.     }
  2992.     if (result.mpDamage !== 0) {
  2993.       var copyResult = JsonEx.makeDeepCopy(result);
  2994.       copyResult.hpAffected = false;
  2995.       this._damagePopup.push(copyResult);
  2996.     }
  2997. };

  2998. Game_Battler.prototype.shiftDamagePopup = function() {
  2999.     if (!this._damagePopup) this.clearDamagePopup();
  3000.     return this._damagePopup.shift();
  3001. };

  3002. Yanfly.BEC.Game_Battler_performCollapse =
  3003.     Game_Battler.prototype.performCollapse;
  3004. Game_Battler.prototype.performCollapse = function() {
  3005.     Yanfly.BEC.Game_Battler_performCollapse.call(this);
  3006.     if ($gameParty.inBattle()) this.forceMotion(this.deadMotion());
  3007. };

  3008. Game_Battler.prototype.performResultEffects = function() {
  3009.     var result = this.result();
  3010.     if (result.missed && result.physical) this.performMiss();
  3011.     if (result.evaded) {
  3012.       if (result.physical) {
  3013.         this.performEvasion();
  3014.       } else {
  3015.         this.performMagicEvasion();
  3016.       }
  3017.     }
  3018.     if (result.hpAffected) {
  3019.       if (result.hpDamage > 0 && !result.drain) {
  3020.         this.performDamage();
  3021.       }
  3022.       if (result.hpDamage < 0) {
  3023.         this.performRecovery();
  3024.       }
  3025.     }
  3026.     if (this.isAlive() && result.mpDamage !== 0 && result.mpDamage < 0) {
  3027.       this.performRecovery();
  3028.     }
  3029.     if (this.isAlive() && result.tpDamage !== 0 && result.tpDamage < 0) {
  3030.       this.performRecovery();
  3031.     }
  3032. };

  3033. Yanfly.BEC.Game_Battler_performDamage =
  3034.   Game_Battler.prototype.performDamage;
  3035. Game_Battler.prototype.performDamage = function() {
  3036.     Yanfly.BEC.Game_Battler_performDamage.call(this);
  3037.     this.performFlinch();
  3038. };

  3039. Yanfly.BEC.Game_Battler_performMiss = Game_Battler.prototype.performMiss;
  3040. Game_Battler.prototype.performMiss = function() {
  3041.     Yanfly.BEC.Game_Battler_performMiss.call(this);
  3042.     this.performFlinch();
  3043. };

  3044. Yanfly.BEC.Game_Battler_performEvasion =
  3045.     Game_Battler.prototype.performEvasion;
  3046. Game_Battler.prototype.performEvasion = function() {
  3047.     Yanfly.BEC.Game_Battler_performEvasion.call(this);
  3048.     this.performFlinch();
  3049. };

  3050. Yanfly.BEC.Game_Battler_performMagicEvasion =
  3051.     Game_Battler.prototype.performMagicEvasion;
  3052. Game_Battler.prototype.performMagicEvasion = function() {
  3053.     Yanfly.BEC.Game_Battler_performMagicEvasion.call(this);
  3054.     this.performFlinch();
  3055. };

  3056. Game_Battler.prototype.performFlinch = function() {
  3057.     if (this._flinched || !$gameSystem.isSideView()) return;
  3058.     this._flinched = true;
  3059.     this.spriteStepFlinch();
  3060. };

  3061. Yanfly.BEC.Game_Battler_performReflection =
  3062.     Game_Battler.prototype.performReflection;
  3063. Game_Battler.prototype.performReflection = function() {
  3064.     Yanfly.BEC.Game_Battler_performReflection.call(this);
  3065.     if (!$gameSystem.isSideView() && this.isActor()) return;
  3066.     var animationId = this.reflectAnimationId();
  3067.     var mirror = this.isActor();
  3068.     this.startAnimation(animationId, mirror, 0);
  3069. };

  3070. Yanfly.BEC.Game_Battler_performSubstitute =
  3071.     Game_Battler.prototype.performSubstitute;
  3072. Game_Battler.prototype.performSubstitute = function(target) {
  3073.     Yanfly.BEC.Game_Battler_performSubstitute.call(this, target);
  3074.     if (!$gameSystem.isSideView()) return;
  3075.     this._flinched = true;
  3076.     if (BattleManager._action.isForAll()) {
  3077.       this.spriteStepForward();
  3078.       target.spriteStepSubBack();
  3079.     } else {
  3080.       this.spriteStepToSubstitute(target);
  3081.       target.spriteStepSubBack();
  3082.     }
  3083. };

  3084. Game_Battler.prototype.setBattler = function(sprite) {
  3085.     BattleManager.registerSprite(this, sprite);
  3086. };

  3087. Game_Battler.prototype.battler = function() {
  3088.     return BattleManager.getSprite(this);
  3089. };

  3090. Game_Battler.prototype.requestMotion = function(motionType) {
  3091.     this._motionType = motionType;
  3092.     if (this.battler()) {
  3093.       this.battler().startMotion(motionType);
  3094.     }
  3095. };

  3096. Game_Battler.prototype.forceMotion = function(motionType) {
  3097.     this._motionType = motionType;
  3098.     if (this.battler()) {
  3099.       this.battler().forceMotion(motionType);
  3100.     }
  3101. };

  3102. Game_Battler.prototype.startWeaponAnimation = function(weaponImageId) {
  3103.     this._weaponImageId = weaponImageId;
  3104.     if (this.battler()) {
  3105.       this.battler().setupWeaponAnimation();
  3106.     }
  3107. };

  3108. Game_Battler.prototype.performActionStart = function(action) {
  3109.     if (!action.isGuard()) {
  3110.         this.setActionState('acting');
  3111.         this.spriteStepForward();
  3112.     }
  3113. };

  3114. Yanfly.BEC.Game_Battler_performActionEnd =
  3115.     Game_Battler.prototype.performActionEnd;
  3116. Game_Battler.prototype.performActionEnd = function() {
  3117.     Yanfly.BEC.Game_Battler_performActionEnd.call(this);
  3118.     this.spriteReturnHome();
  3119. };

  3120. Game_Battler.prototype.spriteStepForward = function() {
  3121.     if ($gameSystem.isSideView() && this.battler()) {
  3122.       this.battler().stepForward();
  3123.     }
  3124. };

  3125. Game_Battler.prototype.spriteStepBack = function() {
  3126.     if ($gameSystem.isSideView() && this.battler()) {
  3127.       this.battler().stepBack();
  3128.     }
  3129. };

  3130. Game_Battler.prototype.spriteStepSubBack = function() {
  3131.     if ($gameSystem.isSideView() && this.battler()) {
  3132.       this.battler().stepSubBack();
  3133.     }
  3134. };

  3135. Game_Battler.prototype.spriteStepToSubstitute = function(target) {
  3136.     if ($gameSystem.isSideView() && this.battler()) {
  3137.       this.battler().stepToSubstitute(target);
  3138.     }
  3139. };

  3140. Game_Battler.prototype.spriteStepFlinch = function() {
  3141.     if ($gameSystem.isSideView() && this.battler()) {
  3142.       this.battler().stepFlinch();
  3143.     }
  3144. };

  3145. Game_Battler.prototype.spriteReturnHome = function() {
  3146.     if ($gameSystem.isSideView() && this.battler()) {
  3147.       this._flinched = false;
  3148.       this.spriteFaceForward();
  3149.       this.battler().stepBack();
  3150.       if (this.numActions() <= 0) {
  3151.         this.setActionState('undecided');
  3152.       }
  3153.       this.battler().refreshMotion();
  3154.     }
  3155. };

  3156. Game_Battler.prototype.reflectAnimationId = function() {
  3157.     for (var i = 0; i < this.states().length; ++i) {
  3158.       var state = this.states()[i];
  3159.       if (state.reflectAnimationId > 0) return state.reflectAnimationId;
  3160.     }
  3161.     return Yanfly.Param.BECReflectAni;
  3162. };

  3163. Game_Battler.prototype.spriteCanMove = function() {
  3164.     if (!$gameSystem.isSideView()) return false;
  3165.     for (var i = 0; i < this.states().length; ++i) {
  3166.       var state = this.states()[i];
  3167.       if (state.spriteCannotMove) return false;
  3168.     }
  3169.     return this.canMove();
  3170. };

  3171. Game_Battler.prototype.spritePosX = function() {
  3172.     if ($gameSystem.isSideView() && this.battler()) {
  3173.       return this.battler().x;
  3174.     } else if (this.battler()) {
  3175.       return this.battler().x;
  3176.     } else {
  3177.       return 0;
  3178.     }
  3179. };

  3180. Game_Battler.prototype.spritePosY = function() {
  3181.     if ($gameSystem.isSideView() && this.battler()) {
  3182.       return this.battler().y;
  3183.     } else if (this.battler()) {
  3184.       return this.battler().y;
  3185.     } else {
  3186.       return 0;
  3187.     }
  3188. };

  3189. Game_Battler.prototype.spriteWidth = function() {
  3190.     if ($gameSystem.isSideView() && this.battler() && this.battler().bitmap) {
  3191.       return this.battler().bitmap.width;
  3192.     } else if (this.battler()) {
  3193.       return this.battler().bitmap.width;
  3194.     } else {
  3195.       return 1;
  3196.     }
  3197. };

  3198. Game_Battler.prototype.spriteHeight = function() {
  3199.     if ($gameSystem.isSideView() && this.battler() && this.battler().bitmap) {
  3200.       return this.battler().bitmap.height;
  3201.     } else if (this.battler()) {
  3202.       return this.battler().bitmap.height;
  3203.     } else {
  3204.       return 1;
  3205.     }
  3206. };

  3207. Game_Battler.prototype.anchorX = function() {
  3208.     return Yanfly.Param.BECAnchorX;
  3209. };

  3210. Game_Battler.prototype.anchorY = function() {
  3211.     return Yanfly.Param.BECAnchorY;
  3212. };

  3213. Game_Battler.prototype.spriteHomeX = function() {
  3214.     if ($gameSystem.isSideView() && this.battler()) {
  3215.       return this.battler()._homeX;
  3216.     } else {
  3217.       return 0;
  3218.     }
  3219. };

  3220. Game_Battler.prototype.spriteHomeY = function() {
  3221.     if ($gameSystem.isSideView() && this.battler()) {
  3222.       return this.battler()._homeY;
  3223.     } else {
  3224.       return 0;
  3225.     }
  3226. };

  3227. Game_Battler.prototype.setMirror = function(value) {
  3228.     if ($gameSystem.isSideView() && this.battler() && this.spriteCanMove()) {
  3229.       this.battler().setMirror(value);
  3230.     }
  3231. };

  3232. Game_Battler.prototype.spriteFaceForward = function() {
  3233.     this.setMirror(false);
  3234. };

  3235. Game_Battler.prototype.spriteFaceBackward = function() {
  3236.     this.setMirror(true);
  3237. };

  3238. Game_Battler.prototype.spriteFacePoint = function(pointX, pointY) {
  3239.     if (this.spritePosX() > pointX) {
  3240.       this.spriteFaceBackward();
  3241.     } else {
  3242.       this.spriteFaceForward();
  3243.     }
  3244. };

  3245. Game_Battler.prototype.spriteFaceAwayPoint = function(pointX, pointY) {
  3246.     if (this.spritePosX() > pointX) {
  3247.       this.spriteFaceForward();
  3248.     } else {
  3249.       this.spriteFaceBackward();
  3250.     }
  3251. };

  3252. Game_Battler.prototype.spriteFaceTarget = function(target) {
  3253.     if (!target) return;
  3254.     var pointX = target.spritePosX();
  3255.     var pointY = target.spritePosY();
  3256.     this.spriteFacePoint(pointX, pointY);
  3257. };

  3258. Game_Battler.prototype.spriteFaceAwayTarget = function(target) {
  3259.     if (!target) return;
  3260.     var pointX = target.spritePosX();
  3261.     var pointY = target.spritePosY();
  3262.     this.spriteFaceAwayPoint(pointX, pointY);
  3263. };

  3264. Game_Battler.prototype.spriteFaceHome = function() {
  3265.     var pointX = this.spriteHomeX();
  3266.     var pointY = this.spriteHomeY();
  3267.     this.spriteFacePoint(pointX, pointY);
  3268. };

  3269. Game_Battler.prototype.spriteFaceAwayHome = function() {
  3270.     var pointX = target.spriteHomeX();
  3271.     var pointY = target.spriteHomeY();
  3272.     this.spriteFaceAwayPoint(pointX, pointY);
  3273. };

  3274. Game_Battler.prototype.attackMotion = function() {
  3275.     return 'thrust';
  3276. };

  3277. Game_Battler.prototype.performAttack = function() {
  3278. };

  3279. Game_Battler.prototype.forceMotionRefresh = function() {
  3280.     if (!$gameParty.inBattle()) return;
  3281.     if (this.battler()) this.battler().refreshMotion();
  3282. };

  3283. Game_Battler.prototype.requestMotionRefresh = function() {
  3284.     var deadMotion = this.deadMotion();
  3285.     if (this.isDead() && this._motionType !== deadMotion) {
  3286.       this.requestMotion(deadMotion);
  3287.     }
  3288.     if (this.isDead() && this._motionType === deadMotion) return;
  3289.     if (this._motionType === 'victory') return;
  3290.     if (this._motionType === 'escape' && !BattleManager.isInputting()) return;
  3291.     if (this._motionType === 'guard' && !BattleManager.isInputting()) return;
  3292.     this.clearMotion();
  3293.     if (this.battler() && BattleManager.isInputting()) {
  3294.       this.battler().refreshMotion();
  3295.     }
  3296. };

  3297. Game_Battler.prototype.onTurnStart = function() {
  3298.     this.updateStateTurnStart();
  3299. };

  3300. Game_Battler.prototype.onTurnEnd = function() {
  3301.     this.clearResult();
  3302.     if (BattleManager.isTurnBased()) {
  3303.       this.regenerateAll();
  3304.     } else if (BattleManager.isTickBased() && !BattleManager.isTurnEnd()) {
  3305.       this.regenerateAll();
  3306.     }
  3307.     this.removeStatesAuto(2);
  3308. };

  3309. Yanfly.BEC.Game_Battler_onAllActionsEnd =
  3310.     Game_Battler.prototype.onAllActionsEnd;
  3311. Game_Battler.prototype.onAllActionsEnd = function() {
  3312.     Yanfly.BEC.Game_Battler_onAllActionsEnd.call(this);
  3313.     if (!BattleManager._processTurn) this.updateStateActionEnd();
  3314. };

  3315. Game_Battler.prototype.updateTick = function() {
  3316.     if (BattleManager.timeBasedStates()) this.updateStateTicks();
  3317.     if (BattleManager.timeBasedBuffs()) this.updateBuffTicks();
  3318. };

  3319. Game_Battler.prototype.increaseSelfTurnCount = function() {
  3320.     if (this._selfTurnCount === undefined) this._selfTurnCount = 0;
  3321.     this._selfTurnCount += 1;
  3322. };

  3323. Game_Battler.prototype.turnCount = function() {
  3324.     if (BattleManager.isTurnBased()) return $gameTroop.turnCount();
  3325.     if (BattleManager.isTickBased() && Yanfly.Param.BECAISelfTurn) {
  3326.       return this._selfTurnCount;
  3327.     }
  3328.     return $gameTroop.turnCount();
  3329. };

  3330. Game_Battler.prototype.createActions = function() {
  3331.     if (this.currentAction()) return;
  3332.     this.makeActions();
  3333. };

  3334. Yanfly.BEC.Game_Battler_addState = Game_Battler.prototype.addState;
  3335. Game_Battler.prototype.addState = function(stateId) {
  3336.     Yanfly.BEC.Game_Battler_addState.call(this, stateId);
  3337.     if (this.canAddStateFreeTurn(stateId)) this.setStateFreeTurn(stateId);
  3338. };

  3339. Game_Battler.prototype.canAddStateFreeTurn = function(stateId) {
  3340.     if (!$gameParty.inBattle()) return false;
  3341.     if (!this.isStateAffected(stateId)) return false;
  3342.     if (BattleManager._subject !== this) return false;
  3343.     if ($dataStates[stateId].autoRemovalTiming !== 1) return false;
  3344.     return true;
  3345. };

  3346. Game_Battler.prototype.setStateFreeTurn = function(stateId) {
  3347.     this._freeStateTurn = this._freeStateTurn || [];
  3348.     this._freeStateTurn.push(stateId);
  3349. };

  3350. Game_Battler.prototype.idleMotion = function() {
  3351.     return 'walk';
  3352. };

  3353. Game_Battler.prototype.deadMotion = function() {
  3354.     return 'dead';
  3355. };

  3356. Game_Battler.prototype.sleepMotion = function() {
  3357.     return 'sleep';
  3358. };

  3359. Game_Battler.prototype.chantMotion = function() {
  3360.     return 'chant';
  3361. };

  3362. Game_Battler.prototype.guardMotion = function() {
  3363.     return 'guard';
  3364. };

  3365. Game_Battler.prototype.abnormalMotion = function() {
  3366.     return 'abnormal';
  3367. };

  3368. Game_Battler.prototype.dyingMotion = function() {
  3369.     return 'dying';
  3370. };

  3371. Game_Battler.prototype.waitMotion = function() {
  3372.     return 'wait';
  3373. };

  3374. //=============================================================================
  3375. // Game_Actor
  3376. //=============================================================================

  3377. Yanfly.BEC.Game_Actor_refresh = Game_Actor.prototype.refresh;
  3378. Game_Actor.prototype.refresh = function() {
  3379.     this._anchorX = undefined;
  3380.     this._anchorY = undefined;
  3381.     Yanfly.BEC.Game_Actor_refresh.call(this);
  3382.     if ($gameParty.inBattle()) this.requestStatusRefresh();
  3383. };

  3384. Game_Actor.prototype.isSpriteVisible = function() {
  3385.     if ($gameSystem.isSideView()) return true;
  3386.     return eval(Yanfly.Param.BECFrontSprite);
  3387. };

  3388. Game_Actor.prototype.reflectAnimationId = function() {
  3389.     if (this.actor().reflectAnimationId > 0) {
  3390.       return this.actor().reflectAnimationId;
  3391.     }
  3392.     if (this.currentClass().reflectAnimationId > 0) {
  3393.       return this.currentClass().reflectAnimationId;
  3394.     }
  3395.     for (var i = 0; i < this.equips().length; ++i) {
  3396.       var equip = this.equips()[i];
  3397.       if (equip && equip.reflectAnimationId > 0) {
  3398.         return equip.reflectAnimationId;
  3399.       }
  3400.     }
  3401.     return Game_Battler.prototype.reflectAnimationId.call(this);
  3402. };

  3403. Game_Actor.prototype.spriteCanMove = function() {
  3404.     if (this.actor().spriteCannotMove) return false;
  3405.     if (this.currentClass().spriteCannotMove) return false;
  3406.     for (var i = 0; i < this.equips().length; ++i) {
  3407.       var equip = this.equips()[i];
  3408.       if (equip && equip.spriteCannotMove) return false;
  3409.     }
  3410.     return Game_Battler.prototype.spriteCanMove.call(this);
  3411. };

  3412. Game_Actor.prototype.spriteWidth = function() {
  3413.     if ($gameSystem.isSideView() && this.battler()) {
  3414.       return this.battler()._mainSprite.width;
  3415.     } else {
  3416.       return 1;
  3417.     }
  3418. };

  3419. Game_Actor.prototype.spriteHeight = function() {
  3420.     if ($gameSystem.isSideView() && this.battler()) {
  3421.       return this.battler()._mainSprite.height;
  3422.     } else {
  3423.       return 1;
  3424.     }
  3425. };

  3426. Game_Actor.prototype.anchorX = function() {
  3427.     if (this._anchorX !== undefined) return this._anchorX;
  3428.     var length = this.states().length;
  3429.     for (var i = 0; i < length; ++i) {
  3430.       var obj = this.states()[i];
  3431.       if (obj && obj.anchorX !== undefined) {
  3432.         this._anchorX = obj.anchorX;
  3433.         return this._anchorX;
  3434.       }
  3435.     }
  3436.     length = this.equips().length;
  3437.     for (var i = 0; i < length; ++i) {
  3438.       var obj = this.equips()[i];
  3439.       if (obj && obj.anchorX !== undefined) {
  3440.         this._anchorX = obj.anchorX;
  3441.         return this._anchorX;
  3442.       }
  3443.     }
  3444.     if (this.currentClass().anchorX !== undefined) {
  3445.       this._anchorX = this.currentClass().anchorX;
  3446.       return this._anchorX;
  3447.     }
  3448.     this._anchorX = this.actor().anchorX;
  3449.     return this._anchorX;
  3450. };

  3451. Game_Actor.prototype.anchorY = function() {
  3452.     if (this._anchorY !== undefined) return this._anchorY;
  3453.     var length = this.states().length;
  3454.     for (var i = 0; i < length; ++i) {
  3455.       var obj = this.states()[i];
  3456.       if (obj && obj.anchorY !== undefined) {
  3457.         this._anchorY = obj.anchorY;
  3458.         return this._anchorY;
  3459.       }
  3460.     }
  3461.     length = this.equips().length;
  3462.     for (var i = 0; i < length; ++i) {
  3463.       var obj = this.equips()[i];
  3464.       if (obj && obj.anchorY !== undefined) {
  3465.         this._anchorY = obj.anchorY;
  3466.         return this._anchorY;
  3467.       }
  3468.     }
  3469.     if (this.currentClass().anchorY !== undefined) {
  3470.       this._anchorY = this.currentClass().anchorY;
  3471.       return this._anchorY;
  3472.     }
  3473.     this._anchorY = this.actor().anchorY;
  3474.     return this._anchorY;
  3475. };

  3476. Game_Actor.prototype.spriteFacePoint = function(pointX, pointY) {
  3477.     if (this.spritePosX() > pointX) {
  3478.       this.spriteFaceForward();
  3479.     } else {
  3480.       this.spriteFaceBackward();
  3481.     }
  3482. };

  3483. Game_Actor.prototype.spriteFaceAwayPoint = function(pointX, pointY) {
  3484.     if (this.spritePosX() > pointX) {
  3485.       this.spriteFaceBackward();
  3486.     } else {
  3487.       this.spriteFaceForward();
  3488.     }
  3489. };

  3490. Game_Actor.prototype.performAttack = function() {
  3491.     var weapons = this.weapons();
  3492.     var wtypeId = weapons[0] ? weapons[0].wtypeId : 0;
  3493.     var attackMotion = $dataSystem.attackMotions[wtypeId];
  3494.     if (attackMotion) {
  3495.       if (attackMotion.type === 0) {
  3496.         this.forceMotion('thrust');
  3497.       } else if (attackMotion.type === 1) {
  3498.         this.forceMotion('swing');
  3499.       } else if (attackMotion.type === 2) {
  3500.         this.forceMotion('missile');
  3501.       }
  3502.       this.startWeaponAnimation(attackMotion.weaponImageId);
  3503.     }
  3504. };

  3505. Game_Actor.prototype.attackMotion = function() {
  3506.     var weapons = this.weapons();
  3507.     var wtypeId = weapons[0] ? weapons[0].wtypeId : 0;
  3508.     var attackMotion = $dataSystem.attackMotions[wtypeId];
  3509.     if (attackMotion) {
  3510.       if (attackMotion.type === 0) {
  3511.         return 'thrust';
  3512.       } else if (attackMotion.type === 1) {
  3513.         return 'swing';
  3514.       } else if (attackMotion.type === 2) {
  3515.         return 'missile';
  3516.       }
  3517.     };
  3518.     return 'thrust';
  3519. };

  3520. Game_Actor.prototype.performEscapeSuccess = function() {
  3521.     if (this.battler()) {
  3522.       this.performEscape();
  3523.       this.battler().startMove(300, 0, 60);
  3524.     }
  3525. };

  3526. //=============================================================================
  3527. // Game_Enemy
  3528. //=============================================================================

  3529. Game_Enemy.prototype.performActionStart = function(action) {
  3530.     Game_Battler.prototype.performActionStart.call(this, action);
  3531.     if (!$gameSystem.isSideView() || !this.spriteCanMove()) {
  3532.       this.requestEffect('whiten');
  3533.     }
  3534. };

  3535. Yanfly.BEC.Game_Enemy_performDamage = Game_Enemy.prototype.performDamage;
  3536. Game_Enemy.prototype.performDamage = function() {
  3537.     if ($gameSystem.isSideView()) {
  3538.       Game_Battler.prototype.performDamage.call(this);
  3539.       SoundManager.playEnemyDamage();
  3540.     } else {
  3541.       Yanfly.BEC.Game_Enemy_performDamage.call(this);
  3542.     }
  3543. };

  3544. Game_Enemy.prototype.attackAnimationId = function() {
  3545.     return this.enemy().attackAnimationId;
  3546. };

  3547. Game_Enemy.prototype.reflectAnimationId = function() {
  3548.     if (this.enemy().reflectAnimationId > 0) {
  3549.       return this.enemy().reflectAnimationId;
  3550.     }
  3551.     return Game_Battler.prototype.reflectAnimationId.call(this);
  3552. };

  3553. Game_Enemy.prototype.spriteCanMove = function() {
  3554.     if (this.enemy().spriteCannotMove) return false;
  3555.     return Game_Battler.prototype.spriteCanMove.call(this);
  3556. };

  3557. Game_Enemy.prototype.meetsTurnCondition = function(param1, param2) {
  3558.     var n = this.turnCount();
  3559.     if (param2 === 0) {
  3560.         return n === param1;
  3561.     } else {
  3562.         return n > 0 && n >= param1 && n % param2 === param1 % param2;
  3563.     }
  3564. };

  3565. //=============================================================================
  3566. // Game_Unit
  3567. //=============================================================================

  3568. Game_Unit.prototype.createActions = function() {
  3569.     var max = this.members().length;
  3570.     for (var i = 0; i < max; ++i) {
  3571.       var member = this.members()[i];
  3572.       if (member) member.createActions();
  3573.     }
  3574. };

  3575. Game_Unit.prototype.requestMotionRefresh = function() {
  3576.     var max = this.members().length;
  3577.     for (var i = 0; i < max; ++i) {
  3578.       var member = this.members()[i];
  3579.       if (member) member.requestMotionRefresh();
  3580.     }
  3581. };

  3582. Game_Unit.prototype.onTurnStart = function() {
  3583.     var max = this.members().length;
  3584.     for (var i = 0; i < max; ++i) {
  3585.       var member = this.members()[i];
  3586.       if (member) member.onTurnStart();
  3587.     }
  3588. };

  3589. Game_Unit.prototype.updateTick = function() {
  3590.     var max = this.members().length;
  3591.     for (var i = 0; i < max; ++i) {
  3592.       var member = this.members()[i];
  3593.       if (member) member.updateTick();
  3594.     }
  3595. };

  3596. //=============================================================================
  3597. // Game_Party
  3598. //=============================================================================

  3599. Game_Party.prototype.performEscapeSuccess = function() {
  3600.     for (var i = 0; i < this.members().length; ++i) {
  3601.       var member = this.members()[i];
  3602.       if (member) member.performEscapeSuccess();
  3603.     }
  3604. };

  3605. //=============================================================================
  3606. // Scene_Battle
  3607. //=============================================================================

  3608. Yanfly.BEC.Scene_Battle_update = Scene_Battle.prototype.update;
  3609. Scene_Battle.prototype.update = function() {
  3610.     Yanfly.BEC.Scene_Battle_update.call(this);
  3611.     this.updateStatusWindowRequests();
  3612. };

  3613. Scene_Battle.prototype.updateStatusWindowRequests = function() {
  3614.     if (!this._statusWindow) return;
  3615.     if (this._statusWindow.isClosed()) return;
  3616.     this._statusWindow.updateStatusRequests();
  3617. };

  3618. Yanfly.BEC.Scene_Battle_createSkillWindow =
  3619.     Scene_Battle.prototype.createSkillWindow;
  3620. Scene_Battle.prototype.createSkillWindow = function() {
  3621.     Yanfly.BEC.Scene_Battle_createSkillWindow.call(this);
  3622.     if (eval(Yanfly.Param.BECLowerWindows)) {
  3623.       this.adjustLowerWindow(this._skillWindow);
  3624.     }
  3625. };

  3626. Yanfly.BEC.Scene_Battle_createItemWindow =
  3627.     Scene_Battle.prototype.createItemWindow;
  3628. Scene_Battle.prototype.createItemWindow = function() {
  3629.     Yanfly.BEC.Scene_Battle_createItemWindow.call(this);
  3630.     if (eval(Yanfly.Param.BECLowerWindows)) {
  3631.       this.adjustLowerWindow(this._itemWindow);
  3632.     }
  3633. };

  3634. Yanfly.BEC.Scene_Battle_createActorWindow =
  3635.     Scene_Battle.prototype.createActorWindow;
  3636. Scene_Battle.prototype.createActorWindow = function() {
  3637.     Yanfly.BEC.Scene_Battle_createActorWindow.call(this);
  3638.     this._actorWindow.x = Graphics.boxWidth - this._actorWindow.width;
  3639.     if (eval(Yanfly.Param.BECSelectHelp)) {
  3640.       this._actorWindow.setHelpWindow(this._helpWindow);
  3641.     }
  3642. };

  3643. Yanfly.BEC.Scene_Battle_createEnemyWindow =
  3644.     Scene_Battle.prototype.createEnemyWindow;
  3645. Scene_Battle.prototype.createEnemyWindow = function() {
  3646.     Yanfly.BEC.Scene_Battle_createEnemyWindow.call(this);
  3647.     if (eval(Yanfly.Param.BECSelectHelp)) {
  3648.       this._enemyWindow.setHelpWindow(this._helpWindow);
  3649.     }
  3650. };

  3651. Scene_Battle.prototype.adjustLowerWindow = function(win) {
  3652.     win.height = win.fittingHeight(eval(Yanfly.Param.BECWindowRows));
  3653.     win.y = Graphics.boxHeight - win.height;
  3654. };

  3655. Yanfly.BEC.Scene_Battle_startPartyCommandSelection =
  3656.     Scene_Battle.prototype.startPartyCommandSelection;
  3657. Scene_Battle.prototype.startPartyCommandSelection = function() {
  3658.     if (this.isStartActorCommand()) {
  3659.       this.selectNextCommand();
  3660.     } else {
  3661.       Yanfly.BEC.Scene_Battle_startPartyCommandSelection.call(this);
  3662.     }
  3663. };

  3664. Scene_Battle.prototype.isStartActorCommand = function() {
  3665.     if (this._isStartActorCommand === undefined) {
  3666.       this._isStartActorCommand = eval(Yanfly.Param.BECStartActCmd)
  3667.     }
  3668.     return this._isStartActorCommand;
  3669. };

  3670. Yanfly.BEC.Scene_Battle_selectPreviousCommand =
  3671.     Scene_Battle.prototype.selectPreviousCommand;
  3672. Scene_Battle.prototype.selectPreviousCommand = function() {
  3673.     if (this.isStartActorCommand()) {
  3674.       BattleManager.selectPreviousCommand();
  3675.       if (BattleManager.isInputting() && BattleManager.actor()) {
  3676.         this.startActorCommandSelection();
  3677.       } else {
  3678.         Yanfly.BEC.Scene_Battle_startPartyCommandSelection.call(this);
  3679.       }
  3680.     } else {
  3681.       Yanfly.BEC.Scene_Battle_selectPreviousCommand.call(this);
  3682.     }
  3683. };

  3684. Yanfly.BEC.Scene_Battle_selectNextCommand =
  3685.     Scene_Battle.prototype.selectNextCommand;
  3686. Scene_Battle.prototype.selectNextCommand = function() {
  3687.     Yanfly.BEC.Scene_Battle_selectNextCommand.call(this);
  3688.     this._helpWindow.clear();
  3689.     BattleManager.stopAllSelection();
  3690. };

  3691. Yanfly.BEC.Scene_Battle_commandSkill = Scene_Battle.prototype.commandSkill;
  3692. Scene_Battle.prototype.commandSkill = function() {
  3693.     this._helpWindow.clear();
  3694.     Yanfly.BEC.Scene_Battle_commandSkill.call(this);
  3695. };

  3696. Yanfly.BEC.Scene_Battle_commandItem = Scene_Battle.prototype.commandItem;
  3697. Scene_Battle.prototype.commandItem = function() {
  3698.     this._helpWindow.clear();
  3699.     Yanfly.BEC.Scene_Battle_commandItem.call(this);
  3700. };

  3701. Yanfly.BEC.Scene_Battle_startActorCommandSelection =
  3702.     Scene_Battle.prototype.startActorCommandSelection;
  3703. Scene_Battle.prototype.startActorCommandSelection = function() {
  3704.     BattleManager.createActions();
  3705.     Yanfly.BEC.Scene_Battle_startActorCommandSelection.call(this);
  3706.     this._statusWindow.refresh();
  3707. };

  3708. Yanfly.BEC.Scene_Battle_selectActorSelection =
  3709.     Scene_Battle.prototype.selectActorSelection;
  3710. Scene_Battle.prototype.selectActorSelection = function() {
  3711.     if (eval(Yanfly.Param.BECSelectHelp)) this._helpWindow.show();
  3712.     this._helpWindow.clear();
  3713.     Yanfly.BEC.Scene_Battle_selectActorSelection.call(this);
  3714.     this._actorWindow.autoSelect();
  3715. };

  3716. Yanfly.BEC.Scene_Battle_onActorCancel = Scene_Battle.prototype.onActorCancel;
  3717. Scene_Battle.prototype.onActorCancel = function() {
  3718.     if (eval(Yanfly.Param.BECSelectHelp)) this._helpWindow.hide();
  3719.     this._helpWindow.clear();
  3720.     Yanfly.BEC.Scene_Battle_onActorCancel.call(this);
  3721.     BattleManager.stopAllSelection();
  3722.     BattleManager.clearInputtingAction();
  3723. };

  3724. Yanfly.BEC.Scene_Battle_selectEnemySelection =
  3725.     Scene_Battle.prototype.selectEnemySelection;
  3726. Scene_Battle.prototype.selectEnemySelection = function() {
  3727.     if (eval(Yanfly.Param.BECSelectHelp)) this._helpWindow.show();
  3728.     this._helpWindow.clear();
  3729.     Yanfly.BEC.Scene_Battle_selectEnemySelection.call(this);
  3730.     this._enemyWindow.autoSelect();
  3731. };

  3732. Yanfly.BEC.Scene_Battle_onEnemyCancel = Scene_Battle.prototype.onEnemyCancel;
  3733. Scene_Battle.prototype.onEnemyCancel = function() {
  3734.     if (eval(Yanfly.Param.BECSelectHelp)) this._helpWindow.hide();
  3735.     this._helpWindow.clear();
  3736.     Yanfly.BEC.Scene_Battle_onEnemyCancel.call(this);
  3737.     BattleManager.stopAllSelection();
  3738.     BattleManager.clearInputtingAction();
  3739. };

  3740. Yanfly.BEC.Scene_Battle_onSelectAction = Scene_Battle.prototype.onSelectAction;
  3741. Scene_Battle.prototype.onSelectAction = function() {
  3742.     if (eval(Yanfly.Param.BECSelectHelp)) BattleManager.forceSelection();
  3743.     this._helpWindow.clear();
  3744.     Yanfly.BEC.Scene_Battle_onSelectAction.call(this);
  3745.     if (eval(Yanfly.Param.BECSelectHelp)) BattleManager.resetSelection();
  3746. };

  3747. Yanfly.BEC.Scene_Battle_onSkillOk =
  3748.     Scene_Battle.prototype.onSkillOk;
  3749. Scene_Battle.prototype.onSkillOk = function() {
  3750.     this._helpWindow.clear();
  3751.     Yanfly.BEC.Scene_Battle_onSkillOk.call(this);
  3752. };

  3753. Yanfly.BEC.Scene_Battle_onSkillCancel =
  3754.     Scene_Battle.prototype.onSkillCancel;
  3755. Scene_Battle.prototype.onSkillCancel = function() {
  3756.     this._helpWindow.clear();
  3757.     Yanfly.BEC.Scene_Battle_onSkillCancel.call(this);
  3758.     BattleManager.clearInputtingAction();
  3759. };

  3760. Yanfly.BEC.Scene_Battle_onItemOk =
  3761.     Scene_Battle.prototype.onItemOk;
  3762. Scene_Battle.prototype.onItemOk = function() {
  3763.     this._helpWindow.clear();
  3764.     Yanfly.BEC.Scene_Battle_onItemOk.call(this);
  3765. };

  3766. Yanfly.BEC.Scene_Battle_onItemCancel =
  3767.     Scene_Battle.prototype.onItemCancel;
  3768. Scene_Battle.prototype.onItemCancel = function() {
  3769.     this._helpWindow.clear();
  3770.     Yanfly.BEC.Scene_Battle_onItemCancel.call(this);
  3771.     BattleManager.clearInputtingAction();
  3772. };

  3773. //=============================================================================
  3774. // Window_Selectable
  3775. //=============================================================================

  3776. Yanfly.BEC.Window_Selectable_isCursorMovable =
  3777.     Window_Selectable.prototype.isCursorMovable;
  3778. Window_Selectable.prototype.isCursorMovable = function() {
  3779.     if (this._inputLock) return false;
  3780.     return Yanfly.BEC.Window_Selectable_isCursorMovable.call(this);
  3781. };

  3782. //=============================================================================
  3783. // Window_Help
  3784. //=============================================================================

  3785. Yanfly.BEC.Window_Help_clear = Window_Help.prototype.clear;
  3786. Window_Help.prototype.clear = function() {
  3787.     Yanfly.BEC.Window_Help_clear.call(this);
  3788.     this.contents.clear();
  3789. };

  3790. Window_Help.prototype.setBattler = function(battler) {
  3791.     this.contents.clear();
  3792.     this.clear();
  3793.     if (!$gameParty.inBattle()) return;
  3794.     if (!battler) return;
  3795.     var action = BattleManager.inputtingAction();
  3796.     if (this.specialSelectionText(action)) {
  3797.       this.drawSpecialSelectionText(action);
  3798.     } else {
  3799.       this.drawBattler(battler);
  3800.     }
  3801. };

  3802. Window_Help.prototype.specialSelectionText = function(action) {
  3803.     BattleManager.resetSelection();
  3804.     if (!action) return false;
  3805.     return !action.needsSelection();
  3806. };

  3807. Window_Help.prototype.drawBattler = function(battler) {
  3808.     var text = battler.name();
  3809.     var wx = 0;
  3810.     var wy = (this.contents.height - this.lineHeight()) / 2;
  3811.     this.drawText(text, wx, wy, this.contents.width, 'center');
  3812. };

  3813. Window_Help.prototype.drawSpecialSelectionText = function(action) {
  3814.     var wx = 0;
  3815.     var wy = (this.contents.height - this.lineHeight()) / 2;
  3816.     var text = '';
  3817.     if (action.isForUser()) {
  3818.       text = Yanfly.Param.BECHelpUserTx;
  3819.     } else if (action.isForRandom()) {
  3820.       BattleManager.startAllSelection();
  3821.       var fmt = Yanfly.Param.BECHelpRandTx;
  3822.       if (action.isForOpponent() && action.numTargets() !== 1) {
  3823.         var target = Yanfly.Param.BECHelpEnemiesTx;
  3824.       } else if (action.isForOpponent() && action.numTargets() === 1) {
  3825.         var target = Yanfly.Param.BECHelpEnemyTx;
  3826.       } else if (action.isForFriend() && action.numTargets() !== 1) {
  3827.         var target = Yanfly.Param.BECHelpAlliesTx;
  3828.       } else {
  3829.         var target = Yanfly.Param.BECHelpAllyTx;
  3830.       }
  3831.       text = fmt.format(target, Yanfly.Util.toGroup(action.numTargets()));
  3832.     } else if (action.isForAll()) {
  3833.       BattleManager.startAllSelection();
  3834.       var fmt = Yanfly.Param.BECHelpAllTx;
  3835.       if (action.isForOpponent()) {
  3836.         var target = Yanfly.Param.BECHelpEnemiesTx;
  3837.       } else {
  3838.         var target = Yanfly.Param.BECHelpAlliesTx;
  3839.       }
  3840.       text = fmt.format(target);
  3841.     }
  3842.     this.drawText(text, wx, wy, this.contents.width, 'center');
  3843. };

  3844. //=============================================================================
  3845. // Window_BattleActor
  3846. //=============================================================================

  3847. Window_BattleActor.prototype.autoSelect = function() {
  3848.     var action = BattleManager.inputtingAction();
  3849.     if (!action) return;
  3850.     this._inputLock = false;
  3851.     this._selectDead = false;
  3852.     if (action.isForUser()) {
  3853.       this.select(BattleManager.actor().index());
  3854.       this._inputLock = true;
  3855.     } else if (action.isForDeadFriend()) {
  3856.       this._selectDead = true;
  3857.     }
  3858. };

  3859. Window_BattleActor.prototype.isOkEnabled = function() {
  3860.     if (this._selectDead) return this.actor().isDead();
  3861.     return Window_Selectable.prototype.isOkEnabled.call(this);
  3862. };

  3863. Window_BattleActor.prototype.updateHelp = function() {
  3864.     if (!this._helpWindow) return;
  3865.     this._helpWindow.setBattler(this.actor());
  3866. };

  3867. Yanfly.BEC.Window_BattleActor_processTouch =
  3868.     Window_BattleActor.prototype.processTouch;
  3869. Window_BattleActor.prototype.processTouch = function() {
  3870.     if (eval(Yanfly.Param.BECActorSelect) && this.isOpenAndActive()) {
  3871.       if (TouchInput.isTriggered() && !this.isTouchedInsideFrame()) {
  3872.         if (this.getClickedActor() >= 0) {
  3873.           var index = this.getClickedActor();
  3874.           if (this.index() === index) {
  3875.             return this.processOk();
  3876.           } else {
  3877.             SoundManager.playCursor();
  3878.             return this.select(index);
  3879.           }
  3880.         }
  3881.       }
  3882.       if (TouchInput.isPressed() && !this.isTouchedInsideFrame()) {
  3883.         if (this.getClickedActor() >= 0) {
  3884.           var index = this.getClickedActor();
  3885.           if (this.index() !== index) {
  3886.             SoundManager.playCursor();
  3887.             return this.select(index);
  3888.           }
  3889.         }
  3890.       }
  3891.       if (Yanfly.Param.BECSelectMouseOver) {
  3892.         var index = this.getMouseOverActor();
  3893.         if (index >= 0 && this.index() !== index) {
  3894.           SoundManager.playCursor();
  3895.           return this.select(index);
  3896.         }
  3897.       }
  3898.     }
  3899.     Yanfly.BEC.Window_BattleActor_processTouch.call(this);
  3900. };

  3901. Window_BattleActor.prototype.getClickedActor = function() {
  3902.     for (var i = 0; i < $gameParty.battleMembers().length; ++i) {
  3903.       var actor = $gameParty.battleMembers().reverse()[i];
  3904.       if (!actor) continue;
  3905.       if (this.isClickedActor(actor)) {
  3906.         if (this._selectDead && !actor.isDead()) continue;
  3907.         if (this._inputLock && actor.index() !== this.index()) continue;
  3908.         return actor.index();
  3909.       }
  3910.     }
  3911.     return -1;
  3912. };

  3913. Window_BattleActor.prototype.isClickedActor = function(actor) {
  3914.     if (!actor) return false;
  3915.     if (!actor.isSpriteVisible()) return false;
  3916.     if (!actor.isAppeared()) return false;
  3917.     var x = TouchInput.x;
  3918.     var y = TouchInput.y;
  3919.     var rect = new Rectangle();
  3920.     rect.width = actor.spriteWidth();
  3921.     rect.height = actor.spriteHeight();
  3922.     rect.x = actor.spritePosX() - rect.width / 2;
  3923.     rect.y = actor.spritePosY() - rect.height;
  3924.     return (x >= rect.x && y >= rect.y && x < rect.x + rect.width &&
  3925.       y < rect.y + rect.height);
  3926. };

  3927. Window_BattleActor.prototype.getMouseOverActor = function() {
  3928.     for (var i = 0; i < $gameParty.battleMembers().length; ++i) {
  3929.       var actor = $gameParty.battleMembers().reverse()[i];
  3930.       if (!actor) continue;
  3931.       if (this.isMouseOverActor(actor)) {
  3932.         if (this._selectDead && !actor.isDead()) continue;
  3933.         if (this._inputLock && actor.index() !== this.index()) continue;
  3934.         return actor.index();
  3935.       }
  3936.     }
  3937.     return -1;
  3938. };

  3939. Window_BattleActor.prototype.isMouseOverActor = function(actor) {
  3940.     if (!actor) return false;
  3941.     if (!actor.isSpriteVisible()) return false;
  3942.     if (!actor.isAppeared()) return false;
  3943.     var x = TouchInput._mouseOverX;
  3944.     var y = TouchInput._mouseOverY;
  3945.     var rect = new Rectangle();
  3946.     rect.width = actor.spriteWidth();
  3947.     rect.height = actor.spriteHeight();
  3948.     rect.x = actor.spritePosX() - rect.width / 2;
  3949.     rect.y = actor.spritePosY() - rect.height;
  3950.     return (x >= rect.x && y >= rect.y && x < rect.x + rect.width &&
  3951.       y < rect.y + rect.height);
  3952. };

  3953. //=============================================================================
  3954. // Window_BattleEnemy
  3955. //=============================================================================

  3956. Yanfly.DisableWebGLMask = false;

  3957. Yanfly.BEC.Window_BattleEnemy_initialize =
  3958.     Window_BattleEnemy.prototype.initialize;
  3959. Window_BattleEnemy.prototype.initialize = function(x, y) {
  3960.     if (eval(Yanfly.Param.BECEnemySelect)) {
  3961.       x -= Graphics.boxWidth * 200;
  3962.       y -= Graphics.boxHeight * 200;
  3963.     };
  3964.     Yanfly.BEC.Window_BattleEnemy_initialize.call(this, x, y);
  3965. };

  3966. Yanfly.BEC.WindowLayer_webglMaskWindow =
  3967.     WindowLayer.prototype._webglMaskWindow;
  3968. WindowLayer.prototype._webglMaskWindow = function(renderSession, win) {
  3969.     if (win._ignoreMask) return;
  3970.     Yanfly.BEC.WindowLayer_webglMaskWindow.call(this, renderSession, win);
  3971. };

  3972. Yanfly.BEC.Window_BattleEnemy_maxCols =
  3973.     Window_BattleEnemy.prototype.maxCols;
  3974. Window_BattleEnemy.prototype.maxCols = function() {
  3975.     if (eval(Yanfly.Param.BECEnemySelect)) return this._enemies.length;
  3976.     return Yanfly.BEC.Window_BattleEnemy_maxCols.call(this);
  3977. };

  3978. Window_BattleEnemy.prototype.allowedTargets = function() {
  3979.     var targets = [];
  3980.     targets = targets.concat($gameTroop.aliveMembers());
  3981.     return targets;
  3982. };

  3983. Window_BattleEnemy.prototype.refresh = function() {
  3984.     this._enemies = this.allowedTargets();
  3985.     this.sortTargets();
  3986.     Window_Selectable.prototype.refresh.call(this);
  3987. };

  3988. Window_BattleEnemy.prototype.sortTargets = function() {
  3989.     this._enemies.sort(function(a, b) {
  3990.         if (a.spritePosX() == b.spritePosX()) {
  3991.           return a.spritePosY() - b.spritePosY();
  3992.         }
  3993.         return a.spritePosX() - b.spritePosX();
  3994.     });
  3995. };

  3996. Window_BattleEnemy.prototype.autoSelect = function() {
  3997.     var selectIndex = eval(Yanfly.Param.BECEnemyAutoSel);
  3998.     this.select(selectIndex);
  3999. };

  4000. Window_BattleEnemy.prototype.furthestRight = function() {
  4001.     return this.maxItems() - 1;
  4002. };

  4003. Window_BattleEnemy.prototype.updateHelp = function() {
  4004.     if (!this._helpWindow) return;
  4005.     this._helpWindow.setBattler(this.enemy());
  4006. };

  4007. Yanfly.BEC.Window_BattleEnemy_processTouch =
  4008.     Window_BattleEnemy.prototype.processTouch;
  4009. Window_BattleEnemy.prototype.processTouch = function() {
  4010.     if (eval(Yanfly.Param.BECEnemySelect) && this.isOpenAndActive()) {
  4011.       if (TouchInput.isTriggered() && !this.isTouchedInsideFrame()) {
  4012.         if (this.getClickedEnemy() >= 0) {
  4013.           var index = this.getClickedEnemy();
  4014.           if (this.index() === index) {
  4015.             return this.processOk();
  4016.           } else {
  4017.             SoundManager.playCursor();
  4018.             return this.select(index);
  4019.           }
  4020.         }
  4021.       }
  4022.       if (TouchInput.isPressed() && !this.isTouchedInsideFrame()) {
  4023.         if (this.getClickedEnemy() >= 0) {
  4024.           var index = this.getClickedEnemy();
  4025.           if (this.index() !== index) {
  4026.             SoundManager.playCursor();
  4027.             return this.select(index);
  4028.           }
  4029.         }
  4030.       }
  4031.       if (Yanfly.Param.BECSelectMouseOver) {
  4032.         var index = this.getMouseOverEnemy();
  4033.         if (index >= 0 && this.index() !== index) {
  4034.           SoundManager.playCursor();
  4035.           return this.select(index);
  4036.         }
  4037.       }
  4038.     };
  4039.     Yanfly.BEC.Window_BattleEnemy_processTouch.call(this);
  4040. };

  4041. Window_BattleEnemy.prototype.getClickedEnemy = function() {
  4042.     for (var i = 0; i < this._enemies.length; ++i) {
  4043.       var enemy = this._enemies[i];
  4044.       if (!enemy) continue;
  4045.       if (this.isClickedEnemy(enemy)) {
  4046.         if (this._selectDead && !enemy.isDead()) continue;
  4047.         var index = this._enemies.indexOf(enemy)
  4048.         if (this._inputLock && index !== this.index()) continue;
  4049.         return index;
  4050.       }
  4051.     }
  4052.     return -1;
  4053. };

  4054. Window_BattleEnemy.prototype.isClickedEnemy = function(enemy) {
  4055.     if (!enemy) return false;
  4056.     if (!enemy.isSpriteVisible()) return false;
  4057.     var x = TouchInput.x;
  4058.     var y = TouchInput.y;
  4059.     var rect = new Rectangle();
  4060.     rect.width = enemy.spriteWidth();
  4061.     rect.height = enemy.spriteHeight();
  4062.     rect.x = enemy.spritePosX() - rect.width / 2;
  4063.     rect.y = enemy.spritePosY() - rect.height;
  4064.     return (x >= rect.x && y >= rect.y && x < rect.x + rect.width &&
  4065.       y < rect.y + rect.height);
  4066. };

  4067. Window_BattleEnemy.prototype.getMouseOverEnemy = function() {
  4068.     for (var i = 0; i < this._enemies.length; ++i) {
  4069.       var enemy = this._enemies[i];
  4070.       if (!enemy) continue;
  4071.       if (this.isMouseOverEnemy(enemy)) {
  4072.         if (this._selectDead && !enemy.isDead()) continue;
  4073.         var index = this._enemies.indexOf(enemy)
  4074.         if (this._inputLock && index !== this.index()) continue;
  4075.         return index;
  4076.       }
  4077.     }
  4078.     return -1;
  4079. };

  4080. Window_BattleEnemy.prototype.isMouseOverEnemy = function(enemy) {
  4081.     if (!enemy) return false;
  4082.     if (!enemy.isSpriteVisible()) return false;
  4083.     var x = TouchInput._mouseOverX;
  4084.     var y = TouchInput._mouseOverY;
  4085.     var rect = new Rectangle();
  4086.     rect.width = enemy.spriteWidth();
  4087.     rect.height = enemy.spriteHeight();
  4088.     rect.x = enemy.spritePosX() - rect.width / 2;
  4089.     rect.y = enemy.spritePosY() - rect.height;
  4090.     return (x >= rect.x && y >= rect.y && x < rect.x + rect.width &&
  4091.       y < rect.y + rect.height);
  4092. };

  4093. //=============================================================================
  4094. // Window_EnemyVisualSelect
  4095. //=============================================================================

  4096. function Window_EnemyVisualSelect() {
  4097.     this.initialize.apply(this, arguments);
  4098. }

  4099. Window_EnemyVisualSelect.prototype = Object.create(Window_Base.prototype);
  4100. Window_EnemyVisualSelect.prototype.constructor = Window_EnemyVisualSelect;

  4101. Window_EnemyVisualSelect.prototype.initialize = function() {
  4102.     Window_Base.prototype.initialize.call(this, 0, 0, 1, 1);
  4103.     this._battler = null;
  4104.     this._battlerName = '';
  4105.     this._requestRefresh = false;
  4106.     this._showSelectCursor = eval(Yanfly.Param.BECShowSelectBox);
  4107.     this._showEnemyName = eval(Yanfly.Param.BECShowEnemyName);
  4108.     this.contentsOpacity = 0;
  4109.     this.opacity = 0;
  4110. };

  4111. Window_EnemyVisualSelect.prototype.setBattler = function(battler) {
  4112.     if (this._battler === battler) return;
  4113.     this._battler = battler;
  4114.     this._battlerName = battler.name();
  4115. };

  4116. Window_EnemyVisualSelect.prototype.update = function() {
  4117.     Window_Base.prototype.update.call(this);
  4118.     if (!this._battler) return;
  4119.     this.updateWindowAspects();
  4120. };

  4121. Window_EnemyVisualSelect.prototype.updateWindowAspects = function() {
  4122.     this.updateBattlerName();
  4123.     this.updateWindowSize();
  4124.     this.updateWindowPosition();
  4125.     this.updateOpacity();
  4126.     this.updateRefresh();
  4127.     this.updateCursor();
  4128. };

  4129. Window_EnemyVisualSelect.prototype.updateBattlerName = function() {
  4130.     if (this._battlerName !== this._battler.name())
  4131.     this._battlerName = this._battler.name();
  4132.     this._requestRefresh = true;
  4133. };

  4134. Window_EnemyVisualSelect.prototype.updateWindowSize = function() {
  4135.     var spriteWidth = this._battler.spriteWidth();
  4136.     this.contents.fontSize = Yanfly.Param.BECEnemyFontSize;
  4137.     var textWidth = this.textWidth(this._battler.name());
  4138.     textWidth += this.textPadding() * 2;
  4139.     var width = Math.max(spriteWidth, textWidth) + this.standardPadding() * 2;
  4140.     var height = this._battler.spriteHeight() + this.standardPadding() * 2;
  4141.     if (width === this.width && height === this.height) return;
  4142.     this.width = width;
  4143.     this.height = height;
  4144.     this.createContents();
  4145.     this._requestRefresh = true;
  4146.     this.makeWindowBoundaries();
  4147. };

  4148. Window_EnemyVisualSelect.prototype.makeWindowBoundaries = function() {
  4149.     if (!this._requestRefresh) return;
  4150.     this._minX = -1 * this.standardPadding();
  4151.     this._maxX = Graphics.boxWidth - this.width + this.standardPadding();
  4152.     this._minY = -1 * this.standardPadding();
  4153.     this._maxY = Graphics.boxHeight - this.height + this.standardPadding();
  4154.     this._maxY -= SceneManager._scene._statusWindow.height;
  4155. };

  4156. Window_EnemyVisualSelect.prototype.updateWindowPosition = function() {
  4157.     if (!this._battler) return;
  4158.     this.x = -1 * this.width / 2;
  4159.     this.y = -1 * this.height + this.standardPadding();
  4160.     this.x += this._battler.spritePosX();
  4161.     this.y += this._battler.spritePosY();
  4162.     this.x = this.x.clamp(this._minX, this._maxX);
  4163.     this.y = this.y.clamp(this._minY, this._maxY);
  4164. };

  4165. Window_EnemyVisualSelect.prototype.updateOpacity = function() {
  4166.     if (this.isShowWindow()) {
  4167.       this.contentsOpacity += 32;
  4168.     } else {
  4169.       this.contentsOpacity -= 32;
  4170.     }
  4171. };

  4172. Window_EnemyVisualSelect.prototype.isShowWindow = function() {
  4173.     var scene = SceneManager._scene;
  4174.     if (!scene._enemyWindow) return false;
  4175.     var enemyWindow = scene._enemyWindow;
  4176.     if (!enemyWindow.active) return false;
  4177.     if (!this._battler.isAppeared()) return false;
  4178.     if (this._battler.isDead()) {
  4179.       return enemyWindow._selectDead;
  4180.     }
  4181.     return enemyWindow._enemies.contains(this._battler);
  4182. };

  4183. Window_EnemyVisualSelect.prototype.updateCursor = function() {
  4184.     if (this.isShowCursor()) {
  4185.       var wy = this.contents.height - this.lineHeight();
  4186.       this.setCursorRect(0, wy, this.contents.width, this.lineHeight());
  4187.     } else {
  4188.       this.setCursorRect(0, 0, 0, 0);
  4189.     }
  4190. };

  4191. Window_EnemyVisualSelect.prototype.isShowCursor = function() {
  4192.     if (!this._showSelectCursor) return false;
  4193.     var scene = SceneManager._scene;
  4194.     if (!scene._enemyWindow) return false;
  4195.     var enemyWindow = scene._enemyWindow;
  4196.     if (!enemyWindow.active) return false;
  4197.     if (!this._battler.isAppeared()) return false;
  4198.     return this._battler.isSelected();
  4199. };

  4200. Window_EnemyVisualSelect.prototype.updateRefresh = function() {
  4201.     if (this._requestRefresh) this.refresh();
  4202. };

  4203. Window_EnemyVisualSelect.prototype.refresh = function() {
  4204.     this.contents.clear();
  4205.     if (!this._battler) return;
  4206.     if (!this._showEnemyName) return;
  4207.     if (this._battler.isHidden()) return;
  4208.     this._requestRefresh = false;
  4209.     this.contents.fontSize = Yanfly.Param.BECEnemyFontSize;
  4210.     var text = this._battler.name();
  4211.     var wy = this.contents.height - this.lineHeight();
  4212.     this.drawText(text, 0, wy, this.contents.width, 'center');
  4213. };

  4214. //=============================================================================
  4215. // Window_PartyCommand
  4216. //=============================================================================

  4217. Window_PartyCommand.prototype.itemTextAlign = function() {
  4218.     return Yanfly.Param.BECCommandAlign;
  4219. };

  4220. Window_PartyCommand.prototype.numVisibleRows = function() {
  4221.     return eval(Yanfly.Param.BECCommandRows);
  4222. };

  4223. //=============================================================================
  4224. // Window_ActorCommand
  4225. //=============================================================================

  4226. Window_ActorCommand.prototype.itemTextAlign = function() {
  4227.     return Yanfly.Param.BECCommandAlign;
  4228. };

  4229. Window_ActorCommand.prototype.numVisibleRows = function() {
  4230.     return eval(Yanfly.Param.BECCommandRows);
  4231. };

  4232. //=============================================================================
  4233. // Window_BattleStatus
  4234. //=============================================================================

  4235. Window_BattleStatus.prototype.numVisibleRows = function() {
  4236.     return eval(Yanfly.Param.BECCommandRows);
  4237. };

  4238. Window_BattleStatus.prototype.updateStatusRequests = function() {
  4239.     if (BattleManager._victoryPhase) return;
  4240.     for (var i = 0; i < $gameParty.battleMembers().length; ++i) {
  4241.       var actor = $gameParty.battleMembers()[i];
  4242.       if (!actor) continue;
  4243.       if (actor.isStatusRefreshRequested()) this.processStatusRefresh(i);
  4244.     }
  4245. };

  4246. Window_BattleStatus.prototype.processStatusRefresh = function(index) {
  4247.     var actor = $gameParty.battleMembers()[index];
  4248.     if (!actor) return;
  4249.     var rect = this.itemRect(index);
  4250.     this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
  4251.     this.drawItem(index);
  4252.     actor.completetStatusRefreshRequest();
  4253. };

  4254. if (!Yanfly.Param.BECCurMax) {

  4255. Window_BattleStatus.prototype.drawCurrentAndMax = function(current, max, x, y,
  4256.                                                    width, color1, color2) {
  4257.     var labelWidth = this.textWidth('HP');
  4258.     var valueWidth = this.textWidth(Yanfly.Util.toGroup(max));
  4259.     var slashWidth = this.textWidth('/');
  4260.     var x1 = x + width - valueWidth;
  4261.     this.changeTextColor(color1);
  4262.     this.drawText(Yanfly.Util.toGroup(current), x1, y, valueWidth, 'right');
  4263. };

  4264. }; // Yanfly.Param.BECCurMax

  4265. //=============================================================================
  4266. // Window_BattleLog
  4267. //=============================================================================

  4268. Yanfly.BEC.Window_BattleLog_isFastForward =
  4269.     Window_BattleLog.prototype.isFastForward;
  4270. Window_BattleLog.prototype.isFastForward = function() {
  4271.     if (eval(Yanfly.Param.BECOptSpeed)) return true;
  4272.     return Yanfly.BEC.Window_BattleLog_isFastForward.call(this);
  4273. };

  4274. Window_BattleLog.prototype.updateWaitCount = function() {
  4275.     if (this._waitCount > 0) {
  4276.         this._waitCount -= 1;
  4277.         if (this._waitCount < 0) {
  4278.             this._waitCount = 0;
  4279.         }
  4280.         return true;
  4281.     }
  4282.     return false;
  4283. };

  4284. Window_BattleLog.prototype.animationBaseDelay = function() {
  4285.     return eval(Yanfly.Param.BECAniBaseDel);
  4286. };

  4287. Window_BattleLog.prototype.animationNextDelay = function() {
  4288.     return eval(Yanfly.Param.BECAniNextDel);
  4289. };

  4290. Window_BattleLog.prototype.updateWaitMode = function() {
  4291.     var waiting = false;
  4292.     switch (this._waitMode) {
  4293.     case 'effect':
  4294.         waiting = this._spriteset.isEffecting();
  4295.         break;
  4296.     case 'movement':
  4297.         waiting = this._spriteset.isAnyoneMoving();
  4298.         break;
  4299.     case 'animation':
  4300.         waiting = this._spriteset.isAnimationPlaying();
  4301.         break;
  4302.     case 'popups':
  4303.         waiting = this._spriteset.isPopupPlaying();
  4304.         break;
  4305.     }
  4306.     if (!waiting) {
  4307.         this._waitMode = '';
  4308.     }
  4309.     return waiting;
  4310. };

  4311. Window_BattleLog.prototype.startAction = function(subject, action, targets) {
  4312. };

  4313. Window_BattleLog.prototype.endAction = function(subject) {
  4314. };

  4315. Window_BattleLog.prototype.waitForAnimation = function() {
  4316.     this.setWaitMode('animation');
  4317. };

  4318. Window_BattleLog.prototype.waitForEffect = function() {
  4319.     this.setWaitMode('effect');
  4320. };

  4321. Window_BattleLog.prototype.waitForPopups = function() {
  4322.     this.setWaitMode('popups');
  4323. };

  4324. Yanfly.BEC.Window_BattleLog_displayAction =
  4325.     Window_BattleLog.prototype.displayAction;
  4326. Window_BattleLog.prototype.displayAction = function(subject, item) {
  4327.     if (eval(Yanfly.Param.BECFullActText)) {
  4328.       Yanfly.BEC.Window_BattleLog_displayAction.call(this, subject, item);
  4329.     } else {
  4330.       this._actionIcon = this.displayIcon(item);
  4331.       var text = this.displayText(item);
  4332.       this.push('addText', '<SIMPLE>' + text);
  4333.       if (item.message2) {
  4334.         this.push('addText', '<CENTER>' + item.message2.format(text));
  4335.       }
  4336.     }
  4337. };

  4338. Window_BattleLog.prototype.displayIcon = function(item) {
  4339.     return item.battleDisplayIcon;
  4340. };

  4341. Window_BattleLog.prototype.displayText = function(item) {
  4342.     return item.battleDisplayText;
  4343. };

  4344. Yanfly.BEC.Window_BattleLog_displayActionResults =
  4345.     Window_BattleLog.prototype.displayActionResults;
  4346. Window_BattleLog.prototype.displayActionResults = function(subject, target) {
  4347.     if (eval(Yanfly.Param.BECOptSpeed)) {
  4348.       if (target.result().used) {
  4349.           this.displayCritical(target);
  4350.           this.displayDamage(target);
  4351.           this.displayAffectedStatus(target);
  4352.           this.displayFailure(target);
  4353.       }
  4354.     } else {
  4355.       Yanfly.BEC.Window_BattleLog_displayActionResults.call(this, subject,
  4356.           target);
  4357.     }
  4358.     if (target.isDead()) target.performCollapse();
  4359. };

  4360. Yanfly.BEC.Window_BattleLog_drawLineText =
  4361.     Window_BattleLog.prototype.drawLineText;
  4362. Window_BattleLog.prototype.drawLineText = function(index) {
  4363.     if (this._lines[index].match('<CENTER>')) {
  4364.       this.drawCenterLine(index);
  4365.     } else if (this._lines[index].match('<SIMPLE>')) {
  4366.       this.drawSimpleActionLine(index);
  4367.     } else {
  4368.       Yanfly.BEC.Window_BattleLog_drawLineText.call(this, index);
  4369.     }
  4370. };

  4371. Window_BattleLog.prototype.textWidthEx = function(text) {
  4372.     return this.drawTextEx(text, 0, this.contents.height);
  4373. };

  4374. Window_BattleLog.prototype.drawCenterLine = function(index) {
  4375.     var text = this._lines[index].replace('<CENTER>', '');
  4376.     var rect = this.itemRectForText(index);
  4377.     this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
  4378.     var tw = this.textWidthEx(text);
  4379.     var wx = rect.x + (rect.width - tw) / 2;
  4380.     this.drawTextEx(text, wx, rect.y);
  4381. };

  4382. Window_BattleLog.prototype.drawSimpleActionLine = function(index) {
  4383.     var text = this._lines[index].replace('<SIMPLE>', '');
  4384.     var rect = this.itemRectForText(index);
  4385.     this.contents.clearRect(rect.x, rect.y, rect.width, rect.height);
  4386.     if (this._actionIcon) {
  4387.       var tw = this.textWidth(text);
  4388.       var ix = (rect.width - tw) / 2 - 4;
  4389.       this.drawIcon(this._actionIcon, ix, rect.y + 2);
  4390.     }
  4391.     this.drawText(text, rect.x, rect.y, Graphics.boxWidth, 'center');
  4392. };

  4393. Window_BattleLog.prototype.displayCounter = function(target) {
  4394.     if (eval(Yanfly.Param.BECShowCntText)) {
  4395.       this.addText(TextManager.counterAttack.format(target.name()));
  4396.     }
  4397.     target.performCounter();
  4398.     this.showAttackAnimation(target, [BattleManager._subject]);
  4399.     this.waitForAnimation();
  4400. };

  4401. Window_BattleLog.prototype.displayReflection = function(target) {
  4402.     if (eval(Yanfly.Param.BECShowRflText)) {
  4403.       this.addText(TextManager.magicReflection.format(target.name()));
  4404.     }
  4405.     target.performReflection();
  4406.     var animationId = BattleManager._action.item().animationId;
  4407.     this.showNormalAnimation([BattleManager._subject], animationId);
  4408.     this.waitForAnimation();
  4409. };

  4410. Window_BattleLog.prototype.displaySubstitute = function(substitute, target) {
  4411.     if (eval(Yanfly.Param.BECShowSubText)) {
  4412.       var substName = substitute.name();
  4413.       this.addText(TextManager.substitute.format(substName, target.name()));
  4414.     }
  4415.     substitute.performSubstitute(target);
  4416. };

  4417. Yanfly.BEC.Window_BattleLog_displayFailure =
  4418.     Window_BattleLog.prototype.displayFailure;
  4419. Window_BattleLog.prototype.displayFailure = function(target) {
  4420.     if (!eval(Yanfly.Param.BECShowFailText)) return;
  4421.     Yanfly.BEC.Window_BattleLog_displayFailure.call(this, target);
  4422. };

  4423. Yanfly.BEC.Window_BattleLog_displayCritical =
  4424.     Window_BattleLog.prototype.displayCritical;
  4425. Window_BattleLog.prototype.displayCritical = function(target) {
  4426.     if (!eval(Yanfly.Param.BECShowCritText)) return;
  4427.     Yanfly.BEC.Window_BattleLog_displayCritical.call(this, target);
  4428. };

  4429. Yanfly.BEC.Window_BattleLog_displayMiss =
  4430.     Window_BattleLog.prototype.displayMiss;
  4431. Window_BattleLog.prototype.displayMiss = function(target) {
  4432.     if (!eval(Yanfly.Param.BECShowMissText)) return;
  4433.     Yanfly.BEC.Window_BattleLog_displayMiss.call(this, target);
  4434. };

  4435. Yanfly.BEC.Window_BattleLog_displayEvasion =
  4436.     Window_BattleLog.prototype.displayEvasion;
  4437. Window_BattleLog.prototype.displayEvasion = function(target) {
  4438.     if (!eval(Yanfly.Param.BECShowEvaText)) return;
  4439.     Yanfly.BEC.Window_BattleLog_displayEvasion.call(this, target);
  4440. };

  4441. Yanfly.BEC.Window_BattleLog_displayHpDamage =
  4442.     Window_BattleLog.prototype.displayHpDamage;
  4443. Window_BattleLog.prototype.displayHpDamage = function(target) {
  4444.     if (!eval(Yanfly.Param.BECShowHpText)) return;
  4445.     Yanfly.BEC.Window_BattleLog_displayHpDamage.call(this, target);
  4446. };

  4447. Yanfly.BEC.Window_BattleLog_displayMpDamage =
  4448.     Window_BattleLog.prototype.displayMpDamage;
  4449. Window_BattleLog.prototype.displayMpDamage = function(target) {
  4450.     if (!eval(Yanfly.Param.BECShowMpText)) return;
  4451.     Yanfly.BEC.Window_BattleLog_displayMpDamage.call(this, target);
  4452. };

  4453. Yanfly.BEC.Window_BattleLog_displayTpDamage =
  4454.     Window_BattleLog.prototype.displayTpDamage;
  4455. Window_BattleLog.prototype.displayTpDamage = function(target) {
  4456.     if (!eval(Yanfly.Param.BECShowTpText)) return;
  4457.     Yanfly.BEC.Window_BattleLog_displayTpDamage.call(this, target);
  4458. };

  4459. Yanfly.BEC.Window_BattleLog_displayCurrentState =
  4460.     Window_BattleLog.prototype.displayCurrentState;
  4461. Window_BattleLog.prototype.displayCurrentState = function(subject) {
  4462.     if (!eval(Yanfly.Param.BECShowStateText)) return;
  4463.     Yanfly.BEC.Window_BattleLog_displayCurrentState.call(this, subject);
  4464. };

  4465. Yanfly.BEC.Window_BattleLog_displayAddedStates =
  4466.     Window_BattleLog.prototype.displayAddedStates;
  4467. Window_BattleLog.prototype.displayAddedStates = function(target) {
  4468.     if (!eval(Yanfly.Param.BECShowStateText)) return;
  4469.     Yanfly.BEC.Window_BattleLog_displayAddedStates.call(this, target);
  4470. };

  4471. Yanfly.BEC.Window_BattleLog_displayRemovedStates =
  4472.     Window_BattleLog.prototype.displayRemovedStates;
  4473. Window_BattleLog.prototype.displayRemovedStates = function(target) {
  4474.     if (!eval(Yanfly.Param.BECShowStateText)) return;
  4475.     Yanfly.BEC.Window_BattleLog_displayRemovedStates.call(this, target);
  4476. };

  4477. Yanfly.BEC.Window_BattleLog_displayChangedBuffs =
  4478.     Window_BattleLog.prototype.displayChangedBuffs;
  4479. Window_BattleLog.prototype.displayChangedBuffs = function(target) {
  4480.     if (!eval(Yanfly.Param.BECShowBuffText)) return;
  4481.     Yanfly.BEC.Window_BattleLog_displayChangedBuffs.call(this, target);
  4482. };

  4483. Window_BattleLog.prototype.popupDamage = function(target) {
  4484. };

  4485. Yanfly.BEC.Window_BattleLog_showEnemyAttackAnimation =
  4486.     Window_BattleLog.prototype.showEnemyAttackAnimation;
  4487. Window_BattleLog.prototype.showEnemyAttackAnimation =
  4488. function(subject, targets) {
  4489.     if ($gameSystem.isSideView()) {
  4490.       this.showNormalAnimation(targets, subject.attackAnimationId(), false);
  4491.     } else {
  4492.       this.showNormalAnimation(targets, subject.attackAnimationId(), false);
  4493.       Yanfly.BEC.Window_BattleLog_showEnemyAttackAnimation.call(this, subject,
  4494.           targets);
  4495.     }
  4496. };

  4497. Window_BattleLog.prototype.showActorAtkAniMirror = function(subject, targets) {
  4498.     this.showNormalAnimation(targets, subject.attackAnimationId1(), true);
  4499.     this.showNormalAnimation(targets, subject.attackAnimationId2(), false);
  4500. };

  4501. //=============================================================================
  4502. // New Function
  4503. //=============================================================================

  4504. Yanfly.Util = Yanfly.Util || {};

  4505. if (!Yanfly.Util.toGroup) {
  4506.     Yanfly.Util.toGroup = function(inVal) {
  4507.         return inVal;
  4508.     }
  4509. };

  4510. Yanfly.Util.getRange = function(n, m) {
  4511.     var result = [];
  4512.     for (var i = n; i <= m; ++i) result.push(i);
  4513.     return result;
  4514. };

  4515. Yanfly.Util.onlyUnique = function(value, index, self) {
  4516.     return self.indexOf(value) === index;
  4517. };

  4518. //=============================================================================
  4519. // End of File
  4520. //=============================================================================
复制代码
梦石
0
星屑
230
在线时间
174 小时
注册时间
2016-2-24
回帖
83
发表于 2016-3-11 23:51:53 | 显示全部楼层
插件参数里最后一项LOG下面全部改成true

评分

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

查看全部评分

回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部