Double_X

DoubleX RMVXA Enhanced YSA Battle System: Classical ATB

May 11th, 2015 (edited)
2,787
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 397.85 KB | None | 1 0
  1. #==============================================================================|
  2. #  ** Script Info                                                              |
  3. #------------------------------------------------------------------------------|
  4. #  * Script Name                                                               |
  5. #    DoubleX RMVXA Enhanced YSA Battle System: Classical ATB                   |
  6. #------------------------------------------------------------------------------|
  7. #  * Functions                                                                 |
  8. #    Be an enhanced version of YSA-CATB with bug fixes and addons integrated   |
  9. #    Features:                                                                 |
  10. #    1. Action Input Events(Core)                                              |
  11. #        You can set something to occur right before/after inputting actions   |
  12. #    2. Action Input Speed(Speed)                                              |
  13. #       You can set some enemys and/or actors with autobattle and/or confusion |
  14. #       to have action input speeds set by you                                 |
  15. #    3. ATB Bar Colors(Core)                                                   |
  16. #       You can set some actors, classes, weapons, armors, enemies and/or      |
  17. #       states to alter their owner's atb bar colors by ways set by you        |
  18. #    4. ATB Clock Window(Clock)                                                |
  19. #       You can set if and how the atb clock info will be shown in battle      |
  20. #    5. ATB Fill Rate(Core)                                                    |
  21. #       You can set some actors, classes, weapons, armors, enemies and/or      |
  22. #       states to alter their owner's atb fill rate by ways set by you         |
  23. #    6. ATB Force Run/Stop(Force)                                              |
  24. #       You can set keys to force the atb clock to run or stop when pressed    |
  25. #       You can also set if and how the atb force status will be shown         |
  26. #    7. ATB Pool(Pool)                                                         |
  27. #       You can set the atb and action points to be shared among the party or  |
  28. #       troop                                                                  |
  29. #       Right now it doesn't support toogling this feature in battles          |
  30. #       (v0.05a+)Right now it doesn't work well with the Gradual Action Points |
  31. #       Gain feature                                                           |
  32. #    8. ATB Reset Events(Core)                                                 |
  33. #       You can set something to occur right before and/or after an atb reset  |
  34. #    9. ATB Reset Value(Core)                                                  |
  35. #       You can set some skill or items to reset their users' atb value by     |
  36. #       values set by You                                                      |
  37. #    10. ATB Turn Type(Core)                                                   |
  38. #        You can set if the turn is based on time, number of actions/battlers  |
  39. #    11. ATB Update Events(Core)                                               |
  40. #        You can set something to occur right before and/or after an atb update|
  41. #    12. Battler Charging Cancellation/Setup/Target Selection Hotkeys(Hotkey)  |
  42. #        You can set hotkeys to call actors/enemies that can input actions, be |
  43. #        targeted or are charging skills/items                                 |
  44. #    13. Battler Cool Down(Cooldown)                                           |
  45. #        You can set some skills or items to cause their users to have to cool |
  46. #        down for a while before their atb bar will be filled again            |
  47. #    14. Battler Order Window(Order)                                           |
  48. #        You can set if and how the battler orders will be shown in battle     |
  49. #    15. Battler Ready SE(SE)                                                  |
  50. #        You can set some battlers to play a se set by users when the battlers |
  51. #        become able to act                                                    |
  52. #    16. Battler Sprite ATB Bars(Bar)                                          |
  53. #        You can set the contents and layouts of the battler sprite atb bars   |
  54. #        and the conditions for them to be shown                               |
  55. #    17. Changing battle systems(Core)                                         |
  56. #        You can change the battle system to any of those supported by         |
  57. #        Yanfly Engine Ace - Ace Battle Engine outside battles                 |
  58. #    18. Cooldown Finish Events(Cooldown)                                      |
  59. #        You can set something to occur right after finishing cooldown normally|
  60. #    19. Countdown States(Countdown)                                           |
  61. #        You can set some states having duration in seconds and conditions     |
  62. #        that trigger actions when they're met                                 |
  63. #    20. (v0.04a+)CTB Replication(Core)                                        |
  64. #        You can set this script to replicate a CTB system by skipping the atb,|
  65. #        charge and cooldown filling times, and the global atb tick clock      |
  66. #    21. Dynamic configuration values(Core)                                    |
  67. #        Almost all user configuration values can be changed by you on the fly |
  68. #    22. Escape/ATB Wait Conditions(Core)                                      |
  69. #        You can set the conditions for party escape and/or the atb clock to   |
  70. #        stop running                                                          |
  71. #    23. Failed Escape Attempt Action Cost(Core)                               |
  72. #        You can set the action costed paid by all party members right after   |
  73. #        a failed escape attempt                                               |
  74. #    24. (v0.05a+)Gradual Action Points Gain(Action)                           |
  75. #        You can set some battlers' action points to be gained 1 by 1 instead  |
  76. #        of gaining all action points at once                                  |
  77. #        Right now it doesn't work well with the ATB Pool feature              |
  78. #    25. Skill/Item Action Cost(Core)                                          |
  79. #        You can set some skills or items to have their own action point       |
  80. #        demands                                                               |
  81. #    26. Skill/Item Cancel(Cancel)                                             |
  82. #        You can cancel party members' charging skill/items                    |
  83. #    27. Skill/Item Charging(Charge)                                           |
  84. #        You can set party escape, some skills or items to demand users to     |
  85. #        charge for a while before executing them                              |
  86. #        You can also set some skills or items requiring charging to demands   |
  87. #        their users to pay the costs after started or finished charging       |
  88. #    28. Start ATB Value(Core)                                                 |
  89. #        You can set some battlers to have their own initial atb values at     |
  90. #        the beginning of a battle under conditions set by you                 |
  91. #    29. Unison Skills(Unison)                                                 |
  92. #        You can set some skills/items to need more than 1 battler to use      |
  93. #        Right now it only supports actor unison skills/items                  |
  94. #    Possibly upcoming features:                                               |
  95. #    1. Action Batch Execution                                                 |
  96. #       You can set some battlers to input and execute more than 1 actions in a|
  97. #       single action input and execution phase respectively                   |
  98. #    2. Multiple ATB Types                                                     |
  99. #       You can set some skills/items to use some ATB types and some other     |
  100. #       skills/items to use some other ATB types                               |
  101. #    3. Premature Discharge                                                    |
  102. #       You can set some skills/items to be able to be prematurely executed    |
  103. #       before it finishes charging under some conditions and trade offs       |
  104. #------------------------------------------------------------------------------|
  105. #  * Terms Of Use                                                              |
  106. #    You shall:                                                                |
  107. #    1. Follow the terms of use of YSA Battle System: Classical ATB            |
  108. #    2. Let your published edits of this script be integrated as parts of it   |
  109. #    3. Keep this script's Script Info part's contents intact                  |
  110. #    You shalln't:                                                             |
  111. #    1. Claim that this script's written by anyone other than DoubleX, his     |
  112. #       aliases, Yami, or his/her aliases                                      |
  113. #    2. Make an edit of this script while saying it isn't                      |
  114. #    3. Make a RMVXA project based on this script's demo while saying it isn't |
  115. #    None of the above applies to Yami or his/her aliases                      |
  116. #------------------------------------------------------------------------------|
  117. #  * Prerequisites                                                             |
  118. #    Scripts:                                                                  |
  119. #    1. Yanfly Engine Ace - Ace Battle Engine                                  |
  120. #    Abilities:                                                                |
  121. #    1. Solid understanding of the active time battle system concepts          |
  122. #    2. Solid understanding of the RMVXA notetag and script call usages        |
  123. #    3. Decent RGSS3 scripting proficiency to fully utilize this script        |
  124. #------------------------------------------------------------------------------|
  125. #  * Instructions                                                              |
  126. #    1. Open the script editor and put this script into an open slot between   |
  127. #       Yanfly Engine Ace - Ace Battle Engine and Main. Save to take effect.   |
  128. #    2. This script can't be used with YSA Battle System: Classical ATB.       |
  129. #    3. Set DEFAULT_BATTLE_SYSTEM in Yanfly Engine Ace - Ace Battle Engine as  |
  130. #       :ecatb to set the default battle system as that of this script.        |
  131. #------------------------------------------------------------------------------|
  132. #  * Author's Notes                                                            |
  133. #    1. Using Yanfly Engine Ace - Ace Core Engine is highly recommended as it  |
  134. #       fixes the force action bug of this script and improve the atb percent  |
  135. #       and action points display in the actor atb bars.                       |
  136. #    2. Using Yanfly Engine Ace - Buff & State Manager is highly recommended as|
  137. #       it displays the states' remaining turns.                               |
  138. #    3. Using Yanfly Engine Ace - Skill Cost Manager is highly recommended as  |
  139. #       it can display the skills/items' action point requirements by using    |
  140. #       <custom cost: skill.ecatb_act_cost[@actor]>.                           |
  141. #    4. Using Cidiomar's Input as well is highly recommended as it lets users  |
  142. #       set custom keymaps, which is useful for features using keyboard inputs.|
  143. #    5. Using DoubleX RMVXA Dynamic Data is highly recommemded as it lets you  |
  144. #       change the notetag values on the fly.                                  |
  145. #       - ecatb_note_strings[note] is an accessor letting you store your new   |
  146. #         notetag values of notetag note.                                      |
  147. #       - reset_ecatb_notes(note) applies the above changes.                   |
  148. #    6. Using DoubleX RMVXA State Counters is highly recommended as it displays|
  149. #       the enemy countdown states.                                            |
  150. #    7. Using DoubleX RMVXA State Triggers is highly recommended as the CATB   |
  151. #       Clear Addon and some features of the CATB Countdown Addon are          |
  152. #       outsourced to that script.                                             |
  153. #    8. This is an advanced complicated script, meaning testings are likely    |
  154. #       needed to comprehend the use of every configuration of this script.    |
  155. #    9. This script can run using the default settings, but you're still highly|
  156. #       recommended to comprehend all user settings of this script.            |
  157. #    10. This script checks and corrects most configuration(but not notetag)   |
  158. #        values, but you're still highly recommended to validate every         |
  159. #        configuration(and notetag) values themselves.                         |
  160. #    11. Using too many and/or complicated notetags and/or configuration values|
  161. #        can cause severe performance issues, especailly on less able machines.|
  162. #------------------------------------------------------------------------------|
  163. #  * FAQ                                                                       |
  164. #    Q1. What's the main difference between ECATB and CATB?                    |
  165. #    A1. 1. The former integrates everything except compatibility fix into 1   |
  166. #           script while the addons and bug fix of the latter are all separate |
  167. #           scripts.                                                           |
  168. #        2. Almost all user settings of the former can be changed on the fly   |
  169. #           easily while lots of the latter are always fixed once set by users |
  170. #           or even just hardcoded.                                            |
  171. #        3. Some notetags of the former lets users do more stuffs than some of |
  172. #           those of the latter.                                               |
  173. #        4. The code structures and documentations of the former are generally |
  174. #           clearer, neater and more logical than those of the latter.         |
  175. #        5. The codes of the former are generally more effective, efficient,   |
  176. #           flexible, maintainable, reliable and robust than the latter.       |
  177. #        6. The former does a more thorough user error checking and corrections|
  178. #           than the latter for most user settings in most cases.              |
  179. #        7. The former generally demands much more from both the users and     |
  180. #           scripters than the latter.                                         |
  181. #        8. Users can't disable addons in the former while they can add and/or |
  182. #           remove the addon of the latter effortlessly.                       |
  183. #        9. The latter outsources little features to other scripts while the   |
  184. #           former does this significantly more heavily.                       |
  185. #    Q2. Some settings need scripting knowledge to use. May you please teach me|
  186. #        scripting?                                                            |
  187. #    A2. You can ask me how to set specific settings to meet your specific     |
  188. #        needs, but it seems to me that there are many good scripting teachers |
  189. #        so you may want to ask them instead of me for learning scripting.     |
  190. #    Q3. Why don't you implement the reverse atb bar feature in this script    |
  191. #        like what Victor Sant did in his atb script?                          |
  192. #    A3. It's implicitly implemented but the feature is still in this script:  |
  193. #        1. Set :ecatb_bar_colors as %Q(Color.new(0, 0, 0, 0),                 |
  194. #           Color.new(0, 0, 0, 0)).                                            |
  195. #           It makes the atb bar invisible.                                    |
  196. #        2. Set :ecatb_base_fill_t as %Q(1 / Graphics.frame_rate).             |
  197. #           It sets the base atb fill rate to be 100% per frame.               |
  198. #        3. Set the charge rate of each skill or item as "x".                  |
  199. #           It makes the skill or item to charge x% atb per frame.             |
  200. #    Q4. Why I'll have to credit Yami but not you when it's your work?         |
  201. #    A4. It's because this script's an edit of CATB and is heavily based on it.|
  202. #        Without Yami's CATB, this script won't exist; Without his term of use |
  203. #        permitting editing his CATB, this script won't exist as well.         |
  204. #    Q5. What's the point of making ECATB when we've CATB?                     |
  205. #    A5. 1. Some users may prefer having everything bundled into a single      |
  206. #           script and that's the main reason for me to make ECATB.            |
  207. #        2. Lets advanced users have much more control and freedom over the    |
  208. #           script settings. ECATB does that at the cost of significantly      |
  209. #           raising the demand of user proficiency, while CATB keeps the       |
  210. #           settings simple at the cost of obviously reducing the settting     |
  211. #           flexibilities.                                                     |
  212. #    Q6. Can you make this script easier for non-scripters to use?             |
  213. #    A6. I tried to make it as easy as I can but right now that's my limit.    |
  214. #    Q7. Why some settings aren't hardcoded when no users would change them?   |
  215. #    A7. If that's really the case, I'll consider making them hardcoded.       |
  216. #    Q8. Why the script configuration part needs to have 2400+ lines?          |
  217. #    A8. That's because this script does need that many lines to let users set |
  218. #        the configurations of this script. You may want to use CATB instead if|
  219. #        you don't need most of this script's configurations.                  |
  220. #    Q9. Why 'Let your published edits of this script be integrated as parts of|
  221. #        it' is included in the terms of use?                                  |
  222. #    A9. 1. It means I want to reserve that right but that doesn't mean I'll   |
  223. #           always do so. I'll never do so without discussing that with you.   |
  224. #           I'll even try to have your permissions beforehand.                 |
  225. #        2. Integrating the edits into this script may perform better in some  |
  226. #           cases. A case-by-case approach will be used for discussing that.   |
  227. #        3. If I didn't reserve that right, things could be chaotic when some  |
  228. #           edits done by some people did conflict with some of the others by  |
  229. #           some other people. Reserving this right can indeed be an insurance.|
  230. #        4. I'll credit you and clearly stating which parts are your work.     |
  231. #------------------------------------------------------------------------------|
  232. #  * Links                                                                     |
  233. #    Script Usage 101:                                                         |
  234. #    1. forums.rpgmakerweb.com/index.php?/topic/32752-rmvxa-script-usage-101/  |
  235. #    2. rpgmakervxace.net/topic/27475-rmvxa-script-usage-101/                  |
  236. #    This script:                                                              |
  237. #    1. http://rpgmaker.net/scripts/549/                                       |
  238. #    (DoubleX)ECATB Base Formula:                                              |
  239. #    1. http://pastebin.com/PRwkrQKb                                           |
  240. #    Compatibility Fix:                                                        |
  241. #    1. http://rpgmaker.net/scripts/551/                                       |
  242. #    Video:                                                                    |
  243. #    1. https://www.youtube.com/watch?v=E692R6s8F0I                            |
  244. #    2. https://www.youtube.com/watch?v=6E0-X0wbLAM                            |
  245. #    Demo:                                                                     |
  246. #    - Coming Soon                                                             |
  247. #    Tutorial:                                                                 |
  248. #    - Link included in http://rpgmaker.net/scripts/549/                       |
  249. #    Mentioned Patreon Supporters:                                             |
  250. #    https://www.patreon.com/posts/71738797                                    |
  251. #------------------------------------------------------------------------------|
  252. #  * Authors                                                                   |
  253. #    DoubleX:                                                                  |
  254. #    1. This script                                                            |
  255. #    Yami:                                                                     |
  256. #    1. YSA Battle System: Classical ATB                                       |
  257. #------------------------------------------------------------------------------|
  258. #  * Changelog                                                                 |
  259. #    v0.05d(GMT 0800 22-09-2026):                                              |
  260. #    1. Fixed crashes due to del_ecatb_act being called outside battles        |
  261. #    2. Fixed successful escape in the last battle causing the next battle to  |
  262. #       falsely trigger a failed escape upon battle start                      |
  263. #    3. Fixed failing to save files due to not properly cleaning up blocks     |
  264. #       before saving and resotring them afterwards                            |
  265. #    v0.05c(GMT 0600 28-11-2021):                                              |
  266. #    1. Fixed wrong eval of ecatb_battler_scale and uninitialized battler turn |
  267. #       bugs                                                                   |
  268. #    v0.05b(GMT 0200 7-11-2015):                                               |
  269. #    1. Updated (DoubleX)ECATB Base Formula                                    |
  270. #    2. Notetag values are now symbols of methods in the configuration regions |
  271. #    3. Fixed battler order icon not placed correctly when atb >= 100.0 bug    |
  272. #    4. Simplified the party/troop atb pool reset implementations              |
  273. #    5. Updated some outdated documentations                                   |
  274. #    6. Further improved this script's compatibility, efficiency and simplicity|
  275. #    v0.05a(GMT 0400 21-10-2015):                                              |
  276. #    1. Implemented the Gradual Action Points Gain feature                     |
  277. #       - Right now it doesn't work well with the ATB Pool feature             |
  278. #    2. Updated (DoubleX)ECATB Base Formula                                    |
  279. #    3. Added configuration :ecatb_countdown_mib in the added feature COUNTDOWN|
  280. #    4. ecatb_se_ready_act changed to take SE or nil instead of an array       |
  281. #    5. Fixed battler order and se notetags falsely returning nil bug          |
  282. #    6. Fixed undisposed battler atb order icons upon battle end bug           |
  283. #    7. Fixed repeated actor sprite creation bug                               |
  284. #    8. Fixed battler atb order icons not keeping updated upon icon change bug |
  285. #    9. Fixed pre ecatb input act only triggering upon becoming able to act bug|
  286. #    10. Fixed split second countdown interval never updating turns bug        |
  287. #    11. Fixed active actor command window not showing in atb pool mode bug    |
  288. #    12. Fixed enemy atb bar not showing for those having at least 1 state bug |
  289. #    13. Fixed nil cooldown rate when the atb gain rate remain unchanged bug   |
  290. #    14. Fixed false unison charging for non unison skills/items after using   |
  291. #        unison ones bug                                                       |
  292. #    15. Fixed corrupted battler's last skill/item cache bug                   |
  293. #    16. Fixed running the atb frame update upon battle end bug                |
  294. #    17. Fixed non-sync unison cooldown with party/troop atb pool mode bug     |
  295. #    18. Fixed troop atb pool reset not resetting all enemies' atb values bug  |
  296. #    19. Fixed party/troop atb pool reset falsely resetting other members'     |
  297. #        actions bug                                                           |
  298. #        Right now all members' actions will still be reset when the action    |
  299. #        point pool's depleted                                                 |
  300. #    21. Fixed battler ready se not playing when the battler's become able to  |
  301. #        act bug                                                               |
  302. #    22. Debugging this script becomes easier and simpler with the console open|
  303. #    23. Removed some more redundant variables and methods                     |
  304. #    24. Further boosted this script's compactness, correctness, effectiveness,|
  305. #        efficiency, maintainability, readability, robustness and simplicity   |
  306. #    v0.04f(GMT 0400 12-9-2015):                                               |
  307. #    1. Added 3 script calls for notifying changes of new status window methods|
  308. #    2. The battler sprite atb bar methods are now under ECATB_Bar             |
  309. #    3. Fixed issues with clearing/resetting battler blocks twice consecutively|
  310. #    4. Further improved this script's effectiveness, efficiency and robustness|
  311. #    v0.04e(GMT 1500 11-8-2015):                                               |
  312. #    1. Fixed crash upon changing equips outside battles bug                   |
  313. #    2. Fixed triggering pre and post atb reset effects upon battle end bug    |
  314. #    3. Fixed enemy ecatb bar show not working properly bug                    |
  315. #    4. Fixed actors added during battles not properly initialized bug         |
  316. #    5. Fixed disabling party escape if not all party members are movable bug  |
  317. #    6. Fixed failed party escape attempts not cooling down properly bug       |
  318. #    7. Updated the outdated configuration documentations                      |
  319. #    8. Further improved this script's compactness, memory usage and robustness|
  320. #    v0.04d(GMT 1400 1-8-2015):                                                |
  321. #    1. Updated (DoubleX)ECATB Base Formula                                    |
  322. #    2. Changed :color to :atb and %Q(%Q()) to %Q()                            |
  323. #    3. Added configuration :ecatb_bar_multilayer in feature BAR               |
  324. #    4. Changed configuration :ecatb_actor_hotkeys to :ecatb_battler_hotkeys   |
  325. #    5. UNISON_DEFS doesn't have to include method arguments now               |
  326. #    6. Battler bars displayed on their sprites can overlap with status window |
  327. #    7. Added video https://www.youtube.com/watch?v=6E0-X0wbLAM                |
  328. #    8. Fixed complete freeze upon battle end in the ctb replication mode bug  |
  329. #    9. Fixed actors being inputable without action points in the atb pool mode|
  330. #    10. Fixed uncleared blocks for actors not in the party when saving bug    |
  331. #    11. Fixed unison rules not being properly applied to user's methods bug   |
  332. #    12. Fixed countdown freeze not freezing the countdown clock entirely bug  |
  333. #    13. Fixed notetag value reevaluation not always correctly triggered bug   |
  334. #    14. Further increased this script's compactness, compatibility,           |
  335. #        correctness, effectiveness, efficiency, flexibility, maintainability, |
  336. #        modularity, readability, robustness, simplicity and user-friendliness |
  337. #    v0.04c(GMT 1600 5-7-2015):                                                |
  338. #    1. Fixed duplicate actor sprite creations from other scripts doing so     |
  339. #    2. Fixed executing and/or inputting actions from/to hidden battlers bug   |
  340. #    3. Further increased this script's compactness and efficiency             |
  341. #    4. Removed some more redundant variables and compatibility socket methods |
  342. #    v0.04b(GMT 1600 29-6-2015):                                               |
  343. #    1. Reduced lag right after executing actions with ctb replication         |
  344. #    2. Fixed nil atb bar color bug upon party member change at battle end     |
  345. #    3. Removed some redundant variables and compatibility socket methods      |
  346. #    v0.04a(GMT 0300 27-6-2015):                                               |
  347. #    1. Implemented the CTB Replication feature                                |
  348. #    2. Lets users set if problematic configuration values will be reset       |
  349. #    3. Fixed retrieving nil battler name bug in the help window               |
  350. #    4. Increased this script's compactness and memory performance             |
  351. #    v0.03a(GMT 0900 27-5-2015):                                               |
  352. #    1. Implemented these features:                                            |
  353. #       -  Action Input Events                                                 |
  354. #       -  ATB Reset Events                                                    |
  355. #       -  Cooldown Finish Events                                              |
  356. #    2. Improved this script's efficiency and robustness                       |
  357. #    v0.02d(GMT 0400 25-5-2015):                                               |
  358. #    1. Fixed starting atb value not working bug                               |
  359. #    2. Fixed some typos and outdated stuffs                                   |
  360. #    v0.02c(GMT 1300 15-5-2015):                                               |
  361. #    1. Fixed default atb starting value not working bug                       |
  362. #    2. Fixed nil color upon victory and unexpected change equip results bug   |
  363. #    3. Fixed not clearing battlers' lambdas before calling Marshal bug        |
  364. #    4. Fixed failing to load saved games upon restarting the game bug         |
  365. #    5. Fixed unison method rules not working bug                              |
  366. #    6. Improved the battler cooldown and party escape implementations         |
  367. #    7. Further improved this script's efficiency                              |
  368. #    v0.02b(GMT 1500 12-5-2015):                                               |
  369. #    1. Fixed some typos and outdated stuffs                                   |
  370. #    2. Fixed order battler icon bugs upon adding/removing party members       |
  371. #    v0.02a(GMT 0700 9-5-2015):                                                |
  372. #    1. Implemented the Action Input Speed feature                             |
  373. #    2. Further improved this script's efficiency                              |
  374. #    v0.01b(GMT 1600 4-5-2015):                                                |
  375. #    1. Improved this script's efficiency                                      |
  376. #    v0.01a(GMT 1300 2-5-2015):                                                |
  377. #    1. Implemented the Battler Order Window feature                           |
  378. #    v0.00d(GMT 0800 22-4-2015):                                               |
  379. #    1. Fixed actor auto battle and confusion action not executing properly bug|
  380. #    2. Fixed compatibility methods not being called bug                       |
  381. #    3. Fixed unison charging value reset bug(the charging finishes upon reset)|
  382. #    v0.00c(GMT 1200 18-4-2015):                                               |
  383. #    1. Fixed the atb bar y offset not working bug                             |
  384. #    2. Fixed the faulty example notetag values of <ecatb color: type, num, CX>|
  385. #    3. Found unison charging value reset bug(the charging finishes upon reset)|
  386. #    v0.00b(GMT 0900 15-4-2015):                                               |
  387. #    1. Outsourced the countdown state sprite display to                       |
  388. #       DoubleX RMVXA State Counters                                           |
  389. #    2. Actor atb bars can be displayed on their sprites                       |
  390. #    v0.00a(GMT 1200 9-4-2015):                                                |
  391. #    1. 1st testing version of this script finished                            |
  392. #==============================================================================|
  393.  
  394. #==============================================================================|
  395. #  ** Notetag Info                                                             |
  396. #     Notetag settings override their corresponding configuration settings     |
  397. #     Search the notetags themselves to navigate between their info and values |
  398. #------------------------------------------------------------------------------|
  399. #  * Actors/Classes/Weapons/Armors/Enemies/States Notetags(in their noteboxes):|
  400. #    1. <ecatb color: type, num, cx>                                           |
  401. #       Sets the color num of atb bar with type being atb, charge or cooldown, |
  402. #       and num being 1or 2 as cx, which can be set in Color Notetag Values    |
  403. #    2. (v0.05a+)<ecatb gradual action gain: gagx>                             |
  404. #       Sets the battler to gradually gain action points instead of gaining its|
  405. #       maximum instantly if gagx, which can be set in Gradual Action Gain     |
  406. #       Notetag Values, returns true                                           |
  407. #    3. <ecatb order battler icon: obix>                                       |
  408. #       Sets the icon representing its battler's order as obix, which can be   |
  409. #       set in Order Battler Icon Notetag Values                               |
  410. #    4. <ecatb order battler opacity: obox>                                    |
  411. #       Sets the opacity of the icon representing its battler's order as obox, |
  412. #       which can be set in Order Battler Opacity Notetag Values               |
  413. #    5. <ecatb order battler scale: obsx>                                      |
  414. #       Sets the scale of the icon representing its battler's order as obsx,   |
  415. #       which can be set in Order Battler Scale Notetag Values                 |
  416. #    6. <ecatb order battler z: obzx>                                          |
  417. #       Sets the z position of the icon representing its battler's order as    |
  418. #       obzx, which can be awr in Order Battler Z Notetag Values               |
  419. #    7. <ecatb rate: rx>                                                       |
  420. #       Sets the atb fill rate of the battler as rx, which can be set in Rate  |
  421. #       Notetag Values                                                         |
  422. #       All rx of all data currently applied to the battler will be used, with |
  423. #       the output of the ith rx being the input of the (i + 1)th rx           |
  424. #    8. <ecatb se ready act: serax>                                            |
  425. #       Sets the se to be played when a battler becomes able to act as serax,  |
  426. #       which can be set in SE Ready Act Notetag Values                        |
  427. #    9. <ecatb speed reduce: srx>                                              |
  428. #       Sets the number of frames an enemy or actor with autobattle and/or     |
  429. #       confusion needs when inputting actions as srx, which can be set in     |
  430. #       Speed Reduce Notetag Values                                            |
  431. #       All srx of all data currently applied to the battler will be used      |
  432. #    10. <ecatb start val: start, svx>                                         |
  433. #        Sets the atb value at the start of the battle as svx, which can be set|
  434. #        in Start Value Notetag Values                                         |
  435. #        start can be either 0, 1 or 2, meaning the notetag will be used in    |
  436. #        normal, preemptive or surprise starts respectively                    |
  437. #        All svx of all data currently applied to the battler will be used     |
  438. #------------------------------------------------------------------------------|
  439. #  * Skill/Item Notetags(in their noteboxes):                                  |
  440. #    1. <ecatb act cost: acx>                                                  |
  441. #       Sets the number of actions needed for the skill/item as acx, which can |
  442. #       be set in Action Cost Notetag Values                                   |
  443. #       Users can't use it if they don't have enough actions                   |
  444. #       Setting acx as 0 means no action point is needed nor will be used      |
  445. #       Setting acx as negative means users will have more actions afterwards  |
  446. #    2. <ecatb charge prior act cost: cpacx>                                   |
  447. #       The skill/item action cost will be paid before and after finished      |
  448. #       charging if cpacx, which can be set in Charge Prior Act Cost Notetag   |
  449. #       Values, returns false and true respectively                            |
  450. #    3. <ecatb charge prior item cost: cpicx>                                  |
  451. #       The skill/item non-action cost will be paid before and after finished  |
  452. #       charging if cpicx, which can be set in Charge Prior Item Cost Notetag  |
  453. #       Values, returns false and true respectively                            |
  454. #    4. <ecatb charge rate: crx>                                               |
  455. #       The skill/item will have to charge with atb fill rate being crx, which |
  456. #       can be set in Charge Rate Notetag Values, before releasing if this     |
  457. #       notetag's used                                                         |
  458. #    5. <ecatb cooldown rate: cdrx>                                            |
  459. #       The battler will have to cool down with atb fill rate being cdrx, which|
  460. #       can be set in Cooldown Rate Notetag Values, after using the skill/item |
  461. #       before the battler's atb will be filled again if this notetag's used   |
  462. #    6. <ecatb force act cost: facx>                                           |
  463. #       The battler will and won't pay the action cost after using the forced  |
  464. #       action if facx, which can be set in Force Action Cost Notetag Values,  |
  465. #       returns false and true respectively                                    |
  466. #    7. <ecatb reset val: rvx>                                                 |
  467. #       Sets the atb value after using the skill/item as rvx, which can be set |
  468. #       in Reset Value Notetag Values                                          |
  469. #       The atb value right after users have no more actions will be the sum of|
  470. #       rvx of all skills/items used before users have no more actions if the  |
  471. #       battler doesn't gain action points gradually                           |
  472. #    8. <ecatb unison actor: uax>                                              |
  473. #       Sets the ids of actors needed to use the skill/item as uax, which can  |
  474. #       be set in Unison Actor Notetag Values                                  |
  475. #       All those actors must be able to use the skill/item                    |
  476. #       They'll charge it with the same charge rate, use it together and have  |
  477. #       a cooldown with the same cooldown rate                                 |
  478. #    9. <ecatb unison actor def: uadx>                                         |
  479. #       Sets the ids of actors used to calculate the result of def as uadx,    |
  480. #       which can be set in Unison Actor Method Notetag Values                 |
  481. #       def must be the symbol of a battler method returning real numbers and  |
  482. #       should be those used in the skill/item's damage formula                |
  483. #       If a method's used in the skill/item's damage formula but doesn't use  |
  484. #       this notetag, its value will be that of the battler inputting the      |
  485. #       skill/item                                                             |
  486. #       Only 1 uadx will be used per def                                       |
  487. #    10. <ecatb unison def rule: udrx>                                         |
  488. #        Sets the calculation rule of def as udrx, which can be set in Unison  |
  489. #        Method Rule Notetag Values                                            |
  490. #        def must be the symbol of a battler method returning real numbers and |
  491. #        should be those used in the skill/item's damage formula               |
  492. #        The rules are used when the skill/item's executing damage             |
  493. #        Only 1 udrx will be used per def                                      |
  494. #    11. <ecatb unison charge rule: ucrx>                                      |
  495. #        Sets the charge rate calculation rule as ucrx, which can be set in    |
  496. #        Unison Charge Rule Notetag Values                                     |
  497. #        The rules are used when the skill/item's charging                     |
  498. #    12. <ecatb unison cooldown rule: ucdrx>                                   |
  499. #        Sets the calculation rule of def as ucdrx, which can be set in Unison |
  500. #        Cooldown Rule Notetag Values                                          |
  501. #        The rules are used when the skill/item's users are cooling down       |
  502. #------------------------------------------------------------------------------|
  503. #  * Enemy/State Notetags(in their noteboxes):                                 |
  504. #    1. <enemy ecatb bar show: kill, bar, percent, act>                        |
  505. #       Sets if the enemy atb bar should be shown with fill percent and action |
  506. #       points                                                                 |
  507. #       The bar won't be shown if kill is true and the enemy isn't killed first|
  508. #       bar, act and percent will be ignored will be above condition is met    |
  509. #       The bar will be shown if bar is true                                   |
  510. #       act and percent will be ignored if bar is false                        |
  511. #       Action points and fill percent will be shown if act and percent are    |
  512. #       true respectively                                                      |
  513. #       Setting the value of an entry as nil means that entry will be ignored  |
  514. #       t, f and n represents true, false and nil values respectively          |
  515. #       The entry with the highest priority will be used if it's not nil       |
  516. #       Enemy's notetags are of the lowest priorities and will never be ignored|
  517. #------------------------------------------------------------------------------|
  518. #  * State Notetags(in their noteboxes):                                       |
  519. #    1. <ecatb countdown interval: cix>                                        |
  520. #       Sets the duration of the state as cix seconds, which  can be set in    |
  521. #       Coundown Interval Notetag Values                                       |
  522. #        All cix of all states currently applied to the battler will be used   |
  523. #==============================================================================|
  524.  
  525. #==============================================================================|
  526. #  ** Script Call Info                                                         |
  527. #------------------------------------------------------------------------------|
  528. #  * Configuration Settings                                                    |
  529. #    1. $game_system.set_battle_system(system)                                 |
  530. #       - Changes the battle system as system, which is one of those supported |
  531. #         by Yanfly Engine Ace - Ace Battle Engine                             |
  532. #       - It can only be used outside battles                                  |
  533. #    2. $game_system.ecatb_config = val                                        |
  534. #       - Sets the value of :ecatb_config as val                               |
  535. #         Example: $game_system.ecatb_base_fill_t = "$game_variables[x]" sets  |
  536. #                  the value of :ecatb_base_fill_t as that of variable with id |
  537. #                  x                                                           |
  538. #    3. create_ecatb_def(config, validate)                                     |
  539. #       - Updates the corresponding method of configuration config             |
  540. #         That method will be validated if validate is true                    |
  541. #         Example: BattleManager.create_ecatb_def(:ecatb_base_fill_t, true)    |
  542. #                  updates and validates the corresponding method of           |
  543. #                  :ecatb_base_fill_t                                          |
  544. #  * Battler manipulations                                                     |
  545. #    1. ecatb_act_times                                                        |
  546. #       - Returns the number of the current action points                      |
  547. #    2. ecatb_act_times = val                                                  |
  548. #       - Sets the number of the current action points as val                  |
  549. #    3. ecatb_countdown_freeze[state_id]                                       |
  550. #       - Returns if the countdown of state with id state_id is frozen         |
  551. #    4. ecatb_countdown_freeze[state_id] = val                                 |
  552. #       - Sets if the duration in turns of a countdown state with id state_id  |
  553. #         will be frozen                                                       |
  554. #    5. ecatb_note_change[note] = true                                         |
  555. #       - Notifies at least a value of a notetag with type note of a data used |
  556. #         by the battler has changed                                           |
  557. #       - note can be :act, :atb, :charge, :cooldown, :order_icon,             |
  558. #         :order_opacity,:order_scale, :order_z, :rate, :se, :speed, :start_0, |
  559. #         :start_1, :start_2, meaning gradual action gain, charge rate,        |
  560. #         bar color, cooldown rate, order icon, order opacity, order scale,    |
  561. #         order z, atb gain rate, speed reduce, battler ready se and start     |
  562. #         value notetags with normal, preemptive and surprise start types      |
  563. #         respectively                                                         |
  564. #       - This script call can also be used to change the charge, cooldown, atb|
  565. #         gain rate and bar colors per frame when it's called per frame        |
  566. #    6. ecatb_reset(reset)                                                     |
  567. #       - Cancels the battler's charging actions                               |
  568. #       - The battler's atb and action points will be reset as well if reset   |
  569. #         is true                                                              |
  570. #    7. ecatb_rate[type]                                                       |
  571. #       Returns the atb gain rate with type type                               |
  572. #       - type can be either :atb, :charge or :cooldown, meaning normal,       |
  573. #         charge and cooldown atb types respectively                           |
  574. #    8. ecatb_val[type]                                                        |
  575. #       Returns the atb value with type type                                   |
  576. #       - type can be either :atb, :charge or :cooldown, meaning normal,       |
  577. #         charge and cooldown atb types respectively                           |
  578. #    9. ecatb_val[type] = val                                                  |
  579. #       - Sets the atb value with type type as val                             |
  580. #       - type can be either :atb, :charge or :cooldown, meaning normal,       |
  581. #         charge and cooldown atb types respectively                           |
  582. #  * Party/Troop manipulations                                                 |
  583. #    1. ecatb_pool = enable                                                    |
  584. #       - Converts all actors/enemies' atb into a party/troop atb if enable is |
  585. #         true and vice versa if enable is false                               |
  586. #       - It can't be used in battles                                          |
  587. #  * Hotkey manipulations                                                      |
  588. #    1. SceneManager.scene.set_ecatb_battler_window_handlers                   |
  589. #       - Creates all battler target selection hotkey handlers                 |
  590. #       - It can only be used in battles                                       |
  591. #    2. SceneManager.scene.set_ecatb_actor_command_window_handlers             |
  592. #       - Creates all inputable actor setup hotkey handlers                    |
  593. #       - It can only be used in battles                                       |
  594. #    3. SceneManager.scene.create_ecatb_cancel_window                          |
  595. #       - Creates all charging actor cancellation hotkey handlers              |
  596. #       - It can only be used in battles                                       |
  597. #  * Window manipulations                                                      |
  598. #    1. SceneManager.scene.create_ecatb_clock_window                           |
  599. #       - Creates the atb clock window if :show_ecatb_clock_window returns     |
  600. #         true                                                                 |
  601. #       - It can only be used in battles                                       |
  602. #    2. SceneManager.scene_close_ecatb_clock_window                            |
  603. #       - Closes the atb clock window                                          |
  604. #       - It can only be used in battles with an atb clock window              |
  605. #    3. SceneManager.scene.ecatb_clock_window.update_text_xy                   |
  606. #       - Updates the atb clock window text x and y positions                  |
  607. #       - It can only be used in battles having an atb clock window            |
  608. #    4. SceneManager.scene.ecatb_clock_window.update_pos                       |
  609. #       - Updates the atb clock window x, y and z positions                    |
  610. #       - It can only be used in battles having an atb clock window            |
  611. #    5. SceneManager.scene.ecatb_clock_window.update_wh                        |
  612. #       - Updates the atb clock window width and height                        |
  613. #       - It can only be used in battles having an atb clock window            |
  614. #    6. SceneManager.scene.ecatb_clock_window.update_text_font                 |
  615. #       - Updates the atb clock window text color and size                     |
  616. #       - It can only be used in battles having an atb clock window            |
  617. #    7. SceneManager.scene.ecatb_clock_window.clock_bar.update_bar_colors      |
  618. #       - Updates the atb clock window bar colors                              |
  619. #       - It can only be used in battles having an atb clock window            |
  620. #    8. SceneManager.scene.ecatb_clock_window.clock_bar.update_bar_wh          |
  621. #       - Updates the atb clock window bar width and height                    |
  622. #       - It can only be used in battles having an atb clock window            |
  623. #    9. SceneManager.scene.ecatb_clock_window.clock_bar.update_bar_xy          |
  624. #       - Updates the atb clock window bar x and y positions                   |
  625. #       - It can only be used in battles having an atb clock window            |
  626. #    10. SceneManager.scene.ecatb_clock_window.refresh                         |
  627. #        - Refreshes the atb clock window bar and text                         |
  628. #        - It can only be used in battles having an atb clock window           |
  629. #    11. SceneManager.scene.create_ecatb_force_window                          |
  630. #        - Creates the atb force window if :show_ecatb_force_window returns    |
  631. #          true                                                                |
  632. #        - It can only be used in battles                                      |
  633. #    12. SceneManager.scene.close_ecatb_force_window                           |
  634. #        - Closes the atb force window                                         |
  635. #        - It can only be used in battles with an atb force window             |
  636. #    13. SceneManager.scene.ecatb_force_window.update_pos                      |
  637. #        - Updates the atb force window x, y and z positions                   |
  638. #        - It can only be used in battles having an atb force window           |
  639. #    14. SceneManager.scene.ecatb_force_window.update_wh                       |
  640. #        - Updates the atb force window width and height                       |
  641. #        - It can only be used in battles having an atb force window           |
  642. #    15. SceneManager.scene.ecatb_force_window.update_text_font                |
  643. #        - Updates the atb force window text color and size                    |
  644. #        - It can only be used in battles having an atb force window           |
  645. #    16. SceneManager.scene.ecatb_force_window.update_text                     |
  646. #        - Updates the atb force window text                                   |
  647. #        - It can only be used in battles having an atb force window           |
  648. #    17. SceneManager.scene.ecatb_force_window.update_text_xy                  |
  649. #        - Updates the atb force window text x and y positions                 |
  650. #        - It can only be used in battles having an atb force window           |
  651. #    18. SceneManager.scene.ecatb_force_window.draw_text                       |
  652. #        - Draws the atb force window text                                     |
  653. #        - It can only be used in battles having an atb force window           |
  654. #    19. SceneManager.scene.create_ecatb_order_window                          |
  655. #        - Creates the atb pool window if :show_ecatb_order_window returns true|
  656. #        - It can only be used in battles                                      |
  657. #    20. SceneManager.scene.close_ecatb_order_window                           |
  658. #        - Closes the atb order window                                         |
  659. #        - It can only be used in battles with an atb order window             |
  660. #    21. SceneManager.scene.ecatb_order_window.draw_bars                       |
  661. #        - Draws the atb order bars and text                                   |
  662. #        - It can only be used in battles with an atb order window             |
  663. #    22. SceneManager.scene.ecatb_pool_window.update_pos                       |
  664. #        - Updates the atb pool window x, y and z positions                    |
  665. #        - It can only be used in battles having an atb pool window            |
  666. #    23. SceneManager.scene.ecatb_pool_window.update_wh                        |
  667. #        - Updates the atb pool window width and height                        |
  668. #        - It can only be used in battles having an atb pool window            |
  669. #    24. SceneManager.scene.ecatb_pool_window.update_text_font                 |
  670. #        - Updates the atb pool window text color and size                     |
  671. #        - It can only be used in battles having an atb pool window            |
  672. #    25. SceneManager.scene.create_ecatb_pool_window                           |
  673. #        - Creates the atb pool window if :show_ecatb_pool_window returns true |
  674. #        - It can only be used in battles                                      |
  675. #    26. SceneManager.scene.close_ecatb_pool_window                            |
  676. #        - Closes the atb pool window                                          |
  677. #        - It can only be used in battles with an atb pool window              |
  678. #    27. SceneManager.scene.ecatb_pool_window.update_pos                       |
  679. #        - Updates the atb pool window x, y and z positions                    |
  680. #        - It can only be used in battles having an atb pool window            |
  681. #    28. SceneManager.scene.ecatb_pool_window.update_wh                        |
  682. #        - Updates the atb pool window width and height                        |
  683. #        - It can only be used in battles having an atb pool window            |
  684. #    29. SceneManager.scene.ecatb_pool_window.update_text_font                 |
  685. #        - Updates the atb pool window text color and size                     |
  686. #        - It can only be used in battles having an atb pool window            |
  687. #    30. SceneManager.scene.ecatb_pool_window.update_text_xy                   |
  688. #        - Updates the atb pool window text x and y positions                  |
  689. #        - It can only be used in battles having an atb pool window            |
  690. #    31. SceneManager.scene.ecatb_pool_window.draw_text                        |
  691. #        - Draws the atb pool window text                                      |
  692. #        - It can only be used in battles having an atb pool window            |
  693. #    32. (v0.04f+)SceneManager.scene.status_window.ecatb_text_change = true    |
  694. #        - Notifies that the atb bar text format's changed                     |
  695. #        - It can only be used in battles                                      |
  696. #    33. (v0.04f+)SceneManager.scene.status_window.ecatb_word_change = true    |
  697. #        - Notifies that the atb bar description word's changed                |
  698. #        - It can only be used in battles                                      |
  699. #    34. (v0.04f+)SceneManager.scene.status_window.ecatb_y_add_change = true   |
  700. #        - Notifies that the atb bar y offset's changed                        |
  701. #        - It can only be used in battles                                      |
  702. #==============================================================================|
  703.  
  704. ($doublex_rmvxa ||= {})[:ECATB] = "v0.05c"
  705.  
  706. #==============================================================================|
  707. #  ** Script Configurations                                                    |
  708. #     You only need to edit this part as it's about what this script does      |
  709. #------------------------------------------------------------------------------|
  710.  
  711. module DoubleX_RMVXA
  712.  
  713.   module ECATB
  714.  
  715.     # Sets if configuration values that can crash the game will be rescued
  716.     # If it's set as true, players will be informed that the values of those
  717.     # configurations are invalid and will be reset to their default ones
  718.     # If it's set as false, the game will crash and the error log will be shown
  719.     # It can't be changed once set
  720.     # Example: To let invalid configuration values crash the game to have the
  721.     #          error log, set this as false
  722.     RESCUE_CONFIG_VAL = true
  723.  
  724.     # (v0.04a+)Sets if configuration values that are invalid or can crash the
  725.     # game will be reset to their defaults
  726.     # It can't be changed once set
  727.     # Example: To reset invalid or faulty configuration values to their
  728.     #          defaults, set this as true
  729.     RESET_CONFIG_VAL = true
  730.  
  731.     # Sets if the text showing an invalid or faulty configuration value will be
  732.     # displayed right after checking them
  733.     # It can't be changed once set
  734.     # Example: To silently reset invalid or faulty configuration values, set
  735.     #          this as true
  736.     SUPPRESS_RESET_CONFIG_VAL_TEXT = false
  737.  
  738.   #----------------------------------------------------------------------------|
  739.   #  * Core                                                                    |
  740.   #    Setups configurations and notetag values of the core features           |
  741.   #----------------------------------------------------------------------------|
  742.  
  743.     #--------------------------------------------------------------------------|
  744.     #  Color Notetag Values                                                    |
  745.     #  - Setups cx used by <ecatb color: type, num, cx> notetags               |
  746.     #--------------------------------------------------------------------------|
  747.     # cx are read at:
  748.     # 1. RPG::Actor, RPG::Class, RPG::EquipItem, RPG::Enemy, RPG::State
  749.     #    - next @ecatb_notes[$1.downcase.to_sym][$2.to_i] ||= $3.downcase.to_sym
  750.     #      in load_ecatb_notes
  751.     # cx are used at:
  752.     # 1. Game_BattlerBase
  753.     #    - @ecatb_notes[note][0] ||= ecatb.send(n, self) if n and
  754.     #    - @ecatb_notes[note][1] ||= ecatb.send(n, self) in
  755.     #      set_ecatb_bar_color_notes
  756.     # cx are strings of names of methods under DoubleX_RMVXA::ECATB
  757.     # cx must return an array of colors
  758.     # cx names can only use alphanumeric characters and can't use uppercase
  759.     # letters
  760.     # battler is the battler calling the cx
  761.     # The below cx are examples added to help you set your cx
  762.     # You can freely use, rewrite and/or delete these examples
  763.  
  764.     # Sets the atb bar colors as text color c and r, g, b, a rgba values
  765.     def self.c1(battler)
  766.       Colour.text_colour(c)
  767.     end
  768.  
  769.     # Sets the atb bar colors as r, g, b, a rgba values
  770.     def self.c2(battler)
  771.       Color.new(r, g, b, a)
  772.     end
  773.  
  774.     # Adds new cx here
  775.    
  776.  
  777.     #--------------------------------------------------------------------------|
  778.     #  Rate Notetag Values                                                     |
  779.     #  - Setups rx used by <ecatb rate: rx> notetags                           |
  780.     #--------------------------------------------------------------------------|
  781.     # rx are read at:
  782.     # 1. RPG::Actor, RPG::Class, RPG::EquipItem, RPG::Enemy, RPG::State
  783.     #    - next @ecatb_notes[:rate] << $1.downcase.to_sym in load_ecatb_notes
  784.     # rx are used at:
  785.     # 1. Game_BattlerBase
  786.     #    - base[:val] = ecatb.send(note, self, base) in set_ecatb_gain_rate
  787.     # rx are strings of names of methods under DoubleX_RMVXA::ECATB
  788.     # rx must return a real number and should return a floating-point number
  789.     # rx names can only use alphanumeric characters and can't use uppercase
  790.     # letters
  791.     # battler is the battler calling the rx
  792.     # The base atb rate can be referenced by base[:val]
  793.     # The number of battlers counted for method sums can be referenced by
  794.     # base[:size]
  795.     # The method sum of all battlers counted can be referneced by
  796.     # base[:sum][method_name]
  797.     # method_name must be included in :ecatb_battlers_def_sum
  798.     # The below rx are examples to help you set your rx
  799.     # You can freely use, rewrite and/or delete these examples
  800.  
  801.     # Mutliplies the atb fill rate by the battler's agi / all battlers'
  802.     # average agi
  803.     # all battlers is the value of :def_sum_battlers
  804.     def self.r1(battler, base)
  805.       base[:val] * battler.agi * base[:size] / base[:sum][:agi]
  806.     end
  807.  
  808.     # Sets the atb fill rate as x% per frame
  809.     def self.r2(battler, base)
  810.       x
  811.     end
  812.  
  813.     # Sets the atb fill rate as the value of variable with id x * 100% per frame
  814.     def self.r3(battler, base)
  815.       $game_variables[x]
  816.     end
  817.  
  818.     # Adds new rx here
  819.    
  820.  
  821.     #--------------------------------------------------------------------------|
  822.     #  Start Value Notetag Values                                              |
  823.     #  - Setups svx used by <ecatb start val: start, svx> notetags             |
  824.     #--------------------------------------------------------------------------|
  825.     # svx are read at:
  826.     # 1. RPG::Actor, RPG::Class, RPG::EquipItem, RPG::Enemy, RPG::State
  827.     #    - next @ecatb_notes[("start_" + $1).to_sym] << $2.downcase.to_sym in
  828.     #      load_ecatb_notes
  829.     # svx are used at:
  830.     # 1. Game_BattlerBase
  831.     #    - ecatb.send(note, self) in set_ecatb_start_val
  832.     # svx are strings of names of methods under DoubleX_RMVXA::ECATB
  833.     # svx must return a non-negative real number and should return a
  834.     # non-negative floating-point number
  835.     # svx names can only use alphanumeric characters and can't use uppercase
  836.     # letters
  837.     # battler is the battler calling the svx
  838.     # The below svx are examples added to help you set your svx
  839.     # You can freely use, rewrite and/or delete these examples
  840.  
  841.     # Sets the starting atb value as x%
  842.     def self.sv1(battler)
  843.       battler.ecatb_val[:atb] = x
  844.     end
  845.  
  846.     # Sets the atb value as that of variable with id x * 100%
  847.     def self.sv2(battler)
  848.       battler.ecatb_val[:atb] = $game_variables[x]
  849.     end
  850.  
  851.     # Adds the atb starting value by x%
  852.     def self.sv3(battler)
  853.       battler.ecatb_val[:atb] += x
  854.     end
  855.  
  856.     # Adds new svx here
  857.    
  858.  
  859.     #--------------------------------------------------------------------------|
  860.     #  Action Cost Notetag Values                                              |
  861.     #  - Setups acx used by <ecatb act cost: acx> notetags                     |
  862.     #--------------------------------------------------------------------------|
  863.     # acx are read at:
  864.     # 1. RPG::UsableItem
  865.     #    - send(:"#{note}=", send(:"#{note}") || val) in load_ecatb_notes
  866.     # acx are used at:
  867.     # 1. Game_BattlerBase
  868.     #    - return false if @ecatb_val[:charge] <= 0.0 && @ecatb_act_times <
  869.     #      ecatb.send(item.ecatb_act_cost, self) in usable?
  870.     # 2. Game_Battler
  871.     #    - cost = DoubleX_RMVXA::ECATB.send(item.ecatb_act_cost, self) in
  872.     #      pay_ecatb_act_cost
  873.     #    - cost = (ecatb = DoubleX_RMVXA::ECATB).send(item.ecatb_act_cost, self)
  874.     #      in ecatb_unison_actor?
  875.     # 3. Window_ItemList
  876.     #    - return battler.usable?(item) if (ecatb = DoubleX_RMVXA::ECATB).send(
  877.     #      item.ecatb_act_cost, battler) > 1 || ecatb.send(
  878.     #      item.ecatb_unison_actor, battler).size > 1 in enable?
  879.     # acx are strings of names of methods under DoubleX_RMVXA::ECATB
  880.     # acx must return a real number and should return a non-random integer
  881.     # acx names can only use alphanumeric characters and can't use uppercase
  882.     # letters
  883.     # battler is the battler calling the acx
  884.     # The below acx are examples added to help you set your acx
  885.     # You can freely use, rewrite and/or delete these examples
  886.  
  887.     # Sets the action cost as x
  888.     def self.ac1(battler)
  889.       x
  890.     end
  891.  
  892.     # Sets the action cost as the value of variable with id x
  893.     def self.ac2(battler)
  894.       $game_variables[x]
  895.     end
  896.  
  897.     # Adds new acx here
  898.    
  899.  
  900.     # Sets the number of action points needed to execute actions
  901.     # It'll be used only if no acx are used
  902.     # It must return a real number and should return a non-random integer
  903.     # battler is the battler calling ecatb_act_cost
  904.     # Example: To set the number of action points needed to execute actions as
  905.     #          the value of variable with id x, set this as
  906.     #          %Q($game_variables[x])
  907.     def self.ecatb_act_cost(battler)
  908.       1
  909.     end
  910.  
  911.     #--------------------------------------------------------------------------|
  912.     #  Force Action Cost Notetags Values                                       |
  913.     #  - Setups facx used by <ecatb force act cost: facx> notetags             |
  914.     #--------------------------------------------------------------------------|
  915.     # facx are read at:
  916.     # 1. RPG::UsableItem
  917.     #    - send(:"#{note}=", send(:"#{note}") || val) in load_ecatb_notes
  918.     # facx are used at:
  919.     # 1. Game_BattlerBase
  920.     #    - if (force_act_cost = ecatb.send(item.ecatb_force_act_cost, self)) ||
  921.     #      !forced in exec_ecatb_act_cost
  922.     # facx are strings of names of methods under DoubleX_RMVXA::ECATB
  923.     # facx names can only use alphanumeric characters and can't use uppercase
  924.     # letters
  925.     # battler is the battler calling the facx
  926.     # The below facx are examples added to help you set your facx
  927.     # You can freely use, rewrite and/or delete these examples
  928.  
  929.     # Sets the force action cost as true
  930.     def self.fac1(battler)
  931.       true
  932.     end
  933.  
  934.     # Sets the force action cost as false
  935.     def self.fac2(battler)
  936.       false
  937.     end
  938.  
  939.     # Sets the force action cost as the state of switch with id x
  940.     def self.fac3(battler)
  941.       $game_switches[x]
  942.     end
  943.  
  944.     # Adds new facx here
  945.    
  946.  
  947.     # Sets if force actions cost action points
  948.     # It'll be used only if no facx are used
  949.     # battler is the battler calling ecatb_force_act_cost
  950.     # Example: To set force actions to cost action points if switch with id x is
  951.     #          on, set this as %Q($game_switches[x])
  952.     def self.ecatb_force_act_cost(battler)
  953.       false
  954.     end
  955.  
  956.     #--------------------------------------------------------------------------|
  957.     #  Reset Value Notetags Values                                             |
  958.     #  - Setups rvx used by <ecatb reset val: rvx> notetags                    |
  959.     #--------------------------------------------------------------------------|
  960.     # rvx are read at:
  961.     # 1. RPG::UsableItem
  962.     #    - send(:"#{note}=", send(:"#{note}") || val) in load_ecatb_notes
  963.     # rvx are used at:
  964.     # 1. Game_BattlerBase
  965.     #    - @ecatb_reset_val = (ecatb = DoubleX_RMVXA::ECATB).send(val, self) in
  966.     #      set_ecatb_reset_val
  967.     # rvx are strings of names of methods under DoubleX_RMVXA::ECATB
  968.     # rvx must return a real number and should return a floating-point number
  969.     # rvx names can only use alphanumeric characters and can't use uppercase
  970.     # letters
  971.     # battler is the battler calling the rvx
  972.     # The below rvx are examples added to help you set your rvx
  973.     # You can freely use, rewrite and/or delete these examples
  974.  
  975.     # Sets the atb reset value as x%
  976.     def self.rv1(battler)
  977.       x
  978.     end
  979.  
  980.     # Sets the atb reset value as the value of variable with id x * 100%
  981.     def self.rv2(battler)
  982.       $game_variables[x]
  983.     end
  984.  
  985.     # Adds the atb reset value by x%
  986.     def self.rv3(battler)
  987.       battler.ecatb_reset_val + x
  988.     end
  989.  
  990.     # Adds new rvx here
  991.    
  992.  
  993.     # Sets the atb reset value after using a skill/item
  994.     # It'll be used only if no rvx are used
  995.     # It must return a real number and should return a floating-point number
  996.     # battler is the battler calling ecatb_reset_val
  997.     # Example: To set the atb reset value as x%, set this as %Q(x)
  998.     def self.ecatb_reset_val(battler)
  999.       battler.set_gradual_ecatb_act_gain ? battler.ecatb_val[:atb] : 0.0
  1000.     end
  1001.  
  1002.     #--------------------------------------------------------------------------|
  1003.     #  Escape Initialization Condition Configurations                          |
  1004.     #  - Setups EICX used by :ecatb_esc_init_cond                              |
  1005.     #--------------------------------------------------------------------------|
  1006.     # EICX are used at:
  1007.     # 1. BattleManager
  1008.     #    - init_ecatb_escape if @ecatb_can_esc && ecatb_esc_init_cond in
  1009.     #      process_escape
  1010.     # EICX are strings of RGSS3 codes
  1011.     # EICX names can only use alphanumeric characters
  1012.     # The below EICX are examples added to help you set your EICX
  1013.     # You can freely use, rewrite and/or delete these examples
  1014.  
  1015.     # Checks if the member can pay the escape action cost
  1016.     EIC1 = -> mem { mem.ecatb_act_times >= mem.ecatb_esc_act_cost }
  1017.  
  1018.     # Adds new EICX here
  1019.    
  1020.  
  1021.     #--------------------------------------------------------------------------|
  1022.     #  Escape Charge Condition Configurations                                  |
  1023.     #  - Setups ECCX used by :ecatb_esc_charge_cond                            |
  1024.     #--------------------------------------------------------------------------|
  1025.     # ECCX are used at:
  1026.     # 1. BattleManager
  1027.     #    - return pay_ecatb_esc_cost unless ecatb_esc_charge_cond in
  1028.     #      ecatb_update
  1029.     # ECCX are strings of RGSS3 codes
  1030.     # ECCX names can only use alphanumeric characters
  1031.     # The below ECCX are examples added to help you set your ECCX
  1032.     # You can freely use, rewrite and/or delete these examples
  1033.  
  1034.     # Checks if the member is charging the party escape
  1035.     ECC1 = -> mem { mem.ecatb_esc }
  1036.  
  1037.     # Adds new ECCX here
  1038.    
  1039.  
  1040.     #--------------------------------------------------------------------------|
  1041.     #  Escape Execution Condition Configurations                               |
  1042.     #  - Setups EECX used by :ecatb_esc_exec_cond                              |
  1043.     #--------------------------------------------------------------------------|
  1044.     # EECX are used at:
  1045.     # 1. BattleManager
  1046.     #    - ecatb_esc_suc if ecatb_esc_exec_cond in ecatb_update
  1047.     # EECX are strings of RGSS3 codes
  1048.     # EECX names can only use alphanumeric characters
  1049.     # The below EECX are examples added to help you set your EECX
  1050.     # You can freely use, rewrite and/or delete these examples
  1051.  
  1052.     # Checks if the member has fully charged a skill/item
  1053.     EEC1 = -> mem { mem.ecatb_val[:charge] >= 100.0 }
  1054.  
  1055.     # Adds new EECX here
  1056.    
  1057.  
  1058.     #--------------------------------------------------------------------------|
  1059.     #  Wait Condition Configurations                                           |
  1060.     #  - Setups WCX used by :ecatb_wait_cond                                   |
  1061.     #--------------------------------------------------------------------------|
  1062.     # WCX are used at:
  1063.     # 1. Scene_Battle
  1064.     #    - BattleManager.phase && !ecatb_wait_cond in ecatb_update?
  1065.     # WCX are strings of RGSS3 codes
  1066.     # WCX names can only use alphanumeric characters
  1067.     # The below WCX are examples added to help you set your WCX
  1068.     # Your can freely use, rewrite and/or delete these examples
  1069.  
  1070.     # Checks if the atb clock is forced to stop
  1071.     WC1 = %Q(@ecatb_force_clock == :stop)
  1072.  
  1073.     # Checks if the atb clock isn't forced to run
  1074.     WC2 = %Q(@ecatb_force_clock != :run)
  1075.  
  1076.     # Checks if an action's executing
  1077.     WC3 = %Q(!BattleManager.ecatb_can_esc)
  1078.  
  1079.     # Checks if the cancel window's active
  1080.     WC4 = %Q(@ecatb_cancel_window && @ecatb_cancel_window.active)
  1081.  
  1082.     # Checks if the party command window's active
  1083.     WC5 = %Q(@party_command_window.active)
  1084.  
  1085.     # Checks if the actor target window's active
  1086.     WC6 = %Q(@actor_window.active)
  1087.  
  1088.     # Checks if the enemy target window's active
  1089.     WC7 = %Q(@enemy_window.active)
  1090.  
  1091.     # Checks if the skill window's active
  1092.     WC8 = %Q(@skill_window.active)
  1093.  
  1094.     # Checks if the item window's active
  1095.     WC9 = %Q(@item_window.active)
  1096.  
  1097.     # Checks if the actor command window's active
  1098.     WC10 = %Q(@actor_command_window.active)
  1099.  
  1100.     # Checks if the combat log window's visible
  1101.     WCC1 = %Q(update_msg_open_ecatb_compatibility?)
  1102.  
  1103.     # Adds new WCX here
  1104.    
  1105.  
  1106.     #--------------------------------------------------------------------------|
  1107.     #  Core Configurations                                                     |
  1108.     #  - Setups the configurations of the core features                        |
  1109.     #  - The value of each configuration is the string of the content of its   |
  1110.     #    corresponding method                                                  |
  1111.     #--------------------------------------------------------------------------|
  1112.  
  1113.     CORE = {
  1114.  
  1115.       # Sets the conditions for initializing party escape
  1116.       # A party escape is first initialized, then charged, and finally executed
  1117.       # An executed party escape can either success or fail
  1118.       # Its corresponding method's created under BattleManager
  1119.       # Party Escape can't be initialized nor executed while executing an action
  1120.       # Example: To demand at least 1 inputable party member that can pay the
  1121.       #          party escape cost, set this as
  1122.       #          %Q(ecatb_input_list.any?(&DoubleX_RMVXA::ECATB::EIC1))
  1123.       :ecatb_esc_init_cond => %Q((list = ecatb_input_list).size >= $game_party.
  1124.                  battle_members.size && list.all?(&DoubleX_RMVXA::ECATB::EIC1)),
  1125.  
  1126.       # Sets the conditions for continuing to charge the party escape
  1127.       # A party escape is first initialized, then charged, and finally executed
  1128.       # An executed party escape can either success or fail
  1129.       # Its corresponding method's created under BattleManager
  1130.       # Example: To demand a key with mapping :KEY to be pressed and at least 1
  1131.       #          party member to continue charging the party escape, set this as
  1132.       #          %Q(Input.press?(:KEY) &&
  1133.       #             $game_party.members.any?(&DoubleX_RMVXA::ECATB::ECC1))
  1134.       :ecatb_esc_charge_cond => %Q($game_party.battle_members.all?(
  1135.                                    &DoubleX_RMVXA::ECATB::ECC1)),
  1136.  
  1137.       # Sets the conditions for executing party escape
  1138.       # A party escape is first initialized, then charged, and finally executed
  1139.       # An executed party escape can either success or fail
  1140.       # Its corresponding method's created under BattleManager
  1141.       # Example: To demand at least 1 party member to finish charging the party
  1142.       #          escape before executing it, set this as
  1143.       #          %Q($game_party.members.any?(&DoubleX_RMVXA::ECATB::EEC1))
  1144.       :ecatb_esc_exec_cond => %Q($game_party.alive_members.all?(
  1145.                                  &DoubleX_RMVXA::ECATB::EEC1)),
  1146.  
  1147.       # Sets the conditions for successful party escape
  1148.       # A party escape is first initialized, then charged, and finally executed
  1149.       # An executed party escape can either success or fail
  1150.       # Its corresponding method's created under BattleManager
  1151.       # Example: To check the preemptive status or use escape ratio as the
  1152.       #          success probability and have at least 1 party member being able
  1153.       #          to pay the party escape cost, set this as
  1154.       #          %Q((@preemptive || rand < @escape_ratio) &&
  1155.       #             $game_party.alive_members.any?(&DoubleX_RMVXA::ECATB::EIC1))
  1156.       :ecatb_esc_suc_cond => %Q((@preemptive || rand < @escape_ratio) &&
  1157.                    $game_party.alive_members.all?(&DoubleX_RMVXA::ECATB::EIC1)),
  1158.  
  1159.       # Sets the atb clock wait condition
  1160.       # Its corresponding method's created under Scene_Battle
  1161.       # The atb clock will always wait if the game message is visible
  1162.       # Only 1 action can be executed at a time
  1163.       # Example: To run the atb clock if switch with id x is on, set this as
  1164.       #          %Q($game_switches[x])
  1165.       :ecatb_wait_cond => %Q(#{WC1} || #{WC2} && (#{WC3} || #{WC4} || #{WC5} ||
  1166.                              #{WC6} || #{WC7} || #{WC8} || #{WC9} || #{WC10} ||
  1167.                              #{WCC1})),
  1168.  
  1169.       # Sets the base atb fill time in seconds
  1170.       # Its corresponding method's created under BattleManager
  1171.       # It must return a positive real number
  1172.       # Example: To set the base atb fill time as 1 frame, set this as
  1173.       #          %Q(1 / Graphics.frame_rate)
  1174.       :ecatb_base_fill_t => %Q(10),
  1175.  
  1176.       # Sets the turn type
  1177.       # Its corresponding method's created under Scene_Battle
  1178.       # It must return either :tick, :battler or :act
  1179.       # :tick means turn length's controlled by the number of ticks
  1180.       # :battler means turn length is controlled by the number of battlers
  1181.       # :act means turn length's controlled by the number of actions executed
  1182.       # Example: To set the atb turn type as :act, set this as %Q(:act)
  1183.       :ecatb_turn_type => %Q(:tick),
  1184.  
  1185.       # Needs :ecatb_turn to be :tick to be used
  1186.       # Sets the turn length in seconds
  1187.       # Its corresponding method's created under Scene_Battle
  1188.       # It must return a positive real number
  1189.       # Example: To set the turn length as the base atb fill time, set this as
  1190.       #          %Q(BattleManager.ecatb_base_fill_t)
  1191.       :ecatb_tick_count => %Q(10),
  1192.  
  1193.       # Needs :ecatb_turn to be :act to be used
  1194.       # Sets the turn length in the number of actions counted
  1195.       # Its corresponding method's created under Scene_Battle
  1196.       # It must return a positive real number and should return a natural number
  1197.       # Example: To set the turn length as x actions, set this as %Q(x)
  1198.       :ecatb_after_act => %Q(10),
  1199.  
  1200.       # Needs :ecatb_turn to be :battler to be used
  1201.       # Sets the number of units per battler counted added to the turn length
  1202.       # The unit can either be :tick or :act
  1203.       # :tick means the unit is second
  1204.       # :act means the unit is the number of actions
  1205.       # Its corresponding method's created under Scene_Battle
  1206.       # It must return an array
  1207.       # Its 1st element must return a positive real number and should return a
  1208.       # natural number
  1209.       # Its 2nd element must return either :tick or :act
  1210.       # Example: To set the battler scale as x actions, set this as
  1211.       #          %Q([x, :act])
  1212.       :ecatb_battler_scale => %Q([1, :tick]),
  1213.  
  1214.       # Needs :ecatb_turn to be :battler to be used
  1215.       # Sets the battlers to be counted in the battler scale
  1216.       # Its corresponding method's created under Scene_Battle
  1217.       # It must return a positive real number and should return the size of
  1218.       # an array of battlers
  1219.       # Example: To include all battlers, set this as
  1220.       #          Q($game_party.members.size + $game_troop.members.size)
  1221.       :ecatb_battler_count => %Q($game_party.alive_members.size +
  1222.                                  $game_troop.alive_members.size),
  1223.  
  1224.       # Needs :ecatb_turn to be :act or :battler to be used
  1225.       # Sets if force actions are counted as well
  1226.       # Its corresponding method's created under Scene_Battle
  1227.       # Example: To count the force actions as well if switch with id x is on,
  1228.       #          set this as %Q($game_switches[x])
  1229.       :ecatb_force_act_count => %Q(false),
  1230.  
  1231.       # (v0.04a+)Sets if battles will behave like a CTB by skipping the atb,
  1232.       # charge and cooldown filling times, and the global atb tick clock
  1233.       # Its corresponding method's created under BattleManager
  1234.       # Example: To replicate a CTB system if switch with id x is on, set this
  1235.       #          as %Q($game_switches[x])
  1236.       :ecatb_ctb => %Q(false),
  1237.  
  1238.       # Sets the priority of the ecatb rate notetags to be used
  1239.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1240.       # It must return an array with elements being either :states, :enemies,
  1241.       # :armors, :weapons, :classes or :actors
  1242.       # Example: To set actors to have a higher priority than that of states,
  1243.       #          set this as %Q([:actors, :states])
  1244.       :ecatb_rate_ord => %Q([:actors, :classes, :weapons, :armors, :enemies,
  1245.                              :states]),
  1246.  
  1247.       # Sets the 1st atb value of actors when battles start normally
  1248.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1249.       # It must return a non-negative real number and should return a
  1250.       # non-negative floating-point number
  1251.       # Example: To set the 1st atb value of actors when battler start normally
  1252.       #          as x%, set this as %Q(@ecatb_val[:atb] = x)
  1253.       :normal_actor_1st_ecatb_val => %Q(@ecatb_val[:atb] = 0.0),
  1254.  
  1255.       # Sets the 1st atb value of enemies when battles start normally
  1256.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1257.       # It must return a non-negative real number and should return a
  1258.       # non-negative floating-point number
  1259.       # Example: To set the 1st atb value of enemies when battler start normally
  1260.       #          as x%, set this as %Q(@ecatb_val[:atb] = x)
  1261.       :normal_enemy_1st_ecatb_val => %Q(@ecatb_val[:atb] = 0.0),
  1262.  
  1263.       # Sets the 1st atb value of actors when battles start with preemptive
  1264.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1265.       # It must return a non-negative real number and should return a
  1266.       # non-negative floating-point number
  1267.       # Example: To set the 1st atb value of actors when battler start with
  1268.       #          preemptive as x%, set this as %Q(@ecatb_val[:atb] = x)
  1269.       :preemptive_actor_1st_ecatb_val => %Q(@ecatb_val[:atb] = 100.0),
  1270.  
  1271.       # Sets the 1st atb value of enemies when battles start with preemptive
  1272.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1273.       # It must return a non-negative real number and should return a
  1274.       # non-negative floating-point number
  1275.       # Example: To set the 1st atb value of enemies when battler start with
  1276.       #          preemptive as x%, set this as %Q(@ecatb_val[:atb] = x)
  1277.       :preemptive_enemy_1st_ecatb_val => %Q(@ecatb_val[:atb] = 0.0),
  1278.  
  1279.       # Sets the 1st atb value of actors when battles start with surprise
  1280.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1281.       # It must return a non-negative real number and should return a
  1282.       # non-negative floating-point number
  1283.       # Example: To set the 1st atb value of actors when battler start with
  1284.       #          surprise as x%, set this as %Q(@ecatb_val[:atb] = x)
  1285.       :surprise_actor_1st_ecatb_val => %Q(@ecatb_val[:atb] = 0.0),
  1286.  
  1287.       # Sets the 1st atb value of enemies when battles start with surprise
  1288.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1289.       # It must return a non-negative real number and should return a
  1290.       # non-negative floating-point number
  1291.       # Example: To set the 1st atb value of enemies when battler start with
  1292.       #          surprise as x%, set this as %Q(@ecatb_val[:atb] = x)
  1293.       :surprise_enemy_1st_ecatb_val => %Q(@ecatb_val[:atb] = 100.0),
  1294.  
  1295.       # Sets the priority of the ecatb start value notetags to be used
  1296.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1297.       # It must return an array with elements being either :states, :enemies,
  1298.       # :armors, :weapons, :classes or :actors
  1299.       # Example: To set actors to have a higher priority than that of states,
  1300.       #          set this as %Q([:actors, :states])
  1301.       :ecatb_start_val_ord => %Q([:actors, :classes, :weapons, :armors,
  1302.                                   :enemies, :states]),
  1303.  
  1304.       # Sets the battler methods included to calculate the sum of each of those
  1305.       # methods of battlers in :ecatb_def_sum_battlers
  1306.       # Its corresponding method's created under BattleManager
  1307.       # It must return an array of symbols being defined battler methods
  1308.       # Example: To calculate the sum of luk of all battlers in
  1309.       #          :ecatb_def_sum_battlers, set this as %Q([:luk])
  1310.       :ecatb_battlers_def_sum => %Q([:agi]),
  1311.  
  1312.       # Sets the battlers to be included to calculate each of their method sums
  1313.       # Its corresponding method's created under BattleManager
  1314.       # It must return an array of battlers
  1315.       # Example: To set all battlers to be included to calculate each of their
  1316.       #          method sums, set this as
  1317.       #          %Q($game_party.battle_members + $game_troop.members)
  1318.       :ecatb_def_sum_battlers => %Q($game_party.alive_members +
  1319.                                     $game_troop.alive_members),
  1320.  
  1321.       # Sets if the sum of each battler method in :ecatb_battlers_def_sum of all
  1322.       # battlers in :ecatb_def_sum_battlers will be updated
  1323.       # Its corresponding method's created under BattleManager
  1324.       # Example: To update the sum of each battler method in
  1325.       #          :ecatb_battlers_def_sum of all battlers in
  1326.       #          :ecatb_def_sum_battlers if switch with id x is on, set this as
  1327.       #          %Q($game_switches[x])
  1328.       :update_ecatb_battlers_def_sums => %Q(ecatb_def_sum_battlers.any?(
  1329.                                             &DoubleX_RMVXA::ECATB::BLOCKS[
  1330.                                             :ecatb_refresh])),
  1331.  
  1332.       # Sets the action points reduced for all party members upon failed escapes
  1333.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1334.       # It must return a real number and should return an integer
  1335.       # Example: To set the escape action cost as x, set this as %Q(x)
  1336.       :ecatb_esc_act_cost => %Q(1),
  1337.  
  1338.       # Sets the atb reset value upon each failed escape
  1339.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1340.       # It must return a real number and should return a floating-point number
  1341.       # Example: To add the atb reset value upon a failed escape by x%, set this
  1342.       #          as %Q(@ecatb_reset_val + x)
  1343.       :ecatb_esc_reset_val => %Q(0.0),
  1344.  
  1345.       # It won't be used if :actor_sprite_ecatb_bar returns true
  1346.       # Sets the text to be displayed on actor atb bars showing its details
  1347.       # The atb bar fill rate and action points can be referneced by percent and
  1348.       # action respectively
  1349.       # Its corresponding method's created under Window_BattleStatus
  1350.       # It must return a string
  1351.       # Example: To set the text to be displayed on actor atb bars showing the
  1352.       #          actors' action points, set this as %Q(act)
  1353.       :actor_ecatb_bar_text => %Q(percent + "% " + act),
  1354.  
  1355.       # It won't be used if :actor_sprite_ecatb_bar returns true
  1356.       # Sets the word describing and displayed on actor atb bars
  1357.       # Its corresponding method's created under Window_BattleStatus
  1358.       # It must return a string
  1359.       # Example: To use the word "ATB" to describe and be displayed on actor atb
  1360.       #          bars, set this as %Q("ATB")
  1361.       :actor_ecatb_bar_word => %Q("AP"),
  1362.  
  1363.       # It won't be used if :actor_sprite_ecatb_bar returns true
  1364.       # Sets the actor atb bar y offset
  1365.       # Its corresponding method's created under Window_BattleStatus
  1366.       # It must return a real number and should return an integer
  1367.       # Example: To set the actor atb bar y offset as x, set this as %Q(x)
  1368.       :actor_ecatb_bar_y_add => %Q(12),
  1369.  
  1370.       # Sets the atb bar colors
  1371.       # It'll be used only if no corresponding color notetags are used
  1372.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1373.       # It must return an array of colors
  1374.       # Example: To set the atb bar colors as text color c and r, g, b, a rgba
  1375.       #          values, set this as
  1376.       #          %Q([Colour.text_colour(c), Color.new(r, g, b, a)])
  1377.       :ecatb_bar_colors => %Q([Colour.text_colour(7), Colour.text_colour(8)]),
  1378.  
  1379.       # Sets the priority of the ecatb bar color notetags to be used
  1380.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1381.       # It must return an array with elements being either :states, :enemies,
  1382.       # :armors, :weapons, :classes or :actors
  1383.       # Example: To set states to have a higher priority than that of actors,
  1384.       #          set this as %Q([:states, :actors])
  1385.       :ecatb_bar_color_ord => %Q([:states, :enemies, :armors, :weapons,
  1386.                                   :classes, :actors]),
  1387.  
  1388.       # (v0.03a+)Sets something to happen right before inputting actions by a
  1389.       # battler
  1390.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1391.       # Example: To call a common event with id x right before inputting actions
  1392.       #          by a battler, set this as
  1393.       #          %Q($game_temp.reserve_common_event(x))
  1394.       :pre_ecatb_input_act => %Q(),
  1395.  
  1396.       # (v0.03a+)Sets something to happen right after inputting actions by a
  1397.       # battler
  1398.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1399.       # Example: To call a common event with id x right after inputting actions
  1400.       #          by a battler, set this as
  1401.       #          %Q($game_temp.reserve_common_event(x))
  1402.       :post_ecatb_input_act => %Q(),
  1403.  
  1404.       # (v0.03a+)Sets something to happen right before resetting a battler's
  1405.       # atb
  1406.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1407.       # Example: To call a common event with id x right before resetting a
  1408.       #          battler's atb, set this as
  1409.       #          %Q($game_temp.reserve_common_event(x))
  1410.       :pre_ecatb_reset => %Q(),
  1411.  
  1412.       # (v0.03a+)Sets something to happen right after resetting a battler's
  1413.       # atb
  1414.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1415.       # Example: To call a common event with id x right after resetting a
  1416.       #          battler's atb, set this as
  1417.       #          %Q($game_temp.reserve_common_event(x))
  1418.       :post_ecatb_reset => %Q(),
  1419.  
  1420.       # Sets something to happen right before updating the atb clock
  1421.       # Its corresponding method's created under Scene_Battle
  1422.       # Example: To support changing atb, charge and cooldown bar colors of all
  1423.       #          battlers per frame, set this as
  1424.       #          %Q(all_battle_members.each { |mem|
  1425.       #               mem.ecatb_note_change[:atb] =
  1426.       #               mem.ecatb_note_change[:charge] =
  1427.       #               mem.ecatb_note_change[:cooldown] = true
  1428.       #             })
  1429.       :pre_ecatb_update => %Q(),
  1430.  
  1431.       # Sets something to happen right after updating the atb clock
  1432.       # Its corresponding method's created under Scene_Battle
  1433.       # Example: To call a common event with id x right after updating the atb
  1434.       #          clock, set this as %Q($game_temp.reserve_common_event(x))
  1435.       :post_ecatb_update => %Q()
  1436.  
  1437.     }
  1438.  
  1439.   #----------------------------------------------------------------------------|
  1440.   #  * (v0.05a+)Action                                                         |
  1441.   #    Setups configurations of the action features                            |
  1442.   #----------------------------------------------------------------------------|
  1443.  
  1444.     #--------------------------------------------------------------------------|
  1445.     #  Gradual Action Gain Notetag Values                                      |
  1446.     #  - Setups gagx used by <ecatb gradual action gain: gagx> notetags        |
  1447.     #--------------------------------------------------------------------------|
  1448.     # gagx are read at:
  1449.     # 1. RPG::Actor, RPG::Class, RPG::EquipItem, RPG::Enemy, RPG::State
  1450.     #    - next @ecatb_notes[:act] = $1.downcase.to_sym in load_ecatb_notes
  1451.     # gagx are used at:
  1452.     # 1. Game_BattlerBase
  1453.     #    - @ecatb_notes[note] = ecatb.send(n, self) in set_ecatb_notes
  1454.     # gagx are strings of names of methods under DoubleX_RMVXA::ECATB
  1455.     # gagx names can only use alphanumeric characters and can't use uppercase
  1456.     # letters
  1457.     # battler is the battler calling the gagx
  1458.     # The below gagx are examples added to help you set your gagx
  1459.     # You can freely use, rewrite and/or delete these examples
  1460.  
  1461.     # Sets gradual action gain as true
  1462.     def self.gag1(battler)
  1463.       true
  1464.     end
  1465.  
  1466.     # Sets gradual action gain as false
  1467.     def self.gag2(battler)
  1468.       false
  1469.     end
  1470.  
  1471.     # Sets gradual action gain as the state of switch with id x
  1472.     def self.gag3(battler)
  1473.       $game_switches[x]
  1474.     end
  1475.  
  1476.     # Adds new gagx here
  1477.    
  1478.  
  1479.     #--------------------------------------------------------------------------|
  1480.     #  Action Configurations                                                   |
  1481.     #  - Setups configurations of the action features                          |
  1482.     #  - The value of each configuration is the string of the content of its   |
  1483.     #    corresponding method                                                  |
  1484.     #--------------------------------------------------------------------------|
  1485.  
  1486.     ACTION = {
  1487.  
  1488.       # Sets whether a battler gains action points gradually instead of gaining
  1489.       # its maximum instantly
  1490.       # It'll be used only if no corresponding color notetags are used
  1491.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1492.       # Example: To set a battler to gain the maximum action points instantly if
  1493.       #          switch with id x is on, set this as %Q($game_switches[x])
  1494.       :gradual_ecatb_action_gain => %Q(true),
  1495.  
  1496.       # Sets the priority of the ecatb gradual action gain notetags to be used
  1497.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1498.       # It must return an array with elements being either :states, :enemies,
  1499.       # :armors, :weapons, :classes or :actors
  1500.       # Example: To set states to have a higher priority than that of actors,
  1501.       #          set this as %Q([:states, :actors])
  1502.       :gradual_ecatb_action_gain_ord => %Q([:states, :enemies, :armors,
  1503.                                             :weapons, :classes, :actors])
  1504.  
  1505.     }
  1506.  
  1507.   #----------------------------------------------------------------------------|
  1508.   #  * Bar                                                                     |
  1509.   #    Setups configurations and default notetag values of the bar features    |
  1510.   #----------------------------------------------------------------------------|
  1511.  
  1512.     #--------------------------------------------------------------------------|
  1513.     #  Bar Configurations                                                      |
  1514.     #  - Setups configurations and default notetag values of the bar features  |
  1515.     #  - The value of each configuration is the string of the content of its   |
  1516.     #    corresponding method                                                  |
  1517.     #--------------------------------------------------------------------------|
  1518.  
  1519.     # Sets if only enemies being dead before are shown with the atb bar
  1520.     # It'll only be used if it's not set by
  1521.     # <enemy ecatb bar show: kill, bar, percent, act> notetags
  1522.     # It must be either true or false
  1523.     # Example: To sets only enemies being dead before to be shown with the atb
  1524.     # bar, set this as %Q(true)
  1525.     BAR_KILL_ENEMY_1ST = %Q(false)
  1526.  
  1527.     # Sets if enemy atb bars are shown
  1528.     # It'll only be used if it's not set by
  1529.     # <enemy ecatb bar show: kill, bar, percent, act> notetags
  1530.     # It must be either true or false
  1531.     # Example: To hide enemy atb bars, set this as %Q(false)
  1532.     ENEMY_BAR_SHOW = %Q(true)
  1533.  
  1534.     # Sets if enemy action point is shown on enemy atb bars
  1535.     # It'll only be used if it's not set by
  1536.     # <enemy ecatb bar show: kill, bar, percent, act> notetags
  1537.     # It must be either true or false
  1538.     # Example: To hide the enemy action points from the enemy atb bar, set this
  1539.     # as %Q(false)
  1540.     ENEMY_BAR_SHOW_ACT = %Q(true)
  1541.  
  1542.     # Sets if atb fill percent is shown on enemy atb bars
  1543.     # It'll only be used if it's not set by
  1544.     # <enemy ecatb bar show: kill, bar, percent, act> notetags
  1545.     # It must be either true or false
  1546.     # Example: To hide the enemy atb fill percent from the enemy atb bar, set
  1547.     # this as %Q(false)
  1548.     ENEMY_BAR_SHOW_PERCENT = %Q(true)
  1549.  
  1550.     BAR = {
  1551.  
  1552.       # Sets if the actor atb bars are displayed on their sprites instead
  1553.       # Its corresponding method's created under BattleManager
  1554.       # It must always return the same result during the same battle
  1555.       # Example: To display the actor atb bars on their sprites as well if
  1556.       #          switch with id x is on, set this as %Q($game_switches[x])
  1557.       :actor_sprite_ecatb_bar => %Q(false),
  1558.  
  1559.       # (v0.04d+)Sets if the atb and charge/cooldown bars are displayed
  1560.       # simultaneously
  1561.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1562.       # It must return the same value during the same battle
  1563.       # Example: To stop displaying atb and charge/cooldown bars simultaneously,
  1564.       #          set this as %Q(false)
  1565.       :ecatb_bar_multilayer => %Q(true),
  1566.  
  1567.       # Sets if battler sprite atb bars are animated
  1568.       # Its corresponding method's created under ECATB_Bar
  1569.       # Example: To animate the battler sprite atb bars if switch with id x is
  1570.       #          on, set this as %Q($game_switches[x])
  1571.       :ecatb_bar_ani => %Q(true),
  1572.  
  1573.       # Sets the battler sprite atb bar to animate horizontally per frame
  1574.       # Its corresponding method's created under ECATB_Bar
  1575.       # It must return a real number and should return an integer
  1576.       # Example: To set the battler sprite atb bar to animate horizontally by
  1577.       #          number of pixels being the value of variable with id x per
  1578.       #          frame, set this as %Q($game_variables[x])
  1579.       :ecatb_bar_ani_ox => %Q(2),
  1580.  
  1581.       # Sets the battler sprite atb bar width and height
  1582.       # Its corresponding method's created under ECATB_Bar
  1583.       # It must return an array of positive real numbers and should return an
  1584.       # array of natural numbers
  1585.       # Example: To set the battler sprite atb bar width and height to be the
  1586.       #          values of variables with id x and y respectively, set this as
  1587.       #          %Q([$game_variables[x], $game_variables[y]])
  1588.       :ecatb_bar_wh => %Q([48, 12]),
  1589.  
  1590.       # Sets the battler sprite atb bar xy offsets from the host battler sprite
  1591.       # Its corresponding method's created under ECATB_Bar
  1592.       # It must return an array of real numbers and should return an array of
  1593.       # integers
  1594.       # Example: To set the battler sprite atb bar x and y offsets as the value
  1595.       #          of variables with id a and b respectively, set this as
  1596.       #          %Q([$game_variables[a], $game_variables[b]])
  1597.       :ecatb_bar_xy_offset => %Q([0, 0]),
  1598.  
  1599.       # Sets the battler sprite atb bar z position
  1600.       # Its corresponding method's created under ECATB_Bar
  1601.       # It must return a non-negative real number and should return a
  1602.       # non-negative integer
  1603.       # Example: To set the battler sprite atb bar z position as the value of
  1604.       #          variable with id x, set this as %Q($game_variables[x])
  1605.       :ecatb_bar_z => %Q(0),
  1606.  
  1607.       # Sets the text to be displayed on battler sprite atb bars showing its
  1608.       # details
  1609.       # The atb bar fill rate and action points can be referneced by percent and
  1610.       # action respectively
  1611.       # Its corresponding method's created under ECATB_Bar
  1612.       # It must return a string
  1613.       # Example: To set the text to be displayed on battler sprite atb bars
  1614.       #          showing the battlers' action points, set this as %Q(act)
  1615.       :ecatb_bar_text => %Q(percent + "% " + act),
  1616.  
  1617.       # Sets the battler sprite atb bar text color
  1618.       # Its corresponding method's created under ECATB_Bar
  1619.       # It must return a color
  1620.       # Example: To set the battler sprite atb bar text color as r, g, b, a rgba
  1621.       #          values, set this as %Q(Color.new(r, g ,b ,a))
  1622.       :ecatb_bar_text_color => %Q(Colour.text_colour(0)),
  1623.  
  1624.       # Sets the battler sprite atb bar text size
  1625.       # Its corresponding method's created under ECATB_Bar
  1626.       # It must return a positive real number and should return an integer
  1627.       # Example: To set the battler sprite atb bar text saize as the value of
  1628.       #          variable with id x, set this as %Q($game_variables[x])
  1629.       :ecatb_bar_text_size => %Q(16),
  1630.  
  1631.       # Sets the battler sprite atb bar text x and y offsets from the atb bars
  1632.       # Its corresponding method's created under ECATB_Bar
  1633.       # It must return an array of real numbers and should return an array of
  1634.       # integers
  1635.       # Example: To set the battler sprite atb bar text x and y offsets from the
  1636.       #          atb bars as the values of variables with id a and b
  1637.       #          respectively, set this as
  1638.       #          %Q([$game_variables[a], $game_variables[b]])
  1639.       :ecatb_bar_text_xy_offset => %Q([-1, -1]),
  1640.  
  1641.       # Sets the battler sprite atb bar back colors
  1642.       # Its corresponding method's created under ECATB_Bar
  1643.       # It must return an array of colors
  1644.       # Example: To set the battler sprite atb back bar colors as text color c
  1645.       #          and r, g, b, a rgba values, set this as
  1646.       #          %Q([Colour.text_colour(c), Color.new(r, g, b, a)])
  1647.       :ecatb_bar_back_colors => %Q([Colour.text_colour(15),
  1648.                                     Colour.text_colour(15)])
  1649.  
  1650.     }
  1651.  
  1652.   #----------------------------------------------------------------------------|
  1653.   #  * Cancel                                                                  |
  1654.   #    Setups configurations of the cancel features                            |
  1655.   #----------------------------------------------------------------------------|
  1656.  
  1657.     #--------------------------------------------------------------------------|
  1658.     #  Cancel Configurations                                                   |
  1659.     #  - Setups configurations of the cancel features                          |
  1660.     #  - The value of each configuration is the string of the content of its   |
  1661.     #    corresponding method                                                  |
  1662.     #--------------------------------------------------------------------------|
  1663.  
  1664.     CANCEL = {
  1665.  
  1666.       # Sets the key opening the cancel window
  1667.       # Its corresponding method's created under Scene_Battle
  1668.       # It must return a symbol and should return an Input constant
  1669.       # Example: To set the cancel window opening key as X, set this as %Q(:X)
  1670.       :ecatb_cancel_key => %Q(:SHIFT),
  1671.  
  1672.       # Sets the description text of the cancel window
  1673.       # Its corresponding method's created under Scene_Battle
  1674.       # It must return a string
  1675.       # Example: To set the description text of the cancel window as
  1676.       #          "Actor name", set this as
  1677.       #          %Q($game_party.members[@ecatb_cancel_window.index].name)
  1678.  
  1679.       :ecatb_cancel_text => %Q("Select an actor without autobattle nor " +
  1680.                                "confusion to\ncancel his/her/its partially " +
  1681.                                "charging skill/item.")
  1682.  
  1683.     }
  1684.  
  1685.   #----------------------------------------------------------------------------|
  1686.   #  * Charge                                                                  |
  1687.   #    Setups configurations and notetag values of the charge features         |
  1688.   #----------------------------------------------------------------------------|
  1689.  
  1690.     #--------------------------------------------------------------------------|
  1691.     #  Charge Prior Action Cost Notetag Values                                 |
  1692.     #  - Setups cpacx used by <ecatb charge prior act cost: cpacx> notetags    |
  1693.     #--------------------------------------------------------------------------|
  1694.     # cpacx are read at:
  1695.     # 1. RPG::UsableItem
  1696.     #    - send(:"#{note}=", send(:"#{note}") || val) in load_ecatb_notes
  1697.     # cpacx are used at:
  1698.     # 1. Game_Battler
  1699.     #    - unless ecatb.send(@last_ecatb_item.ecatb_charge_prior_act_cost, self)
  1700.     #      in pay_prior_ecatb_charge
  1701.     #    - if ecatb.send(item.ecatb_charge_prior_act_cost, self) in
  1702.     #      exec_ecatb_act_cost
  1703.     #    - !ecatb.send(item.ecatb_charge_prior_act_cost, self) in
  1704.     #      ecatb_unison_actor?
  1705.     # cpacx shouldn't return random values
  1706.     # cpacx are strings of names of methods under DoubleX_RMVXA::ECATB
  1707.     # cpacx names can only use alphanumeric characters and can't use uppercase
  1708.     # letters
  1709.     # battler is the battler calling the cpacx
  1710.     # The below cpacx are examples to help you set your cpacx
  1711.     # You can freely use, rewrite and/or delete these examples
  1712.  
  1713.     # Sets charge prior action cost as true
  1714.     def self.cpac1(battler)
  1715.       true
  1716.     end
  1717.  
  1718.     # Sets charge prior action cost as false
  1719.     def self.cpac2(battler)
  1720.       false
  1721.     end
  1722.  
  1723.     # Sets charge prior action cost as the state of switch with id x
  1724.     def self.cpac3(battler)
  1725.       $game_switches[x]
  1726.     end
  1727.  
  1728.     # Adds new cpacx here
  1729.    
  1730.  
  1731.     # Sets if action cost is paid after finished charging
  1732.     # It'll be used only if no cpacx are used
  1733.     # battler is the battler calling the ecatb_charge_prior_act_cost
  1734.     # Example: To set the default action costs to be paid after charging if
  1735.     #          switch with id x is on, set this as %Q($game_switches[x])
  1736.     def self.ecatb_charge_prior_act_cost(battler)
  1737.       true
  1738.     end
  1739.  
  1740.     #--------------------------------------------------------------------------|
  1741.     #  Charge Prior Item Cost Notetag Values                                   |
  1742.     #  - Setups cpicx used by <ecatb charge prior item cost: cpicx> notetags   |
  1743.     #--------------------------------------------------------------------------|
  1744.     # cpicx are read at:
  1745.     # 1. RPG::UsableItem
  1746.     #    - send(:"#{note}=", send(:"#{note}") || val) in load_ecatb_notes
  1747.     # cpicx are used at:
  1748.     # 1. Game_Battler
  1749.     #    - !DoubleX_RMVXA::ECATB.send(skill.ecatb_charge_prior_item_cost, self)
  1750.     #      in skill_cost_payable?
  1751.     #    - unless DoubleX_RMVXA::ECATB.send(item.ecatb_charge_prior_item_cost,
  1752.     #      self)in use_item
  1753.     #    - return if ecatb.send(@last_ecatb_item.ecatb_charge_prior_item_cost,
  1754.     #      self) in pay_prior_ecatb_charge
  1755.     # cpicx shouldn't return random values
  1756.     # cpicx are strings of names of methods under DoubleX_RMVXA::ECATB
  1757.     # cpicx names can only use alphanumeric characters and can't use uppercase
  1758.     # letters
  1759.     # battler is the battler calling the cpicx
  1760.     # The below cpicx are examples to help you set your cpicx
  1761.     # You can freely use, rewrite and/or delete these examples
  1762.  
  1763.     # Sets charge prior item cost as true
  1764.     def self.cpic1(battler)
  1765.       true
  1766.     end
  1767.  
  1768.     # Sets charge prior item cost as false
  1769.     def self.cpic2(battler)
  1770.       false
  1771.     end
  1772.  
  1773.     # Sets charge prior item cost as the state of switch with id x
  1774.     def self.cpic3(battler)
  1775.       $game_switches[x]
  1776.     end
  1777.  
  1778.     # Adds new cpicx here
  1779.    
  1780.  
  1781.     # Sets if item costs are paid after finished charging
  1782.     # It'll be used only if no cpicx are used
  1783.     # battler is the battler calling ecatb_charge_prior_item_cost
  1784.     # Example: To set the default item costs to be paid after charging if switch
  1785.     #          with id x is on, set this as %Q($game_switches[x])
  1786.     def self.ecatb_charge_prior_item_cost(battler)
  1787.       true
  1788.     end
  1789.  
  1790.     #--------------------------------------------------------------------------|
  1791.     #  Charge Rate Notetag Values                                              |
  1792.     #  - Setups crx used by <ecatb charge rate: crx> notetags                  |
  1793.     #--------------------------------------------------------------------------|
  1794.     # crx are read at:
  1795.     # 1. RPG::UsableItem
  1796.     #    - send(:"#{note}=", send(:"#{note}") || val) in load_ecatb_notes
  1797.     # crx are used at:
  1798.     # 1. Game_BattlerBase
  1799.     #    - DoubleX_RMVXA::ECATB.send(@last_ecatb_item.ecatb_charge_rate, self,
  1800.     #      @last_ecatb_rate[:charge]) in ecatb_charge_gain_rate
  1801.     # crx are strings of names of methods under DoubleX_RMVXA::ECATB
  1802.     # crx must return a real number and should return a floating-point number
  1803.     # crx names can only use alphanumeric characters and can't use uppercase
  1804.     # letters
  1805.     # battler is the battler calling the crx
  1806.     # rate is the atb gain rate of battler
  1807.     # The below crx are examples to help you set your crx
  1808.     # You can freely use, rewrite and/or delete these examples
  1809.  
  1810.     # Sets the charge rate as x% per frame
  1811.     def self.cr1(battler, rate)
  1812.       x
  1813.     end
  1814.  
  1815.     # Sets the charge rate as the value of variable with id x * 100% per frame
  1816.     def self.cr2(battler, rate)
  1817.       $game_variables[x]
  1818.     end
  1819.  
  1820.     # Sets the charge rate as x times the atb gain rate
  1821.     def self.cr3(battler, rate)
  1822.       rate * x
  1823.     end
  1824.  
  1825.     # Adds new crx here
  1826.    
  1827.  
  1828.     # Sets the default charge rate
  1829.     # It'll be used only if no crx are used
  1830.     # battler is the battler calling ecatb_charge_rate
  1831.     # rate is the atb gain rate of battler
  1832.     # Example: To disable charging, set this as %Q(100.0)
  1833.     def self.ecatb_charge_rate(battler, rate)
  1834.       100.0
  1835.     end
  1836.  
  1837.     #--------------------------------------------------------------------------|
  1838.     #  Charge Configurations                                                   |
  1839.     #  - Setups configurations of the charge features                          |
  1840.     #  - The value of each configuration is the string of the content of its   |
  1841.     #    corresponding method                                                  |
  1842.     #--------------------------------------------------------------------------|
  1843.  
  1844.     CHARGE = {
  1845.  
  1846.       # Sets the charge bar colors
  1847.       # It'll be used only if no corresponding color notetags are used
  1848.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1849.       # It must return an array of colors
  1850.       # Example: To set the charge bar colors as text color c and r, g, b, a
  1851.       #          rgba values, set this as
  1852.       #          %Q([Colour.text_colour(c), Color.new(r, g, b, a)])
  1853.       :ecatb_charge_bar_colors => %Q([Colour.text_colour(30),
  1854.                                       Colour.text_colour(31)]),
  1855.  
  1856.       # Sets the priority of the ecatb charge bar color notetags to be used
  1857.       # Its corresponding method's created under Game_Actor and Game_Enemy
  1858.       # It must return an array with elements being either :states, :enemies,
  1859.       # :armors, :weapons, :classes or :actors
  1860.       # Example: To set states to have a higher priority than that of actors,
  1861.       #          set this as %Q([:states, :actors])
  1862.       :ecatb_charge_bar_color_ord => %Q([:states, :enemies, :armors, :weapons,
  1863.                                          :classes, :actors]),
  1864.  
  1865.       # Sets the party escape charge rate
  1866.       # The atb rate can be referneced by charge
  1867.       # Its corresponding method's created under Game_Actor
  1868.       # It must return a real number and should return a floating-point number
  1869.       # Example: To disable party escape charging, set this as %Q(100.0)
  1870.       :esc_ecatb_charge_rate => %Q(100.0)
  1871.  
  1872.     }
  1873.  
  1874.   #----------------------------------------------------------------------------|
  1875.   #  * Clock                                                                   |
  1876.   #    Setups configurations of the clock features                             |
  1877.   #----------------------------------------------------------------------------|
  1878.  
  1879.     #--------------------------------------------------------------------------|
  1880.     #  Clock Configurations                                                    |
  1881.     #--------------------------------------------------------------------------|
  1882.  
  1883.     CLOCK = {
  1884.  
  1885.       # Shows the atb clock window
  1886.       # It's used under Scene_Battle but it doesn't have any associated method
  1887.       # Example: To show the atb clock window if switch with id x is on, set
  1888.       #          this as %Q($game_switches[x])
  1889.       :show_ecatb_clock_window => %Q(true),
  1890.  
  1891.       # Sets the atb clock window width and height
  1892.       # Its corresponding method's created under ECATB_Clock_Window
  1893.       # It must return an array of positive real numbers and should return an
  1894.       # array of natural numbers
  1895.       # Example: To set the atb clock window width and height as the value of
  1896.       #          variables with id x and y respectively, set this as
  1897.       #          %Q([$game_variables[x], $game_variables[y]])
  1898.       :ecatb_clock_window_wh => %Q([128, 48]),
  1899.  
  1900.       # Sets the atb clock window x, y and z positions
  1901.       # Its corresponding method's created under ECATB_Clock_Window
  1902.       # It must return an array of real numbers and should return an array of
  1903.       # integers
  1904.       # Example: To set the atb clock window x, y and z positions as the value
  1905.       #          of variables with id a, b and c respectively, set this as
  1906.       #         %Q([$game_variables[a], $game_variables[b], $game_variables[c]])
  1907.       :ecatb_clock_window_xyz => %Q([0, 0, 0]),
  1908.  
  1909.       # Sets the turn portion bar colors
  1910.       # Its corresponding method's created under ECATB_Clock_Bar
  1911.       # It must return an array of colors
  1912.       # Example: To set the turn portion bar colors as text color c and r, g, b,
  1913.       #          a rgba values, set this as
  1914.       #          %Q([Colour.text_colour(c), Color.new(r, g, b, a)])
  1915.       :ecatb_clock_bar_colors => %Q([Colour.text_colour(7),
  1916.                                      Colour.text_colour(8)]),
  1917.  
  1918.       # Sets the turn portion bar width and height
  1919.       # Its corresponding method's created under ECATB_Clock_Bar
  1920.       # It must return an array of positive real numbers and should return an
  1921.       # array of natural numbers
  1922.       # Example: To set the turn portion bar width and height as the value of
  1923.       #          variables with id x and y respectively, set this as
  1924.       #          %Q([$game_variables[x], $game_variables[y]])
  1925.       :ecatb_clock_bar_wh => %Q([104, 12]),
  1926.  
  1927.       # Sets the turn portion bar x and y positions
  1928.       # Its corresponding method's created under ECATB_Clock_Bar
  1929.       # It must return an array of real numbers and should return an array of
  1930.       # integers
  1931.       # Example: To set the turn portion bar x and y positions as the value of
  1932.       #          variables with id x and y respectively, set this as
  1933.       #          %Q([$game_variables[x], $game_variables[y]])
  1934.       :ecatb_clock_bar_xy => %Q([8, 8]),
  1935.  
  1936.       # Sets the way the turn portion and count text are shown
  1937.       # The current atb clcok can be referneced by cur_clock
  1938.       # The maximum atb clock can be referneced by max_clock
  1939.       # The turn count can be referenced by turn_count
  1940.       # Its corresponding method's created under ECATB_Clock_Window
  1941.       # It must return a string
  1942.       # Example: To set the way the turn portion and count text are shown as
  1943.       #          "cur_clock/max_clock", set this as
  1944.       #          %Q(cur_clock.to_s + "/" + max_clock.to_s)
  1945.       :ecatb_clock_text => %Q(cur_clock.to_s + "/" + max_clock.to_s + " " +
  1946.                               turn_count.to_s),
  1947.  
  1948.       # Sets the turn portion and count text color
  1949.       # Its corresponding method's created under ECATB_Clock_Window
  1950.       # It must return a color
  1951.       # Example: To set the turn portion and count text color's rgba values as
  1952.       #          r, g, b and a, set this as %Q(Color.new(r, g, b, a))
  1953.       :ecatb_clock_text_color => %Q(Colour.text_colour(0)),
  1954.  
  1955.       # Sets the turn portion and count text size
  1956.       # Its corresponding method's created under ECATB_Clock_Window
  1957.       # It must return a positive real number and should return a natural number
  1958.       # Example: To set the turn portion and count text size as the value of
  1959.       #          variable with id x, set this as %Q($game_variables[x])
  1960.       :ecatb_clock_text_size => %Q(16),
  1961.  
  1962.       # Sets the turn portion and count text x and y positions
  1963.       # Its corresponding method's created under ECATB_Clock_Window
  1964.       # It must return an array of real numbers and should return an array of
  1965.       # integers
  1966.       # Example: To set the turn portion and count text x and y positions as the
  1967.       #          value of variables with id a and b respectively, set this as
  1968.       #          %Q([$game_variables[a], $game_variables[b]])
  1969.       :ecatb_clock_text_xy => %Q([0, 4])
  1970.  
  1971.     }
  1972.  
  1973.   #----------------------------------------------------------------------------|
  1974.   #  * Cooldown                                                                |
  1975.   #    Setups configurations and notetag values of the cooldown features       |
  1976.   #----------------------------------------------------------------------------|
  1977.  
  1978.     #--------------------------------------------------------------------------|
  1979.     #  Cooldown Rate Notetag Values                                            |
  1980.     #  - Setups cdrx used by <ecatb cooldown rate: cdrx> notetags              |
  1981.     #--------------------------------------------------------------------------|
  1982.     # cdrx are read at:
  1983.     # 1. RPG::UsableItem
  1984.     #    - send(:"#{note}=", send(:"#{note}") || val) in load_ecatb_notes
  1985.     # cdrx are used at:
  1986.     # 1. Game_BattlerBase
  1987.     #    - DoubleX_RMVXA::ECATB.send(@last_ecatb_item.ecatb_cooldown_rate, self,
  1988.     #      @last_ecatb_rate[:cooldown]) in ecatb_cooldown_loss_rate
  1989.     # The atb rate can be referenced by val
  1990.     # cdrx are strings of names of methods under DoubleX_RMVXA::ECATB
  1991.     # cdrx must return a real number and should return a floating-point number
  1992.     # cdrx names can only use alphanumeric characters and can't use uppercase
  1993.     # letters
  1994.     # battler is the battler calling the cdrx
  1995.     # rate is the atb gain rate of battler
  1996.     # The below cdrx are examples to help you set your cdrx
  1997.     # You can freely use, rewrite and/or delete these examples
  1998.  
  1999.     # Sets the cooldown rate as x% per frame
  2000.     def self.cdr1(battler, rate)
  2001.       x
  2002.     end
  2003.  
  2004.     # Sets the cooldown rate as the value of variable with id x* 100% per frame
  2005.     def self.cdr2(battler, rate)
  2006.       $game_variables[x]
  2007.     end
  2008.  
  2009.     # Sets the cooldown rate as x times the atb gain rate
  2010.     def self.cdr3(battler, rate)
  2011.       rate * x
  2012.     end
  2013.  
  2014.     # Adds new cdrx here
  2015.    
  2016.  
  2017.     # Sets the default cooldown rate
  2018.     # It'll be used only if no cdrx are used
  2019.     # battler is the battler calling ecatb_cooldown_rate
  2020.     # rate is the atb gain rate of battler
  2021.     # Example: To disable cooldown, set this as %Q(100.0)
  2022.     def self.ecatb_cooldown_rate(battler, rate)
  2023.       100.0
  2024.     end
  2025.  
  2026.     #--------------------------------------------------------------------------|
  2027.     #  Cooldown Configurations                                                 |
  2028.     #  - Setups configurations of the cooldown features                        |
  2029.     #  - The value of each configuration is the string of the content of its   |
  2030.     #    corresponding method                                                  |
  2031.     #--------------------------------------------------------------------------|
  2032.  
  2033.     COOLDOWN = {
  2034.  
  2035.       # Sets the cooldown bar colors
  2036.       # It'll be used only if no corresponding color notetags are used
  2037.       # Its corresponding method's created under Game_Actor and Game_Enemy
  2038.       # It must return an array of colors
  2039.       # Example: To set the cooldown bar colors as text color c and r, g, b, a
  2040.       #          rgba values, set this as
  2041.       #          %Q([Colour.text_colour(c), Color.new(r, g, b, a)])
  2042.       :ecatb_cooldown_bar_colors => %Q([Colour.text_colour(19),
  2043.                                         Colour.text_colour(26)]),
  2044.  
  2045.       # Sets the priority of the ecatb cooldown bar color notetags to be used
  2046.       # Its corresponding method's created under Game_Actor and Game_Enemy
  2047.       # It must return an array with elements being either :states, :enemies,
  2048.       # :armors, :weapons, :classes or :actors
  2049.       # Example: To set states to have a higher priority than that of actors,
  2050.       #          set this as %Q([:states, :actors])
  2051.       :ecatb_cooldown_bar_color_ord => %Q([:states, :enemies, :armors,
  2052.                                            :weapons, :classes, :actors]),
  2053.  
  2054.       # (v0.03a+)Sets something to happen right after finishing cooling down
  2055.       # normally
  2056.       # Its corresponding method's created under Game_Actor and Game_Enemy
  2057.       # Example: To call a common event with id x right after finishing cooling
  2058.       #          down normally, set this as
  2059.       #          %Q($game_temp.reserve_common_event(x))
  2060.       :ecatb_cooldown_finish => %Q(),
  2061.  
  2062.       # Sets the failed party escape cooldown rate
  2063.       # The atb rate can be referneced by cooldown
  2064.       # Its corresponding method's created under Game_Actor
  2065.       # It must return a real number and should return a floating-point number
  2066.       # Example: To disable failed party escape cooldown, set this as %Q(100.0)
  2067.       :esc_ecatb_cooldown_rate => %Q(100.0)
  2068.  
  2069.     }
  2070.  
  2071.   #----------------------------------------------------------------------------|
  2072.   #  * Countdown                                                               |
  2073.   #    Setups configurations and notetag values of the countdown features      |
  2074.   #----------------------------------------------------------------------------|
  2075.  
  2076.     #--------------------------------------------------------------------------|
  2077.     #  Countdown Interval Notetag Values                                       |
  2078.     #  - Setups cix used by <ecatb countdown interval: cix> notetags           |
  2079.     #--------------------------------------------------------------------------|
  2080.     # cix are read at:
  2081.     # 1. RPG::State
  2082.     #    - next @ecatb_countdown_interval = $1.downcase.to_sym in
  2083.     #      load_ecatb_notes
  2084.     # cix are used at:
  2085.     # 1. Game_Battler
  2086.     #    - return unless $data_states[state_id].ecatb_countdown_interval in
  2087.     #      reset_state_counts
  2088.     #    - @ecatb_countdown_clock.each_key(&@ecatb_countdown_updates) in
  2089.     #      ecatb_countdown_update
  2090.     # cix are strings of names of methods under DoubleX_RMVXA::ECATB
  2091.     # cix must return a positive real number and should return a natural number
  2092.     # cix names can only use alphanumeric characters and can't use uppercase
  2093.     # letters
  2094.     # battler is the battler calling the cix
  2095.     # The below cix are examples to help you set your cix
  2096.     # You can freely use, rewrite and/or delete these examples
  2097.  
  2098.     # Sets the countdown interval as x seconds
  2099.     def self.ci1(battler)
  2100.       x
  2101.     end
  2102.  
  2103.     # Sets the countdown interval as the number of seconds equal to the value of
  2104.     # variable with id x
  2105.     def self.ci2(battler)
  2106.       $game_variables[x]
  2107.     end
  2108.  
  2109.     # Adds new cix here
  2110.    
  2111.  
  2112.     #--------------------------------------------------------------------------|
  2113.     #  (v0.05a+)Countdown Configurations                                       |
  2114.     #  - Setups configurations of the countdown features                       |
  2115.     #  - The value of each configuration is the string of the content of its   |
  2116.     #    corresponding method                                                  |
  2117.     #--------------------------------------------------------------------------|
  2118.  
  2119.     COUNTDOWN = {
  2120.  
  2121.       # Sets the minimum countdown interval for all states in frames
  2122.       # Its corresponding method's created under Game_Actor and Game_Enemy
  2123.       # It must return a natural number
  2124.       # Example: To minimum countdown interval for all states in frames as the
  2125.       #          half of the number of frames per second, set this as
  2126.       #          %Q(Graphics.frame_rate / 2)
  2127.       :ecatb_countdown_min => %Q(Graphics.frame_rate)
  2128.  
  2129.     }
  2130.  
  2131.   #----------------------------------------------------------------------------|
  2132.   #  * Force                                                                   |
  2133.   #    Setups configurations of the force features                             |
  2134.   #----------------------------------------------------------------------------|
  2135.  
  2136.     #--------------------------------------------------------------------------|
  2137.     #  Force Configurations                                                    |
  2138.     #  - Setups configurations of the force features                           |
  2139.     #  - The value of each configuration is the string of the content of its   |
  2140.     #    corresponding method                                                  |
  2141.     #--------------------------------------------------------------------------|
  2142.  
  2143.     FORCE = {
  2144.  
  2145.       # Sets the key forcing the atb clock to run
  2146.       # Its corresponding method's created under Scene_Battle
  2147.       # It must return a symbol and should return an Input constant
  2148.       # If :ecatb_force_stop_key is pressed before pressing
  2149.       # :ecatb_force_run_key, the latter will cancel the former instead of
  2150.       # forcing the atb clock to run
  2151.       # Pressing :ecatb_force_run_key again will force the atb clock to run
  2152.       # Example: To disable this feature, set this as %Q(:unused), where :unused
  2153.       #          is an unused keymap
  2154.       :ecatb_force_run_key => %Q(:CTRL),
  2155.  
  2156.       # Sets the key forcing the atb clock to stop
  2157.       # Its corresponding method's created under Scene_Battle
  2158.       # It must return a symbol and should return an Input constant
  2159.       # If :ecatb_force_run_key is pressed before pressing
  2160.       # :ecatb_force_stop_key, the latter will cancel the former instead of
  2161.       # forcing the atb clock to stop
  2162.       # Example: To disable this feature, set this as %Q(:unused), where :unused
  2163.       #          is an unused keymap
  2164.       :ecatb_force_stop_key => %Q(:ALT),
  2165.  
  2166.       # Shows the atb force window displaying the atb force status
  2167.       # It's used under Scene_Battle but it doesn't have any associated method
  2168.       # Example: To show the atb force window if switch with id x is on, set
  2169.       #          this as %Q($game_switches[x])
  2170.       :show_ecatb_force_window => %Q(true),
  2171.  
  2172.       # Sets the atb force window width and height
  2173.       # Its corresponding method's created under ECATB_Force_Window
  2174.       # It must return an array of positive real numbers and should return an
  2175.       # array of natural numbers
  2176.       # Example: To set the atb force window width and height as the value of
  2177.       #          variables with id x and y respectively, set this as
  2178.       #          %Q([$game_variables[x], $game_variables[y]])
  2179.       :ecatb_force_window_wh => %Q([128, 40]),
  2180.  
  2181.       # Sets the atb force widnow x, y and z positions
  2182.       # Its corresponding method's created under ECATB_Force_Window
  2183.       # It must return an array of real numbers and should return an array of
  2184.       # integers
  2185.       # Example: To set the atb force window x, y and z positions as the value
  2186.       #          of variables with id a, b and c respectively, set this as
  2187.       #         %Q([$game_variables[a], $game_variables[b], $game_variables[c]])
  2188.       :ecatb_force_window_xyz => %Q([0, 48, 0]),
  2189.  
  2190.       # Sets the atb force window text to be displayed when the atb clock isn't
  2191.       # forced
  2192.       # Its corresponding method's created under ECATB_Force_Window
  2193.       # It must return a string
  2194.       # Example: To set the atb force window text to be displayed when the atb
  2195.       #          clock isn't forced as "nil", set this as %Q("nil")
  2196.       :ecatb_force_nil_text => %Q("No Force ATB"),
  2197.  
  2198.       # Sets the atb force window text to be displayed when the atb clock's
  2199.       # forced to run
  2200.       # Its corresponding method's created under ECATB_Force_Window
  2201.       # It must return a string
  2202.       # Example: To set the atb force window text to be displayed when the atb
  2203.       #          clock's force to run as "run", set this as %Q("run")
  2204.       :ecatb_force_run_text => %Q("ATB Force Run"),
  2205.  
  2206.       # Sets the atb force window text to be displayed when the atb clock's
  2207.       # forced to stop
  2208.       # Its corresponding method's created under ECATB_Force_Window
  2209.       # It must return a string
  2210.       # Example: To set the atb force window text to be displayed when the atb
  2211.       #          clock's force to run as "stop", set this as %Q("stop")
  2212.       :ecatb_force_stop_text => %Q("ATB Force Stop"),
  2213.  
  2214.       # Sets the atb force window text color
  2215.       # Its corresponding method's created under ECATB_Force_Window
  2216.       # It must return a color
  2217.       # Example: To set the atb force window text color's rgba values as r, g, b
  2218.       #          and a, set this as %Q(Color.new(r, g, b, a))
  2219.       :ecatb_force_text_color => %Q(Colour.text_colour(0)),
  2220.  
  2221.       # Sets the atb force window text size
  2222.       # Its corresponding method's created under ECATB_Force_Window
  2223.       # It must return a positive real number and should return a natural number
  2224.       # Example: To set the atb force window text size as the value of variable
  2225.       #          with id x, set this as %Q($game_variables[x])
  2226.       :ecatb_force_text_size => %Q(16),
  2227.  
  2228.       # Sets the atb force window text x and y positions
  2229.       # Its corresponding method's created under ECATB_Force_Window
  2230.       # It must return an array of real numbers and should return an array of
  2231.       # integers
  2232.       # Example: To set the atb force window text x and y positions as the value
  2233.       #          of variables with id a and b respectively, set this as
  2234.       #          %Q([$game_variables[a], $game_variables[b]])
  2235.       :ecatb_force_text_xy => %Q([0, 0])
  2236.  
  2237.     }
  2238.  
  2239.   #----------------------------------------------------------------------------|
  2240.   #  * Hotkey                                                                  |
  2241.   #    Setups configurations of the hotkey features                            |
  2242.   #----------------------------------------------------------------------------|
  2243.  
  2244.     #--------------------------------------------------------------------------|
  2245.     #  Hotkey Configurations                                                   |
  2246.     #  - Setups configurations of the hotkey features                          |
  2247.     #  - The value of each configuration is the string of the content of its   |
  2248.     #    corresponding method                                                  |
  2249.     #--------------------------------------------------------------------------|
  2250.  
  2251.     HOTKEY = {
  2252.  
  2253.       # Sets the hotkeys calling an actor in the status window that can input
  2254.       # actions or in the cancel window, or a battler in the target window
  2255.       # Its corresponding method's created under Scene_Battle
  2256.       # It must return an array of symbols and should return an array of
  2257.       # Input constants
  2258.       # The ith hotkey calls the actor with index i
  2259.       # Nothing will happen if the actor in the status window can't input
  2260.       # actions
  2261.       # Example: To disable this feature, set this as %Q([])
  2262.       :ecatb_battler_hotkeys => %Q([
  2263.         :NUMPAD1,
  2264.         :NUMPAD2,
  2265.         :NUMPAD3,
  2266.         :NUMPAD4,
  2267.         :NUMPAD5,
  2268.         :NUMPAD6,
  2269.         :NUMPAD7,
  2270.         :NUMPAD8,
  2271.         :NUMPAD9,
  2272.         :NUMPAD0
  2273.       ])
  2274.  
  2275.     }
  2276.  
  2277.   #----------------------------------------------------------------------------|
  2278.   #  * (v0.01a+)Order                                                          |
  2279.   #    Setups configurations of the order features                             |
  2280.   #----------------------------------------------------------------------------|
  2281.  
  2282.     #--------------------------------------------------------------------------|
  2283.     #  Order Battler Icon Notetag Values                                       |
  2284.     #  - Setups obix used by <ecatb order battler icon: obix> notetags         |
  2285.     #--------------------------------------------------------------------------|
  2286.     # obix are read at:
  2287.     # 1. RPG::Actor, RPG::Class, RPG::EquipItem, RPG::Enemy, RPG::State
  2288.     #    - next @ecatb_notes[:order_icon] = $1.downcase.to_sym in
  2289.     #      load_ecatb_notes
  2290.     # obix are used at:
  2291.     # 1. Game_BattlerBase
  2292.     #    - @ecatb_notes[note] = ecatb.send(n, self) in set_ecatb_notes
  2293.     # obix are strings of names of methods under DoubleX_RMVXA::ECATB
  2294.     # obix must return an array with its 1st and 2nd element being a bitmap and
  2295.     # a rect respectively
  2296.     # obix names can only use alphanumeric characters and can't use uppercase
  2297.     # letters
  2298.     # battler is the battler calling the obix
  2299.     # The below obix are examples added to help you set your obix
  2300.     # You can freely use, rewrite and/or delete these examples
  2301.  
  2302.     # Uses the actor character graphic with frame at 1st row and 2nd column
  2303.     def self.obi1(battler)
  2304.       bitmap = Cache.character(battler.actor.character_name)
  2305.       w = bitmap.width / 12
  2306.       h = bitmap.height / 8
  2307.       index = battler.actor.character_index
  2308.       [bitmap, Rect.new((index % 4 * 3 + 1) * w, (index / 4 * 4) * h, w, h)]
  2309.     end
  2310.  
  2311.     # Uses bitmap "Monsters2" in "Characters" with part at 1st row and 3rd
  2312.     # column and frame in that part at 1st row and 2nd column
  2313.     def self.obi2(battler)
  2314.       bitmap = Cache.character("Monster2")
  2315.       w = bitmap.width / 12
  2316.       h = bitmap.height / 8
  2317.       [bitmap, Rect.new((2 % 4 * 3 + 1) * w, (2 / 4 * 4) * h, w, h)]
  2318.     end
  2319.  
  2320.     # Adds new obix here
  2321.    
  2322.  
  2323.     #--------------------------------------------------------------------------|
  2324.     #  Order Battler Opacity Notetag Values                                    |
  2325.     #  - Setups obox used by <ecatb order battler opacity: obox> notetags      |
  2326.     #--------------------------------------------------------------------------|
  2327.     # obox are read at:
  2328.     # 1. RPG::Actor, RPG::Class, RPG::EquipItem, RPG::Enemy, RPG::State
  2329.     #    - next @ecatb_notes[:order_opacity] = $1.downcase.to_sym in
  2330.     #      load_ecatb_notes
  2331.     # obox are used at:
  2332.     # 1. Game_BattlerBase
  2333.     #    - @ecatb_notes[note] = ecatb.send(n, self) in set_ecatb_notes
  2334.     # obox are strings of names of methods under DoubleX_RMVXA::ECATB
  2335.     # obox must return a non-negative real number and should return a
  2336.     # non-negatve integer
  2337.     # obox names can only use alphanumeric characters and can't use uppercase
  2338.     # letters
  2339.     # battler is the battler calling the obox
  2340.     # The below obox are examples added to help you set your obox
  2341.     # You can freely use, rewrite and/or delete these examples
  2342.  
  2343.     # Sets the opacity of the icon representing its battler order as x
  2344.     def self.obo1(battler)
  2345.       x
  2346.     end
  2347.  
  2348.     # Sets the opacity of the icon representing its battler order as the value
  2349.     # of variable with id x
  2350.     def self.obo2(battler)
  2351.       $game_variables[x]
  2352.     end
  2353.  
  2354.     # Adds new obox here
  2355.    
  2356.  
  2357.     #--------------------------------------------------------------------------|
  2358.     #  Order Battler Scale Notetag Values                                      |
  2359.     #  - Setups obsx used by <ecatb order battler scale: obsx> notetags        |
  2360.     #--------------------------------------------------------------------------|
  2361.     # obsx are read at:
  2362.     # 1. RPG::Actor, RPG::Class, RPG::EquipItem, RPG::Enemy, RPG::State
  2363.     #    - next @ecatb_notes[:order_scale] = $1.downcase.to_sym in
  2364.     #      load_ecatb_notes
  2365.     # obsx are used at:
  2366.     # 1. Game_BattlerBase
  2367.     #    - @ecatb_notes[note] = ecatb.send(n, self) in set_ecatb_notes
  2368.     # obsx are strings of names of methods under DoubleX_RMVXA::ECATB
  2369.     # obsx must return a positive real number
  2370.     # obsx names can only use alphanumeric characters and can't use uppercase
  2371.     # letters
  2372.     # battler is the battler calling the obsx
  2373.     # The below obsx are examples added to help you set your obsx
  2374.     # You can freely use, rewrite and/or delete these examples
  2375.  
  2376.     # Sets the opacity of the icon representing its battler order as x
  2377.     def self.obs1(battler)
  2378.       x
  2379.     end
  2380.  
  2381.     # Sets the opacity of the icon representing its battler order as the value
  2382.     # of variable with id x
  2383.     def self.obs2(battler)
  2384.       $game_variables[x]
  2385.     end
  2386.  
  2387.     # Adds new obsx here
  2388.    
  2389.  
  2390.     #--------------------------------------------------------------------------|
  2391.     #  Order Battler Z Notetag Values                                          |
  2392.     #  - Setups obzx used by <ecatb order battler z: obzx> notetags            |
  2393.     #--------------------------------------------------------------------------|
  2394.     # obzx are read at:
  2395.     # 1. RPG::Actor, RPG::Class, RPG::EquipItem, RPG::Enemy, RPG::State
  2396.     #    - next @ecatb_notes[:order_z] = $1.downcase.to_sym in load_ecatb_notes
  2397.     # obzx are used at:
  2398.     # 1. Game_BattlerBase
  2399.     #    - @ecatb_notes[note] = ecatb.send(n, self) in set_ecatb_notes
  2400.     # obzx are strings of names of methods under DoubleX_RMVXA::ECATB
  2401.     # obzx must return a non-negative real number and should return a
  2402.     # non-negatve integer
  2403.     # obzx names can only use alphanumeric characters and can't use uppercase
  2404.     # letters
  2405.     # battler is the battler calling the obzx
  2406.     # The below obzx are examples added to help you set your obzx
  2407.     # You can freely use, rewrite and/or delete these examples
  2408.  
  2409.     # Sets the z position of the icon representing its battler order as x
  2410.     def self.obz1(battler)
  2411.       x
  2412.     end
  2413.  
  2414.     # Sets the z position of the icon representing its battler order as the
  2415.     # value of variable with id x
  2416.     def self.obz2(battler)
  2417.       $game_variables[x]
  2418.     end
  2419.  
  2420.     # Adds new obzx here
  2421.    
  2422.  
  2423.     #--------------------------------------------------------------------------|
  2424.     #  Order Configurations                                                    |
  2425.     #  - Setups configurations of the order features                           |
  2426.     #  - The value of each configuration is the string of the content of its   |
  2427.     #    corresponding method                                                  |
  2428.     #--------------------------------------------------------------------------|
  2429.  
  2430.     ORDER = {
  2431.  
  2432.       # Shows the battler order window
  2433.       # It's used under Scene_Battle but it doesn't have any associated method
  2434.       # Example: To show the battler atb window if switch with id x is on, set
  2435.       #          this as %Q($game_switches[x])
  2436.       :show_ecatb_order_window => %Q(true),
  2437.  
  2438.       # Sets the battler order window width and height
  2439.       # Its corresponding method's created under ECATB_Order_Window
  2440.       # It must return an array of positive real numbers and should return an
  2441.       # array of natural numbers
  2442.       # Example: To set the battler order window width and height as the value
  2443.       #          of variables with id x and y respectively, set this as
  2444.       #          %Q([$game_variables[x], $game_variables[y]])
  2445.       :ecatb_order_window_wh => %Q([128, 60]),
  2446.  
  2447.       # Sets the battler order window x, y and z positions
  2448.       # Its corresponding method's created under ECATB_Order_Window
  2449.       # It must return an array of real numbers and should return an array of
  2450.       # integers
  2451.       # Example: To set the battler order window x, y and z positions as the
  2452.       #          value of variables with id a, b and c respectively, set this as
  2453.       #     %Q([$game_variables[a], $game_variables[b], $game_variables[c]])
  2454.       :ecatb_order_window_xyz => %Q([0, 88, 0]),
  2455.  
  2456.       # Sets the battler order atb bar colors
  2457.       # Its corresponding method's created under ECATB_Order_Window
  2458.       # It must return an array of colors
  2459.       # Example: To set the battler order atb bar colors as text color c and r,
  2460.       #          g, b, a rgba values, set this as
  2461.       #          %Q([Colour.text_colour(c), Color.new(r, g, b, a)])
  2462.       :ecatb_order_bar_colors => %Q([Colour.text_colour(7),
  2463.                                      Colour.text_colour(8)]),
  2464.  
  2465.       # Sets the battler order atb charge bar colors
  2466.       # Its corresponding method's created under ECATB_Order_Window
  2467.       # It must return an array of colors
  2468.       # Example: To set the battler order atb charge bar colors as text color c
  2469.       #          and r, g, b, a rgba values, set this as
  2470.       #          %Q([Colour.text_colour(c), Color.new(r, g, b, a)])
  2471.       :ecatb_order_charge_bar_colors => %Q([Colour.text_colour(30),
  2472.                                             Colour.text_colour(31)]),
  2473.  
  2474.       # Sets the battler order atb cooldown bar colors
  2475.       # Its corresponding method's created under ECATB_Order_Window
  2476.       # It must return an array of colors
  2477.       # Example: To set the battler order atb cooldown bar colors as text color
  2478.       #          c and r, g, b, a rgba values, set this as
  2479.       #          %Q([Colour.text_colour(c), Color.new(r, g, b, a)])
  2480.       :ecatb_order_cooldown_bar_colors => %Q([Colour.text_colour(19),
  2481.                                               Colour.text_colour(26)]),
  2482.  
  2483.       # Sets the battler order bars width and height
  2484.       # Its corresponding method's created under ECATB_Order_Window
  2485.       # It must return an array of positive real numbers and should return an
  2486.       # array of natural numbers
  2487.       # Example: To set the battler order bars width and height as the value of
  2488.       #          variables with id x and y respectively, set this as
  2489.       #          %Q([$game_variables[x], $game_variables[y]])
  2490.       :ecatb_order_bar_wh => %Q([108, 12]),
  2491.  
  2492.       # Sets the battler order bars x and y positions
  2493.       # Its corresponding method's created under ECATB_Order_Window
  2494.       # It must return an array of real numbers and should return an array of
  2495.       # integers
  2496.       # Example: To set the battler order bars x and y positions as the value of
  2497.       #          variables with id x and y respectively, set this as
  2498.       #          %Q([$game_variables[x], $game_variables[y]])
  2499.       :ecatb_order_bar_xy => %Q([0, 12]),
  2500.  
  2501.       # Sets the battler order atb bar text
  2502.       # Its corresponding method's created under ECATB_Order_Window
  2503.       # It must return a string
  2504.       # Example: To set the battler order atb bar text as "Norm", set this as
  2505.       #          %Q("Norm")
  2506.       :ecatb_order_bar_text => %Q("ATB"),
  2507.  
  2508.       # Sets the battler order atb charge bar text
  2509.       # Its corresponding method's created under ECATB_Order_Window
  2510.       # It must return a string
  2511.       # Example: To set the battler order atb charge bar text as "Charging", set
  2512.       #          this as %Q("Charging")
  2513.       :ecatb_order_charge_bar_text => %Q("Charge"),
  2514.  
  2515.       # Sets the battler order atb cooldown bar text
  2516.       # Its corresponding method's created under ECATB_Order_Window
  2517.       # It must return a string
  2518.       # Example: To set the battler order atb cooldown bar text as "Cooldown",
  2519.       #          set this as %Q("Cooldown")
  2520.       :ecatb_order_cooldown_bar_text => %Q("Cool"),
  2521.  
  2522.       # Sets the battler order bars text color
  2523.       # Its corresponding method's created under ECATB_Order_Window
  2524.       # It must return a color
  2525.       # Example: To set the battler order bars text color's rgba values as
  2526.       #          r, g, b and a, set this as %Q(Color.new(r, g, b, a))
  2527.       :ecatb_order_text_color => %Q(Colour.text_colour(0)),
  2528.  
  2529.       # Sets the battler order bars text size
  2530.       # Its corresponding method's created under ECATB_Order_Window
  2531.       # It must return a positive real number and should return a natural number
  2532.       # Example: To set the battler order bars text size as the value of
  2533.       #          variable with id x, set this as %Q($game_variables[x])
  2534.       :ecatb_order_text_size => %Q(12),
  2535.  
  2536.       # Sets the battler order bars text x and y positions
  2537.       # Its corresponding method's created under ECATB_Order_Window
  2538.       # It must return an array of real numbers and should return an array of
  2539.       # integers
  2540.       # Example: To set the battler order bars text x and y positions as the
  2541.       #          value of variables with id a and b respectively, set this as
  2542.       #          %Q([$game_variables[a], $game_variables[b]])
  2543.       :ecatb_order_text_xy => %Q([2, 14]),
  2544.  
  2545.       # Sets the icon representing the battlers in the battler order window
  2546.       # It'll be used only if no corresponding order battler icon notetags are
  2547.       # used
  2548.       # Its corresponding method's created under Game_Actor and Game_Enemy
  2549.       # It must return an array with its 1st and 2nd element being a bitmap and
  2550.       # a rect respectively
  2551.       # Example: To use the icon with index x in the iconset, set this as
  2552.       #          %Q(
  2553.       #    [Cache.system("Iconset"), Rect.new(x % 16 * 24, x / 16 * 24, 24, 24)]
  2554.       #    ),
  2555.       :ecatb_order_battler_icon => %Q(
  2556.        [Cache.system("Iconset"), Rect.new(121 % 16 * 24, 121 / 16 * 24, 24, 24)]
  2557.       ),
  2558.  
  2559.       # Sets the priority of the ecatb order battler icon notetags to be used
  2560.       # Its corresponding method's created under Game_Actor and Game_Enemy
  2561.       # It must return an array with elements being either :states, :enemies,
  2562.       # :armors, :weapons, :classes or :actors
  2563.       # Example: To set states to have a higher priority than that of actors,
  2564.       #          set this as %Q([:states, :actors])
  2565.       :ecatb_order_battler_icon_ord => %Q([:states, :enemies, :armors,
  2566.                                            :weapons, :classes, :actors]),
  2567.  
  2568.       # Sets the opacity of icons representing the battlers in the battler order
  2569.       # window
  2570.       # It'll be used only if no corresponding order battler icon notetags are
  2571.       # used
  2572.       # Its corresponding method's created under Game_Actor and Game_Enemy
  2573.       # It must return a non-negative real number and should return an integer
  2574.       # between 0 and 255
  2575.       # Example: To set the opacity of icons representing the actors as the
  2576.       #          value of variable with id x, set this as %Q($game_variables[x])
  2577.       :ecatb_order_battler_opacity => %Q(255),
  2578.  
  2579.       # Sets the priority of the ecatb order battler opacity notetags to be used
  2580.       # Its corresponding method's created under Game_Actor and Game_Enemy
  2581.       # It must return an array with elements being either :states, :enemies,
  2582.       # :armors, :weapons, :classes or :actors
  2583.       # Example: To set states to have a higher priority than that of actors,
  2584.       #          set this as %Q([:states, :actors])
  2585.       :ecatb_order_battler_opacity_ord => %Q([:states, :enemies, :armors,
  2586.                                               :weapons, :classes, :actors]),
  2587.  
  2588.       # Sets the scale of icons representing the battlers in the battler order
  2589.       # window
  2590.       # It'll be used only if no corresponding order battler icon notetags are
  2591.       # used
  2592.       # Its corresponding method's created under Game_Actor and Game_Enemy
  2593.       # It must return a positive real number
  2594.       # Example: To set the scale of icons representing the actors as the
  2595.       #          value of variable with id x, set this as %Q($game_variables[x])
  2596.       :ecatb_order_battler_scale => %Q(0.5),
  2597.  
  2598.       # Sets the priority of the ecatb order battler scale notetags to be used
  2599.       # Its corresponding method's created under Game_Actor and Game_Enemy
  2600.       # It must return an array with elements being either :states, :enemies,
  2601.       # :armors, :weapons, :classes or :actors
  2602.       # Example: To set states to have a higher priority than that of actors,
  2603.       #          set this as %Q([:states, :actors])
  2604.       :ecatb_order_battler_scale_ord => %Q([:states, :enemies, :armors,
  2605.                                             :weapons, :classes, :actors]),
  2606.  
  2607.       # Sets the z position of icons representing the battlers in the battler
  2608.       # order window
  2609.       # It'll be used only if no corresponding order battler icon notetags are
  2610.       # used
  2611.       # Its corresponding method's created under Game_Actor and Game_Enemy
  2612.       # It must return a non-negative real number and should return a
  2613.       # non-negatve integer
  2614.       # Example: To set the z position of icons representing the actors as the
  2615.       #          value of variable with id x, set this as %Q($game_variables[x])
  2616.       :ecatb_order_battler_z => %Q(500),
  2617.  
  2618.       # Sets the priority of the ecatb order battler z notetags to be used
  2619.       # Its corresponding method's created under Game_Actor and Game_Enemy
  2620.       # It must return an array with elements being either :states, :enemies,
  2621.       # :armors, :weapons, :classes or :actors
  2622.       # Example: To set states to have a higher priority than that of actors,
  2623.       #          set this as %Q([:states, :actors])
  2624.       :ecatb_order_battler_z_ord => %Q([:states, :enemies, :armors, :weapons,
  2625.                                         :classes, :actors]),
  2626.  
  2627.       # Sets the x position of icons representing the battlers in the battler
  2628.       # order window
  2629.       # It must return a real number and should return an integer
  2630.       # Its corresponding method's created under Game_Actor and Game_Enemy
  2631.       # Example: To set the x position of icons representing the battlers as the
  2632.       #          value of variable with id x, set this as %Q($game_variables[x])
  2633.       :ecatb_order_battler_icon_x => %Q(4),
  2634.  
  2635.       # Sets the y position of icons representing the actors in the battler
  2636.       # order window
  2637.       # It must return a real number and should return an integer
  2638.       # Its corresponding method's created under Game_Actor and Game_Enemy
  2639.       # Example: To set the y position of icons representing the actors as the
  2640.       #          value of variable with id x, set this as %Q($game_variables[x])
  2641.       :ecatb_order_actor_icon_y => %Q(36),
  2642.  
  2643.       # Sets the y position of icons representing the enemies in the battler
  2644.       # order window
  2645.       # It must return a real number and should return an integer
  2646.       # Its corresponding method's created under Game_Actor and Game_Enemy
  2647.       # Example: To set the y position of icons representing the enemies as the
  2648.       #          value of variable with id x, set this as %Q($game_variables[x])
  2649.       :ecatb_order_enemy_icon_y => %Q(8)
  2650.  
  2651.     }
  2652.  
  2653.   #----------------------------------------------------------------------------|
  2654.   #  * Pool                                                                    |
  2655.   #    Setups configurations of the pool features                              |
  2656.   #----------------------------------------------------------------------------|
  2657.  
  2658.     #--------------------------------------------------------------------------|
  2659.     #  Pool Configurations                                                     |
  2660.     #  - Setups configurations of the pool features                            |
  2661.     #  - The value of each configuration is the string of the content of its   |
  2662.     #    corresponding method                                                  |
  2663.     #--------------------------------------------------------------------------|
  2664.  
  2665.     POOL = {
  2666.  
  2667.       # Evaluates the party/troop pool atb value from all actors/enemies' ones
  2668.       # The actors/enemies' atb values can be referenced by vals
  2669.       # Its corresponding method's created under Game_Party and Game_Troop
  2670.       # It must return a non-negative real number and should return a
  2671.       # non-negative integer
  2672.       # Example: To use the minimum atb value of all actors/enemies, set this as
  2673.       #          %Q(vals.empty? ? 0 : vals.min)
  2674.       :ecatb_pool_val => %Q(vals.empty? ? 0 : vals.inject(:+) / vals.size),
  2675.  
  2676.       # Shows the atb pool window displaying the atb mode
  2677.       # It's used under Scene_Battle but it doesn't have any associated method
  2678.       # Example: To show the atb pool window if switch with id x is on, set
  2679.       #          this as %Q($game_switches[x])
  2680.       :show_ecatb_pool_window => %Q(true),
  2681.  
  2682.       # Sets the atb pool window width and height
  2683.       # Its corresponding method's created under ECATB_Pool_Window
  2684.       # It must return an array of positive real numbers and should return an
  2685.       # array of natural numbers
  2686.       # Example: To set the atb pool window width and height as the value of
  2687.       #          variables with id x and y respectively, set this as
  2688.       # %Q([$game_variables[x], $game_variables[y]])
  2689.       :ecatb_pool_window_wh => %Q([128, 56]),
  2690.  
  2691.       # Sets the atb pool widnow x, y and z positions
  2692.       # Its corresponding method's created under ECATB_Pool_Window
  2693.       # It must return an array of real numbers and should return an array of
  2694.       # integers
  2695.       # Example: To set the atb pool window x, y and z positions as the value
  2696.       #          of variables with id a, b and c respectively, set this as
  2697.       # %Q([$game_variables[a], $game_variables[b], $game_variables[c]])
  2698.       :ecatb_pool_window_xyz => %Q([0, 148, 0]),
  2699.  
  2700.       # Sets the party atb pool window text to be displayed
  2701.       # Its corresponding method's created under ECATB_Pool_Window
  2702.       # It must return an array of strings
  2703.       # The 1st and 2nd element of the array is displayed when the atb pool
  2704.       # mode's on and off respectively
  2705.       # Example: To set the party atb pool window text to be displayed when the
  2706.       #          atb pool mode's on and off as "Party ATB Pool Mode On" and
  2707.       #          "Party ATB Pool Mode Off" respectively, set this as
  2708.       #          %Q(["Party ATB Pool Mode On", "Party ATB Pool Mode Off"])
  2709.       :ecatb_pool_party_actor_text => %Q(["Party ATB", "Actor ATB"]),
  2710.  
  2711.       # Sets the troop atb pool window text to be displayed
  2712.       # Its corresponding method's created under ECATB_Pool_Window
  2713.       # It must return an array of strings
  2714.       # The 1st and 2nd element of the array is displayed when the atb pool
  2715.       # mode's on and off respectively
  2716.       # Example: To set the troop atb pool window text to be displayed when the
  2717.       #          atb pool mode's on and off as "Troop ATB Pool Mode On" and
  2718.       #          "Troop ATB Pool Mode Off" respectively, set this as
  2719.       #          %Q(["Troop ATB Pool Mode On", "Troop ATB Pool Mode Off"])
  2720.       :ecatb_pool_troop_enemy_text => %Q(["Troop ATB", "Enemy ATB"]),
  2721.  
  2722.       # Sets the atb pool window text color
  2723.       # Its corresponding method's created under ECATB_Pool_Window
  2724.       # It must return a color
  2725.       # Example: To set the atb pool window text color's rgba values as r, g, b
  2726.       #          and a, set this as %Q(Color.new(r, g, b, a))
  2727.       :ecatb_pool_text_color => %Q(Colour.text_colour(0)),
  2728.  
  2729.       # Sets the atb pool window text size
  2730.       # Its corresponding method's created under ECATB_Pool_Window
  2731.       # It must return a positive real number and should return a natural number
  2732.       # Example: To set the atb pool window text size as the value of variable
  2733.       #          with id x, set this as %Q($game_variables[x])
  2734.       :ecatb_pool_text_size => %Q(16),
  2735.  
  2736.       # Sets the atb party pool window text x and y positions
  2737.       # Its corresponding method's created under ECATB_Pool_Window
  2738.       # It must return an array of real numbers and should return an array of
  2739.       # integers
  2740.       # Example: To set the atb party pool window text x and y positions as the
  2741.       #          value of variables with id a and b respectively, set this as
  2742.       #          %Q([$game_variables[a], $game_variables[b]])
  2743.       :ecatb_pool_party_text_xy => %Q([0, 8]),
  2744.  
  2745.       # Sets the atb troop pool window text x and y positions
  2746.       # Its corresponding method's created under ECATB_Pool_Window
  2747.       # It must return an array of real numbers and should return an array of
  2748.       # integers
  2749.       # Example: To set the atb troop pool window text x and y positions as the
  2750.       #          value of variables with id a and b respectively, set this as
  2751.       #          %Q([$game_variables[a], $game_variables[b]])
  2752.       :ecatb_pool_troop_text_xy => %Q([0, -8])
  2753.  
  2754.     }
  2755.  
  2756.   #----------------------------------------------------------------------------|
  2757.   #  * SE                                                                      |
  2758.   #    Setups configurations of the se features                                |
  2759.   #----------------------------------------------------------------------------|
  2760.  
  2761.     #--------------------------------------------------------------------------|
  2762.     #  SE Ready Act Notetag Values                                             |
  2763.     #  - Setups serax used by <ecatb se ready act: serax> notetags             |
  2764.     #--------------------------------------------------------------------------|
  2765.     # serax are read at:
  2766.     # 1. RPG::Actor, RPG::Class, RPG::EquipItem, RPG::Enemy, RPG::State
  2767.     #    - next @ecatb_notes[:se] = $1.downcase.to_sym in load_ecatb_notes
  2768.     # serax are used at:
  2769.     # 1. Game_BattlerBase
  2770.     #    - @ecatb_notes[note] = ecatb.send(n, self) in set_ecatb_notes
  2771.     # serax are strings of names of methods under DoubleX_RMVXA::ECATB
  2772.     # serax names can only use alphanumeric characters and can't use uppercase
  2773.     # letters
  2774.     # battler is the battler calling the serax
  2775.     # The below serax are examples added to help you set your serax
  2776.     # You can freely use, rewrite and/or delete these examples
  2777.  
  2778.     # Sets the battler ready se as se with name "name", volume volume and pitch
  2779.     # pitch
  2780.     def self.sera1(battler)
  2781.       RPG::SE.new("file", volume, pitch)
  2782.     end
  2783.  
  2784.     # Disables the use of the battler ready se
  2785.     def self.sera2(battler)
  2786.       nil
  2787.     end
  2788.  
  2789.     # Adds new serax here
  2790.    
  2791.  
  2792.     #--------------------------------------------------------------------------|
  2793.     #  SE Configurations                                                       |
  2794.     #  - Setups configurations of the se features                              |
  2795.     #  - The value of each configuration is the string of the content of its   |
  2796.     #    corresponding method                                                  |
  2797.     #--------------------------------------------------------------------------|
  2798.  
  2799.     SE = {
  2800.  
  2801.       # Sets the se to be played when a battler becomes able to act
  2802.       # It'll be used only if no corresponding color notetags are used
  2803.       # Its corresponding method's created under Game_Actor and Game_Enemy
  2804.       # Example: To set the se to be played when a battler becomes able to act
  2805.       #          as se with name "name", volume volume and pitch pitch, set this
  2806.       #          as %Q(RPG::SE.new("name", volume, pitch))
  2807.       :ecatb_se_ready_act => %Q(nil),
  2808.  
  2809.       # Sets the priority of the ecatb se ready act notetags to be used
  2810.       # Its corresponding method's created under Game_Actor and Game_Enemy
  2811.       # It must return an array with elements being either :states, :enemies,
  2812.       # :armors, :weapons, :classes or :actors
  2813.       # Example: To set states to have a higher priority than that of actors,
  2814.       #          set this as %Q([:states, :actors])
  2815.       :ecatb_se_ready_act_ord => %Q([:states, :enemies, :armors, :weapons,
  2816.                                      :classes, :actors])
  2817.  
  2818.     }
  2819.  
  2820.   #----------------------------------------------------------------------------|
  2821.   #  * (v0.02a+)Speed                                                          |
  2822.   #    Setups configurations and notetag values of the speed features          |
  2823.   #----------------------------------------------------------------------------|
  2824.  
  2825.     #--------------------------------------------------------------------------|
  2826.     #  Speed Reduce Notetag Values                                             |
  2827.     #  - Setups srx used by <ecatb speed reduce: srx> notetags                 |
  2828.     #--------------------------------------------------------------------------|
  2829.     # srx are read at:
  2830.     # 1. RPG::Actor, RPG::Class, RPG::EquipItem, RPG::Enemy, RPG::State
  2831.     #    - next @ecatb_notes[:speed] << $1.downcase.to_sym in load_ecatb_notes
  2832.     # srx are used at:
  2833.     # 1. Game_BattlerBase
  2834.     #    - ecatb.send(note, self) in set_ecatb_speed_reduce
  2835.     # srx are strings of names of methods under DoubleX_RMVXA::ECATB
  2836.     # srx must return a non-negative integer
  2837.     # srx names can only use alphanumeric characters and can't use uppercase
  2838.     # letters
  2839.     # battler is the battler calling the srx
  2840.     # The below srx are examples to help you set your srx
  2841.     # You can freely use, rewrite and/or delete these examples
  2842.  
  2843.     # Sets the action input speed reduction as x frames
  2844.     def self.sr1(battler)
  2845.       battler.instance_exec { @last_ecatb_speed_reduce = x }
  2846.     end
  2847.  
  2848.     # Sets the action input speed reduction as the number of frames being the
  2849.     # value of variable with id x
  2850.     def self.sr2(battler)
  2851.       battler.instance_exec { @last_ecatb_speed_reduce = $game_variables[x] }
  2852.     end
  2853.  
  2854.     # Adds the action input speed reduction by x frames
  2855.     def self.sr3(battler)
  2856.       battler.instance_exec { @last_ecatb_speed_reduce += x }
  2857.     end
  2858.  
  2859.     # Adds new srx here
  2860.    
  2861.  
  2862.     #--------------------------------------------------------------------------|
  2863.     #  Speed Configurations                                                    |
  2864.     #  - Setups configurations of the speed features                           |
  2865.     #  - The value of each configuration is the string of the content of its   |
  2866.     #    corresponding method                                                  |
  2867.     #--------------------------------------------------------------------------|
  2868.  
  2869.     SPEED = {
  2870.  
  2871.       # Sets the action input speed reduction for enemies and/or actors with
  2872.       # autobattle and/or confusion
  2873.       # Its corresponding method's created under Game_Actor and Game_Enemy
  2874.       # It must return a non-negative integer
  2875.       # Example: To set the action input speed reduction for enemies and/or
  2876.       #          actors with autobattle and/or confusion as the value of
  2877.       #          variable with id x, set this as
  2878.       #          %Q(@last_ecatb_speed_reduce = $game_variables[x])
  2879.       :ecatb_speed_reduce => %Q(@last_ecatb_speed_reduce = 0),
  2880.  
  2881.       # Sets the priority of the ecatb speed reduce notetags to be used
  2882.       # Its corresponding method's created under Game_Actor and Game_Enemy
  2883.       # It must return an array with elements being either :states, :enemies,
  2884.       # :armors, :weapons, :classes or :actors
  2885.       # Example: To set actors to have a higher priority than that of states,
  2886.       #          set this as %Q([:actors, :states])
  2887.       :ecatb_speed_reduce_ord => %Q([:actors, :classes, :weapons, :armors,
  2888.                                      :enemies, :states])
  2889.  
  2890.     }
  2891.  
  2892.   #----------------------------------------------------------------------------|
  2893.   #  * Unison                                                                  |
  2894.   #    Setups configurations of the unison features                            |
  2895.   #----------------------------------------------------------------------------|
  2896.  
  2897.     #--------------------------------------------------------------------------|
  2898.     #  Unison Actor Notetag Values                                             |
  2899.     #  - Setups uax used by <ecatb unison actor: uax> notetags                 |
  2900.     #--------------------------------------------------------------------------|
  2901.     # uax are read at:
  2902.     # 1. RPG::UsableItem
  2903.     #    - send(:"#{note}=", send(:"#{note}") || val) in load_ecatb_notes
  2904.     # uax are used at:
  2905.     # 1. Game_BattlerBase
  2906.     #    - actors = ecatb.send(item.ecatb_unison_actor, self).collect!(
  2907.     #      &ecatb::BLOCKS[:usable?]) in usable?
  2908.     # 2. Game_Actor
  2909.     #    - @ecatb_unison_actors = ecatb.send(
  2910.     #      @last_ecatb_item.ecatb_unison_actor, self) in confirm_ecatb_item
  2911.     # 3. Window_ItemList
  2912.     #    - return battler.usable?(item) if (ecatb = DoubleX_RMVXA::ECATB).send(
  2913.     #      item.ecatb_act_cost, battler) > 1 || ecatb.send(
  2914.     #      item.ecatb_unison_actor, battler).size > 1 in enable?
  2915.     # 4. Scene_Battle
  2916.     #    - actors = ecatb.send($data_skills[actor.attack_skill_id].
  2917.     #      ecatb_unison_actor, actor).collect!(&ecatb::BLOCKS[:usable?]) in
  2918.     #      command_attack
  2919.     #    - actors = ecatb.send($data_skills[actor.guard_skill_id].
  2920.     #      ecatb_unison_actor, actor).collect!(&ecatb::BLOCKS[:usable?]) in
  2921.     #      command_guard
  2922.     #    - actors = ecatb.send(window.item.ecatb_unison_actor,
  2923.     #      BattleManager.actor) in on_ecatb_unison_item_ok?
  2924.     #    - actors = ecatb.send(actor.input.item.ecatb_unison_actor, actor) in
  2925.     #      on_ecatb_unison?
  2926.     # uax are strings of names of methods under DoubleX_RMVXA::ECATB
  2927.     # uax shouldn't return random values
  2928.     # uax must return an array of actor ids and the array must have more
  2929.     # than 1 actor ids
  2930.     # uax names can only use alphanumeric characters and can't use uppercase
  2931.     # letters
  2932.     # battler is the battler calling the uax
  2933.     # The below uax are examples added to help you set your uax
  2934.     # You can freely use, rewrite and/or delete these examples
  2935.  
  2936.     # Sets the unison actors as those with id x, y and z respectively
  2937.     def self.ua1(battler)
  2938.       [x, y, z]
  2939.     end
  2940.  
  2941.     # Adds new uax here
  2942.    
  2943.  
  2944.     # Don't edit this unless you understand what it does and how it works
  2945.     def self.ecatb_unison_actor(battler)
  2946.       []
  2947.     end
  2948.  
  2949.     #--------------------------------------------------------------------------|
  2950.     #  Unison Charge Rule Notetag Values                                       |
  2951.     #  - Setups ucrx used by <ecatb unison charge rule: ucrx> notetags         |
  2952.     #--------------------------------------------------------------------------|
  2953.     # ucrx are read at:
  2954.     # 1. RPG::UsableItem
  2955.     #    - send(:"#{note}=", send(:"#{note}") || val) in load_ecatb_notes
  2956.     # ucrx are used at:
  2957.     # 1. Game_Actor
  2958.     #    - @ecatb_unison_rule[:charge] = ecatb.send(
  2959.     #      @last_ecatb_item.ecatb_unison_charge_rule, self) in
  2960.     #      confirm_ecatb_item
  2961.     # ucrx are strings of names of methods under DoubleX_RMVXA::ECATB
  2962.     # ucrx must return a symbol
  2963.     # You must implement the rule in ecatb_unison_rules
  2964.     # ucrx names can only use alphanumeric characters and can't use uppercase
  2965.     # letters
  2966.     # battler is the battler calling the ucrx
  2967.     # The below ucrx are examples added to help you set your ucrx
  2968.     # You can freely use, rewrite and/or delete these examples
  2969.  
  2970.     # Sets the unison charge rule as returning the maximum
  2971.     def self.ucr1(battler)
  2972.       :max
  2973.     end
  2974.  
  2975.     # Adds new ucrx here
  2976.    
  2977.  
  2978.     # Sets the default unison charge rule
  2979.     # It'll be used for def only if it's no ucrx to use
  2980.     # battler is the battler calling ecatb_unison_charge_rule
  2981.     # Example: To set the default unison charge rule as returning the minimum,
  2982.     # set this as %Q(:min)
  2983.     def self.ecatb_unison_charge_rule(battler)
  2984.       :avg
  2985.     end
  2986.  
  2987.     #--------------------------------------------------------------------------|
  2988.     #  Unison Cooldown Rule Notetag Values                                     |
  2989.     #  - Setups ucdrx used by <ecatb unison cooldown rule: ucdrx> notetags     |
  2990.     #--------------------------------------------------------------------------|
  2991.     # ucdrx are read at:
  2992.     # 1. RPG::UsableItem
  2993.     #    - send(:"#{note}=", send(:"#{note}") || val) in load_ecatb_notes
  2994.     # ucdrx are used at:
  2995.     # 1. Game_Actor
  2996.     #    - @ecatb_unison_rule[:cooldown] = ecatb.send(
  2997.     #      @last_ecatb_item.ecatb_unison_cooldown_rule, self) in
  2998.     #      confirm_ecatb_item
  2999.     # ucdrx are strings of names of methods under DoubleX_RMVXA::ECATB
  3000.     # ucdrx must return a symbol
  3001.     # You must implement the rule in ecatb_unison_rules
  3002.     # ucdrx names can only use alphanumeric characters and can't use uppercase
  3003.     # letters
  3004.     # battler is the battler calling the ucdrx
  3005.     # The below UCDRX are examples added to help you set your ucdrx
  3006.     # You can freely use, rewrite and/or delete these examples
  3007.  
  3008.     # Sets the unison cooldown rule as returning the maximum
  3009.     def self.ucdr1(battler)
  3010.       :max
  3011.     end
  3012.  
  3013.     # Adds new ucdrx here
  3014.    
  3015.  
  3016.     # Sets the default unison charge rule
  3017.     # It'll be used for def only if it's no ucdrx to use
  3018.     # battler is the battler calling ecatb_unison_cooldown_rule
  3019.     # Example: To set the default unison cooldown rule as returning the minimum,
  3020.     # set this as %Q(:min)
  3021.     def self.ecatb_unison_cooldown_rule(battler)
  3022.       :avg
  3023.     end
  3024.  
  3025.     #--------------------------------------------------------------------------|
  3026.     #  Unison Actor Method Notetag Values                                      |
  3027.     #  - Setups uadx used by <ecatb unison actor def: uadx> notetags           |
  3028.     #--------------------------------------------------------------------------|
  3029.     # uadx are read at:
  3030.     # 1. RPG::UsableItem
  3031.     #    - send(:"#{note}=", send(:"#{note}") || val) in load_ecatb_notes
  3032.     # uadx are used at methods included in UNISON_DEFS
  3033.     # uadx are strings of names of methods under DoubleX_RMVXA::ECATB
  3034.     # uadx must return an array of actor ids
  3035.     # uadx names can only use alphanumeric characters and can't use uppercase
  3036.     # letters
  3037.     # battler is the battler calling the uadx
  3038.     # The below uadx are examples added to help you set your uadx
  3039.     # You can freely use, rewrite and/or delete these examples
  3040.  
  3041.     # Sets the def used to be those of actors with id x, y and z respectively
  3042.     def self.uad1(battler)
  3043.       [x, y, z]
  3044.     end
  3045.  
  3046.     # Adds new uadx here
  3047.    
  3048.  
  3049.     # Don't edit this unless you understand what it does and how it works
  3050.     def self.ecatb_unison_actor_def(battler)
  3051.       []
  3052.     end
  3053.  
  3054.     #--------------------------------------------------------------------------|
  3055.     #  Unison Method Rule Notetag Values                                       |
  3056.     #  - Setups udrx used by <ecatb unison def rule: udrx> notetags            |
  3057.     #--------------------------------------------------------------------------|
  3058.     # udrx are read at:
  3059.     # 1. RPG::UsableItem
  3060.     #    - send(:"#{note}=", send(:"#{note}") || val) in load_ecatb_notes
  3061.     # udrx are used at methods included in UNISON_DEFS
  3062.     # udrx are strings of names of methods under DoubleX_RMVXA::ECATB
  3063.     # udrx must return a symbol
  3064.     # You must implement the rule in ecatb_unison_rules
  3065.     # udrx names can only use alphanumeric characters and can't use uppercase
  3066.     # letters
  3067.     # battler is the battler calling the udrx
  3068.     # The below udrx are examples added to help you set your udrx
  3069.     # You can freely use, rewrite and/or delete these examples
  3070.  
  3071.     # Sets the unison method rule as returning the maximum
  3072.     UDR1 = %Q(:max)
  3073.     def self.udr1(battler)
  3074.       :max
  3075.     end
  3076.  
  3077.     # Adds new udrx here
  3078.    
  3079.  
  3080.     # Sets the default unison method rule
  3081.     # It'll be used for def only if it's no udrx to use
  3082.     # battler is the battler calling ecatb_unison_def_rule
  3083.     # Example: To set the default unison mthod rule as returning the minimum,
  3084.     # set this as %Q(:min)
  3085.     def self.ecatb_unison_def_rule(battler)
  3086.       :avg
  3087.     end
  3088.  
  3089.     #--------------------------------------------------------------------------|
  3090.     #  Unison Configurations                                                   |
  3091.     #  - Setups configurations of the unison features                          |
  3092.     #  - The value of each configuration is the string of the content of its   |
  3093.     #    corresponding method                                                  |
  3094.     #--------------------------------------------------------------------------|
  3095.  
  3096.     # Sets the battler methods to use the unison method rules
  3097.     # It can't be chnaged once set
  3098.     # Its keys must be the battler method name symbols
  3099.     # Methods with name method_name will be aliased to method_name_ecatb
  3100.     UNISON_DEFS = {
  3101.  
  3102.       # General Form:
  3103.       # [:method_class, :super_class] => [
  3104.       #   :method_name
  3105.       # ]
  3106.  
  3107.       [:Game_BattlerBase] => [
  3108.         :hp,
  3109.         :mp,
  3110.         :tp,
  3111.         :mhp,
  3112.         :mmp,
  3113.         :atk,
  3114.         :def,
  3115.         :mat,
  3116.         :mdf,
  3117.         :agi
  3118.         # Adds new methods here
  3119.        
  3120.       ],
  3121.  
  3122.       [:Game_Actor, :Game_Battler] => [
  3123.         :level
  3124.         # Adds new methods here
  3125.        
  3126.       ]
  3127.  
  3128.       # Adds new classes here
  3129.      
  3130.  
  3131.     }
  3132.  
  3133.     UNISON = {
  3134.  
  3135.       # Sets if all battlers using the unison skill/item are shown in the
  3136.       # battle log window
  3137.       # Its corresponding method's created under Game_Actor and Game_Enemy
  3138.       # Example: To show all battlers using the unison skill/item if switch with
  3139.       #          id x is on, set this as %Q($game_switches[x])
  3140.       :show_ecatb_unison_battlers => %Q(true),
  3141.  
  3142.       # Implements the unison method rules
  3143.       # The unison method of all unison battlers can be referneced by vals
  3144.       # The unison method rule can be referenced by rule
  3145.       # Its corresponding method's created under Game_Actor and Game_Enemy
  3146.       # It must return a real number
  3147.       :ecatb_unison_rules => %Q(
  3148.         if rule == :min
  3149.           vals.min
  3150.         elsif rule == :avg
  3151.           vals.inject(:+) / vals.size
  3152.         elsif rule == :max
  3153.           vals.max
  3154.         else
  3155.           0
  3156.         end
  3157.       )
  3158.  
  3159.     }
  3160.  
  3161. #==============================================================================|
  3162.  
  3163. #==============================================================================|
  3164. #  ** Script Implementations                                                   |
  3165. #     You need not edit this part as it's about how this script works          |
  3166. #     You need to understand the related parts of a configuration/notetag value|
  3167. #     locally to fully utilize that configuration/notetag value                |
  3168. #------------------------------------------------------------------------------|
  3169. #  * Script Support Info:                                                      |
  3170. #    1. Prerequisites                                                          |
  3171. #       - Thorough comprehension of how this script works on the user level    |
  3172. #       - Thorough comprehension of how Yanfly Engine Ace - Ace Battle Engine  |
  3173. #         works                                                                |
  3174. #       - Advanced RGSS3 scripting proficiency to fully comprehend this script |
  3175. #    2. Method documentation                                                   |
  3176. #       - The 1st part describes why this method's rewritten/aliased for       |
  3177. #         rewritten/aliased methods or what the method does for new methods    |
  3178. #       - The 2nd part describes what the arguments of the method are          |
  3179. #       - The 3rd part informs which version rewritten, aliased or created this|
  3180. #         method                                                               |
  3181. #       - The 4th part informs whether the method's rewritten or new           |
  3182. #       - The 5th part informs whether the method's a real or potential hotspot|
  3183. #       - The 6th part describes how this method works for new methods only,   |
  3184. #         and describes the parts added, removed or rewritten for rewritten or |
  3185. #         aliased methods only                                                 |
  3186. #       Example:                                                               |
  3187. # #--------------------------------------------------------------------------| |
  3188. # #  Why rewrite/alias/What this method does                                 | |
  3189. # #--------------------------------------------------------------------------| |
  3190. # # *argv: What these variables are                                            |
  3191. # # &argb: What this block is                                                  |
  3192. # def def_name(*argv, &argb) # Version X+; Rewrite/New; Hotspot                |
  3193. #   # Added/Removed/Rewritten to do something/How this method works            |
  3194. #   def_name_code                                                              |
  3195. #   #                                                                          |
  3196. # end # def_name                                                               |
  3197. #------------------------------------------------------------------------------|
  3198.  
  3199.     # Stores all types of configurations
  3200.     CONFIG = [CORE, ACTION, BAR, CANCEL, CHARGE, CLOCK, COOLDOWN, COUNTDOWN,
  3201.               FORCE, HOTKEY, ORDER, POOL, SE, SPEED, UNISON]
  3202.  
  3203.     # Stores all configurations having methods in BattleManager
  3204.     # General form: :config => [
  3205.     #                 %Q(arguments),
  3206.     #                 %Q(validation check),
  3207.     #                 %Q(default value)
  3208.     #               ]
  3209.     BATTLEMANAGER = {
  3210.       :ecatb_esc_init_cond => [
  3211.         %Q(),
  3212.         %Q(true),
  3213.         %Q((list = ecatb_input_list).size >= $game_party.battle_members.size &&
  3214.            list.all?(&DoubleX_RMVXA::ECATB::EIC1))
  3215.       ],
  3216.       :ecatb_esc_charge_cond => [
  3217.         %Q(),
  3218.         %Q(true),
  3219.         %Q($game_party.battle_members.all?(&DoubleX_RMVXA::ECATB::ECC1))
  3220.       ],
  3221.       :ecatb_esc_exec_cond => [
  3222.         %Q(),
  3223.         %Q(true),
  3224.         %Q($game_party.alive_members.all?(&DoubleX_RMVXA::ECATB::EEC1))
  3225.       ],
  3226.       :ecatb_esc_suc_cond => [
  3227.         %Q(),
  3228.         %Q(true),
  3229.         %Q((@preemptive || rand < @escape_ratio) &&
  3230.            $game_party.alive_members.all?(&DoubleX_RMVXA::ECATB::EIC1))
  3231.       ],
  3232.       :ecatb_base_fill_t => [
  3233.         %Q(),
  3234.         %Q(val.is_a?(Numeric) && val >= 0),
  3235.         %Q(10)
  3236.       ],
  3237.       :ecatb_ctb => [
  3238.         %Q(),
  3239.         %Q(true),
  3240.         %Q(false),
  3241.       ],
  3242.       :ecatb_battlers_def_sum => [
  3243.         %Q(),
  3244.         %Q(val.is_a?(Array) &&
  3245.            val.all?(&DoubleX_RMVXA::ECATB::BLOCKS[:check_sym])),
  3246.         %Q([:agi])
  3247.       ],
  3248.       :ecatb_def_sum_battlers => [
  3249.         %Q(),
  3250.         %Q(val.is_a?(Array) &&
  3251.            val.all?(&DoubleX_RMVXA::ECATB::BLOCKS[:check_game_battler])),
  3252.         %Q($game_party.alive_members + $game_troop.alive_members)
  3253.       ],
  3254.       :update_ecatb_battlers_def_sums => [
  3255.         %Q(),
  3256.         %Q(true),
  3257.         %Q(ecatb_def_sum_battlers.any?(
  3258.            &DoubleX_RMVXA::ECATB::BLOCKS[:ecatb_refresh]))
  3259.       ],
  3260.       :actor_sprite_ecatb_bar => [
  3261.         %Q(),
  3262.         %Q(true),
  3263.         %Q(false)
  3264.       ],
  3265.     }
  3266.  
  3267.     # Stores all configurations having methods in Game_Battler
  3268.     # General form: :config => [
  3269.     #                 %Q(arguments),
  3270.     #                 %Q(validation check),
  3271.     #                 %Q(default value)
  3272.     #               ]
  3273.     GAME_BATTLER = {
  3274.       :ecatb_rate_ord => [
  3275.         %Q(),
  3276.         %Q(val.is_a?(Array) &&
  3277.            val.all?(&DoubleX_RMVXA::ECATB::BLOCKS[:check_ord])),
  3278.         %Q([:actors, :classes, :weapons, :armors, :enemies, :states])
  3279.       ],
  3280.       :normal_actor_1st_ecatb_val => [
  3281.         %Q(),
  3282.         %Q(val.is_a?(Numeric) && val >= 0),
  3283.         %Q(0.0)
  3284.       ],
  3285.       :normal_enemy_1st_ecatb_val => [
  3286.         %Q(),
  3287.         %Q(val.is_a?(Numeric) && val >= 0),
  3288.         %Q(0.0)
  3289.       ],
  3290.       :preemptive_actor_1st_ecatb_val => [
  3291.         %Q(),
  3292.         %Q(val.is_a?(Numeric) && val >= 0),
  3293.         %Q(100.0)
  3294.       ],
  3295.       :preemptive_enemy_1st_ecatb_val => [
  3296.         %Q(),
  3297.         %Q(val.is_a?(Numeric) && val >= 0),
  3298.         %Q(0.0)
  3299.       ],
  3300.       :surprise_actor_1st_ecatb_val => [
  3301.         %Q(),
  3302.         %Q(val.is_a?(Numeric) && val >= 0),
  3303.         %Q(0.0)
  3304.       ],
  3305.       :surprise_enemy_1st_ecatb_val => [
  3306.         %Q(),
  3307.         %Q(val.is_a?(Numeric) && val >= 0),
  3308.         %Q(100.0)
  3309.       ],
  3310.       :ecatb_start_val_ord => [
  3311.         %Q(),
  3312.         %Q(val.is_a?(Array) &&
  3313.            val.all?(&DoubleX_RMVXA::ECATB::BLOCKS[:check_ord])),
  3314.         %Q([:actors, :classes, :weapons, :armors, :enemies, :states])
  3315.       ],
  3316.       :pre_ecatb_input_act => [
  3317.         %Q(),
  3318.         %Q(true),
  3319.         %Q()
  3320.       ],
  3321.       :post_ecatb_input_act => [
  3322.         %Q(),
  3323.         %Q(true),
  3324.         %Q()
  3325.       ],
  3326.       :pre_ecatb_reset => [
  3327.         %Q(),
  3328.         %Q(true),
  3329.         %Q()
  3330.       ],
  3331.       :post_ecatb_reset => [
  3332.         %Q(),
  3333.         %Q(true),
  3334.         %Q()
  3335.       ],
  3336.       :ecatb_bar_colors => [
  3337.         %Q(),
  3338.         %Q(val.is_a?(Array) && val[0].is_a?(Color) && val[1].is_a?(Color)),
  3339.         %Q([Colour.text_colour(7), Colour.text_colour(8)])
  3340.       ],
  3341.       :ecatb_bar_color_ord => [
  3342.         %Q(),
  3343.         %Q(val.is_a?(Array) &&
  3344.            val.all?(&DoubleX_RMVXA::ECATB::BLOCKS[:check_ord])),
  3345.         %Q([:states, :enemies, :armors, :weapons, :classes, :actors])
  3346.       ],
  3347.       :gradual_ecatb_action_gain => [
  3348.         %Q(),
  3349.         %Q(true),
  3350.         %Q(false),
  3351.       ],
  3352.       :gradual_ecatb_action_gain_ord => [
  3353.         %Q(),
  3354.         %Q(val.is_a?(Array) &&
  3355.            val.all?(&DoubleX_RMVXA::ECATB::BLOCKS[:check_ord])),
  3356.         %Q([:states, :enemies, :armors, :weapons, :classes, :actors])
  3357.       ],
  3358.       :ecatb_bar_multilayer => [
  3359.         %Q(),
  3360.         %Q(true),
  3361.         %Q(true)
  3362.       ],
  3363.       :ecatb_charge_bar_colors => [
  3364.         %Q(),
  3365.         %Q(val.is_a?(Array) && val[0].is_a?(Color) && val[1].is_a?(Color)),
  3366.         %Q([Colour.text_colour(30), Colour.text_colour(31)])
  3367.       ],
  3368.       :ecatb_charge_bar_color_ord => [
  3369.         %Q(),
  3370.         %Q(val.is_a?(Array) &&
  3371.            val.all?(&DoubleX_RMVXA::ECATB::BLOCKS[:check_ord])),
  3372.         %Q([:states, :enemies, :armors, :weapons, :classes, :actors])
  3373.       ],
  3374.       :ecatb_cooldown_bar_colors => [
  3375.         %Q(),
  3376.         %Q(val.is_a?(Array) && val[0].is_a?(Color) && val[1].is_a?(Color)),
  3377.         %Q([Colour.text_colour(19), Colour.text_colour(26)])
  3378.       ],
  3379.       :ecatb_cooldown_bar_color_ord => [
  3380.         %Q(),
  3381.         %Q(val.is_a?(Array) &&
  3382.            val.all?(&DoubleX_RMVXA::ECATB::BLOCKS[:check_ord])),
  3383.         %Q([:states, :enemies, :armors, :weapons, :classes, :actors])
  3384.       ],
  3385.       :ecatb_cooldown_finish => [
  3386.         %Q(),
  3387.         %Q(true),
  3388.         %Q()
  3389.       ],
  3390.       :ecatb_countdown_min => [
  3391.         %Q(),
  3392.         %Q(val.is_a?(Integer) && val >= 0),
  3393.         %Q(Graphics.frame_rate)
  3394.       ],
  3395.       :ecatb_order_battler_icon => [
  3396.         %Q(),
  3397.         %Q(val.is_a?(Array) && val[0].is_a?(Bitmap) && val[1].is_a?(Rect)),
  3398.         %Q(
  3399.        [Cache.system("Iconset"), Rect.new(121 % 16 * 24, 121 / 16 * 24, 24, 24)]
  3400.         )
  3401.       ],
  3402.       :ecatb_order_battler_icon_ord => [
  3403.         %Q(),
  3404.         %Q(val.is_a?(Array) &&
  3405.            val.all?(&DoubleX_RMVXA::ECATB::BLOCKS[:check_ord])),
  3406.         %Q([:states, :enemies, :armors, :weapons, :classes, :actors])
  3407.       ],
  3408.       :ecatb_order_battler_opacity => [
  3409.         %Q(),
  3410.         %Q(val.is_a?(Numeric) && val >= 0),
  3411.         %Q(255)
  3412.       ],
  3413.       :ecatb_order_battler_opacity_ord => [
  3414.         %Q(),
  3415.         %Q(val.is_a?(Array) &&
  3416.            val.all?(&DoubleX_RMVXA::ECATB::BLOCKS[:check_ord])),
  3417.         %Q([:states, :enemies, :armors, :weapons, :classes, :actors])
  3418.       ],
  3419.       :ecatb_order_battler_scale => [
  3420.         %Q(),
  3421.         %Q(val.is_a?(Numeric) && val >= 0),
  3422.         %Q(0.5)
  3423.       ],
  3424.       :ecatb_order_battler_scale_ord => [
  3425.         %Q(),
  3426.         %Q(val.is_a?(Array) &&
  3427.            val.all?(&DoubleX_RMVXA::ECATB::BLOCKS[:check_ord])),
  3428.         %Q([:states, :enemies, :armors, :weapons, :classes, :actors])
  3429.       ],
  3430.       :ecatb_order_battler_z => [
  3431.         %Q(),
  3432.         %Q(val.is_a?(Numeric) && val >= 0),
  3433.         %Q(500)
  3434.       ],
  3435.       :ecatb_order_battler_z_ord => [
  3436.         %Q(),
  3437.         %Q(val.is_a?(Array) &&
  3438.            val.all?(&DoubleX_RMVXA::ECATB::BLOCKS[:check_ord])),
  3439.         %Q([:states, :enemies, :armors, :weapons, :classes, :actors])
  3440.       ],
  3441.       :ecatb_order_battler_icon_x => [
  3442.         %Q(),
  3443.         %Q(val.is_a?(Numeric)),
  3444.         %Q(4)
  3445.       ],
  3446.       :ecatb_se_ready_act => [
  3447.         %Q(),
  3448.         %Q(true),
  3449.         %Q(nil)
  3450.       ],
  3451.       :ecatb_se_ready_act_ord => [
  3452.         %Q(),
  3453.         %Q(val.is_a?(Array) &&
  3454.            val.all?(&DoubleX_RMVXA::ECATB::BLOCKS[:check_ord])),
  3455.         %Q([:states, :enemies, :armors, :weapons, :classes, :actors])
  3456.       ],
  3457.       :ecatb_speed_reduce => [
  3458.         %Q(),
  3459.         %Q(val.is_a?(Numeric) && val >= 0),
  3460.         %Q(0)
  3461.       ],
  3462.       :ecatb_speed_reduce_ord => [
  3463.         %Q(),
  3464.         %Q(val.is_a?(Array) &&
  3465.            val.all?(&DoubleX_RMVXA::ECATB::BLOCKS[:check_ord])),
  3466.         %Q([:actors, :classes, :weapons, :armors, :enemies, :states])
  3467.       ],
  3468.       :show_ecatb_unison_battlers => [
  3469.         %Q(),
  3470.         %Q(true),
  3471.         %Q(true)
  3472.       ],
  3473.       :ecatb_unison_rules => [
  3474.         %Q((vals, rule)),
  3475.         %Q(val.is_a?(Numeric)),
  3476.         %Q(
  3477.     if rule == :min
  3478.       vals.min
  3479.     elsif rule == :avg
  3480.       vals.inject(:+) / vals.size
  3481.     elsif rule == :max
  3482.       vals.max
  3483.     end
  3484.         )
  3485.       ]
  3486.     }
  3487.  
  3488.     # Stores all configurations having methods in Game_Actor
  3489.     # General form: :config => [
  3490.     #                 %Q(arguments),
  3491.     #                 %Q(validation check),
  3492.     #                 %Q(default value)
  3493.     #               ]
  3494.     GAME_ACTOR = GAME_BATTLER.merge({
  3495.       :ecatb_esc_act_cost => [
  3496.         %Q(),
  3497.         %Q(val.is_a?(Numeric)),
  3498.         %Q(1)
  3499.       ],
  3500.       :ecatb_esc_reset_val => [
  3501.         %Q(),
  3502.         %Q(val.is_a?(Numeric)),
  3503.         %Q(0.0)
  3504.       ],
  3505.       :esc_ecatb_charge_rate => [
  3506.         %Q((charge)),
  3507.         %Q(val.is_a?(Numeric) && val >= 0),
  3508.         %Q(100.0)
  3509.       ],
  3510.       :esc_ecatb_cooldown_rate => [
  3511.         %Q((cooldown)),
  3512.         %Q(val.is_a?(Numeric) && val >= 0),
  3513.         %Q(100.0)
  3514.       ],
  3515.       :ecatb_order_actor_icon_y => [
  3516.         %Q(),
  3517.         %Q(val.is_a?(Numeric)),
  3518.         %Q(36)
  3519.       ]
  3520.     })
  3521.  
  3522.     # (v0.01a+)Stores all configurations having methods in Game_Enemy
  3523.     # General form: :config => [
  3524.     #                 %Q(arguments),
  3525.     #                 %Q(validation check),
  3526.     #                 %Q(default value)
  3527.     #               ]
  3528.     GAME_ENEMY = GAME_BATTLER.merge({
  3529.       :ecatb_order_enemy_icon_y => [
  3530.         %Q(),
  3531.         %Q(val.is_a?(Numeric)),
  3532.         %Q(8)
  3533.       ]
  3534.     })
  3535.  
  3536.     # Stores all configurations having methods in Game_Party and Game_Troop
  3537.     # General form: :config => [
  3538.     #                 %Q(arguments),
  3539.     #                 %Q(validation check),
  3540.     #                 %Q(default value)
  3541.     #               ]
  3542.     GAME_PARTY_TROOP = {
  3543.       :ecatb_pool_val => [
  3544.         %Q((vals)),
  3545.         %Q(val.is_a?(Numeric) && val >= 0),
  3546.         %Q(vals.empty? ? 0 : vals.inject(:+) / vals.size)
  3547.       ]
  3548.     }
  3549.  
  3550.     # Stores all configurations having methods in ECATB_Bar
  3551.     # General form: :config => [
  3552.     #                 %Q(arguments),
  3553.     #                 %Q(validation check),
  3554.     #                 %Q(default value)
  3555.     #               ]
  3556.     ECATB_BAR = {
  3557.       :ecatb_bar_ani => [
  3558.         %Q(),
  3559.         %Q(true),
  3560.         %Q(true)
  3561.       ],
  3562.       :ecatb_bar_ani_ox => [
  3563.         %Q(),
  3564.         %Q(val.is_a?(Numeric)),
  3565.         %Q(2)
  3566.       ],
  3567.       :ecatb_bar_wh => [
  3568.         %Q(),
  3569.         %Q(val.is_a?(Array) && val[0].is_a?(Numeric) && val[0] >= 0 &&
  3570.            val[1].is_a?(Numeric) && val[1] >= 0),
  3571.         %Q([48, 12])
  3572.       ],
  3573.       :ecatb_bar_xy_offset => [
  3574.         %Q(),
  3575.         %Q(val.is_a?(Array) && val[0].is_a?(Numeric) &&val[1].is_a?(Numeric)),
  3576.         %Q([0, 0])
  3577.       ],
  3578.       :ecatb_bar_z => [
  3579.         %Q(),
  3580.         %Q(val.is_a?(Numeric) && val >= 0),
  3581.         %Q(0)
  3582.       ],
  3583.       :ecatb_bar_text => [
  3584.         %Q((percent, act)),
  3585.         %Q("val.is_a?(String)"),
  3586.         %Q(percent + "% " + act)
  3587.       ],
  3588.       :ecatb_bar_text_color => [
  3589.         %Q(),
  3590.         %Q(val.is_a?(Color)),
  3591.         %Q(Colour.text_colour(0))
  3592.       ],
  3593.       :ecatb_bar_text_size => [
  3594.         %Q(),
  3595.         %Q(val.is_a?(Numeric) && val >= 0),
  3596.         %Q(16)
  3597.       ],
  3598.       :ecatb_bar_text_xy_offset => [
  3599.         %Q(),
  3600.         %Q(val.is_a?(Array) && val[0].is_a?(Numeric) && val[1].is_a?(Numeric)),
  3601.         %Q([-1, -1])
  3602.       ],
  3603.       :ecatb_bar_back_colors => [
  3604.         %Q(),
  3605.         %Q(val.is_a?(Array) && val[0].is_a?(Color) && val[1].is_a?(Color)),
  3606.         %Q([Colour.text_colour(15), Colour.text_colour(15)])
  3607.       ]
  3608.     }
  3609.  
  3610.     # Stores all configurations having methods in ECATB_Clock_Bar
  3611.     # General form: :config => [
  3612.     #                 %Q(arguments),
  3613.     #                 %Q(validation check),
  3614.     #                 %Q(default value)
  3615.     #               ]
  3616.     ECATB_CLOCK_BAR = {
  3617.       :ecatb_clock_bar_colors => [
  3618.         %Q(),
  3619.         %Q(val.is_a?(Array) && val[0].is_a?(Color) && val[1].is_a?(Color)),
  3620.         %Q([Colour.text_colour(7), Colour.text_colour(8)])
  3621.       ],
  3622.       :ecatb_clock_bar_wh => [
  3623.         %Q(),
  3624.         %Q(val.is_a?(Array) && val[0].is_a?(Numeric) && val[0] >= 0 &&
  3625.            val[1].is_a?(Numeric) && val[1] >= 0),
  3626.         %Q([112, 12])
  3627.       ],
  3628.       :ecatb_clock_bar_xy => [
  3629.         %Q(),
  3630.         %Q(val.is_a?(Array) && val[0].is_a?(Numeric) && val[1].is_a?(Numeric)),
  3631.         %Q([8, 8])
  3632.       ]
  3633.     }
  3634.  
  3635.     # Stores all configurations having methods in Window_BattleStatus
  3636.     # General form: :config => [
  3637.     #                 %Q(arguments),
  3638.     #                 %Q(validation check),
  3639.     #                 %Q(default value)
  3640.     #               ]
  3641.     WINDOW_BATTLESTATUS = {
  3642.       :actor_ecatb_bar_text => [
  3643.         %Q((percent, act)),
  3644.         %Q(val.is_a?(String)),
  3645.         %Q(percent + "% " + act)
  3646.       ],
  3647.       :actor_ecatb_bar_word => [
  3648.         %Q(),
  3649.         %Q(val.is_a?(String)),
  3650.         %Q("AP")
  3651.       ],
  3652.       :actor_ecatb_bar_y_add => [
  3653.         %Q(),
  3654.         %Q(val.is_a?(Numeric)),
  3655.         %Q(12)
  3656.       ]
  3657.     }
  3658.  
  3659.     # Stores all configurations having methods in ECATB_Clock_Window
  3660.     # General form: :config => [
  3661.     #                 %Q(arguments),
  3662.     #                 %Q(validation check),
  3663.     #                 %Q(default value)
  3664.     #               ]
  3665.     ECATB_CLOCK_WINDOW = {
  3666.       :ecatb_clock_window_wh => [
  3667.         %Q(),
  3668.         %Q(val.is_a?(Array) && val[0].is_a?(Numeric) && val[0] >= 0 &&
  3669.            val[1].is_a?(Numeric) && val[1] >= 0),
  3670.         %Q([128, 48])
  3671.       ],
  3672.       :ecatb_clock_window_xyz => [
  3673.         %Q(),
  3674.         %Q(val.is_a?(Array) &&
  3675.            val.all?(&DoubleX_RMVXA::ECATB::BLOCKS[:check_us_num])),
  3676.         %Q([0, 0, 0])
  3677.       ],
  3678.       :ecatb_clock_text => [
  3679.         %Q((cur_clock, max_clock, turn_count)),
  3680.         %Q(val.is_a?(String)),
  3681.         %Q(cur_clock.to_s + "/" + max_clock.to_s + " " + turn_count.to_s)
  3682.       ],
  3683.       :ecatb_clock_text_color => [
  3684.         %Q(),
  3685.         %Q(val.is_a?(Color)),
  3686.         %Q(Colour.text_colour(0))
  3687.       ],
  3688.       :ecatb_clock_text_size => [
  3689.         %Q(),
  3690.         %Q(val.is_a?(Numeric) && val >= 0),
  3691.         %Q(16)
  3692.       ],
  3693.       :ecatb_clock_text_xy => [
  3694.         %Q(),
  3695.         %Q(val.is_a?(Array) && val[0].is_a?(Numeric) && val[1].is_a?(Numeric)),
  3696.         %Q([0, 4])
  3697.       ]
  3698.     }
  3699.  
  3700.     # Stores all configurations having methods in ECATB_Force_Window
  3701.     # General form: :config => [
  3702.     #                 %Q(arguments),
  3703.     #                 %Q(validation check),
  3704.     #                 %Q(default value)
  3705.     #               ]
  3706.     ECATB_FORCE_WINDOW = {
  3707.       :ecatb_force_window_wh => [
  3708.         %Q(),
  3709.         %Q(val.is_a?(Array) && val[0].is_a?(Numeric) && val[0] >= 0 &&
  3710.            val[1].is_a?(Numeric) && val[1] >= 0),
  3711.         %Q([128, 40])
  3712.       ],
  3713.       :ecatb_force_window_xyz => [
  3714.         %Q(),
  3715.         %Q(val.is_a?(Array) &&
  3716.            val.all?(&DoubleX_RMVXA::ECATB::BLOCKS[:check_us_num])),
  3717.         %Q([0, 48, 0])
  3718.       ],
  3719.       :ecatb_force_nil_text => [
  3720.         %Q(),
  3721.         %Q(val.is_a?(String)),
  3722.         %Q("No Force ATB")
  3723.       ],
  3724.       :ecatb_force_run_text => [
  3725.         %Q(),
  3726.         %Q(val.is_a?(String)),
  3727.         %Q("ATB Force Run")
  3728.       ],
  3729.       :ecatb_force_stop_text => [
  3730.         %Q(),
  3731.         %Q(val.is_a?(String)),
  3732.         %Q("ATB Force Stop")
  3733.       ],
  3734.       :ecatb_force_text_color => [
  3735.         %Q(),
  3736.         %Q(val.is_a?(Color)),
  3737.         %Q(Colour.text_colour(0))
  3738.       ],
  3739.       :ecatb_force_text_size => [
  3740.         %Q(),
  3741.         %Q(val.is_a?(Numeric) && val >= 0),
  3742.         %Q(16)
  3743.       ],
  3744.       :ecatb_force_text_xy => [
  3745.         %Q(),
  3746.         %Q(val.is_a?(Array) && val[0].is_a?(Numeric) && val[1].is_a?(Numeric)),
  3747.         %Q([0, 0])
  3748.       ]
  3749.     }
  3750.  
  3751.     # (v0.01a+)Stores all configurations having methods in ECATB_Order_Window
  3752.     # General form: :config => [
  3753.     #                 %Q(arguments),
  3754.     #                 %Q(validation check),
  3755.     #                 %Q(default value)
  3756.     #               ]
  3757.     ECATB_ORDER_WINDOW = {
  3758.       :ecatb_order_window_wh => [
  3759.         %Q(),
  3760.         %Q(val.is_a?(Array) && val[0].is_a?(Numeric) && val[0] >= 0 &&
  3761.            val[1].is_a?(Numeric) && val[1] >= 0),
  3762.         %Q([128, 60])
  3763.       ],
  3764.       :ecatb_order_window_xyz => [
  3765.         %Q(),
  3766.         %Q(val.is_a?(Array) &&
  3767.            val.all?(&DoubleX_RMVXA::ECATB::BLOCKS[:check_us_num])),
  3768.         %Q([0, 88, 0])
  3769.       ],
  3770.       :ecatb_order_bar_colors => [
  3771.         %Q(),
  3772.         %Q(val.is_a?(Array) && val[0].is_a?(Color) && val[1].is_a?(Color)),
  3773.         %Q([Colour.text_colour(7), Colour.text_colour(8)])
  3774.       ],
  3775.       :ecatb_order_charge_bar_colors => [
  3776.         %Q(),
  3777.         %Q(val.is_a?(Array) && val[0].is_a?(Color) && val[1].is_a?(Color)),
  3778.         %Q([Colour.text_colour(30), Colour.text_colour(31)])
  3779.       ],
  3780.       :ecatb_order_cooldown_bar_colors => [
  3781.         %Q(),
  3782.         %Q(val.is_a?(Array) && val[0].is_a?(Color) && val[1].is_a?(Color)),
  3783.         %Q([Colour.text_colour(19), Colour.text_colour(26)])
  3784.       ],
  3785.       :ecatb_order_bar_wh => [
  3786.         %Q(),
  3787.         %Q(val.is_a?(Array) && val[0].is_a?(Numeric) && val[0] >= 0 &&
  3788.            val[1].is_a?(Numeric) && val[1] >= 0),
  3789.         %Q([108, 12])
  3790.       ],
  3791.       :ecatb_order_bar_xy => [
  3792.         %Q(),
  3793.         %Q(val.is_a?(Array) && val[0].is_a?(Numeric) && val[1].is_a?(Numeric)),
  3794.         %Q([0, 12])
  3795.       ],
  3796.       :ecatb_order_bar_text => [
  3797.         %Q(),
  3798.         %Q(val.is_a?(String)),
  3799.         %Q("ATB")
  3800.       ],
  3801.       :ecatb_order_charge_bar_text => [
  3802.         %Q(),
  3803.         %Q(val.is_a?(String)),
  3804.         %Q("Charge")
  3805.       ],
  3806.       :ecatb_order_cooldown_bar_text => [
  3807.         %Q(),
  3808.         %Q(val.is_a?(String)),
  3809.         %Q("Cool")
  3810.       ],
  3811.       :ecatb_order_text_color => [
  3812.         %Q(),
  3813.         %Q(val.is_a?(Color) || val.is_a?(Color)),
  3814.         %Q(Colour.text_colour(0))
  3815.       ],
  3816.       :ecatb_order_text_size => [
  3817.         %Q(),
  3818.         %Q(val.is_a?(Numeric) && val >= 0),
  3819.         %Q(12)
  3820.       ],
  3821.       :ecatb_order_text_xy => [
  3822.         %Q(),
  3823.         %Q(val.is_a?(Array) && val[0].is_a?(Numeric) && val[1].is_a?(Numeric)),
  3824.         %Q([2, 14])
  3825.       ]
  3826.     }
  3827.  
  3828.     # Stores all configurations having methods in ECATB_Pool_Window
  3829.     # General form: :config => [
  3830.     #                 %Q(arguments),
  3831.     #                 %Q(validation check),
  3832.     #                 %Q(default value)
  3833.     #               ]
  3834.     ECATB_POOL_WINDOW = {
  3835.       :ecatb_pool_window_wh => [
  3836.         %Q(),
  3837.         %Q(val.is_a?(Array) && val[0].is_a?(Numeric) && val[0] >= 0 &&
  3838.            val[1].is_a?(Numeric) && val[1] >= 0),
  3839.         %Q([128, 56])
  3840.       ],
  3841.       :ecatb_pool_window_xyz => [
  3842.         %Q(),
  3843.         %Q(val.is_a?(Array) &&
  3844.            val.all?(&DoubleX_RMVXA::ECATB::BLOCKS[:check_us_num])),
  3845.         %Q([0, 148, 0])
  3846.       ],
  3847.       :ecatb_pool_party_actor_text => [
  3848.         %Q(),
  3849.         %Q(val.is_a?(Array) && val[0].is_a?(String) && val[1].is_a?(String)),
  3850.         %Q(["Party ATB", "Actor ATB"])
  3851.       ],
  3852.       :ecatb_pool_troop_enemy_text => [
  3853.         %Q(),
  3854.         %Q(val.is_a?(Array) && val[0].is_a?(String) && val[1].is_a?(String)),
  3855.         %Q(["Troop ATB", "Enemy ATB"])
  3856.       ],
  3857.       :ecatb_pool_text_color => [
  3858.         %Q(),
  3859.         %Q(val.is_a?(Color)),
  3860.         %Q(Colour.text_colour(0))
  3861.       ],
  3862.       :ecatb_pool_text_size => [
  3863.         %Q(),
  3864.         %Q(val.is_a?(Numeric) && val >= 0),
  3865.         %Q(16)
  3866.       ],
  3867.       :ecatb_pool_party_text_xy => [
  3868.         %Q(),
  3869.         %Q(val.is_a?(Array) && val[0].is_a?(Numeric) && val[1].is_a?(Numeric)),
  3870.         %Q([0, 8])
  3871.       ],
  3872.       :ecatb_pool_troop_text_xy => [
  3873.         %Q(),
  3874.         %Q(val.is_a?(Array) && val[0].is_a?(Numeric) && val[1].is_a?(Numeric)),
  3875.         %Q([0, -8])
  3876.       ]
  3877.     }
  3878.  
  3879.     # Stores all configurations having methods in Scene_Battle
  3880.     # General form: :config => [
  3881.     #                 %Q(arguments),
  3882.     #                 %Q(validation check),
  3883.     #                 %Q(default value)
  3884.     #               ]
  3885.     SCENE_BATTLE = {
  3886.       :ecatb_wait_cond => [
  3887.         %Q(),
  3888.         %Q(true),
  3889.         %Q(#{WC1} || #{WC2} && (#{WC3} || #{WC4} || #{WC5} || #{WC6} ||
  3890.            #{WC7} || #{WC8} || #{WC9} || #{WC10} || #{WCC1}))
  3891.       ],
  3892.       :ecatb_turn_type => [
  3893.         %Q(),
  3894.         %Q(val == :tick || val == :act || val == :battler),
  3895.         %Q(:tick)
  3896.       ],
  3897.       :ecatb_tick_count => [
  3898.         %Q(),
  3899.         %Q(val.is_a?(Numeric) && val >= 0),
  3900.         %Q(10)
  3901.       ],
  3902.       :ecatb_after_act => [
  3903.         %Q(),
  3904.         %Q(val.is_a?(Numeric) && val >= 0),
  3905.         %Q(10)
  3906.       ],
  3907.       :ecatb_battler_scale => [
  3908.         %Q(),
  3909.         %Q(val.is_a?(Array) && val[0].is_a?(Numeric) && val[0] >= 0 &&
  3910.            (val[1] == :tick || val[1] == :act)),
  3911.         %Q([1, :tick])
  3912.       ],
  3913.       :ecatb_battler_count => [
  3914.         %Q(),
  3915.         %Q(val.is_a?(Numeric) && val >= 0),
  3916.         %Q($game_party.alive_members.size + $game_troop.alive_members.size)
  3917.       ],
  3918.       :ecatb_force_act_count => [
  3919.         %Q(),
  3920.         %Q(true),
  3921.         %Q(false)
  3922.       ],
  3923.       :pre_ecatb_update => [
  3924.         %Q(),
  3925.         %Q(true),
  3926.         %Q()
  3927.       ],
  3928.       :post_ecatb_update => [
  3929.         %Q(),
  3930.         %Q(true),
  3931.         %Q()
  3932.       ],
  3933.       :ecatb_cancel_key => [
  3934.         %Q(),
  3935.         %Q(val.is_a?(Symbol)),
  3936.         %Q(:SHIFT)
  3937.       ],
  3938.       :ecatb_cancel_text=> [
  3939.         %Q(),
  3940.         %Q(val.is_a?(String)),
  3941.         %Q("Select an actor without autobattle norconfusion to\ncancel " +
  3942.            "his/her/its partially charging skill/item.")
  3943.       ],
  3944.       :ecatb_force_run_key => [
  3945.         %Q(),
  3946.         %Q(val.is_a?(Symbol)),
  3947.         %Q(:CTRL)
  3948.       ],
  3949.       :ecatb_force_stop_key => [
  3950.         %Q(),
  3951.         %Q(val.is_a?(Symbol)),
  3952.         %Q(:ALT)
  3953.       ],
  3954.       :ecatb_battler_hotkeys => [
  3955.         %Q(),
  3956.         %Q(val.is_a?(Array) &&
  3957.            val.all?(&DoubleX_RMVXA::ECATB::BLOCKS[:check_sym])),
  3958.         %Q([:NUMPAD1, :NUMPAD2, :NUMPAD3, :NUMPAD4, :NUMPAD5, :NUMPAD6,
  3959.             :NUMPAD7, :NUMPAD8, :NUMPAD9, :NUMPAD0])
  3960.       ]
  3961.     }
  3962.  
  3963.     # Stores all iterator blocks
  3964.     # General form: :def_name => iterator_block
  3965.     BLOCKS = {
  3966.       :check_game_battler => -> v { v.is_a?(Game_Battler) },
  3967.       :check_ord => -> v { v == :states || v == :enemies || v == :armors ||
  3968.                            v == :weapons || v == :classes || v == :actors },
  3969.       :check_sym => -> v { v.is_a?(Symbol) },
  3970.       :check_us_num => -> v { v.is_a?(Numeric) && v >= 0 },
  3971.       :close_ecatb_windows => -> window { window.hide.deactivate.close },
  3972.       :clear_ecatb_blocks => -> mem { mem.clear_ecatb_blocks },
  3973.       :create_ecatb_defs => -> mem { mem.create_ecatb_defs },
  3974.       :dispose => -> obj { obj.dispose if obj && !obj.disposed? },
  3975.       :ecatb_ctb_break? => -> b { b.actor? && b.ecatb_inputable? ||
  3976.                                   b.exec_ecatb_act? },
  3977.       :ecatb_reset => -> mem { mem.ecatb_reset },
  3978.       :ecatb_input_list_1 => -> actor { actor.ecatb_inputable? },
  3979.       :ecatb_input_list_2 => -> actor { actor.index },
  3980.       :ecatb_on_turn_end => -> mem { mem.on_turn_end },
  3981.       :ecatb_refresh => -> battler { battler.ecatb_refresh },
  3982.       :ecatb_update_windows => -> w { w.hide.deactivate.close if w.active },
  3983.       :ecatb_updates => -> mem { mem.ecatb_updates },
  3984.       :init_ecatb_escape => -> mem { mem.init_ecatb_escape },
  3985.       :load_ecatb_notes => -> d { d.each(&BLOCKS[:load_ecatb_notes_each]) },
  3986.       :load_ecatb_notes_each => -> obj { obj.load_ecatb_notes if obj },
  3987.       :pay_ecatb_act_cost => -> actor { actor.pay_ecatb_act_cost },
  3988.       :pay_ecatb_esc_cost => -> mem { mem.pay_ecatb_esc_cost if mem.ecatb_esc },
  3989.       :refresh_ecatb_windows => ->  window { window.refresh if window.active },
  3990.       :reset_ecatb_blocks => -> mem { mem.reset_ecatb_blocks },
  3991.       :reset_ecatb_refresh => -> battler { battler.ecatb_refresh = false },
  3992.       :sort_screen_x => -> a, b { a.screen_x - b.screen_x },
  3993.       :update => -> obj { obj.update },
  3994.       :update_ecatb_pool => -> unit {
  3995.         next unless unit.ecatb_pool
  3996.         if (members = unit.alive_members).any?(&BLOCKS[:update_ecatb_pool_any])
  3997.           val = members.collect(&BLOCKS[:update_ecatb_pool_collect])
  3998.           max = val.max
  3999.           size = val.size
  4000.           val = unit.ecatb_pool_val(val)
  4001.           val = max if max - val <= Float::EPSILON * size * max
  4002.           members.each { |mem|
  4003.             mem.ecatb_val[:atb] = val
  4004.             mem.ecatb_val_change = false
  4005.           }
  4006.         end
  4007.         next unless members.all?(&BLOCKS[:update_ecatb_pool_all])
  4008.         act = 0
  4009.         members.each { |mem|
  4010.           next if mem.ecatb_act_times_cap
  4011.           mem.ecatb_act_times_cap = false
  4012.           act += mem.ecatb_act_times_add
  4013.           mem.ecatb_act_times -= mem.ecatb_act_times_add
  4014.           mem.ecatb_act_times_add = 0
  4015.         }
  4016.         members.each { |mem| mem.ecatb_act_times += act } if act > 0
  4017.       },
  4018.       :update_ecatb_pool_any => -> mem { mem.ecatb_val_change },
  4019.       :update_ecatb_pool_collect => -> mem { mem.ecatb_val[:atb] },
  4020.       :update_ecatb_pool_all => -> mem { mem.ecatb_act_times_add > 0 },
  4021.       :update_ecatb_unison => -> mem {
  4022.         next unless mem.ecatb_unison_invoker
  4023.         actors = mem.ecatb_unison_actors
  4024.         if actors.any?(&BLOCKS[:update_ecatb_unison_any_1])
  4025.           type = :charge
  4026.         elsif actors.any?(&BLOCKS[:update_ecatb_unison_any_2])
  4027.           actors &= $game_party.alive_members
  4028.           type = :cooldown
  4029.         else
  4030.           next
  4031.         end
  4032.         val = actors.collect { |actor| actor.ecatb_val[type] }
  4033.         val = mem.ecatb_unison_rules(val, mem.ecatb_unison_rule[type])
  4034.         actors.each { |actor| actor.ecatb_val[type] = val }
  4035.       },
  4036.       :update_ecatb_unison_any_1 => -> actor { actor.ecatb_val[:charge] > 0.0 },
  4037.       :update_ecatb_unison_any_2 => -> a { a.ecatb_val[:cooldown] > 0.0 },
  4038.       :usable? => -> actor_id { $game_actors[actor_id] },
  4039.       :window_battleenemy_update => -> m { m.sprite_effect_type = :whiten }
  4040.     }
  4041.  
  4042.     # Stores all regular expressions of the non-usableitem notetags
  4043.     REGEX = [
  4044.       /< *ecatb +color *: *(\w+) *, *(\d+) *, *(\w+) *>/i,
  4045.       /< *ecatb +gradual +action +gain *: *(\w+) *>/i,
  4046.       /< *ecatb +order +battler +icon *: *(\w+) *>/i,
  4047.       /< *ecatb +order +battler +opacity *: *(\w+) *>/i,
  4048.       /< *ecatb +order +battler +scale *: *(\w+) *>/i,
  4049.       /< *ecatb +order +battler +z *: *(\w+) *>/i,
  4050.       /< *ecatb +rate *: *(\w+) *>/i,
  4051.       /< *ecatb +se +ready +act *: *(\w+) *>/i,
  4052.       /< *ecatb +speed +reduce *: *(\w+) *>/i,
  4053.       /< *ecatb +start +val *: *(\d+) *, *(\w+) *>/i,
  4054.       /< *enemy +ecatb +bar +show *: *(\w+) *, *(\w+) *, *(\w+) *, *(\w+) *>/i,
  4055.       /< *ecatb +countdown +interval *: *(\w+) *>/i,
  4056.       /< *ecatb +act +cost *: *(\w+) *>/i,
  4057.       /< *ecatb +charge +prior +act +cost *: *(\w+) *>/i,
  4058.       /< *ecatb +charge +prior +item +cost *: *(\w+) *>/i,
  4059.       /< *ecatb +charge +rate *: *(\w+) *>/i,
  4060.       /< *ecatb +cooldown +rate *: *(\w+) *>/i,
  4061.       /< *ecatb +force +act +cost *: *(\w+) *>/i,
  4062.       /< *ecatb +reset +val *: *(\w+) *>/i,
  4063.       /< *ecatb +unison +actor *: *(\w+) *>/i,
  4064.       /< *ecatb +unison +charge +rule *: *(\w+) *>/i,
  4065.       /< *ecatb +unison +cooldown +rule *: *(\w+) *>/i,
  4066.       /< *ecatb +unison +actor +(\w+) *: *(\w+) *>/i,
  4067.       /< *ecatb +unison +(\w+) +rule *: *(\w+) *>/
  4068.     ]
  4069.  
  4070.     # Stores all regular expressions of the usableitem notetags
  4071.     USABLEITEM_NOTES = [
  4072.       "ecatb_act_cost",
  4073.       "ecatb_charge_prior_act_cost",
  4074.       "ecatb_charge_prior_item_cost",
  4075.       "ecatb_charge_rate",
  4076.       "ecatb_cooldown_rate",
  4077.       "ecatb_force_act_cost",
  4078.       "ecatb_reset_val",
  4079.       "ecatb_unison_actor",
  4080.       "ecatb_unison_charge_rule",
  4081.       "ecatb_unison_cooldown_rule",
  4082.       "ecatb_unison_actor_def",
  4083.       "ecatb_unison_def_rule"
  4084.     ]
  4085.  
  4086.     #Stores all pieces of codes used for reading notetags in all database parts
  4087.     NOTE_START = %Q(
  4088.   attr_reader :ecatb_notes
  4089.   def load_ecatb_notes
  4090.     @ecatb_notes = {}
  4091.     ecatb = DoubleX_RMVXA::ECATB
  4092.     )
  4093.     NOTE_MID = %Q(
  4094.     [:atb, :charge, :cooldown, :rate, :speed, :start_0, :start_1, :start_2].
  4095.     each { |note| @ecatb_notes[note] = [] }
  4096.     @note.split(/[\r\n]+/).each { |line|
  4097.       if line =~ ecatb::REGEX[0]
  4098.         next @ecatb_notes[$1.downcase.to_sym][$2.to_i] ||= $3.downcase.to_sym
  4099.       elsif line =~ ecatb::REGEX[1]
  4100.         next @ecatb_notes[:act] = $1.downcase.to_sym
  4101.       elsif line =~ ecatb::REGEX[2]
  4102.         next @ecatb_notes[:order_icon] = $1.downcase.to_sym
  4103.       elsif line =~ ecatb::REGEX[3]
  4104.         next @ecatb_notes[:order_opacity] = $1.downcase.to_sym
  4105.       elsif line =~ ecatb::REGEX[4]
  4106.         next @ecatb_notes[:order_scale] = $1.downcase.to_sym
  4107.       elsif line =~ ecatb::REGEX[5]
  4108.         next @ecatb_notes[:order_z] = $1.downcase.to_sym
  4109.       elsif line =~ ecatb::REGEX[6]
  4110.         next @ecatb_notes[:rate] << $1.downcase.to_sym
  4111.       elsif line =~ ecatb::REGEX[7]
  4112.         next @ecatb_notes[:se] = $1.downcase.to_sym
  4113.       elsif line =~ ecatb::REGEX[8]
  4114.         next @ecatb_notes[:speed] << $1.downcase.to_sym
  4115.       elsif line =~ ecatb::REGEX[9]
  4116.         next @ecatb_notes[("start_" + $1).to_sym] << $2.downcase.to_sym
  4117.     )
  4118.     NOTE_QUARTER = %Q(
  4119.       end
  4120.     }
  4121.     )
  4122.     NOTE_END = %Q(
  4123.   end
  4124.     )
  4125.     BAR_NOTE_START = %Q(
  4126.   attr_accessor :enemy_ecatb_bar_show
  4127.     )
  4128.     BAR_NOTE_MID = %Q(
  4129.     @enemy_ecatb_bar_show = [
  4130.       eval(ecatb::BAR_KILL_ENEMY_1ST),
  4131.       eval(ecatb::ENEMY_BAR_SHOW),
  4132.       eval(ecatb::ENEMY_BAR_SHOW_PERCENT),
  4133.       eval(ecatb::ENEMY_BAR_SHOW_ACT),
  4134.     ]
  4135.     )
  4136.     BAR_NOTE_END = %Q(
  4137.       elsif line =~ ecatb::REGEX[10]
  4138.         next @enemy_ecatb_bar_show = [eval($1.downcase), eval($2.downcase),
  4139.         eval($3.downcase), eval($4.downcase)]
  4140.     )
  4141.     COUNTDOWN_NOTE_START = %Q(
  4142.   attr_accessor :ecatb_countdown_interval
  4143.     )
  4144.     COUNTDOWN_NOTE_MID = %Q(
  4145.       elsif line =~ ecatb::REGEX[11]
  4146.         next @ecatb_countdown_interval = $1.downcase.to_sym
  4147.     )
  4148.     COUNTDOWN_NOTE_END = %Q(
  4149.     @auto_removal_timing = 3 if @ecatb_countdown_interval
  4150.     )
  4151.  
  4152.     # Stores the method load_ecatb_notes in actors, classes and equips
  4153.     CLASS_NOTES = EQUIP_NOTES = ACTOR_NOTES = NOTE_START + NOTE_MID +
  4154.     NOTE_QUARTER + NOTE_END
  4155.  
  4156.     # Stores the method load_ecatb_notes in enemies
  4157.     ENEMY_NOTES = BAR_NOTE_START + NOTE_START + %Q(
  4158.     t, f, n = true, false, nil
  4159.     ) + BAR_NOTE_MID + NOTE_MID + BAR_NOTE_END + NOTE_QUARTER + NOTE_END
  4160.  
  4161.     # Stores the method load_ecatb_notes in states
  4162.     STATE_NOTES = BAR_NOTE_START + COUNTDOWN_NOTE_START + NOTE_START +
  4163.                   BAR_NOTE_MID + NOTE_MID + COUNTDOWN_NOTE_MID + BAR_NOTE_END +
  4164.                   NOTE_QUARTER + COUNTDOWN_NOTE_END + NOTE_END
  4165.  
  4166.     # Stores the abstract method creator and validator for all configurations
  4167.     CHECK_RESET_DEF = {}
  4168.     [:BATTLEMANAGER, :GAME_ACTOR, :GAME_ENEMY, :GAME_PARTY_TROOP,
  4169.      :WINDOW_BATTLESTATUS, :ECATB_CLOCK_WINDOW, :ECATB_BAR, :ECATB_CLOCK_BAR,
  4170.      :ECATB_FORCE_WINDOW, :ECATB_ORDER_WINDOW, :ECATB_POOL_WINDOW,
  4171.      :SCENE_BATTLE].each { |key|
  4172.       CHECK_RESET_DEF[key] = %Q(
  4173.   def create_ecatb_defs
  4174.     DoubleX_RMVXA::ECATB::#{key.id2name}.each_key { |config|
  4175.       create_ecatb_def(config) unless respond_to?(config)
  4176.     }
  4177.   end
  4178.  
  4179.   def check_ecatb_def(config, check)
  4180.     percent = act = ""
  4181.     charge = cooldown = cur_clock = max_clock = turn_count = rule = -1
  4182.     vals = []
  4183.     #{RESCUE_CONFIG_VAL ? "begin" : ""}
  4184.     val = eval(config + check[0])
  4185.     reset_ecatb_def(config, check, "is invalid.") unless eval(check[1])
  4186.     #{RESCUE_CONFIG_VAL ? %Q(rescue Exception => error
  4187.     msgbox("This error message's raised:\n" + error.message)
  4188.     reset_ecatb_def(config, check, "could crash the game.")
  4189.     end) : ""}
  4190.   end
  4191.  
  4192.   def reset_ecatb_def(config, check, type)
  4193.     #{RESET_CONFIG_VAL ? "" : "return"}
  4194.     #{SUPPRESS_RESET_CONFIG_VAL_TEXT ? "" : %Q(msgbox("The validation code " +
  4195.     "of " + config + " is\n" + check[1])
  4196.     msgbox("The value of " +
  4197.     config + " is\n" + $game_system.send(config.to_sym) + "\nwhich " + type))}
  4198.     $game_system.send((config + "=").to_sym, check[2])
  4199.     create_ecatb_def(config.to_sym, false)
  4200.     #{SUPPRESS_RESET_CONFIG_VAL_TEXT ? "" : %Q(msgbox(
  4201.     "Its value is reset to its default:\n" + check[2]))}
  4202.   end
  4203.       )
  4204.     }
  4205.  
  4206.     # (v0.02c+)Returns the atb charge gain and cooldown loss rate
  4207.     CHARGE_COOLDOWN_RATE = {}
  4208.     [:charge, :cooldown].each { |key|
  4209.       CHARGE_COOLDOWN_RATE[key] = %Q(
  4210.   def ecatb_#{type = key.id2name}_#{key == :charge ? "gain" : "loss"}_rate
  4211.     return @ecatb_rate[:#{type}] unless (@last_ecatb_rate[:#{type}] !=
  4212.     @last_ecatb_rate[:#{type}] = ecatb_gain_rate) ||
  4213.     @ecatb_item_change[:#{type}]
  4214.     @ecatb_item_change[:#{type}] = false
  4215.     @ecatb_rate[:#{type}] = if @#{key == :charge ? "" : "fail_"}ecatb_esc
  4216.       esc_ecatb_#{type}_rate(@last_ecatb_rate[:#{type}])
  4217.     else
  4218.       DoubleX_RMVXA::ECATB.send(@last_ecatb_item.ecatb_#{type}_rate, self,
  4219.       @last_ecatb_rate[:#{type}])
  4220.     end
  4221.   end
  4222.       )
  4223.     }
  4224.  
  4225.     # (v0.01a+)Reads all atb order battler icon, opacity, scale and z notetags
  4226.     ORDER = {}
  4227.     [:icon, :opacity, :scale, :z].each { |key|
  4228.       type = key.id2name
  4229.       ORDER[key] = %Q(
  4230.   def set_ecatb_order_battler_#{type}
  4231.     unless ecatb_battler_change?(:order_#{type})
  4232.       return @ecatb_notes[:order_#{type}]
  4233.     end
  4234.     @ecatb_notes[:order_#{type}] = nil
  4235.     ecatb_order_battler_#{type}_ord.each { |data|
  4236.       if send(@ecatb_item[data][0])
  4237.         set_ecatb_notes(send(@ecatb_item[data][1]), :order_#{type})
  4238.       end
  4239.       return @ecatb_notes[:order_#{type}] if @ecatb_notes[:order_#{type}]
  4240.     }
  4241.     @ecatb_notes[:order_#{type}] = ecatb_order_battler_#{type}
  4242.   end
  4243.       )
  4244.     }
  4245.  
  4246.     # Processes actor hotkeys used by Window_ActorCommand and Window_BattleActor
  4247.     ACTOR_HOTKEY = %Q(
  4248.   alias process_handling_ecatb process_handling
  4249.   def process_handling
  4250.     if BattleManager.btype?(:ecatb) && open? && active
  4251.       SceneManager.scene.ecatb_battler_hotkeys.each(&@ecatb_hotkey_block)
  4252.     end
  4253.     process_handling_ecatb
  4254.   end # process_handling
  4255.     )
  4256.  
  4257.     # Updates the positions, width and height and text font update methods
  4258.     WINDOW_DEFS = {}
  4259.     [:clock, :force, :order, :pool].each { |key|
  4260.       klass = key.id2name
  4261.       WINDOW_DEFS[key] = %Q(
  4262.   def update_pos
  4263.     xyz = ecatb_#{klass}_window_xyz
  4264.     self.x = xyz[0] if x != xyz[0]
  4265.     self.y = xyz[1] if y != xyz[1]
  4266.     self.z = xyz[2] if z != xyz[2]
  4267.   end
  4268.  
  4269.   def update_wh
  4270.     wh = ecatb_#{klass}_window_wh
  4271.     self.width = wh[0] if width != wh[0]
  4272.     self.height = wh[1] if height != wh[1]
  4273.   end
  4274.  
  4275.   def update_text_font
  4276.     if (font = contents.font).color != color = ecatb_#{klass}_text_color
  4277.       font.color = color
  4278.     end
  4279.     return if font.size == size = ecatb_#{klass}_text_size
  4280.     font.size = size
  4281.   end
  4282.       )
  4283.     }
  4284.  
  4285.     # (v0.04d+)Processes the skill/item target cancellation command
  4286.     ON_TARGET_CANCEL = {}
  4287.     [:actor, :enemy].each { |key|
  4288.       ON_TARGET_CANCEL[key] = %Q(
  4289.   alias on_#{key = key.id2name}_cancel_ecatb on_#{key}_cancel
  4290.   def on_#{key}_cancel(*argv, &argb)
  4291.     return unless actor = BattleManager.actor
  4292.     if BattleManager.btype?(:ecatb) && on_ecatb_unison?(:cancel, @#{key}_window)
  4293.       return
  4294.     end
  4295.     on_#{key}_cancel_ecatb(*argv, &argb)
  4296.     @status_window.draw_item(actor.index)
  4297.   end
  4298.       )
  4299.     }
  4300.  
  4301.     # (v0.04d+)Processes the skill/item selection confirmation command
  4302.     ON_SKILL_ITEM_OK = {}
  4303.     [:skill, :item].each { |key|
  4304.       ON_SKILL_ITEM_OK[key] = %Q(
  4305.   alias on_#{key = key.id2name}_ok_ecatb on_#{key}_ok
  4306.   def on_#{key}_ok(*argv, &argb)
  4307.     return unless actor = BattleManager.actor
  4308.     return if on_ecatb_unison_item_ok?(@#{key}_window)
  4309.     on_#{key}_ok_ecatb(*argv, &argb)
  4310.     @status_window.draw_item(actor.index)
  4311.   end
  4312.       )
  4313.     }
  4314.  
  4315.     # (v0.01b+)Creates the atb force, order and pool windows
  4316.     CREATE_WINDOW = {}
  4317.     [:Force, :Order, :Pool].each { |key|
  4318.       name1 = key.id2name
  4319.       CREATE_WINDOW[key] = %Q(
  4320.   def create_ecatb_#{name2 = name1.downcase}_window
  4321.     return if @ecatb_#{name2}_window
  4322.     return unless eval($game_system.show_ecatb_#{name2}_window)
  4323.     @ecatb_#{name2}_window =
  4324.     ECATB_#{name1}_Window.new#{key == :Force ? "(@ecatb_force_clock)" : ""}
  4325.   end
  4326.       )
  4327.     }
  4328.  
  4329.     # (v0.01b+)Closes the atb clock, force, order and pool windows
  4330.     CLOSE_WINDOW = {}
  4331.     [:clock, :force, :order, :pool].each { |key|
  4332.       CLOSE_WINDOW[key] = %Q(
  4333.   def close_ecatb_#{name = key.id2name}_window
  4334.     @ecatb_#{name}_window.hide.deactivate.close
  4335.     @ecatb_#{name}_window.dispose unless @ecatb_#{name}_window.disposed?
  4336.     @ecatb_#{name}_window = nil
  4337.   end
  4338.       )
  4339.     }
  4340.  
  4341.   end # ECATB
  4342.  
  4343. end # DoubleX_RMVXA
  4344.  
  4345. if $imported["YEA-BattleEngine"] && !$imported["YSA-CATB"]
  4346.  
  4347. #------------------------------------------------------------------------------|
  4348.  
  4349. #------------------------------------------------------------------------------|
  4350. #  * Load all data's notetags and fixes bugs and edge cases                    |
  4351. #------------------------------------------------------------------------------|
  4352. class << DataManager # Edit
  4353.  
  4354.   #----------------------------------------------------------------------------|
  4355.   #  Loads all this script's notetags from the database as well                |
  4356.   #----------------------------------------------------------------------------|
  4357.   alias load_database_ecatb load_database
  4358.   def load_database(*argv, &argb)
  4359.     load_database_ecatb(*argv, &argb)
  4360.     load_ecatb_notes # Added
  4361.   end # load_database
  4362.  
  4363.   #----------------------------------------------------------------------------|
  4364.   #  Clears and resets all battlers' blocks before and after saving also       |
  4365.   #----------------------------------------------------------------------------|
  4366.   alias save_game_without_rescue_ecatb save_game_without_rescue
  4367.   def save_game_without_rescue(index, &argb)
  4368.     clear_ecatb_blocks # Added
  4369.     save_game_without_rescue_ecatb(index, &argb)
  4370.     init_ecatb_def_blocks # Added
  4371.   end # save_game_without_rescue
  4372.  
  4373.   #----------------------------------------------------------------------------|
  4374.   #  Resets all battlers' blocks and methods after loading as well             |
  4375.   #----------------------------------------------------------------------------|
  4376.   alias extract_save_contents_ecatb extract_save_contents
  4377.   def extract_save_contents(contents, &argb)
  4378.     extract_save_contents_ecatb(contents, &argb)
  4379.     init_ecatb_def_blocks(true) # Added
  4380.   end # extract_save_contents
  4381.  
  4382.   def load_ecatb_notes # New
  4383.     [$data_actors, $data_classes, $data_skills, $data_items, $data_weapons,
  4384.      $data_armors, $data_enemies, $data_states].each(
  4385.      &DoubleX_RMVXA::ECATB::BLOCKS[:load_ecatb_notes])
  4386.   end # load_ecatb_notes
  4387.  
  4388.   #----------------------------------------------------------------------------|
  4389.   #  Clears all blocks before serializations and after being unneeded          |
  4390.   #----------------------------------------------------------------------------|
  4391.   def clear_ecatb_blocks # New
  4392.     block = DoubleX_RMVXA::ECATB::BLOCKS[:clear_ecatb_blocks]
  4393.     $game_actors.instance_exec { @data.compact.each(&block) }
  4394.     $game_troop.members.each(&block)
  4395.   end # clear_ecatb_blocks
  4396.  
  4397.   #----------------------------------------------------------------------------|
  4398.   #  Resets all blocks after serializations and being needed                   |
  4399.   #----------------------------------------------------------------------------|
  4400.   def init_ecatb_def_blocks(create_def = false) # New
  4401.     block = DoubleX_RMVXA::ECATB::BLOCKS
  4402.     $game_party.all_members.each(&block[:create_ecatb_defs]) if create_def
  4403.     $game_party.all_members.each(&block[:reset_ecatb_blocks])
  4404.     $game_troop.members.each(&block[:reset_ecatb_blocks])
  4405.   end # init_ecatb_def_blocks
  4406.  
  4407. end # DataManager
  4408.  
  4409. #------------------------------------------------------------------------------|
  4410. #  * Loads all the actor's notetags                                            |
  4411. #------------------------------------------------------------------------------|
  4412. class RPG::Actor < RPG::BaseItem # Edit
  4413.  
  4414.   module_eval(DoubleX_RMVXA::ECATB::ACTOR_NOTES) # New
  4415.  
  4416. end # RPG::Actor
  4417.  
  4418. #------------------------------------------------------------------------------|
  4419. #  * Loads all the class's notetags                                            |
  4420. #------------------------------------------------------------------------------|
  4421. class RPG::Class < RPG::BaseItem # Edit
  4422.  
  4423.   module_eval(DoubleX_RMVXA::ECATB::CLASS_NOTES) # New
  4424.  
  4425. end # RPG::Class
  4426.  
  4427. #------------------------------------------------------------------------------|
  4428. #  * Loads all the enemy's notetags                                            |
  4429. #------------------------------------------------------------------------------|
  4430. class RPG::Enemy < RPG::BaseItem # Edit
  4431.  
  4432.   module_eval(DoubleX_RMVXA::ECATB::ENEMY_NOTES) # New
  4433.  
  4434. end # RPG::Enemy
  4435.  
  4436. #------------------------------------------------------------------------------|
  4437. #  * Loads all the equip's notetags                                            |
  4438. #------------------------------------------------------------------------------|
  4439. class RPG::EquipItem < RPG::BaseItem # Edit
  4440.  
  4441.   module_eval(DoubleX_RMVXA::ECATB::EQUIP_NOTES) # New
  4442.  
  4443. end # RPG::EquipItem
  4444.  
  4445. #------------------------------------------------------------------------------|
  4446. #  * Loads all the state's notetags                                            |
  4447. #------------------------------------------------------------------------------|
  4448. class RPG::State < RPG::BaseItem # Edit
  4449.  
  4450.   module_eval(DoubleX_RMVXA::ECATB::STATE_NOTES) # New
  4451.  
  4452. end # RPG::State
  4453.  
  4454. class RPG::UsableItem < RPG::BaseItem # Edit
  4455.  
  4456.   #----------------------------------------------------------------------------|
  4457.   #  New public instance variables                                             |
  4458.   #----------------------------------------------------------------------------|
  4459.   # The values of all the skill/item's notetags
  4460.   DoubleX_RMVXA::ECATB::USABLEITEM_NOTES.each { |note|
  4461.     attr_accessor eval(":#{note}")
  4462.   }
  4463.   #
  4464.  
  4465.   def load_ecatb_notes # New
  4466.     @ecatb_unison_actor_def = {}
  4467.     @ecatb_unison_def_rule = {}
  4468.     ecatb = DoubleX_RMVXA::ECATB
  4469.     @note.split(/[\r\n]+/).each { |line|
  4470.       ecatb::USABLEITEM_NOTES.each_with_index { |note, index|
  4471.         next unless line =~ ecatb::REGEX[index + 12]
  4472.         if index > 9
  4473.           note += "[:#{$1}]"
  4474.           val = $2.downcase.to_sym
  4475.         else
  4476.           val = $1.downcase.to_sym
  4477.         end
  4478.         send(:"#{note}=", send(:"#{note}") || val)
  4479.       }
  4480.     }
  4481.     ecatb::USABLEITEM_NOTES.each_with_index { |note, index|
  4482.       send(:"#{note}=", send(:"#{note}") || note.to_sym) if index < 10
  4483.     }
  4484.   end # load_ecatb_notes
  4485.  
  4486. end # RPG::UsableItem
  4487.  
  4488. #------------------------------------------------------------------------------|
  4489. #  * Reimplements the the whole battle flow to run the atb system              |
  4490. #------------------------------------------------------------------------------|
  4491. class << BattleManager # Edit
  4492.  
  4493.   #----------------------------------------------------------------------------|
  4494.   #  New public instance variables                                             |
  4495.   #----------------------------------------------------------------------------|
  4496.   attr_accessor :actor_index # Accessed by Scene_Battle to setup actors
  4497.   attr_accessor :ecatb_can_esc # The party escape permission flag
  4498.   attr_reader :ecatb_actor_act_list # The list of actors that can act
  4499.   attr_reader :ecatb_base # The base atb rate determinators
  4500.   attr_reader :ecatb_base_change # The base atb rate determinators change flag
  4501.   attr_reader :action_battlers # Read by Scene_Battle to execute actions
  4502.   attr_reader :phase # Read by Scene_Battle to get the battle phase
  4503.  
  4504.   #----------------------------------------------------------------------------|
  4505.   #  New private instance variables                                            |
  4506.   #----------------------------------------------------------------------------|
  4507.   # @ecatb_battlers_def_sums: All method sums of all battlers
  4508.   # @ecatb_def_sums: The iteraotr block running all method sums of all battlers
  4509.   # @ecatb_esc: The party escape attempt flag
  4510.   # @ecatb_pool_reset_lock: The party/troop atb pool reset lock
  4511.  
  4512.   alias setup_ecatb setup
  4513.   def setup(troop_id, can_escape = true, can_lose = false, &argb)
  4514.     setup_ecatb(troop_id, can_escape, can_lose, &argb)
  4515.     # Added
  4516.     init_ecatb_vars
  4517.     create_ecatb_defs
  4518.     #
  4519.   end # setup
  4520.  
  4521.   #----------------------------------------------------------------------------|
  4522.   #  Always let actions to be executed at any frame for ecatb battle system    |
  4523.   #----------------------------------------------------------------------------|
  4524.   alias in_turn_ecatb? in_turn?
  4525.   def in_turn? # Hotspot
  4526.     btype?(:ecatb) || in_turn_ecatb? # Rewritten
  4527.   end # in_turn?
  4528.  
  4529.   #----------------------------------------------------------------------------|
  4530.   #  Disables the next command for ecatb battle system                         |
  4531.   #----------------------------------------------------------------------------|
  4532.   alias next_command_ecatb next_command
  4533.   def next_command(*argv, &argb)
  4534.     # Rewritten
  4535.     return false if btype?(:ecatb)
  4536.     next_command_ecatb(*argv, &argb)
  4537.     #
  4538.   end # next_command
  4539.  
  4540.   #----------------------------------------------------------------------------|
  4541.   #  Disables the prior command for ecatb battle system                        |
  4542.   #----------------------------------------------------------------------------|
  4543.   alias prior_command_ecatb prior_command
  4544.   def prior_command(*argv, &argb)
  4545.     # Rewritten
  4546.     return false if btype?(:ecatb)
  4547.     prior_command_ecatb(*argv, &argb)
  4548.     #
  4549.   end # prior_command
  4550.  
  4551.   #----------------------------------------------------------------------------|
  4552.   #  Initializes all battlers' starting atb values and their method sums also  |
  4553.   #----------------------------------------------------------------------------|
  4554.   alias battle_start_ecatb battle_start
  4555.   def battle_start(*argv, &argb)
  4556.     battle_start_ecatb(*argv, &argb)
  4557.     ecatb_battle_start if btype?(:ecatb) # Added
  4558.   end # battle_start
  4559.  
  4560.   #----------------------------------------------------------------------------|
  4561.   #  Closes all windows that should be closed before ending the battle as well |
  4562.   #----------------------------------------------------------------------------|
  4563.   alias process_victory_ecatb process_victory
  4564.   def process_victory(*argv, &argb)
  4565.     # Added
  4566.     if btype?(:ecatb) && SceneManager.scene_is?(Scene_Battle)
  4567.       SceneManager.scene.close_ecatb_windows
  4568.     end
  4569.     #
  4570.     process_victory_ecatb(*argv, &argb)
  4571.   end # process_victory
  4572.  
  4573.   #----------------------------------------------------------------------------|
  4574.   #  Checks if escape's allowed, no such attempt exists and the conditions' met|
  4575.   #----------------------------------------------------------------------------|
  4576.   alias process_escape_ecatb process_escape
  4577.   def process_escape(*argv, &argb)
  4578.     return process_escape_ecatb(*argv, &argb) unless btype?(:ecatb) # Rewritten
  4579.     # Added to initializes the escape attempt if all the requirements are met
  4580.     return false if @ecatb_esc
  4581.     init_ecatb_escape if @ecatb_can_esc && ecatb_esc_init_cond
  4582.     false
  4583.     #
  4584.   end # process_escape
  4585.  
  4586.   #----------------------------------------------------------------------------|
  4587.   #  Closes all windows that should be closed before ending the battle as well |
  4588.   #----------------------------------------------------------------------------|
  4589.   alias process_defeat_ecatb process_defeat
  4590.   def process_defeat(*argv, &argb)
  4591.     # Added
  4592.     if btype?(:ecatb) && SceneManager.scene_is?(Scene_Battle)
  4593.       SceneManager.scene.close_ecatb_windows
  4594.     end
  4595.     #
  4596.     process_defeat_ecatb(*argv, &argb)
  4597.   end # process_defeat
  4598.  
  4599.   #----------------------------------------------------------------------------|
  4600.   #  Stops making actions for any battler and unselecting any inputable actor  |
  4601.   #----------------------------------------------------------------------------|
  4602.   alias input_start_ecatb input_start
  4603.   def input_start(*argv, &argb)
  4604.     # Added
  4605.     if btype?(:ecatb)
  4606.       @phase = :input
  4607.       @surprise = false
  4608.     end
  4609.     #
  4610.     input_start_ecatb(*argv, &argb)
  4611.   end # input_start
  4612.  
  4613.   #----------------------------------------------------------------------------|
  4614.   #  Clears all temporarily stored battlers' blocks as well                    |
  4615.   #----------------------------------------------------------------------------|
  4616.   alias battle_end_ecatb battle_end # v0.03b+
  4617.   def battle_end(result, &argb)
  4618.     battle_end_ecatb(result, &argb)
  4619.     clear_ecatb_blocks # Added
  4620.   end # battle_end
  4621.  
  4622.   def init_ecatb_vars # New
  4623.     $game_temp.init_ecatb_vars
  4624.     @ecatb_actor_act_list = []
  4625.     @ecatb_base = { size: -1, sum: -1, val: -1 }
  4626.     @ecatb_battlers_def_sums = {}
  4627.     @ecatb_can_esc = true
  4628.     @ecatb_esc = false
  4629.     @ecatb_pool_reset_lock = []
  4630.     init_ecatb_block
  4631.   end # init_ecatb_vars
  4632.  
  4633.   #----------------------------------------------------------------------------|
  4634.   #  Initializes the new block to trade memory usage for time performance      |
  4635.   #----------------------------------------------------------------------------|
  4636.   def init_ecatb_block # New
  4637.     # Calls this block instead of an anonymous function per enumerable iteration
  4638.     @ecatb_def_sums = -> method {
  4639.       @ecatb_battlers_def_sums[method] = ecatb_def_sum_battlers.inject(0) {
  4640.       |sum, battler| sum + battler.send(method) }
  4641.     }
  4642.     #
  4643.   end # init_ecatb_block
  4644.  
  4645.   #----------------------------------------------------------------------------|
  4646.   #  Clears all temporarily stored battlers' blocks and frees memory as well   |
  4647.   #----------------------------------------------------------------------------|
  4648.   def clear_ecatb_blocks # v0.05a+; New
  4649.     $game_temp.clear_ecatb_vars
  4650.     @action_battlers = @ecatb_actor_act_list = @ecatb_base = nil
  4651.     @ecatb_battlers_def_sums = @ecatb_def_sums = @ecatb_pool_reset_lock = nil
  4652.   end # clear_ecatb_blocks
  4653.  
  4654.   #----------------------------------------------------------------------------|
  4655.   #  Creates and checks the associated method for each configuration used here |
  4656.   #----------------------------------------------------------------------------|
  4657.   # config: The configuration requesting its associated method
  4658.   # validate: The configuration value validation flag
  4659.   def create_ecatb_def(config, validate = true) # New
  4660.     # Uses the name and value of configuration as its method's name and contents
  4661.     method = config.id2name
  4662.     eval(%Q(
  4663.   def #{method}#{DoubleX_RMVXA::ECATB::BATTLEMANAGER[config][0]}
  4664.     #{$game_system.send(config)}
  4665.   end
  4666.     ))
  4667.     #
  4668.     return unless validate
  4669.     check_ecatb_def(method, DoubleX_RMVXA::ECATB::BATTLEMANAGER[config])
  4670.   end # create_ecatb_def
  4671.  
  4672.   #----------------------------------------------------------------------------|
  4673.   #  Checks all new methods and resets them to the defaults if they're invalid |
  4674.   #----------------------------------------------------------------------------|
  4675.   module_eval(DoubleX_RMVXA::ECATB::CHECK_RESET_DEF[:BATTLEMANAGER]) # New
  4676.  
  4677.   #----------------------------------------------------------------------------|
  4678.   #  Initializes all battlers' starting atb values and their method sums       |
  4679.   #----------------------------------------------------------------------------|
  4680.   def ecatb_battle_start # New
  4681.     type = @preemptive ? :start_1 : @surprise ? :start_2 : :start_0
  4682.     $game_party.battle_members.each { |mem| mem.set_ecatb_start_val(type) }
  4683.     $game_troop.members.each { |mem| mem.set_ecatb_start_val(type) }
  4684.     ecatb_battlers_def_sum.each(&@ecatb_def_sums)
  4685.   end # ecatb_battle_start
  4686.  
  4687.   #----------------------------------------------------------------------------|
  4688.   #  Updates all battlers' atb values and the party escape attempt status      |
  4689.   #----------------------------------------------------------------------------|
  4690.   def ecatb_update # New; Hotspot
  4691.     update_ecatb_base
  4692.     ecatb_block_update
  4693.     if update_ecatb_battlers_def_sums
  4694.       ecatb_battlers_def_sum.each(&@ecatb_def_sums)
  4695.     end
  4696.     return unless @ecatb_esc
  4697.     return pay_ecatb_esc_cost unless ecatb_esc_charge_cond
  4698.     ecatb_esc_suc if ecatb_esc_exec_cond
  4699.   end # ecatb_update
  4700.  
  4701.   def ecatb_block_update # v0.05a+; New; Hotspot
  4702.     block = DoubleX_RMVXA::ECATB::BLOCKS
  4703.     $game_party.battle_members.each(&block[:ecatb_updates])
  4704.     $game_troop.alive_members.each(&block[:ecatb_updates])
  4705.     [$game_party, $game_troop].each(&block[:update_ecatb_pool])
  4706.     $game_party.alive_members.each(&block[:update_ecatb_unison])
  4707.     $game_troop.alive_members.each(&block[:reset_ecatb_refresh])
  4708.   end # ecatb_block_update
  4709.  
  4710.   #----------------------------------------------------------------------------|
  4711.   #  Checks if the atb rate needs to be reevaluated                            |
  4712.   #----------------------------------------------------------------------------|
  4713.   def update_ecatb_base # New; Hotspot
  4714.     # Checks if the number of battlers, methods sums or the fill time's changed
  4715.     @ecatb_base_change = false
  4716.     base = {
  4717.       size: ecatb_def_sum_battlers.size,
  4718.       sum: @ecatb_battlers_def_sums,
  4719.       val: 100.0 / ecatb_base_fill_t / Graphics.frame_rate
  4720.     }
  4721.     base.each { |key, val|
  4722.       @ecatb_base_change = @ecatb_base[key] = val if @ecatb_base[key] != val
  4723.     }
  4724.     #
  4725.   end # update_ecatb_base
  4726.  
  4727.   #----------------------------------------------------------------------------|
  4728.   #  Initializes a party escape attempt                                        |
  4729.   #----------------------------------------------------------------------------|
  4730.   def init_ecatb_escape # New
  4731.     $game_message.add(sprintf(Vocab::EscapeStart, $game_party.name))
  4732.     @ecatb_esc = true
  4733.     # Resets all party members' charge rate and clears all unison data as well
  4734.     $game_party.battle_members.each(
  4735.     &DoubleX_RMVXA::ECATB::BLOCKS[:init_ecatb_escape])
  4736.     #
  4737.   end # init_ecatb_escape
  4738.  
  4739.   #----------------------------------------------------------------------------|
  4740.   #  Executes the fully charged party escape attempt                           |
  4741.   #----------------------------------------------------------------------------|
  4742.   def ecatb_esc_suc # New
  4743.     Sound.play_escape
  4744.     ecatb_esc_suc_cond ? process_abort : pay_ecatb_esc_cost
  4745.     wait_for_message
  4746.   end # ecatb_esc_suc
  4747.  
  4748.   #----------------------------------------------------------------------------|
  4749.   #  Asks all party members to pay the failed party escape attempt's costs     |
  4750.   #----------------------------------------------------------------------------|
  4751.   def pay_ecatb_esc_cost # New
  4752.     @escape_ratio += set_ecatb_esc_cost_compatibility
  4753.     $game_message.add('\.' + Vocab::EscapeFailure)
  4754.     block = DoubleX_RMVXA::ECATB::BLOCKS
  4755.     $game_party.battle_members.each(&block[:pay_ecatb_esc_cost])
  4756.     @ecatb_esc = false
  4757.     $game_party.alive_members.each(&block[:ecatb_reset])
  4758.   end # pay_ecatb_escape_cost
  4759.  
  4760.   #----------------------------------------------------------------------------|
  4761.   #  Triggers all battlers' turn end effects and collapses all collapsible ones|
  4762.   #----------------------------------------------------------------------------|
  4763.   def ecatb_on_turn_end # New
  4764.     $game_party.alive_members.each(
  4765.     &DoubleX_RMVXA::ECATB::BLOCKS[:ecatb_on_turn_end])
  4766.     esc_phase = @ecatb_can_esc || @phase
  4767.     $game_troop.alive_members.each { |m|
  4768.       m.on_turn_end
  4769.       m.perform_collapse_effect if esc_phase && m.enemy? && m.can_collapse?
  4770.     }
  4771.   end # ecatb_on_turn_end
  4772.  
  4773.   #----------------------------------------------------------------------------|
  4774.   #  Marks a battler to become able to act and plays that battler's ready se   |
  4775.   #----------------------------------------------------------------------------|
  4776.   def make_ecatb_act(battler) # New
  4777.     # Stores that battler in the actable battler list and actor list for actors
  4778.     return if @action_battlers.include?(battler)
  4779.     @action_battlers << battler
  4780.     @ecatb_actor_act_list << battler if battler.actor?
  4781.     battler.make_actions
  4782.     battler.pre_ecatb_input_act
  4783.     return unless (se = battler.set_ecatb_se_ready_act).is_a?(RPG::SE)
  4784.     se.play
  4785.     #
  4786.   end # make_ecatb_act
  4787.  
  4788.   #----------------------------------------------------------------------------|
  4789.   #  Marks a battler to become unable to act                                   |
  4790.   #----------------------------------------------------------------------------|
  4791.   def del_ecatb_act(battler) # New
  4792.     # Removes that battler from the actable battler and actor list for actors
  4793.     return unless @action_battlers && @action_battlers.include?(battler)
  4794.     @action_battlers.delete(battler)
  4795.     battler.clear_actions
  4796.     return unless battler.actor? && @ecatb_actor_act_list.include?(battler)
  4797.     @ecatb_actor_act_list.delete(battler)
  4798.     clear_actor if actor == self
  4799.     #
  4800.   end # del_ecatb_act
  4801.  
  4802.   #----------------------------------------------------------------------------|
  4803.   #  Returns the list of all currently inputable actors                        |
  4804.   #----------------------------------------------------------------------------|
  4805.   # id : The inputable actor id list request flag
  4806.   def ecatb_input_list(id = false) # New; Hotspot
  4807.     block = DoubleX_RMVXA::ECATB::BLOCKS
  4808.     list = @ecatb_actor_act_list.select(&block[:ecatb_input_list_1])
  4809.     id ? list.collect!(&block[:ecatb_input_list_2]) : list
  4810.   end # ecatb_input_list
  4811.  
  4812.   # actors: The unison actors
  4813.   def ecatb_pool_reset(battler, actors) # v0.05a+; New
  4814.     # Ensures no repeated ecatb_reset call for any battler including unison ones
  4815.     if @ecatb_pool_reset_lock.include?(battler)
  4816.       return @ecatb_pool_reset_lock.delete(battler)
  4817.     end
  4818.     battlers = battler.actor? ? @ecatb_actor_act_list :
  4819.     @action_battlers - @ecatb_actor_act_list
  4820.     @ecatb_pool_reset_lock = battlers - [battler]
  4821.     (battlers - actors - [battler]).each(
  4822.     &DoubleX_RMVXA::ECATB::BLOCKS[:ecatb_reset])
  4823.     #
  4824.   end # ecatb_pool_reset
  4825.  
  4826.   #----------------------------------------------------------------------------|
  4827.   #  Checks if the battler atb values should be continually updated            |
  4828.   #----------------------------------------------------------------------------|
  4829.   def ecatb_ctb_break? # v0.04d+; New; Hotspot
  4830.     return true if $game_message.visible
  4831.     # Checks if the battle ended, action's executing or command window's showing
  4832.     return true if $game_party.all_dead? || $game_troop.all_dead?
  4833.     return true unless @phase && @ecatb_can_esc && ecatb_ctb
  4834.     return true unless SceneManager.scene_is?(Scene_Battle)
  4835.     block = DoubleX_RMVXA::ECATB::BLOCKS
  4836.     return true if $game_party.alive_members.any?(&block[:ecatb_refresh])
  4837.     return true if $game_troop.alive_members.any?(&block[:ecatb_refresh])
  4838.     @action_battlers.any?(&block[:ecatb_ctb_break?])
  4839.     #
  4840.   end # ecatb_ctb_break?
  4841.  
  4842.   #----------------------------------------------------------------------------|
  4843.   #  Tries to pick an inputable actor and returns if the attempt succeeded     |
  4844.   #----------------------------------------------------------------------------|
  4845.   def ecatb_update_act_actor? # v0.04d+; New; Hotspot
  4846.     # Points the actor index to the 1st inputable actor if any
  4847.     return false if (act_list = ecatb_input_list(true)).empty?
  4848.     @actor_index = act_list[0]
  4849.     #
  4850.   end # ecatb_update_act_actor?
  4851.  
  4852.   #----------------------------------------------------------------------------|
  4853.   #  Picks the prior or next inputable actor and returns the result            |
  4854.   #----------------------------------------------------------------------------|
  4855.   # sign: Indicator of whether the prior or next actor is to be picked
  4856.   def change_ecatb_actor?(sign) # v0.04d+; New; Potential Hotspot
  4857.     # Points the actor index to the prior or next actor if any
  4858.     return false if (act_list = ecatb_input_list(true)).empty?
  4859.     act_list.sort! { |a, b| a * sign <=> b * sign }.each { |a_index|
  4860.       return @actor_index = a_index if @actor_index * sign < a_index * sign
  4861.     }
  4862.     @actor_index = act_list[0]
  4863.     #
  4864.   end # change_ecatb_actor?
  4865.  
  4866.   #----------------------------------------------------------------------------|
  4867.   #  Lets the compatibility fix deals with compatibility issues                |
  4868.   #----------------------------------------------------------------------------|
  4869.   def set_ecatb_esc_cost_compatibility # New
  4870.     0.1
  4871.   end # set_ecatb_esc_cost_compatibility
  4872.  
  4873. end # BattleManager
  4874.  
  4875. #------------------------------------------------------------------------------|
  4876. #  * Temporarily stores the blocks right before clearing them                  |
  4877. #------------------------------------------------------------------------------|
  4878. class Game_Temp # v0.02c+; Edit
  4879.  
  4880.   #----------------------------------------------------------------------------|
  4881.   #  New public instance variables                                             |
  4882.   #----------------------------------------------------------------------------|
  4883.   attr_accessor :ecatb_add_actors # The member adding flag
  4884.   attr_accessor :ecatb_remove_actors # The member removing flag
  4885.   attr_reader :ecatb_unison_actors # All battlers' cached unison actors
  4886.   attr_reader :last_ecatb_item # All battlers' cached last used item
  4887.  
  4888.   def init_ecatb_vars # v0.05a+; New
  4889.     @ecatb_add_actors = []
  4890.     @ecatb_remove_actors = []
  4891.     @ecatb_unison_actors = {}
  4892.     @last_ecatb_item = {}
  4893.   end # init_ecatb_vars
  4894.  
  4895.   def clear_ecatb_vars # v0.05a+; New
  4896.     @ecatb_add_actors = @ecatb_remove_actors = nil
  4897.     @ecatb_unison_actors = @last_ecatb_item = nil
  4898.   end # clear_ecatb_vars
  4899.  
  4900. end # Game_Temp
  4901.  
  4902. #------------------------------------------------------------------------------|
  4903. #  * Selects the battle system and stores all configuration values             |
  4904. #------------------------------------------------------------------------------|
  4905. class Game_System # Edit
  4906.  
  4907.   #----------------------------------------------------------------------------|
  4908.   #  New public instance variables                                             |
  4909.   #----------------------------------------------------------------------------|
  4910.   # Stores all configuration values
  4911.   DoubleX_RMVXA::ECATB::CONFIG.each { |configs|
  4912.     configs.each_key { |config| attr_accessor eval(":#{config.id2name}") }
  4913.   }
  4914.   #
  4915.  
  4916.   #----------------------------------------------------------------------------|
  4917.   #  Stores all configuration values as well                                   |
  4918.   #----------------------------------------------------------------------------|
  4919.   alias initialize_ecatb initialize
  4920.   def initialize(*argv, &argb)
  4921.     initialize_ecatb(*argv, &argb)
  4922.     init_ecatb_configs # Added
  4923.   end # initialize
  4924.  
  4925.   #----------------------------------------------------------------------------|
  4926.   #  Set the battle system as :ecatb for using the ecatb battle system         |
  4927.   #----------------------------------------------------------------------------|
  4928.   alias set_battle_system_ecatb set_battle_system
  4929.   def set_battle_system(type, &argb)
  4930.     return @battle_system = :ecatb if type == :ecatb # Added
  4931.     set_battle_system_ecatb(type, &argb)
  4932.   end # set_battle_system
  4933.  
  4934.   #----------------------------------------------------------------------------|
  4935.   #  Returns :ecatb if using the ecatb battle system                           |
  4936.   #----------------------------------------------------------------------------|
  4937.   alias battle_system_corrected_ecatb battle_system_corrected
  4938.   def battle_system_corrected(type, &argb)
  4939.     # Rewritten
  4940.     type == :ecatb ? :ecatb : battle_system_corrected_ecatb(type, &argb)
  4941.     #
  4942.   end # battle_system_corrected
  4943.  
  4944.   #----------------------------------------------------------------------------|
  4945.   #  Stores all configuration values into this class's new variables           |
  4946.   #----------------------------------------------------------------------------|
  4947.   def init_ecatb_configs # New
  4948.     DoubleX_RMVXA::ECATB::CONFIG.each { |configs|
  4949.       configs.each { |config, val| send(:"#{config}=", val) }
  4950.     }
  4951.   end # init_ecatb_configs
  4952.  
  4953. end # Game_System
  4954.  
  4955. #------------------------------------------------------------------------------|
  4956. #  * Adds the action input confirmation flag for action executions             |
  4957. #------------------------------------------------------------------------------|
  4958. class Game_Action # Edit
  4959.  
  4960.   #----------------------------------------------------------------------------|
  4961.   #  New public instance variables                                             |
  4962.   #----------------------------------------------------------------------------|
  4963.   attr_accessor :last_ecatb_confirm # The last action confirmation flag
  4964.   attr_writer :ecatb_confirm # The action confirmation flag
  4965.  
  4966.   #----------------------------------------------------------------------------|
  4967.   #  Cancel the input confirmation as well                                     |
  4968.   #----------------------------------------------------------------------------|
  4969.   alias clear_ecatb clear
  4970.   def clear(*argv, &argb)
  4971.     clear_ecatb(*argv, &argb)
  4972.     @ecatb_confirm = @last_ecatb_confirm = false # Added
  4973.   end # clear
  4974.  
  4975.   #----------------------------------------------------------------------------|
  4976.   #  Corrects the action confirmation flag before returning it                 |
  4977.   #----------------------------------------------------------------------------|
  4978.   def ecatb_confirm # New
  4979.     @ecatb_confirm ||= !@subject.inputable?
  4980.   end # ecatb_confirm
  4981.  
  4982. end # Game_Action
  4983.  
  4984. #------------------------------------------------------------------------------|
  4985. #  * Implements the battler's calculations and decision making criteria        |
  4986. #------------------------------------------------------------------------------|
  4987. class Game_BattlerBase # Edit
  4988.  
  4989.   #----------------------------------------------------------------------------|
  4990.   #  Raises the display redraw and cached notetag value reevaluation flags also|
  4991.   #----------------------------------------------------------------------------|
  4992.   alias erase_state_ecatb erase_state
  4993.   def erase_state(state_id, &argb)
  4994.     # Added
  4995.     if @states.include?(state_id)
  4996.       @ecatb_countdown_clock.delete(state_id)
  4997.       @ecatb_countdown_freeze.delete(state_id)
  4998.     end
  4999.     #
  5000.     erase_state_ecatb(state_id, &argb)
  5001.     set_ecatb_battler_change # Added
  5002.   end # erase_state
  5003.  
  5004.   #----------------------------------------------------------------------------|
  5005.   #  Raises the display redraw and cached notetag value reevaluation flags also|
  5006.   #----------------------------------------------------------------------------|
  5007.   alias tp_equal_ecatb tp=
  5008.   def tp=(tp, &argb)
  5009.     tp_equal_ecatb(tp, &argb)
  5010.     set_ecatb_battler_change # Added
  5011.   end # tp=
  5012.  
  5013.   #----------------------------------------------------------------------------|
  5014.   #  Raises the display redraw and cached notetag value reevaluation flags also|
  5015.   #----------------------------------------------------------------------------|
  5016.   alias refresh_ecatb refresh
  5017.   def refresh(*argv, &argb)
  5018.     refresh_ecatb(*argv, &argb)
  5019.     set_ecatb_battler_change # Added
  5020.   end # refresh
  5021.  
  5022.   #----------------------------------------------------------------------------|
  5023.   #  Resets the battler's atb values and clear all actions as well             |
  5024.   #----------------------------------------------------------------------------|
  5025.   alias hide_ecatb hide # v0.04c+
  5026.   def hide(*argv, &argb)
  5027.     hide_ecatb(*argv, &argb)
  5028.     ecatb_reset(true) # Added
  5029.   end # hide
  5030.  
  5031.   #----------------------------------------------------------------------------|
  5032.   #  Checks if the user's charging and the costs need to be paid now as well   |
  5033.   #----------------------------------------------------------------------------|
  5034.   alias skill_cost_payable_ecatb? skill_cost_payable?
  5035.   def skill_cost_payable?(skill, &argb)
  5036.     return true if skill_cost_payable_ecatb?(skill, &argb) # Rewritten
  5037.     # Added
  5038.     return false unless BattleManager.btype?(:ecatb)
  5039.     return false if @ecatb_val[:charge] <= 0.0
  5040.     !DoubleX_RMVXA::ECATB.send(skill.ecatb_charge_prior_item_cost, self)
  5041.     #
  5042.   end # skill_cost_payable?
  5043.  
  5044.   #----------------------------------------------------------------------------|
  5045.   #  Checks if all unison battlers have enough action points as well           |
  5046.   #----------------------------------------------------------------------------|
  5047.   alias usable_ecatb? usable?
  5048.   def usable?(item, &argb)
  5049.     # Added
  5050.     if BattleManager.btype?(:ecatb) && item && item.is_a?(RPG::UsableItem)
  5051.       if SceneManager.scene_is?(Scene_Battle)
  5052.         ecatb = DoubleX_RMVXA::ECATB
  5053.         if actor?
  5054.           actors = ecatb.send(item.ecatb_unison_actor, self).collect!(
  5055.           &ecatb::BLOCKS[:usable?])
  5056.           return ecatb_unison_usable?(item, actors) if actors.size > 1
  5057.         end
  5058.         return false if @ecatb_val[:charge] <= 0.0 && @ecatb_act_times <
  5059.         ecatb.send(item.ecatb_act_cost, self)
  5060.       end
  5061.     end
  5062.     #
  5063.     usable_ecatb?(item, &argb)
  5064.   end # usable?(item)
  5065.  
  5066.   # act_times: The number of action points
  5067.   def ecatb_act_times=(act_times) # New
  5068.     return if @ecatb_act_times == act_times
  5069.     @ecatb_act_times = act_times
  5070.     set_ecatb_battler_change
  5071.   end # ecatb_act_times=
  5072.  
  5073.   #----------------------------------------------------------------------------|
  5074.   #  Raises the display redraw and cached notetag value reevaluation flags     |
  5075.   #----------------------------------------------------------------------------|
  5076.   def set_ecatb_battler_change # New
  5077.     @ecatb_battler_change ||= {}
  5078.     [:act, :atb, :charge, :cooldown, :order_icon, :order_opacity, :order_scale,
  5079.      :order_z, :rate, :se, :speed].each { |t| @ecatb_battler_change[t] = true }
  5080.     @ecatb_refresh = true
  5081.   end # set_ecatb_battler_change
  5082.  
  5083.   #----------------------------------------------------------------------------|
  5084.   #  Returns the currently displayed atb bar type                              |
  5085.   #----------------------------------------------------------------------------|
  5086.   def ecatb_bar_type # New; Hotspot
  5087.     return :cooldown if @ecatb_val[:cooldown] > 0.0
  5088.     @ecatb_val[:charge] > 0.0 ? :charge : :atb
  5089.   end # ecatb_bar_type
  5090.  
  5091.   #----------------------------------------------------------------------------|
  5092.   #  Returns the charge gain and cooldown loss value per frame                 |
  5093.   #----------------------------------------------------------------------------|
  5094.   # v0.02c+; New; Hotspot
  5095.   DoubleX_RMVXA::ECATB::CHARGE_COOLDOWN_RATE.each_value { |v| module_eval(v) }
  5096.   #
  5097.  
  5098.   #----------------------------------------------------------------------------|
  5099.   #  Caches and returns the atb rate                                           |
  5100.   #----------------------------------------------------------------------------|
  5101.   def ecatb_gain_rate # New; Hotspot
  5102.     # Reevaluates the atb rate only if any of its determinators' changed
  5103.     return @ecatb_rate[:atb] unless BattleManager.ecatb_base_change ||
  5104.     ecatb_battler_change?(:rate)
  5105.     @ecatb_rate[:atb] = set_ecatb_gain_rate(BattleManager.ecatb_base.clone)
  5106.     #
  5107.   end # ecatb_gain_rate
  5108.  
  5109.   #----------------------------------------------------------------------------|
  5110.   #  Evaluates the value of all atb gain rate notetags using its ordering      |
  5111.   #----------------------------------------------------------------------------|
  5112.   # base: The base atb gain rate
  5113.   def set_ecatb_gain_rate(base) # v0.05a+; New; Potential Hotspot
  5114.     ecatb = DoubleX_RMVXA::ECATB
  5115.     ecatb_rate_ord.each { |data|
  5116.       next unless send(@ecatb_item[data][0])
  5117.       send(@ecatb_item[data][1]).each { |item|
  5118.         (0..(item.ecatb_notes[:rate].size - 1)).each { |index|
  5119.           next unless note = item.ecatb_notes[:rate][index]
  5120.           base[:val] = ecatb.send(note, self, base)
  5121.         }
  5122.       }
  5123.     }
  5124.     base[:val]
  5125.   end # set_ecatb_gain_rate
  5126.  
  5127.   #----------------------------------------------------------------------------|
  5128.   #  Sets the current battler gradual action gain flag when its notetags change|
  5129.   #----------------------------------------------------------------------------|
  5130.   def set_gradual_ecatb_act_gain # v0.05a+; New; Hotspot
  5131.     # Updates the battler gradual action gain notetags using the current order
  5132.     return @ecatb_notes[:act] unless ecatb_battler_change?(:act)
  5133.     @ecatb_notes[:act] = nil
  5134.     gradual_ecatb_action_gain_ord.each { |data|
  5135.       if send(@ecatb_item[data][0])
  5136.         set_ecatb_notes(send(@ecatb_item[data][1]), :act)
  5137.       end
  5138.       return @ecatb_notes[:act] unless @ecatb_notes[:act].nil?
  5139.     }
  5140.     @ecatb_notes[:act] = gradual_ecatb_action_gain
  5141.     #
  5142.   end # set_gradual_ecatb_act_gain
  5143.  
  5144.   #----------------------------------------------------------------------------|
  5145.   #  Sets the color of the current atb bar type when its notetags change       |
  5146.   #----------------------------------------------------------------------------|
  5147.   # type: The atb type
  5148.   def set_ecatb_bar_colors(type) # New; Potential Hotspot
  5149.     # Updates the color notetags using the current order of the current atb type
  5150.     @ecatb_notes[type].clear
  5151.     (color_ord = set_ecatb_bar_color_ord(type))[0].each { |data|
  5152.       if send(@ecatb_item[data][0])
  5153.         set_ecatb_bar_color_notes(send(@ecatb_item[data][1]), type)
  5154.       end
  5155.       return if @ecatb_notes[type].size == 2
  5156.     }
  5157.     color_ord[1].each_with_index { |color, i| @ecatb_notes[type][i] ||= color }
  5158.     #
  5159.   end # set_ecatb_bar_colors
  5160.  
  5161.   #----------------------------------------------------------------------------|
  5162.   #  Returns the atb bar color orders and default values for current type      |
  5163.   #----------------------------------------------------------------------------|
  5164.   # type: The atb type
  5165.   def set_ecatb_bar_color_ord(type) # New; Potential Hotspot
  5166.     return [ecatb_bar_color_ord, ecatb_bar_colors] if type == :atb
  5167.     if type == :charge
  5168.       return [ecatb_charge_bar_color_ord, ecatb_charge_bar_colors]
  5169.     elsif type == :cooldown
  5170.       return [ecatb_cooldown_bar_color_ord, ecatb_cooldown_bar_colors]
  5171.     end
  5172.     [[], []] # Does nothing if type stores an invalid value
  5173.   end # set_ecatb_bar_color_ord(type)
  5174.  
  5175.   #----------------------------------------------------------------------------|
  5176.   #  Evaluates the value of all atb bar color notetags using their orderings   |
  5177.   #----------------------------------------------------------------------------|
  5178.   # items: The data containing the notetags
  5179.   # note: The notetag type
  5180.   def set_ecatb_bar_color_notes(items, note) # v0.05a+; New; Potential Hotspot
  5181.     # Reads all item's atb bar color 1 and 2 notetag values
  5182.     ecatb = DoubleX_RMVXA::ECATB
  5183.     items.each { |item|
  5184.       return if @ecatb_notes[note].size >= 2
  5185.       n = item.ecatb_notes[note][0]
  5186.       @ecatb_notes[note][0] ||= ecatb.send(n, self) if n
  5187.       next unless n = item.ecatb_notes[note][1]
  5188.       @ecatb_notes[note][1] ||= ecatb.send(n, self)
  5189.     }
  5190.     #
  5191.   end # set_ecatb_bar_color_notes
  5192.  
  5193.   #----------------------------------------------------------------------------|
  5194.   #  Reads all atb order battler icon, opacity, scale and z notes              |
  5195.   #----------------------------------------------------------------------------|
  5196.   # v0.01a+; New; Potential Hotspot
  5197.   DoubleX_RMVXA::ECATB::ORDER.each_value { |method| module_eval(method) }
  5198.   #
  5199.  
  5200.   #----------------------------------------------------------------------------|
  5201.   #  Sets the current battler ready se when its notetags change                |
  5202.   #----------------------------------------------------------------------------|
  5203.   def set_ecatb_se_ready_act # New
  5204.     # Updates the battler ready se notetags using the current order
  5205.     return @ecatb_notes[:se] unless ecatb_battler_change?(:se)
  5206.     @ecatb_notes[:se] = nil
  5207.     ecatb_se_ready_act_ord.each { |data|
  5208.       if send(@ecatb_item[data][0])
  5209.         set_ecatb_notes(send(@ecatb_item[data][1]), :se)
  5210.       end
  5211.       return @ecatb_notes[:se] if @ecatb_notes[:se]
  5212.     }
  5213.     @ecatb_notes[:se] = ecatb_se_ready_act
  5214.     #
  5215.   end # set_ecatb_se_ready_act
  5216.  
  5217.   #----------------------------------------------------------------------------|
  5218.   #  Sets the current battler action input speed reduction in frames           |
  5219.   #----------------------------------------------------------------------------|
  5220.   def set_ecatb_speed_reduce # v0.02a+; New
  5221.     # Updates the battler speed reduce notetags using the current order
  5222.     ecatb = DoubleX_RMVXA::ECATB
  5223.     ecatb_speed_reduce_ord.each { |data|
  5224.       next unless send(@ecatb_item[data][0])
  5225.       send(@ecatb_item[data][1]).each { |item|
  5226.         (0..(item.ecatb_notes[:speed].size - 1)).each { |index|
  5227.           next unless note = item.ecatb_notes[:speed][index]
  5228.           ecatb.send(note, self)
  5229.         }
  5230.       }
  5231.     }
  5232.     #
  5233.   end # set_ecatb_speed_reduce
  5234.  
  5235.   #----------------------------------------------------------------------------|
  5236.   #  Sets the starting atb value of the start type at the start of a battle    |
  5237.   #----------------------------------------------------------------------------|
  5238.   # start: The battle start type
  5239.   def set_ecatb_start_val(start) # New
  5240.     # Updates the start notetags of the start type using the current order
  5241.     ecatb = DoubleX_RMVXA::ECATB
  5242.     ecatb_start_val_ord.each { |data|
  5243.       next unless send(@ecatb_item[data][0])
  5244.       send(@ecatb_item[data][1]).each { |item|
  5245.         (0..(item.ecatb_notes[start].size - 1)).each { |index|
  5246.           next unless note = item.ecatb_notes[start][index]
  5247.           ecatb.send(note, self)
  5248.         }
  5249.       }
  5250.     }
  5251.     #
  5252.   end # set_ecatb_start_val
  5253.  
  5254.   #----------------------------------------------------------------------------|
  5255.   #  Evaluates the value of all specified notetags using their orderings       |
  5256.   #----------------------------------------------------------------------------|
  5257.   # items: The data containing the notetags
  5258.   # note: The notetag type
  5259.   def set_ecatb_notes(items, note) # New; Potential Hotspot
  5260.     # Reads all item's speficied notetag values until the maximum size's reached
  5261.     ecatb = DoubleX_RMVXA::ECATB
  5262.     items.each { |item|
  5263.       return if @ecatb_notes[note]
  5264.       next unless n = item.ecatb_notes[note]
  5265.       @ecatb_notes[note] = ecatb.send(n, self)
  5266.     }
  5267.     #
  5268.   end # set_ecatb_notes
  5269.  
  5270.   #----------------------------------------------------------------------------|
  5271.   #  Checks if any new notetag added, old one gone or its value changed        |
  5272.   #----------------------------------------------------------------------------|
  5273.   # note: The notetag type to be checked
  5274.   def ecatb_battler_change?(note) # New; Hotspot
  5275.     change = @ecatb_note_change[note]
  5276.     @ecatb_note_change[note] &&= !change
  5277.     return change unless @ecatb_battler_change[note]
  5278.     !(@ecatb_battler_change[note] = false)
  5279.   end # ecatb_battler_change?
  5280.  
  5281.   #----------------------------------------------------------------------------|
  5282.   #  Checks if charging should take place                                      |
  5283.   #----------------------------------------------------------------------------|
  5284.   def ecatb_charge_update? # New; Hotspot
  5285.     return false if @ecatb_val[:cooldown] > 0.0 || @ecatb_val[:atb] < 100.0
  5286.     return false unless current_action
  5287.     return enemy? || current_action.ecatb_confirm if current_action.item
  5288.     !(@ecatb_val[:charge] = 0.0)
  5289.   end # ecatb_charge_update?
  5290.  
  5291.   #----------------------------------------------------------------------------|
  5292.   #  Checks if the unison skill/item can continue charging                     |
  5293.   #----------------------------------------------------------------------------|
  5294.   def ecatb_unison_charge_update? # New; Hotspot
  5295.     return false unless actor? && current_action && item = current_action.item
  5296.     # Rechecks the unison skill/item usability if any unison actor's refreshed
  5297.     return usable?(item) if @ecatb_unison_actors.any?(
  5298.     &DoubleX_RMVXA::ECATB::BLOCKS[:ecatb_refresh])
  5299.     #
  5300.     true
  5301.   end # ecatb_unison_charge_update?
  5302.  
  5303.   #----------------------------------------------------------------------------|
  5304.   #  Checks if the battler's actions should be executed                        |
  5305.   #----------------------------------------------------------------------------|
  5306.   def exec_ecatb_act? # New; Hotspot
  5307.     # Checks if the battler's valid and has valid input being fully charged
  5308.     return false if ecatb_val[:charge] < 100.0 || ecatb_val[:atb] < 100.0
  5309.     enemy? || input && input.item && input.ecatb_confirm
  5310.     #
  5311.   end # exec_ecatb_act?
  5312.  
  5313.   #----------------------------------------------------------------------------|
  5314.   #  Helper methods used by @ecatb_item                                        |
  5315.   #----------------------------------------------------------------------------|
  5316.  
  5317.   def ecatb_states # New; Potential Hotspot
  5318.     @states
  5319.   end # ecatb_states
  5320.  
  5321.   def ecatb_enemy # New; Potential Hotspot
  5322.     [enemy]
  5323.   end # ecatb_enemy
  5324.  
  5325.   def enemy # New; Potential Hotspot
  5326.   end # enemy
  5327.  
  5328.   def armors # New; Potential Hotspot
  5329.     []
  5330.   end # armors
  5331.  
  5332.   def weapons # New; Potential Hotspot
  5333.     []
  5334.   end # armors
  5335.  
  5336.   def ecatb_class # New; Potential Hotspot
  5337.     [self.class]
  5338.   end # ecatb_class
  5339.  
  5340.   def class # New; Potential Hotspot
  5341.   end # class
  5342.  
  5343.   def ecatb_actor # New; Potential Hotspot
  5344.     [actor]
  5345.   end # ecatb_actor
  5346.  
  5347.   def actor # New
  5348.   end # actor
  5349.  
  5350.   #----------------------------------------------------------------------------|
  5351.   #  Lets the compatibility fix deals with compatibility issues                |
  5352.   #----------------------------------------------------------------------------|
  5353.   def ecatb_reset_compatibility? # New
  5354.   end # ecatb_reset_compatibility?
  5355.  
  5356. end # Game_BattlerBase
  5357.  
  5358. #------------------------------------------------------------------------------|
  5359. #  * Implements the battler's atb actions, control flows and logics            |
  5360. #------------------------------------------------------------------------------|
  5361. class Game_Battler < Game_BattlerBase # Edit
  5362.  
  5363.   #----------------------------------------------------------------------------|
  5364.   #  New public instance variables                                             |
  5365.   #----------------------------------------------------------------------------|
  5366.   attr_accessor :ecatb_act_times_add # The action point increment
  5367.   attr_accessor :ecatb_act_times_cap # The action point cap reaching flag
  5368.   attr_accessor :ecatb_refresh # The refresh calling flag
  5369.   attr_accessor :ecatb_reset_val # The atb reset value upon resetting atb
  5370.   attr_accessor :ecatb_unison_invoker # The unison skill/item invoker flag
  5371.   attr_accessor :ecatb_val_change # The atb value change flags
  5372.   attr_reader :ecatb_act_times # The number of action points
  5373.   attr_reader :ecatb_countdown_freeze # The countdown freeze statuses
  5374.   attr_reader :ecatb_note_change # The notetag value change flags
  5375.   attr_reader :ecatb_notes # The caches of all notetags used
  5376.   attr_reader :ecatb_rate # The cached atb rates
  5377.   attr_reader :ecatb_unison_actors # The cached unison actor list
  5378.   attr_reader :ecatb_unison_rule # The cached unison charge/cooldown rule
  5379.   attr_reader :ecatb_val # The atb values
  5380.   attr_writer :ecatb_unison_item # The unison skill/item for damage evaluation
  5381.  
  5382.   #----------------------------------------------------------------------------|
  5383.   #  New private instance variables                                            |
  5384.   #----------------------------------------------------------------------------|
  5385.   # @ecatb_battler_change: The battler data change flags
  5386.   # @ecatb_countdown_updates: The countdown update method iterator block
  5387.   # @ecatb_item: The notetag value reader storing data types with their ordering
  5388.   # @ecatb_item_change: The skill/item usage change flags
  5389.   # @ecatb_speed_reduce: The action input speed frame number
  5390.   # @fail_ecatb_esc: The party escape attempt failure flag
  5391.   # @last_ecatb_item: The last item used/being used
  5392.   # @last_ecatb_rate: The last atb gain rate
  5393.   # @last_ecatb_speed_reduce: The last action input speed frame number
  5394.   # @max_ecatb_act_times The maximum number of action points
  5395.   # @temp_ecatb_act_times The temporary number of action points
  5396.  
  5397.   #----------------------------------------------------------------------------|
  5398.   #  Updates states with different auto removal timing to at different timings |
  5399.   #----------------------------------------------------------------------------|
  5400.   def update_state_turns # Rewrite
  5401.     ecatb_update_state_turns(2) # Rewritten
  5402.   end # update_state_turns
  5403.  
  5404.   #----------------------------------------------------------------------------|
  5405.   #  Fixes bugs and initializes all new variables as well                      |
  5406.   #----------------------------------------------------------------------------|
  5407.   alias initialize_ecatb initialize
  5408.   def initialize(*argv, &argb)
  5409.     initialize_ecatb(*argv, &argb)
  5410.     init_ecatb_vars # Added to let created methods to use new variables as well
  5411.   end # initialize
  5412.  
  5413.   #----------------------------------------------------------------------------|
  5414.   #  Raises the display redraw and cached notetag value reevaluation flags also|
  5415.   #----------------------------------------------------------------------------|
  5416.   alias clear_states_ecatb clear_states
  5417.   def clear_states(*argv, &argb)
  5418.     clear_states_ecatb(*argv, &argb)
  5419.     # Added
  5420.     set_ecatb_battler_change
  5421.     @ecatb_countdown_clock = {}
  5422.     @ecatb_countdown_freeze = {}
  5423.     #
  5424.   end # clear_states
  5425.  
  5426.   #----------------------------------------------------------------------------|
  5427.   #  Raises the display redraw and cached notetag value reevaluation flags also|
  5428.   #----------------------------------------------------------------------------|
  5429.   alias add_new_state_ecatb add_new_state # v0.05a+
  5430.   def add_new_state(state_id, &argb)
  5431.     add_new_state_ecatb(state_id, &argb)
  5432.     set_ecatb_battler_change # Added
  5433.   end # add_new_state
  5434.  
  5435.   #----------------------------------------------------------------------------|
  5436.   #  Clears the atb values but not action points in the ecatb battle system    |
  5437.   #----------------------------------------------------------------------------|
  5438.   alias on_restrict_ecatb on_restrict
  5439.   def on_restrict(*argv, &argb)
  5440.     # Rewritten
  5441.     return on_restrict_ecatb(*argv, &argb) unless BattleManager.btype?(:ecatb)
  5442.     #
  5443.     # Added
  5444.     ecatb_reset
  5445.     states.each { |s| remove_state(s.id) if s.remove_by_restriction }
  5446.     #
  5447.   end # on_restrict
  5448.  
  5449.   #----------------------------------------------------------------------------|
  5450.   #  Initializes the state's countdown as well if any                          |
  5451.   #----------------------------------------------------------------------------|
  5452.   alias reset_state_counts_ecatb reset_state_counts
  5453.   def reset_state_counts(state_id, &argb)
  5454.     reset_state_counts_ecatb(state_id, &argb)
  5455.     # Added
  5456.     return unless $data_states[state_id].ecatb_countdown_interval
  5457.     return unless @states.include?(state_id)
  5458.     @ecatb_countdown_clock[state_id] = 0
  5459.     @ecatb_countdown_freeze[state_id] = false
  5460.     #
  5461.   end # reset_state_counts
  5462.  
  5463.   #----------------------------------------------------------------------------|
  5464.   #  Ensures only 1 non forced action can be inputted and executed at a time   |
  5465.   #----------------------------------------------------------------------------|
  5466.   alias make_action_times_ecatb make_action_times
  5467.   def make_action_times(*argv, &argb)
  5468.     # Rewritten
  5469.     BattleManager.btype?(:ecatb) ? 1 : make_action_times_ecatb(*argv, &argb)
  5470.     #
  5471.   end # make_action_times
  5472.  
  5473.   #----------------------------------------------------------------------------|
  5474.   #  Preserves the existing actions but executes the forced one first instead  |
  5475.   #----------------------------------------------------------------------------|
  5476.   alias force_action_ecatb force_action
  5477.   def force_action(skill_id, target_index, &argb)
  5478.     # Added
  5479.     if BattleManager.btype?(:ecatb)
  5480.       return set_ecatb_force_action(skill_id, target_index)
  5481.     end
  5482.     #
  5483.     force_action_ecatb(skill_id, target_index, &argb)
  5484.   end # force_action
  5485.  
  5486.   #----------------------------------------------------------------------------|
  5487.   #  Sets and resets user's methods before and after using an unison skill/item|
  5488.   #----------------------------------------------------------------------------|
  5489.   alias make_damage_value_ecatb make_damage_value
  5490.   def make_damage_value(user, item, &argb)
  5491.     # Added
  5492.     if user.actor? && user.ecatb_unison_actors.size > 1
  5493.       user.ecatb_unison_item = item
  5494.     end
  5495.     #
  5496.     make_damage_value_ecatb(user, item, &argb)
  5497.     user.ecatb_unison_item = nil # Added
  5498.   end # make_damage_value
  5499.  
  5500.   #----------------------------------------------------------------------------|
  5501.   #  Asks all unison invokees to pay the skill/item costs for unison skill/item|
  5502.   #----------------------------------------------------------------------------|
  5503.   alias use_item_ecatb use_item
  5504.   def use_item(item, &argb)
  5505.     # Rewritten
  5506.     return use_item_ecatb(item, &argb) unless BattleManager.btype?(:ecatb)
  5507.     #
  5508.     # Added
  5509.     unless DoubleX_RMVXA::ECATB.send(item.ecatb_charge_prior_item_cost, self)
  5510.       return item.effects.each { |effect| item_global_effect_apply(effect) }
  5511.     end
  5512.     return if @ecatb_unison_actors.size <= 1
  5513.     @ecatb_unison_actors.each { |actor| actor.pay_skill_cost(item) }
  5514.     item.effects.each { |effect| item_global_effect_apply(effect) }
  5515.     #
  5516.   end # use_item
  5517.  
  5518.   #----------------------------------------------------------------------------|
  5519.   #  Updates states with Auto-removal Timing being Action End as well          |
  5520.   #----------------------------------------------------------------------------|
  5521.   alias on_action_end_ecatb on_action_end
  5522.   def on_action_end(*argv, &argb)
  5523.     on_action_end_ecatb(*argv, &argb)
  5524.     ecatb_update_state_turns(1) if BattleManager.btype?(:ecatb) # Added
  5525.   end # on_action_end
  5526.  
  5527.   #----------------------------------------------------------------------------|
  5528.   #  Removes buffs and debuffs having 0 remaining turns as well                |
  5529.   #----------------------------------------------------------------------------|
  5530.   alias on_turn_end_ecatb on_turn_end
  5531.   def on_turn_end(*argv, &argb)
  5532.     on_turn_end_ecatb(*argv, &argb)
  5533.     remove_buffs_auto if BattleManager.btype?(:ecatb) # Added
  5534.   end # on_turn_end
  5535.  
  5536.   #----------------------------------------------------------------------------|
  5537.   #  Frees up unnecessary memory usage upon battle end                         |
  5538.   #----------------------------------------------------------------------------|
  5539.   alias on_battle_end_ecatb on_battle_end
  5540.   def on_battle_end(*argv, &argb) # v0.02c+
  5541.     on_battle_end_ecatb(*argv, &argb)
  5542.     # Added to clear all new variables that are only used in battles
  5543.     clear_ecatb_vars
  5544.     #
  5545.   end # on_battle_end
  5546.  
  5547.   #----------------------------------------------------------------------------|
  5548.   #  Preserves the existing actions but executes the forced one first          |
  5549.   #----------------------------------------------------------------------------|
  5550.   def set_ecatb_force_action(skill_id, target_index) # New
  5551.     @ecatb_unison_invoker = false
  5552.     @ecatb_unison_rule.clear
  5553.     (act = Game_Action.new(self, true)).set_skill(skill_id)
  5554.     if target_index == -2
  5555.       act.target_index = last_target_index
  5556.     elsif target_index == -1
  5557.       act.decide_random_target
  5558.     else
  5559.       act.target_index = target_index
  5560.     end
  5561.     @actions.unshift(act)
  5562.   end # set_ecatb_force_action
  5563.  
  5564.   #----------------------------------------------------------------------------|
  5565.   #  Initializes all new variables before checking any configuration validities|
  5566.   #----------------------------------------------------------------------------|
  5567.   def init_ecatb_vars # New
  5568.     @ecatb_esc = false
  5569.     @ecatb_item_change = {}
  5570.     @ecatb_note_change = {}
  5571.     @ecatb_notes = {}
  5572.     [:atb, :charge, :cooldown].each { |type| @ecatb_notes[type] = [] }
  5573.     @ecatb_unison_actors = []
  5574.     @ecatb_unison_rule = {}
  5575.     init_ecatb_block
  5576.     init_ecatb_item_vars
  5577.     init_ecatb_val_vars
  5578.   end # init_ecatb_vars
  5579.  
  5580.   def init_ecatb_val_vars # New
  5581.     @ecatb_act_times = @ecatb_act_times_add = @temp_ecatb_act_times = 0
  5582.     @ecatb_speed_reduce = @last_ecatb_speed_reduce = 0
  5583.     @ecatb_rate = {}
  5584.     @ecatb_reset_val = 0.0
  5585.     @ecatb_val = { atb: 0.0, charge: 0.0, cooldown: 0.0 }
  5586.     @ecatb_val_change = true
  5587.     @last_ecatb_rate = { charge: -1, cooldown: -1 }
  5588.     @max_ecatb_act_times = 1
  5589.   end # init_ecatb_val_vars
  5590.  
  5591.   def init_ecatb_item_vars # New
  5592.     @ecatb_item = {}
  5593.     notes = [:states, :enemies, :armors, :weapons, :classes, :actors]
  5594.     conds = [:ecatb_states, :enemy?, :actor?, :actor?, :actor?, :actor?]
  5595.     items = [:states, :ecatb_enemy, :armors, :weapons, :ecatb_class,
  5596.              :ecatb_actor]
  5597.     notes.each_with_index { |n, i| @ecatb_item[n] = [conds[i], items[i]] }
  5598.   end # init_ecatb_item_vars
  5599.  
  5600.   #----------------------------------------------------------------------------|
  5601.   #  Initializes the new block to trade memory usage for time performance      |
  5602.   #----------------------------------------------------------------------------|
  5603.   def init_ecatb_block # New
  5604.     # Calls this block instead of an anonymous function per enumerable iteration
  5605.     @ecatb_countdown_updates = -> state_id {
  5606.       next if @ecatb_countdown_freeze[state_id]
  5607.       next if (@ecatb_countdown_clock[state_id] += 1) % ecatb_countdown_min != 0
  5608.       @ecatb_countdown_clock[state_id] %= Graphics.frame_rate * DoubleX_RMVXA::
  5609.       ECATB.send($data_states[state_id].ecatb_countdown_interval, self)
  5610.       next if @ecatb_countdown_clock[state_id] != 0
  5611.       if @state_turns[state_id] > 0
  5612.         @state_turns[state_id] -= 1
  5613.         set_ecatb_battler_change
  5614.       end
  5615.       ecatb_countdown_update_compatibility_3(state_id)
  5616.       next unless @ecatb_battler_sprite
  5617.       ecatb_countdown_update_compatibility_2(@ecatb_battler_sprite, state_id)
  5618.     }
  5619.     #
  5620.   end # init_ecatb_block
  5621.  
  5622.   #----------------------------------------------------------------------------|
  5623.   #  Clears all variables that are useless outside battles upon battle end     |
  5624.   #----------------------------------------------------------------------------|
  5625.   def clear_ecatb_vars # v0.05a+; New
  5626.     clear_ecatb_blocks
  5627.     @ecatb_item = @ecatb_item_change = @ecatb_note_change = @ecatb_notes = nil
  5628.     @ecatb_rate = @ecatb_unison_actors = @ecatb_unison_rule = @ecatb_val = nil
  5629.     @ecatb_val_change = nil
  5630.   end # clear_ecatb_vars
  5631.  
  5632.   #----------------------------------------------------------------------------|
  5633.   #  Clears all cached blocks used in battles                                  |
  5634.   #----------------------------------------------------------------------------|
  5635.   def clear_ecatb_blocks # v0.01a; New
  5636.     # Clears all cached notetag values, the unison actor id list and skill/item
  5637.     if @ecatb_notes
  5638.         if @ecatb_notes[:order_icon]
  5639.           bitmap = @ecatb_notes[:order_icon][0]
  5640.           bitmap.dispose if bitmap && !bitmap.disposed?
  5641.         end
  5642.         [:act, :order_icon, :order_opacity, :order_scale, :order_z, :se].each {
  5643.         |type| @ecatb_notes.delete(type) }
  5644.         [:atb, :charge, :cooldown].each { |type| @ecatb_notes[type].clear }
  5645.     end
  5646.     if $game_temp.ecatb_unison_actors
  5647.         $game_temp.ecatb_unison_actors[self] ||= @ecatb_unison_actors
  5648.         @ecatb_unison_actors.clear
  5649.     end
  5650.     if $game_temp.last_ecatb_item
  5651.         $game_temp.last_ecatb_item[self] ||= @last_ecatb_item
  5652.     end
  5653.     @ecatb_battler_sprite = @ecatb_countdown_updates = @last_ecatb_item = nil
  5654.     #
  5655.   end # clear_ecatb_blocks
  5656.  
  5657.   #----------------------------------------------------------------------------|
  5658.   #  Resets all cached blocks used in battles                                  |
  5659.   #----------------------------------------------------------------------------|
  5660.   def reset_ecatb_blocks # v0.01a; New
  5661.     # Marks that all cached notetag values have to reread and restores the rest
  5662.     set_ecatb_battler_change
  5663.     if $game_temp.ecatb_unison_actors && $game_temp.ecatb_unison_actors[self]
  5664.       @ecatb_unison_actors = $game_temp.ecatb_unison_actors.delete(self)
  5665.     end
  5666.     if $game_temp.last_ecatb_item && $game_temp.last_ecatb_item[self]
  5667.       @last_ecatb_item = $game_temp.last_ecatb_item.delete(self)
  5668.     end
  5669.     init_ecatb_block
  5670.     #
  5671.   end # reset_ecatb_blocks
  5672.  
  5673.   # start: The battle start type
  5674.   def set_ecatb_start_val(start = :start_0) # New
  5675.     init_ecatb_vars
  5676.     set_ecatb_battler_change
  5677.     # Applies all the read notetag values to the default starting atb value
  5678.     default_ecatb_start_val(start)
  5679.     super(start)
  5680.     #
  5681.   end # set_ecatb_start_val
  5682.  
  5683.   # timing: The state auto removal timing
  5684.   def ecatb_update_state_turns(timing) # New
  5685.     change = false
  5686.     states.each { |state|
  5687.       next if @state_turns[state.id] <= 0 || state.auto_removal_timing != timing
  5688.       @state_turns[state.id] -= 1
  5689.       change = true
  5690.     }
  5691.     set_ecatb_battler_change if change
  5692.   end # ecatb_update_state_turns
  5693.  
  5694.   #----------------------------------------------------------------------------|
  5695.   #  Performs all the battler's atb frame updates                              |
  5696.   #----------------------------------------------------------------------------|
  5697.   def ecatb_updates # New; Hotspot
  5698.     unless @ecatb_val[:atb] <= 100.0 || set_gradual_ecatb_act_gain
  5699.       @temp_ecatb_act_times = @max_ecatb_act_times
  5700.       @ecatb_val[:atb] = 100.0
  5701.       @max_ecatb_act_times = 1
  5702.     end
  5703.     return unless @ecatb_esc || movable = restriction < 4
  5704.     # Updates the atb values, speed and countdown statuses and makes actions
  5705.     ecatb_val_updates(movable)
  5706.     ecatb_countdown_update unless @ecatb_countdown_clock.empty?
  5707.     #
  5708.   end # ecatb_updates
  5709.  
  5710.   #----------------------------------------------------------------------------|
  5711.   #  (v0.04c)Updates atb, charge and cooldown, speed reduce and makes actions  |
  5712.   #----------------------------------------------------------------------------|
  5713.   def ecatb_val_updates(movable) # New; Hotspot
  5714.     return ecatb_charge_update if @ecatb_esc || movable && ecatb_charge_update?
  5715.     if !@ecatb_esc && movable
  5716.       return ecatb_cooldown_update if @ecatb_val[:cooldown] > 0.0
  5717.       ecatb_update if @ecatb_val[:atb] < 100.0 * @max_ecatb_act_times
  5718.       return if @ecatb_val[:atb] < 100.0
  5719.       return ecatb_speed_reduce_update if @ecatb_speed_reduce > 0
  5720.     end
  5721.     make_ecatb_act unless @ecatb_val[:atb] < 100.0 || @ecatb_val[:charge] >
  5722.     0.0 || ecatb_reset_compatibility? || actor? && inputable? &&
  5723.     current_action && current_action.item && current_action.ecatb_confirm
  5724.   end # ecatb_val_updates
  5725.  
  5726.   #----------------------------------------------------------------------------|
  5727.   #  Updates the atb cooldown value and triggers cooldown finish upon finishing|
  5728.   #----------------------------------------------------------------------------|
  5729.   def ecatb_cooldown_update # New; Hotspot
  5730.     @ecatb_val[:cooldown] -= ecatb_cooldown_loss_rate
  5731.     return if @ecatb_val[:cooldown] > 0.0
  5732.     @ecatb_val[:cooldown] = 0.0 if @ecatb_val[:cooldown] < 0.0
  5733.     @ecatb_unison_actors.clear
  5734.     @ecatb_unison_invoker = @fail_ecatb_esc = false
  5735.     @ecatb_unison_rule.clear
  5736.     ecatb_cooldown_finish
  5737.   end # ecatb_cooldown_update
  5738.  
  5739.   def ecatb_update # New; Hotspot
  5740.     # Raises the change flag upon atb value change and caps it to its max
  5741.     @ecatb_val_change = @ecatb_val[:atb] != @ecatb_val[:atb] += ecatb_gain_rate
  5742.     max = 100.0 * @max_ecatb_act_times
  5743.     @ecatb_val[:atb] = max if @ecatb_val[:atb] > max
  5744.     #
  5745.   end # ecatb_update
  5746.  
  5747.   #----------------------------------------------------------------------------|
  5748.   #  Updates the atb action input speed reduction by frames                    |
  5749.   #----------------------------------------------------------------------------|
  5750.   def ecatb_speed_reduce_update # v0.02a+; New; Hotspot
  5751.     # Returns the cached value unless it's to be reevalauted
  5752.     return set_ecatb_speed_reduce if ecatb_battler_change?(:speed)
  5753.     @ecatb_speed_reduce = 0 if (@ecatb_speed_reduce -= 1) < 0
  5754.     #
  5755.   end # ecatb_speed_reduce_update
  5756.  
  5757.   #----------------------------------------------------------------------------|
  5758.   #  Sets the atb action input speed reduction by frames                       |
  5759.   #----------------------------------------------------------------------------|
  5760.   def set_ecatb_speed_reduce # v0.02a+; New; Potential Hotspot
  5761.     # Adds the difference between the new and old to the current speed reduction
  5762.     last_speed_reduce = @last_ecatb_speed_reduce
  5763.     ecatb_speed_reduce
  5764.     super
  5765.     @ecatb_speed_reduce += @last_ecatb_speed_reduce - last_speed_reduce
  5766.     @ecatb_speed_reduce = 0 if @ecatb_speed_reduce < 0
  5767.     #
  5768.   end # set_ecatb_speed_reduce
  5769.  
  5770.   #----------------------------------------------------------------------------|
  5771.   #  Updates the atb charge value including the unison version                 |
  5772.   #----------------------------------------------------------------------------|
  5773.   def ecatb_charge_update # New; Hotspot
  5774.     unless @ecatb_unison_actors.size <= 1 || ecatb_unison_charge_update?
  5775.       return ecatb_reset
  5776.     end
  5777.     @ecatb_val[:charge] += ecatb_charge_gain_rate
  5778.     @ecatb_val[:charge] = 100.0 if @ecatb_val[:charge] > 100.0
  5779.   end # ecatb_charge_update
  5780.  
  5781.   #----------------------------------------------------------------------------|
  5782.   #  Makes actions and marks the battler as actable upon becoming able to act  |
  5783.   #----------------------------------------------------------------------------|
  5784.   def make_ecatb_act # New; Hotspot
  5785.     if @ecatb_act_times <= 0
  5786.       make_gradual_ecatb_act_gain
  5787.     elsif @ecatb_val[:atb] > 100.0
  5788.       make_ecatb_act_pool
  5789.     end
  5790.     BattleManager.make_ecatb_act(self)
  5791.   end # make_ecatb_act
  5792.  
  5793.   def make_gradual_ecatb_act_gain # v0.05a+; New
  5794.     unless set_gradual_ecatb_act_gain
  5795.       return @ecatb_act_times_add = @ecatb_act_times =
  5796.       @temp_ecatb_act_times = make_action_times_ecatb
  5797.     end
  5798.     @ecatb_act_times_add = @ecatb_act_times = @temp_ecatb_act_times = 1
  5799.     @max_ecatb_act_times = make_action_times_ecatb
  5800.     # Prevents the previously reset atb value from exceeding the new maximum
  5801.     max = 100.0 * @max_ecatb_act_times
  5802.     @ecatb_val[:atb] = max if @ecatb_val[:atb] > max
  5803.     #
  5804.     set_ecatb_battler_change
  5805.   end # make_gradual_ecatb_act_gain
  5806.  
  5807.   #----------------------------------------------------------------------------|
  5808.   #  Synchronize the party/troop action point pool when changing action points |
  5809.   #----------------------------------------------------------------------------|
  5810.   def make_ecatb_act_pool # v0.05a+; New; Hotspot
  5811.     # Ensures that all party/troop members change their action points together
  5812.     return if
  5813.     (act_add = @ecatb_val[:atb].to_i / 100 - @temp_ecatb_act_times) == 0
  5814.     @ecatb_act_times_add = act_add
  5815.     return if @ecatb_act_times_cap =
  5816.     @temp_ecatb_act_times >= @max_ecatb_act_times
  5817.     @ecatb_act_times += @ecatb_act_times_add
  5818.     @temp_ecatb_act_times += @ecatb_act_times_add
  5819.     set_ecatb_battler_change
  5820.     #
  5821.   end # make_ecatb_act_pool
  5822.  
  5823.   #----------------------------------------------------------------------------|
  5824.   #  Updates all states' countdown clocks that aren't frozen if any            |
  5825.   #----------------------------------------------------------------------------|
  5826.   def ecatb_countdown_update # New; Hotspot
  5827.     @ecatb_battler_sprite ||= ecatb_countdown_update_compatibility_1
  5828.     # Checks if the clocks are divisible by seconds to boost time performance
  5829.     @ecatb_countdown_clock.each_key(&@ecatb_countdown_updates)
  5830.     #
  5831.     remove_states_auto(3)
  5832.   end # ecatb_countdown_update
  5833.  
  5834.   def confirm_ecatb_item # New
  5835.     # Recaches the cached values upon changes and pays costs now if specified
  5836.     @ecatb_item_change[:charge] = @ecatb_item_change[:cooldown] =
  5837.     @last_ecatb_item != @last_ecatb_item = current_action.item
  5838.     pay_prior_ecatb_charge if @last_ecatb_item
  5839.     #
  5840.   end # confirm_ecatb_item
  5841.  
  5842.   def pay_prior_ecatb_charge # New
  5843.     ecatb = DoubleX_RMVXA::ECATB
  5844.     unless ecatb.send(@last_ecatb_item.ecatb_charge_prior_act_cost, self)
  5845.       pay_ecatb_unison_act_cost
  5846.     end
  5847.     return if ecatb.send(@last_ecatb_item.ecatb_charge_prior_item_cost, self)
  5848.     return consume_item(@last_ecatb_item) if @last_ecatb_item.is_a?(RPG::Item)
  5849.     pay_skill_cost(@last_ecatb_item) if @last_ecatb_item.is_a?(RPG::Skill)
  5850.   end # pay_prior_ecatb_charge
  5851.  
  5852.   #----------------------------------------------------------------------------|
  5853.   #  Pays the action cost and sets the atb reset value unless it's forced      |
  5854.   #----------------------------------------------------------------------------|
  5855.   # forced: The action force flag
  5856.   def exec_ecatb_act_cost(forced) # New
  5857.     return unless current_action && item = current_action.item
  5858.     ecatb = DoubleX_RMVXA::ECATB
  5859.     if (force_act_cost = ecatb.send(item.ecatb_force_act_cost, self)) || !forced
  5860.       # Pays the action cost now if the skill/item requests so
  5861.       if ecatb.send(item.ecatb_charge_prior_act_cost, self)
  5862.         pay_ecatb_unison_act_cost
  5863.       end
  5864.       #
  5865.       set_ecatb_reset_val
  5866.     end
  5867.     force_act_cost
  5868.   end # exec_ecatb_act_cost
  5869.  
  5870.   def pay_ecatb_unison_act_cost # New
  5871.     return pay_ecatb_act_cost if @ecatb_unison_actors.size <= 1
  5872.     @ecatb_unison_actors.each(
  5873.     &DoubleX_RMVXA::ECATB::BLOCKS[:pay_ecatb_act_cost])
  5874.   end # pay_ecatb_unison_act_cost
  5875.  
  5876.   def pay_ecatb_act_cost # New
  5877.     return unless current_action && item = current_action.item
  5878.     set_ecatb_battler_change
  5879.     cost = DoubleX_RMVXA::ECATB.send(item.ecatb_act_cost, self)
  5880.     @temp_ecatb_act_times -= cost
  5881.     unless friends_unit.ecatb_pool
  5882.       @ecatb_val[:atb] -= cost * 100.0 if set_gradual_ecatb_act_gain
  5883.       return @ecatb_act_times -= cost
  5884.     end
  5885.     size = (members = friends_unit.alive_members).size
  5886.     members.each { |mem|
  5887.       mem.ecatb_act_times -= cost
  5888.       next unless mem.set_gradual_ecatb_act_gain
  5889.       mem.ecatb_val[:atb] -= cost * 100.0 / size
  5890.     }
  5891.   end # pay_ecatb_act_cost
  5892.  
  5893.   def set_ecatb_reset_val # New
  5894.     # Sets all unison invokee's atb reset values as well for unison skill/item
  5895.     val = current_action.item.ecatb_reset_val
  5896.     @ecatb_reset_val = (ecatb = DoubleX_RMVXA::ECATB).send(val, self)
  5897.     return if @ecatb_unison_actors.size <= 1
  5898.     (@ecatb_unison_actors & $game_party.alive_members).each{ |actor|
  5899.       actor.ecatb_reset_val = ecatb.send(val, actor)
  5900.     }
  5901.     #
  5902.   end # set_ecatb_reset_val
  5903.  
  5904.   #----------------------------------------------------------------------------|
  5905.   #  Resets the atb values and reset value, speed reduce and action points     |
  5906.   #----------------------------------------------------------------------------|
  5907.   # reset: The atb reset flag
  5908.   def ecatb_reset(reset = restriction > 3) # New
  5909.     # Pays the escape cost, refreshes the battler and triggers the pre and post
  5910.     pre_ecatb_reset
  5911.     pay_ecatb_esc_cost if @ecatb_esc
  5912.     @ecatb_speed_reduce = 0
  5913.     @ecatb_val_change = true
  5914.     return ecatb_val_reset_compatibility(reset) if ecatb_reset_compatibility?
  5915.     BattleManager.del_ecatb_act(self)
  5916.     ecatb_act_val_reset(reset)
  5917.     post_ecatb_reset
  5918.     set_ecatb_battler_change
  5919.     #
  5920.   end # ecatb_reset
  5921.  
  5922.   # reset: The atb reset flag
  5923.   def ecatb_act_val_reset(reset) # New
  5924.     @ecatb_val[:cooldown] = 0.0 if dead?
  5925.     use_ecatb_reset_val if reset || @ecatb_act_times <= 0
  5926.     @temp_ecatb_act_times = @ecatb_act_times = 0 if reset &&
  5927.     @ecatb_act_times > 0
  5928.     @max_ecatb_act_times = 1 if reset || @ecatb_act_times <= 0
  5929.     ecatb_unison_reset(reset)
  5930.     @ecatb_val[:charge] = 0.0
  5931.     return if @ecatb_act_times > 0 && index && restriction <= 0
  5932.     @ecatb_reset_val = 0.0
  5933.   end # ecatb_act_val_reset
  5934.  
  5935.   def use_ecatb_reset_val # v0.04d+; New
  5936.     BattleManager.ecatb_pool_reset(self, @ecatb_unison_actors) if
  5937.     friends_unit.ecatb_pool
  5938.     @ecatb_val[:atb] = @ecatb_reset_val
  5939.     return @ecatb_val[:atb] = 0.0 if @ecatb_val[:atb] < 0.0
  5940.     max = 100.0 * @max_ecatb_act_times
  5941.     @ecatb_val[:atb] = max if @ecatb_val[:atb] > max
  5942.   end # use_ecatb_reset_val
  5943.  
  5944.   def ecatb_unison_reset(reset) # v0.05a+; New
  5945.     # Clears the unison actor and invoker cache if there's no unison cooldown
  5946.     if reset || @ecatb_val[:charge] < 100.0
  5947.       @ecatb_unison_actors.clear
  5948.       @ecatb_unison_invoker = false
  5949.       return @ecatb_unison_rule.clear
  5950.     end
  5951.     #
  5952.     @ecatb_val[:cooldown] = 100.0
  5953.   end # ecatb_unison_reset
  5954.  
  5955.   #----------------------------------------------------------------------------|
  5956.   #  Lets the compatibility fix deals with compatibility issues                |
  5957.   #----------------------------------------------------------------------------|
  5958.  
  5959.   def ecatb_countdown_update_compatibility_1 # New; Hotspot
  5960.   end # ecatb_countdown_update_compatibility_1
  5961.  
  5962.   def ecatb_countdown_update_compatibility_2(battler_sprite, state_id) # New;
  5963.   # Potential Hotspot
  5964.   end # ecatb_countdown_update_compatibility_2
  5965.  
  5966.   def ecatb_countdown_update_compatibility_3(state_id) # New; Potential Hotspot
  5967.   end # ecatb_countdown_update_compatibility_3
  5968.  
  5969.   # reset: The atb reset flag
  5970.   def ecatb_val_reset_compatibility(reset) # New
  5971.   end # ecatb_val_reset_compatibility
  5972.  
  5973. end # Game_Battler
  5974.  
  5975. #------------------------------------------------------------------------------|
  5976. #  * Implements the actor's additional atb actions, control flows and logics   |
  5977. #------------------------------------------------------------------------------|
  5978. class Game_Actor < Game_Battler # Edit
  5979.  
  5980.   #----------------------------------------------------------------------------|
  5981.   #  New public instance variable                                              |
  5982.   #----------------------------------------------------------------------------|
  5983.   attr_accessor :ecatb_esc # The party escape attempt flag
  5984.  
  5985.   #----------------------------------------------------------------------------|
  5986.   #  New private instance variable                                             |
  5987.   #----------------------------------------------------------------------------|
  5988.   # @ecatb_reserve: The reserved member flag
  5989.  
  5990.   #----------------------------------------------------------------------------|
  5991.   #  Creates new methods of all configurations used by actors as well          |
  5992.   #----------------------------------------------------------------------------|
  5993.   alias setup_ecatb setup
  5994.   def setup(actor_id, &argb)
  5995.     setup_ecatb(actor_id, &argb)
  5996.     # Added to fix nil @action_input_index and actors added during battle bugs
  5997.     @action_input_index = 0
  5998.     @ecatb_reserve = true
  5999.     create_ecatb_defs
  6000.     #
  6001.   end # setup
  6002.  
  6003.   #----------------------------------------------------------------------------|
  6004.   #  Confirms inputs made with the auto battle status as well                  |
  6005.   #----------------------------------------------------------------------------|
  6006.   alias make_auto_battle_actions_ecatb make_auto_battle_actions
  6007.   def make_auto_battle_actions(*argv, &argb) # v0.00d+
  6008.     make_auto_battle_actions_ecatb(*argv, &argb)
  6009.     # Added
  6010.     return unless BattleManager.btype?(:ecatb)
  6011.     confirm_ecatb_item
  6012.     set_ecatb_speed_reduce
  6013.     #
  6014.   end # make_auto_battle_actions
  6015.  
  6016.   #----------------------------------------------------------------------------|
  6017.   #  Confirms inputs made with the confusion status as well                    |
  6018.   #----------------------------------------------------------------------------|
  6019.   alias make_confusion_actions_ecatb make_confusion_actions
  6020.   def make_confusion_actions(*argv, &argb) # v0.00d+
  6021.     make_confusion_actions_ecatb(*argv, &argb)
  6022.     # Added
  6023.     return unless BattleManager.btype?(:ecatb)
  6024.     confirm_ecatb_item
  6025.     set_ecatb_speed_reduce
  6026.     #
  6027.   end # make_confusion_actions
  6028.  
  6029.   #----------------------------------------------------------------------------|
  6030.   #  Ensures actors added during battles are properly initialized as well      |
  6031.   #----------------------------------------------------------------------------|
  6032.   def on_battle_end(*argv, &argb) # v0.04e+; New
  6033.     super(*argv, &argb)
  6034.     @ecatb_reserve = true
  6035.   end # on_battle_end
  6036.  
  6037.   #----------------------------------------------------------------------------|
  6038.   #  Creates and checks the associated method for each configuration used here |
  6039.   #----------------------------------------------------------------------------|
  6040.   # config: The configuration requesting its associated method
  6041.   # validate: The configuration value validation flag
  6042.   def create_ecatb_def(config, validate = true) # New
  6043.     # Uses the name and value of configuration as its method's name and contents
  6044.     method = config.id2name
  6045.     eval(%Q(
  6046.   def #{method}#{DoubleX_RMVXA::ECATB::GAME_ACTOR[config][0]}
  6047.     #{$game_system.send(config)}
  6048.   end
  6049.     ))
  6050.     #
  6051.     return unless validate
  6052.     check_ecatb_def(method, DoubleX_RMVXA::ECATB::GAME_ACTOR[config])
  6053.   end # create_ecatb_def
  6054.  
  6055.   #----------------------------------------------------------------------------|
  6056.   #  Checks all new methods and resets them to the defaults if they're invalid |
  6057.   #----------------------------------------------------------------------------|
  6058.   module_eval(DoubleX_RMVXA::ECATB::CHECK_RESET_DEF[:GAME_ACTOR]) # New
  6059.  
  6060.   #----------------------------------------------------------------------------|
  6061.   #  Ensures actors added during battles are properly initialized as well      |
  6062.   #----------------------------------------------------------------------------|
  6063.   def set_ecatb_start_val(start = :start_0) # v0.04e+; New
  6064.     super(start)
  6065.     @ecatb_reserve = false
  6066.   end # set_ecatb_start_val
  6067.  
  6068.   # start: The battle start type
  6069.   def default_ecatb_start_val(start) # New
  6070.     return normal_actor_1st_ecatb_val if start == :start_0
  6071.     return preemptive_actor_1st_ecatb_val if start == :start_1
  6072.     surprise_actor_1st_ecatb_val
  6073.   end # default_ecatb_start_val
  6074.  
  6075.   #----------------------------------------------------------------------------|
  6076.   #  Ensures actors added during battles are properly initialized as well      |
  6077.   #----------------------------------------------------------------------------|
  6078.   def ecatb_updates # v0.04e+; New ; Hotspot
  6079.     if @ecatb_reserve
  6080.       init_ecatb_vars
  6081.       @ecatb_reserve = false
  6082.     end
  6083.     super
  6084.   end # ecatb_updates
  6085.  
  6086.   def confirm_ecatb_item # New
  6087.     super
  6088.     input.ecatb_confirm = input.last_ecatb_confirm = true
  6089.     # Caches the unison actors, charge and cooldown rules if any as well
  6090.     ecatb = DoubleX_RMVXA::ECATB
  6091.     @ecatb_unison_actors = ecatb.send(@last_ecatb_item.ecatb_unison_actor, self)
  6092.     @ecatb_unison_actors.collect!(&ecatb::BLOCKS[:usable?])
  6093.     if @ecatb_unison_invoker
  6094.       @ecatb_unison_rule[:charge] = ecatb.send(
  6095.       @last_ecatb_item.ecatb_unison_charge_rule, self)
  6096.       @ecatb_unison_rule[:cooldown] = ecatb.send(
  6097.       @last_ecatb_item.ecatb_unison_cooldown_rule, self)
  6098.     end
  6099.     #
  6100.     post_ecatb_input_act
  6101.     set_ecatb_battler_change
  6102.   end # confirm_ecatb_item
  6103.  
  6104.   def init_ecatb_escape # v0.05a+; New
  6105.     @ecatb_esc = @ecatb_item_change[:charge] = true
  6106.     @ecatb_unison_actors.clear
  6107.     @ecatb_unison_invoker = false
  6108.     @ecatb_unison_rule.clear
  6109.     BattleManager.del_ecatb_act(self)
  6110.   end # init_ecatb_escape
  6111.  
  6112.   def pay_ecatb_esc_cost # New
  6113.     @ecatb_act_times -= cost = ecatb_esc_act_cost
  6114.     @temp_ecatb_act_times -= cost
  6115.     @ecatb_reset_val = ecatb_esc_reset_val
  6116.     @ecatb_val[:atb] -= cost * 100.0 if @ecatb_val[:atb] > 100.0
  6117.     @ecatb_val[:charge] = 100.0
  6118.     @ecatb_esc = false
  6119.     @ecatb_item_change[:cooldown] = @fail_ecatb_esc = true
  6120.     set_ecatb_battler_change
  6121.   end # pay_ecatb_esc_cost
  6122.  
  6123.   def ecatb_inputable? # New; Hotspot
  6124.     return false if @ecatb_val[:charge] > 0.0 || @ecatb_val[:cooldown] > 0.0
  6125.     @ecatb_act_times > 0 && inputable? && !ecatb_reset_compatibility?
  6126.   end # ecatb_inputable?
  6127.  
  6128.   # actors: The unison actors
  6129.   def ecatb_unison_usable?(item, actors) # New
  6130.     return false unless item.is_a?(RPG::UsableItem) && actors.include?(self)
  6131.     # Checks if all unison actors are inputable and can use the skill/item
  6132.     return false unless (actors - BattleManager.ecatb_actor_act_list).empty?
  6133.     unless actors.all? { |actor| actor.ecatb_unison_actor?(item, actors) }
  6134.       return false
  6135.     end
  6136.     #
  6137.     ecatb_unison_skill_item_usable?(item, actors)
  6138.   end # ecatb_unison_usable?
  6139.  
  6140.   #----------------------------------------------------------------------------|
  6141.   #  Checks if the actor's can input the skill/item and pay its costs          |
  6142.   #----------------------------------------------------------------------------|
  6143.   # actors: The unison actors
  6144.   def ecatb_unison_actor?(item, actors) # New
  6145.     return false unless inputable?
  6146.     return false unless item.is_a?(RPG::Skill) || item_conditions_met?(item)
  6147.     return false unless skills.include?(item) || skill_conditions_met?(item)
  6148.     cost = (ecatb = DoubleX_RMVXA::ECATB).send(item.ecatb_act_cost, self)
  6149.     cost *= actors.size if $game_party.ecatb_pool
  6150.     return true if @ecatb_act_times >= cost
  6151.     return false if @ecatb_val[:charge] <= 0.0
  6152.     !ecatb.send(item.ecatb_charge_prior_act_cost, self)
  6153.   end # ecatb_unison_actor?
  6154.  
  6155.   #----------------------------------------------------------------------------|
  6156.   #  Checks if the unison actors can input or use the unison skill/item        |
  6157.   #----------------------------------------------------------------------------|
  6158.   # actors: The unison actors
  6159.   def ecatb_unison_skill_item_usable?(item, actors) # New
  6160.     # Checks if all unison actors are inputable or they're all charging
  6161.     input = charge = true
  6162.     actors.each { |actor|
  6163.       act = actor.current_action
  6164.       input &&= (!act || !act.item) && actor.ecatb_val[:charge] <= 0.0
  6165.       charge &&= act && act.item == item
  6166.       return false unless input || charge
  6167.     }
  6168.     #
  6169.   end # ecatb_unison_skill_item_usable?
  6170.  
  6171. end # Game_Actor
  6172.  
  6173. #------------------------------------------------------------------------------|
  6174. #  * Implements the enemy's additional atb actions, control flows and logics   |
  6175. #------------------------------------------------------------------------------|
  6176. class Game_Enemy < Game_Battler # New
  6177.  
  6178.   #----------------------------------------------------------------------------|
  6179.   #  New private instance variables                                            |
  6180.   #----------------------------------------------------------------------------|
  6181.   # @ecatb_bar_show: The cached atb bar part display flags with display details
  6182.   # @ecatb_state_change: The state change flags
  6183.  
  6184.   #----------------------------------------------------------------------------|
  6185.   #  Confirms the action and pays its now if charge prior costs are true also  |
  6186.   #----------------------------------------------------------------------------|
  6187.   alias make_actions_ecatb make_actions
  6188.   def make_actions(*argv, &argb)
  6189.     make_actions_ecatb(*argv, &argb)
  6190.     # Added
  6191.     return unless BattleManager.btype?(:ecatb)
  6192.     return unless current_action && current_action.item
  6193.     confirm_ecatb_item
  6194.     set_ecatb_speed_reduce
  6195.     #
  6196.   end # make_actions
  6197.  
  6198.   #----------------------------------------------------------------------------|
  6199.   #  Creates and checks the associated method for each configuration used here |
  6200.   #----------------------------------------------------------------------------|
  6201.   # config: The configuration requesting its associated method
  6202.   # validate: The configuration value validation flag
  6203.   def create_ecatb_def(config, validate = true) # New
  6204.     # Uses the name and value of configuration as its method's name and contents
  6205.     method = config.id2name
  6206.     eval(%Q(
  6207.   def #{method}#{DoubleX_RMVXA::ECATB::GAME_ENEMY[config][0]}
  6208.     #{$game_system.send(config)}
  6209.   end
  6210.     ))
  6211.     #
  6212.     return unless validate
  6213.     check_ecatb_def(method, DoubleX_RMVXA::ECATB::GAME_ENEMY[config])
  6214.   end # create_ecatb_def
  6215.  
  6216.   #----------------------------------------------------------------------------|
  6217.   #  Checks all new methods and resets them to the defaults if they're invalid |
  6218.   #----------------------------------------------------------------------------|
  6219.   module_eval(DoubleX_RMVXA::ECATB::CHECK_RESET_DEF[:GAME_ENEMY]) # New
  6220.  
  6221.   #----------------------------------------------------------------------------|
  6222.   #  Marks that the state array changed as well                                |
  6223.   #----------------------------------------------------------------------------|
  6224.   def erase_state(state_id, &argb) # New
  6225.     @ecatb_state_change = [true, true, true, true] if @states.include?(state_id)
  6226.     super(state_id, &argb)
  6227.   end # erase_state
  6228.  
  6229.   #----------------------------------------------------------------------------|
  6230.   #  Marks that the state array changed as well                                |
  6231.   #----------------------------------------------------------------------------|
  6232.   def clear_states(*argv, &argb) # New
  6233.     super(*argv, &argb)
  6234.     @ecatb_state_change = [true, true, true, true]
  6235.   end # clear_states
  6236.  
  6237.   #----------------------------------------------------------------------------|
  6238.   #  Marks that the state array changed as well                                |
  6239.   #----------------------------------------------------------------------------|
  6240.   def add_new_state(state_id, &argb) # New
  6241.     super(state_id, &argb)
  6242.     @ecatb_state_change = [true, true, true, true]
  6243.   end # add_new_state
  6244.  
  6245.   def init_ecatb_vars # New
  6246.     super
  6247.     @ecatb_bar_show = []
  6248.   end # init_ecatb_vars
  6249.  
  6250.   #----------------------------------------------------------------------------|
  6251.   #  Marks that the enemy with id being this enemy's id has been killed before |
  6252.   #----------------------------------------------------------------------------|
  6253.   def die # New
  6254.     super
  6255.     return if $game_party.ecatb_dead_enemies.include?(@enemy_id)
  6256.     $game_party.ecatb_dead_enemies << @enemy_id
  6257.   end # die
  6258.  
  6259.   # start: The battle start type
  6260.   def default_ecatb_start_val(start) # New
  6261.     return normal_enemy_1st_ecatb_val if start == :start_0
  6262.     return preemptive_enemy_1st_ecatb_val if start == :start_1
  6263.     surprise_enemy_1st_ecatb_val
  6264.   end # default_ecatb_start_val
  6265.  
  6266.   def confirm_ecatb_item # New
  6267.     super
  6268.     post_ecatb_input_act
  6269.   end # confirm_ecatb_item
  6270.  
  6271.   # index: The indicator of which atb bar parts queries its display flag
  6272.   def ecatb_bar_show?(index) # New; Hotspot
  6273.     # Reevaluates the atb bar part display flags only if the states changed
  6274.     if @ecatb_state_change[index]
  6275.       @ecatb_state_change[index] = @ecatb_bar_show[index] = nil
  6276.       states.each { |state|
  6277.         next if (show = state.enemy_ecatb_bar_show[index]).nil?
  6278.         return @ecatb_bar_show[index] = show
  6279.       }
  6280.     end
  6281.     #
  6282.     return @ecatb_bar_show[index] unless @ecatb_bar_show[index].nil?
  6283.     enemy.enemy_ecatb_bar_show[index]
  6284.   end # ecatb_bar_show?
  6285.  
  6286. end # Game_Enemy
  6287.  
  6288. #------------------------------------------------------------------------------|
  6289. #  * Hosts the atb pool mode flag for game party and troop                     |
  6290. #------------------------------------------------------------------------------|
  6291. class Game_Unit # Edit
  6292.  
  6293.   #----------------------------------------------------------------------------|
  6294.   #  New public instance variable                                              |
  6295.   #----------------------------------------------------------------------------|
  6296.   attr_accessor :ecatb_pool # The party/troop atb pool mode flag
  6297.  
  6298. end # Game_Unit
  6299.  
  6300. #------------------------------------------------------------------------------|
  6301. #  * Holds the defeated enemies, added actors and removed actors during battles|
  6302. #------------------------------------------------------------------------------|
  6303. class Game_Party < Game_Unit # Edit
  6304.  
  6305.   #----------------------------------------------------------------------------|
  6306.   #  New public instance variable                                              |
  6307.   #----------------------------------------------------------------------------|
  6308.   attr_accessor :ecatb_dead_enemies # The list of defeated enemies
  6309.  
  6310.   #----------------------------------------------------------------------------|
  6311.   #  Creates new methods of all configurations used by actors as well          |
  6312.   #----------------------------------------------------------------------------|
  6313.   alias initialize_ecatb initialize
  6314.   def initialize(*argv, &argb)
  6315.     initialize_ecatb(*argv, &argb)
  6316.     create_ecatb_defs # Added
  6317.   end # initialize
  6318.  
  6319.   #----------------------------------------------------------------------------|
  6320.   #  Initializes all new variables as well                                     |
  6321.   #----------------------------------------------------------------------------|
  6322.   alias init_all_items_ecatb init_all_items
  6323.   def init_all_items(*argv, &argb)
  6324.     init_all_items_ecatb(*argv, &argb)
  6325.     @ecatb_dead_enemies = [] # Added
  6326.   end # init_all_items
  6327.  
  6328.   #----------------------------------------------------------------------------|
  6329.   #  Notifies that an actor's added into the party as well                     |
  6330.   #----------------------------------------------------------------------------|
  6331.   alias add_actor_ecatb add_actor # v0.02b+
  6332.   def add_actor(actor_id, &argb)
  6333.     # Added
  6334.     if @in_battle && !@actors.include?(actor_id)
  6335.       $game_temp.ecatb_add_actors << $game_actors[actor_id]
  6336.     end
  6337.     #
  6338.     add_actor_ecatb(actor_id, &argb)
  6339.   end # add_actor
  6340.  
  6341.   #----------------------------------------------------------------------------|
  6342.   #  Notifies that an actor's removed from the party as well                   |
  6343.   #----------------------------------------------------------------------------|
  6344.   alias remove_actor_ecatb remove_actor # v0.02b+
  6345.   def remove_actor(actor_id, &argb)
  6346.     # Added
  6347.     if @in_battle && @actors.include?(actor_id)
  6348.       $game_temp.ecatb_remove_actors << $game_actors[actor_id]
  6349.     end
  6350.     #
  6351.     remove_actor_ecatb(actor_id, &argb)
  6352.   end # remove_actor
  6353.  
  6354.   #----------------------------------------------------------------------------|
  6355.   #  Creates and checks the associated method for each configuration used here |
  6356.   #----------------------------------------------------------------------------|
  6357.   # config: The configuration requesting its associated method
  6358.   # validate: The configuration value validation flag
  6359.   def create_ecatb_def(config, validate = true) # New
  6360.     # Uses the name and value of configuration as its method's name and contents
  6361.     method = config.id2name
  6362.     eval(%Q(
  6363.   def #{method}#{DoubleX_RMVXA::ECATB::GAME_PARTY_TROOP[config][0]}
  6364.     #{$game_system.send(config)}
  6365.   end
  6366.     ))
  6367.     #
  6368.     return unless validate
  6369.     check_ecatb_def(method, DoubleX_RMVXA::ECATB::GAME_PARTY_TROOP[config])
  6370.   end # create_ecatb_def
  6371.  
  6372.   #----------------------------------------------------------------------------|
  6373.   #  Checks all new methods and resets them to the defaults if they're invalid |
  6374.   #----------------------------------------------------------------------------|
  6375.   module_eval(DoubleX_RMVXA::ECATB::CHECK_RESET_DEF[:GAME_PARTY_TROOP]) # New
  6376.  
  6377. end # Game_Party
  6378.  
  6379. class Game_Troop < Game_Unit # Edit
  6380.  
  6381.   #----------------------------------------------------------------------------|
  6382.   #  Initializes all enemies' new variables and methods as well                |
  6383.   #----------------------------------------------------------------------------|
  6384.   alias setup_ecatb setup
  6385.   def setup(troop_id, &argb)
  6386.     setup_ecatb(troop_id, &argb)
  6387.     @enemies.each(&DoubleX_RMVXA::ECATB::BLOCKS[:create_ecatb_defs]) # Added
  6388.   end # setup
  6389.  
  6390.   #----------------------------------------------------------------------------|
  6391.   #  Creates and checks the associated method for each configuration used here |
  6392.   #----------------------------------------------------------------------------|
  6393.   # config: The configuration requesting its associated method
  6394.   # validate: The configuration value validation flag
  6395.   def create_ecatb_def(config, validate = true) # New
  6396.     # Uses the name and value of configuration as its method's name and contents
  6397.     method = config.id2name
  6398.     eval(%Q(
  6399.   def #{method}#{DoubleX_RMVXA::ECATB::GAME_PARTY_TROOP[config][0]}
  6400.     #{$game_system.send(config)}
  6401.   end
  6402.     ))
  6403.     #
  6404.     return unless validate
  6405.     check_ecatb_def(method, DoubleX_RMVXA::ECATB::GAME_PARTY_TROOP[config])
  6406.   end # create_ecatb_def
  6407.  
  6408.   #----------------------------------------------------------------------------|
  6409.   #  Checks all new methods and resets them to the defaults if they're invalid |
  6410.   #----------------------------------------------------------------------------|
  6411.   module_eval(DoubleX_RMVXA::ECATB::CHECK_RESET_DEF[:GAME_PARTY_TROOP]) # New
  6412.  
  6413. end # Game_Troop
  6414.  
  6415. #------------------------------------------------------------------------------|
  6416. #  * Hosts actor/enemy sprite atb, charge and cooldown bars                    |
  6417. #------------------------------------------------------------------------------|
  6418. class Sprite_Battler < Sprite_Base # Edit
  6419.  
  6420.   #----------------------------------------------------------------------------|
  6421.   #  New private instance variable                                             |
  6422.   #----------------------------------------------------------------------------|
  6423.   # @ecatb_bars: The battler's atb bars
  6424.  
  6425.   #----------------------------------------------------------------------------|
  6426.   #  Create all atb bars as well                                               |
  6427.   #----------------------------------------------------------------------------|
  6428.   alias initialize_ecatb initialize
  6429.   def initialize(viewport, battler = nil, &argb)
  6430.     initialize_ecatb(viewport, battler, &argb)
  6431.     # Added
  6432.     return unless BattleManager.btype?(:ecatb) && @battler
  6433.     return unless @battler.enemy? || BattleManager.actor_sprite_ecatb_bar
  6434.     create_ecatb_bars
  6435.     #
  6436.   end # initialize
  6437.  
  6438.   #----------------------------------------------------------------------------|
  6439.   #  Disposes all atb bars as well                                             |
  6440.   #----------------------------------------------------------------------------|
  6441.   alias dispose_ecatb dispose
  6442.   def dispose(*argv, &argb)
  6443.     dispose_ecatb(*argv, &argb)
  6444.     # Added
  6445.     return unless @ecatb_bars && BattleManager.btype?(:ecatb)
  6446.     @ecatb_bars.each_value(&DoubleX_RMVXA::ECATB::BLOCKS[:dispose])
  6447.     @ecatb_bars = nil
  6448.     #
  6449.   end # dispose
  6450.  
  6451.   #----------------------------------------------------------------------------|
  6452.   #  Updates all atb bars as well                                              |
  6453.   #----------------------------------------------------------------------------|
  6454.   alias update_ecatb update
  6455.   def update # Hotspot
  6456.     update_ecatb
  6457.     # Added
  6458.     return unless @ecatb_bars && BattleManager.btype?(:ecatb)
  6459.     @ecatb_bars.each_value(&DoubleX_RMVXA::ECATB::BLOCKS[:update])
  6460.     #
  6461.   end # update
  6462.  
  6463.   #----------------------------------------------------------------------------|
  6464.   #  Creates the back, atb, charge, color and text bars                        |
  6465.   #----------------------------------------------------------------------------|
  6466.   def create_ecatb_bars # New
  6467.     @ecatb_bars = {}
  6468.     # Uses 1 bar for each atb type if multilayer's used
  6469.     types = if @battler.ecatb_bar_multilayer
  6470.       [:back, :atb, :charge, :cooldown, :text]
  6471.     else
  6472.       [:back, :atbs, :text]
  6473.     end
  6474.     #
  6475.     types.each { |type| @ecatb_bars[type] = ECATB_Bar.new(@battler, type) }
  6476.   end # create_ecatb_bars
  6477.  
  6478. end # Sprite_Battler
  6479.  
  6480. #------------------------------------------------------------------------------|
  6481. #  * (v0.00b+)Fixes bugs and edge cases                                        |
  6482. #------------------------------------------------------------------------------|
  6483. class Spriteset_Battle # Edit
  6484.  
  6485.   #----------------------------------------------------------------------------|
  6486.   #  Inserts actors into the actor sprites as well                             |
  6487.   #----------------------------------------------------------------------------|
  6488.   alias create_actors_ecatb create_actors
  6489.   def create_actors(*argv, &argb)
  6490.     # Rewritten
  6491.     return create_actors_ecatb(*argv, &argb) unless BattleManager.btype?(:ecatb)
  6492.     dispose_actors if @actor_sprites
  6493.     @actor_sprites = $game_party.battle_members.reverse!.collect! { |actor|
  6494.       Sprite_Battler.new(@viewport1, actor)
  6495.     }
  6496.     #
  6497.   end # create_actors
  6498.  
  6499. end # Spriteset_Battle
  6500.  
  6501. #------------------------------------------------------------------------------|
  6502. #  * (v0.01a+)Handles the battler icons in the atb battler order window        |
  6503. #------------------------------------------------------------------------------|
  6504. class ECATB_Order_Battler_Icon < Sprite # New
  6505.  
  6506.   #----------------------------------------------------------------------------|
  6507.   #  Private instance variables                                                |
  6508.   #----------------------------------------------------------------------------|
  6509.   # @battler: The battler using the atb order icon
  6510.   # @icon: The battler atb order icon
  6511.   # @window: The battler atb order window
  6512.  
  6513.   def initialize(battler, window)
  6514.     super(SceneManager.scene.spriteset.viewport1)
  6515.     @battler = battler
  6516.     @window = window
  6517.     update
  6518.   end # initialize
  6519.  
  6520.   def dispose
  6521.     return if disposed?
  6522.     bitmap.dispose unless bitmap.disposed?
  6523.     super
  6524.   end # dispose
  6525.  
  6526.   def update # Hotspot
  6527.     return unless (self.visible = @battler.alive?) &&
  6528.     BattleManager.phase != :init
  6529.     if @icon != icon = @battler.set_ecatb_order_battler_icon
  6530.       @icon = icon.clone
  6531.       create_sprite_bitmap
  6532.     end
  6533.     update_pos
  6534.   end # update
  6535.  
  6536.   def create_sprite_bitmap # Potential Hotspot
  6537.     bitmap.dispose if bitmap && !bitmap.disposed?
  6538.     self.bitmap = Bitmap.new(dw = @icon[1].width, dh = @icon[1].height)
  6539.     self.ox = self.oy = 0
  6540.     scale = @battler.set_ecatb_order_battler_scale
  6541.     bitmap.stretch_blt(Rect.new(0, 0, dw * scale, dh * scale), @icon[0],
  6542.     @icon[1], @battler.set_ecatb_order_battler_opacity)
  6543.     @icon[0].dispose unless @icon[0].disposed?
  6544.   end # create_sprite_bitmap
  6545.  
  6546.   #----------------------------------------------------------------------------|
  6547.   #  Updates the icon x, y and z positions if they're changed                  |
  6548.   #----------------------------------------------------------------------------|
  6549.   def update_pos # Hotspot
  6550.     # Checks the battler's atb type and updates the icon positions accordingly
  6551.     dw = @window.ecatb_order_bar_wh[0] / 3
  6552.     xyz = @window.ecatb_order_window_xyz
  6553.     dx = xyz[0] + @battler.ecatb_order_battler_icon_x
  6554.     dx += if (type = @battler.ecatb_bar_type) == :cooldown
  6555.       (100.0 - @battler.ecatb_val[type] % 100.0) / 100.0 * dw
  6556.     else
  6557.       ([@battler.ecatb_val[type], 100.0].min / 100.0 +
  6558.       (type == :atb ? 1 : 2)) * dw
  6559.     end
  6560.     #
  6561.     self.x = dx if x != dx
  6562.     dy = xyz[1] + if @battler.actor?
  6563.       @battler.ecatb_order_actor_icon_y
  6564.     else
  6565.       @battler.ecatb_order_enemy_icon_y
  6566.     end
  6567.     self.y = dy if y != dy
  6568.     dz = @battler.set_ecatb_order_battler_z
  6569.     self.z = dz if z != dz
  6570.   end # update_pos
  6571.  
  6572. end # ECATB_Order_Battler_Icon
  6573.  
  6574. #------------------------------------------------------------------------------|
  6575. #  * Handles the actor/enemy sprite atb, charge and cooldown bars              |
  6576. #------------------------------------------------------------------------------|
  6577. class ECATB_Bar < Viewport # New
  6578.  
  6579.   #----------------------------------------------------------------------------|
  6580.   #  Private instance variables                                                |
  6581.   #----------------------------------------------------------------------------|
  6582.   # @battler: The battler using the atb bar
  6583.   # @last_wh: The last atb bar width and height
  6584.   # @last_text_xy_offset : The last text x and y offsets
  6585.   # @last_x: The last atb bar x position
  6586.   # @last_y: The last atb bar y position
  6587.   # @last_xy_offset: The last atb bar x and y offsets
  6588.   # @one_color: The color 1 and color 2 being the same flag
  6589.   # @outline: The atb bar outline drawing flag
  6590.   # @plane: The plane with the bitmap drawing the atb bar
  6591.   # @type: The atb bar type
  6592.  
  6593.   # type: The atb bar type
  6594.   def initialize(battler, type)
  6595.     init_vars(battler, type)
  6596.     create_ecatb_defs
  6597.     dw = (wh = ecatb_bar_wh)[0]
  6598.     dh = @type == :text ? ecatb_bar_text_size : wh[1]
  6599.     if @outline
  6600.       dw += 2
  6601.       dh += 2
  6602.     end
  6603.     super(Rect.new((xy = ecatb_bar_xy_offset)[0], xy[1], dw, dh))
  6604.     init_bars
  6605.   end # initialize
  6606.  
  6607.   # type: The atb bar type
  6608.   def init_vars(battler, type)
  6609.     @battler = battler
  6610.     @type = type
  6611.     @outline = @type == :back || @type == :text
  6612.   end # init_vars
  6613.  
  6614.   #----------------------------------------------------------------------------|
  6615.   #  Creates and checks the associated method for each configuration used here |
  6616.   #----------------------------------------------------------------------------|
  6617.   # config: The configuration requesting its associated method
  6618.   # validate: The configuration value validation flag
  6619.   def create_ecatb_def(config, validate = true) # v0.04f+
  6620.     # Uses the name and value of configuration as its method's name and contents
  6621.     method = config.id2name
  6622.     eval(%Q(
  6623.   def #{method}#{DoubleX_RMVXA::ECATB::ECATB_BAR[config][0]}
  6624.     #{$game_system.send(config)}
  6625.   end
  6626.     ))
  6627.     #
  6628.     return unless validate
  6629.     check_ecatb_def(method, DoubleX_RMVXA::ECATB::ECATB_BAR[config])
  6630.   end # create_ecatb_def
  6631.  
  6632.   #----------------------------------------------------------------------------|
  6633.   #  Checks all new methods and resets them to the defaults if they're invalid |
  6634.   #----------------------------------------------------------------------------|
  6635.   module_eval(DoubleX_RMVXA::ECATB::CHECK_RESET_DEF[:ECATB_BAR]) # v0.04f+
  6636.  
  6637.   def init_bars
  6638.     (@plane = Plane.new(self)).bitmap = Bitmap.new(rect.width * 2, rect.height)
  6639.     self.visible = false
  6640.     update_pos
  6641.     draw_bars
  6642.   end # init_bars
  6643.  
  6644.   def dispose
  6645.     return if @plane.disposed?
  6646.     @plane.bitmap.dispose if @plane.bitmap
  6647.     @plane.dispose
  6648.     super
  6649.   end # dispose
  6650.  
  6651.   #----------------------------------------------------------------------------|
  6652.   #  Updates the bar visibility, xy positions, width, height, color and text   |
  6653.   #----------------------------------------------------------------------------|
  6654.   def update # Hotspot
  6655.     super
  6656.     return unless self.visible = visible?
  6657.     update_pos
  6658.     unless @outline
  6659.       update_bar_w
  6660.       if @battler.ecatb_battler_change?(type = @battler.ecatb_bar_type)
  6661.         return draw_bars unless @type != type && @battler.ecatb_bar_multilayer
  6662.       end
  6663.     end
  6664.     return update_text if @type == :text
  6665.     @plane.ox -= ecatb_bar_ani_ox if @one_color && ecatb_bar_ani
  6666.   end # update
  6667.  
  6668.   #----------------------------------------------------------------------------|
  6669.   #  Updates the bar xy positions and height only if any of them changes       |
  6670.   #----------------------------------------------------------------------------|
  6671.   def update_pos # Hotspot
  6672.     z_pos = ecatb_bar_z
  6673.     self.z = z_pos if z != z_pos
  6674.     return unless update_pos?
  6675.     rect.width = @last_wh[0] + 2 if @outline
  6676.     rect.height = @last_wh[1] + (@outline ? 2 : 0)
  6677.     update_xy
  6678.   end # update_pos
  6679.  
  6680.   #----------------------------------------------------------------------------|
  6681.   #  Updates the bar and text xy positions                                     |
  6682.   #----------------------------------------------------------------------------|
  6683.   def update_xy # Hotspot
  6684.     dx = @last_x + @last_xy_offset[0] - (@last_wh[0] + (@outline ? 2 : 0)) / 2
  6685.     dy = @last_y + @last_xy_offset[1]
  6686.     if @type == :text
  6687.       dx += @last_text_xy_offset[0]
  6688.       dy += @last_text_xy_offset[1]
  6689.     end
  6690.     rect.x = dx
  6691.     dh = rect.height + (@outline ? 1 : 3)
  6692.     rect.y = dy + (@outline ? 0 : 1)
  6693.   end # update_xy
  6694.  
  6695.   def draw_bars
  6696.     dw = rect.width
  6697.     dh = rect.height
  6698.     @outline ? rect.width = @last_wh[0] + 2 : update_bar_w
  6699.     @one_color = (colors = set_bar_colors)[0] == colors[1]
  6700.     (bitmap = @plane.bitmap).gradient_fill_rect(0, 0, dw, dh, colors[0],
  6701.     colors[1])
  6702.     bitmap.gradient_fill_rect(dw, 0, dw, dh, colors[1], colors[0])
  6703.   end # draw_bars
  6704.  
  6705.   #----------------------------------------------------------------------------|
  6706.   #  Updates the atb bar width if it's changed                                 |
  6707.   #----------------------------------------------------------------------------|
  6708.   def update_bar_w # Hotspot
  6709.     type = @battler.ecatb_bar_multilayer ? @type : @battler.ecatb_bar_type
  6710.     w = @battler.ecatb_val[type] % 100.0 * @last_wh[0] / 100.0
  6711.     rect.width = w if rect.width != w
  6712.   end # update_bar_w
  6713.  
  6714.   def set_bar_colors
  6715.     return ecatb_bar_back_colors if @type == :back
  6716.     return [Color.new(0, 0, 0, 0), Color.new(0, 0, 0, 0)] if @type == :text
  6717.     type = @battler.ecatb_bar_multilayer ? @type : @battler.ecatb_bar_type
  6718.     @battler.set_ecatb_bar_colors(type)
  6719.     @battler.ecatb_notes[type]
  6720.   end # set_bar_colors
  6721.  
  6722.   #----------------------------------------------------------------------------|
  6723.   #  Redraws the atb bar texts only if its contents and/or fonts changed       |
  6724.   #----------------------------------------------------------------------------|
  6725.   def update_text # Hotspot
  6726.     text = ecatb_bar_text((text = set_text)[0], text[1])
  6727.     return unless update_text_font? || @last_text != text
  6728.     @last_text = text
  6729.     return self.visible = false if text.empty?
  6730.     self.visible = true
  6731.     dw = (bitmap = @plane.bitmap).text_size(text).width
  6732.     bitmap.clear
  6733.     bitmap.draw_text(@last_wh[0] + 2 - dw, 0, dw,
  6734.     bitmap.text_size(text).height, text)
  6735.   end # update_text
  6736.  
  6737.   #----------------------------------------------------------------------------|
  6738.   #  Sets the atb bar fill percent and action point text if they're to be shown|
  6739.   #----------------------------------------------------------------------------|
  6740.   def set_text # Hotspot
  6741.     [@battler.actor? || @battler.ecatb_bar_show?(2) ?
  6742.      @battler.ecatb_val[@battler.ecatb_bar_type].to_i.to_s : "",
  6743.      @battler.actor? || @battler.ecatb_bar_show?(3) ?
  6744.      @battler.ecatb_act_times.to_s : ""]
  6745.   end # set_text
  6746.  
  6747.   #----------------------------------------------------------------------------|
  6748.   #  Checks if the atb bars and text should be visible                         |
  6749.   #----------------------------------------------------------------------------|
  6750.   def visible? # Hotspot
  6751.     # Checks if the battler's alive and the enemy's bars should be shown
  6752.     return false if $game_party.all_dead? || $game_troop.all_dead?
  6753.     return @battler.alive? if @battler.actor?
  6754.     return false unless @battler.alive? && @battler.ecatb_bar_show?(1)
  6755.     return true unless @battler.ecatb_bar_show?(0)
  6756.     $game_party.ecatb_dead_enemies.include?(@battler.enemy_id)
  6757.     #
  6758.   end # visible?
  6759.  
  6760.   #----------------------------------------------------------------------------|
  6761.   #  Checks if the atb bar and text positions need to be updated               |
  6762.   #----------------------------------------------------------------------------|
  6763.   def update_pos? # Hotspot
  6764.     # Checks if the bar width, height, offset or battler x or y position changes
  6765.     dx = @battler.screen_x
  6766.     dy = @battler.screen_y
  6767.     xy_offset = ecatb_bar_xy_offset
  6768.     same_pos = @last_wh == (wh = ecatb_bar_wh) && @last_x == dx &&
  6769.     @last_y == dy && @last_xy_offset == xy_offset
  6770.     return false if @type != :text && same_pos
  6771.     if @type == :text
  6772.       text_xy_offset = ecatb_bar_text_xy_offset
  6773.       return false if same_pos && @last_text_xy_offset == text_xy_offset
  6774.       @last_text_xy_offset = text_xy_offset.clone
  6775.     end
  6776.     @last_wh = wh.clone
  6777.     @last_x = dx
  6778.     @last_y = dy
  6779.     @last_xy_offset = xy_offset
  6780.     #
  6781.   end # update_pos?
  6782.  
  6783.   #----------------------------------------------------------------------------|
  6784.   #  Checks if the atb bar text color and size's changed and updates them if so|
  6785.   #----------------------------------------------------------------------------|
  6786.   def update_text_font? # Hotspot
  6787.     change = false
  6788.     if (font = @plane.bitmap.font).color != color = ecatb_bar_text_color
  6789.       change = font.color = color
  6790.     end
  6791.     size = ecatb_bar_text_size
  6792.     change = font.size = size if font.size != size
  6793.     change
  6794.     #
  6795.   end # update_text_font?
  6796.  
  6797. end # ECATB_Bar
  6798.  
  6799. #------------------------------------------------------------------------------|
  6800. #  * Handles the battle atb clock bar in battle atb clock and turn window      |
  6801. #------------------------------------------------------------------------------|
  6802. class ECATB_Clock_Bar < Viewport # New
  6803.  
  6804.   #----------------------------------------------------------------------------|
  6805.   #  Private instance variables                                                |
  6806.   #----------------------------------------------------------------------------|
  6807.   # @last_w: Stores the last width of the atb clock bar
  6808.   # @plane: Stores the plane with the bitmap drawing the atb clock bar
  6809.  
  6810.   def initialize
  6811.     create_ecatb_defs
  6812.     xy = ecatb_clock_bar_xy
  6813.     rect = Rect.new(xy[0], xy[1], (wh = ecatb_clock_bar_wh)[0], wh[1])
  6814.     super(rect)
  6815.     create_bars
  6816.     update_bar_wh
  6817.     update_bar_xy
  6818.   end # initialize
  6819.  
  6820.   #----------------------------------------------------------------------------|
  6821.   #  Creates and checks the associated method for each configuration used here |
  6822.   #----------------------------------------------------------------------------|
  6823.   # config: The configuration requesting its associated method
  6824.   # validate: The configuration value validation flag
  6825.   def create_ecatb_def(config, validate = true) # New
  6826.     # Uses the name and value of configuration as its method's name and contents
  6827.     method = config.id2name
  6828.     eval(%Q(
  6829.   def #{method}#{DoubleX_RMVXA::ECATB::ECATB_CLOCK_BAR[config][0]}
  6830.     #{$game_system.send(config)}
  6831.   end
  6832.     ))
  6833.     #
  6834.     return unless validate
  6835.     check_ecatb_def(method, DoubleX_RMVXA::ECATB::ECATB_CLOCK_BAR[config])
  6836.   end # create_ecatb_def
  6837.  
  6838.   #----------------------------------------------------------------------------|
  6839.   #  Checks all new methods and resets them to the defaults if they're invalid |
  6840.   #----------------------------------------------------------------------------|
  6841.   module_eval(DoubleX_RMVXA::ECATB::CHECK_RESET_DEF[:ECATB_CLOCK_BAR]) # New
  6842.  
  6843.   def dispose
  6844.     return if @plane.disposed?
  6845.     @plane.bitmap.dispose if @plane.bitmap
  6846.     @plane.dispose
  6847.     super
  6848.   end # dispose
  6849.  
  6850.   def create_bars
  6851.     (@plane = Plane.new(self)).bitmap = Bitmap.new(rect.width * 2, rect.height)
  6852.     update_bar_colors
  6853.     self.visible = true
  6854.   end # create_bars
  6855.  
  6856.   def update_bar_colors # Potential Hotspot
  6857.     @plane.bitmap.gradient_fill_rect(0, 0, rect.width, rect.height,
  6858.     (colors = ecatb_clock_bar_colors)[0], colors[1])
  6859.     rect.width = 0
  6860.   end # update_bar_colors
  6861.  
  6862.   #----------------------------------------------------------------------------|
  6863.   #  Updates the atb clock window bar width and height only if they've changed |
  6864.   #----------------------------------------------------------------------------|
  6865.   def update_bar_wh # Potential Hotspot
  6866.     wh = ecatb_clock_bar_wh
  6867.     rect.width = @last_w = wh[0] if @last_w != wh[0]
  6868.     rect.height = wh[1] if rect.height != wh[1]
  6869.   end # update_bar_wh
  6870.  
  6871.   #----------------------------------------------------------------------------|
  6872.   #  Updates the atb clock window bar xy positions only if they've changed     |
  6873.   #----------------------------------------------------------------------------|
  6874.   def update_bar_xy # Potential Hotspot
  6875.     xy = ecatb_clock_bar_xy
  6876.     rect.x = xy[0] if rect.x != xy[0]
  6877.     rect.y = xy[1] if rect.y != xy[1]
  6878.   end # update_bar_xy
  6879.  
  6880.   #----------------------------------------------------------------------------|
  6881.   #  Updates the atb clock window bar length only if it needs to change        |
  6882.   #----------------------------------------------------------------------------|
  6883.   # cur_clock: The number of frames passed in the current turn
  6884.   # max_clock: The number of frames of the current turn
  6885.   def update_bar(cur_clock, max_clock) # Hotspot
  6886.     update
  6887.     w = @last_w * 1.0 * cur_clock / max_clock
  6888.     rect.width = w if rect.width != w
  6889.   end # update_bar
  6890.  
  6891. end # ECATB_Clock_Bar
  6892.  
  6893. #------------------------------------------------------------------------------|
  6894. #  * Fixes bugs and edge cases                                                 |
  6895. #------------------------------------------------------------------------------|
  6896. class Window_ItemList < Window_Selectable # Edit
  6897.  
  6898.   #----------------------------------------------------------------------------|
  6899.   #  Disables items in battles when the user doesn't have enough action points |
  6900.   #----------------------------------------------------------------------------|
  6901.   alias enable_ecatb? enable?
  6902.   def enable?(item)
  6903.     # Added
  6904.     if SceneManager.scene_is?(Scene_Battle) && item && item.is_a?(RPG::Item)
  6905.       if BattleManager.btype?(:ecatb)
  6906.         battler = BattleManager.actor
  6907.         return battler.usable?(item) if (ecatb = DoubleX_RMVXA::ECATB).send(
  6908.         item.ecatb_act_cost, battler) > 1 || ecatb.send(
  6909.         item.ecatb_unison_actor, battler).size > 1
  6910.       end
  6911.     end
  6912.     #
  6913.     enable_ecatb?(item)
  6914.   end # enable?
  6915.  
  6916. end # Window_ItemList
  6917.  
  6918. #------------------------------------------------------------------------------|
  6919. #  * Fixes bugs and edge cases                                                 |
  6920. #------------------------------------------------------------------------------|
  6921. class Window_EquipItem < Window_ItemList # v0.02d+; Edit
  6922.  
  6923.   #----------------------------------------------------------------------------|
  6924.   #  Clears and resets all blocks of the actor before and after serialization  |
  6925.   #----------------------------------------------------------------------------|
  6926.   alias update_help_ecatb update_help
  6927.   def update_help
  6928.     @actor.clear_ecatb_blocks # Added
  6929.     update_help_ecatb
  6930.     @actor.reset_ecatb_blocks if SceneManager.scene_is?(Scene_Battle) # Added
  6931.   end # update_help
  6932.  
  6933. end # Window_EquipItem
  6934.  
  6935. #------------------------------------------------------------------------------|
  6936. #  * Shows all unison actors' names when executing an unison skill/item        |
  6937. #------------------------------------------------------------------------------|
  6938. class Window_BattleLog < Window_Selectable # Edit
  6939.  
  6940.   #----------------------------------------------------------------------------|
  6941.   #  Displays all unison actors' names if they're all to be shown as well      |
  6942.   #----------------------------------------------------------------------------|
  6943.   alias display_use_item_ecatb display_use_item
  6944.   def display_use_item(subject, item, &argb)
  6945.     # Added
  6946.     if BattleManager.btype?(:ecatb) && subject.show_ecatb_unison_battlers
  6947.       if subject.ecatb_unison_actors.size > 1
  6948.         return display_ecatb_unison_item(item, subject.ecatb_unison_actors)
  6949.       end
  6950.     end
  6951.     #
  6952.     display_use_item_ecatb(subject, item, &argb)
  6953.   end # display_use_item
  6954.  
  6955.   # actors: The unison actors
  6956.   def display_ecatb_unison_item(item, actors) # New
  6957.     battler_names = ecatb_unison_battler_names(actors)
  6958.     unless item.is_a?(RPG::Skill)
  6959.       return add_text(sprintf(Vocab::UseItem, battler_names, item.name))
  6960.     end
  6961.     add_text(battler_names + item.message1)
  6962.     return if item.message2.empty?
  6963.     wait
  6964.     add_text(item.message2)
  6965.   end # display_use_item
  6966.  
  6967.   # actors: The unison actors
  6968.   def ecatb_unison_battler_names(actors) # New
  6969.     names = ""
  6970.     max_index = actors.size - 1
  6971.     actors.each_with_index { |actor, index|
  6972.       (names += index < max_index ? ", " : " and ") if index > 0
  6973.       names += actor.name
  6974.     }
  6975.     names
  6976.   end # ecatb_unison_battler_names
  6977.  
  6978. end # Window_BattleLog
  6979.  
  6980. #------------------------------------------------------------------------------|
  6981. #  * Adds actor selection hotkeys and lets directional commands cycle          |
  6982. #------------------------------------------------------------------------------|
  6983. class Window_ActorCommand < Window_Command # Edit
  6984.  
  6985.   #----------------------------------------------------------------------------|
  6986.   #  New private instance variable                                             |
  6987.   #----------------------------------------------------------------------------|
  6988.   # @ecatb_hotkey_block: The hotkey handling block
  6989.  
  6990.   #----------------------------------------------------------------------------|
  6991.   #  Initializes the new block used by process_handling as well                |
  6992.   #----------------------------------------------------------------------------|
  6993.   alias initialize_ecatb initialize
  6994.   def initialize(*argv, &argb)
  6995.     initialize_ecatb(*argv, &argb)
  6996.     init_ecatb_block # Added
  6997.   end # initialize
  6998.  
  6999.   #----------------------------------------------------------------------------|
  7000.   #  Set left arrow output as switching to prior actor in ecatb battle system  |
  7001.   #----------------------------------------------------------------------------|
  7002.   alias process_dir4_ecatb process_dir4
  7003.   def process_dir4 # Potential Hotspot
  7004.     return process_dir4_ecatb unless BattleManager.btype?(:ecatb) # Rewritten
  7005.     # Added
  7006.     Sound.play_cursor
  7007.     Input.update
  7008.     deactivate
  7009.     call_handler(:dir4)
  7010.     #
  7011.   end # process_dir4
  7012.  
  7013.   #----------------------------------------------------------------------------|
  7014.   #  Calls the hotkey handler methods if the hotkey's pressed                  |
  7015.   #----------------------------------------------------------------------------|
  7016.   module_eval(DoubleX_RMVXA::ECATB::ACTOR_HOTKEY) # Alias; Hotspot
  7017.  
  7018.   #----------------------------------------------------------------------------|
  7019.   #  Initializes the new block to trade memory usage for time performance      |
  7020.   #----------------------------------------------------------------------------|
  7021.   def init_ecatb_block # New
  7022.     # Calls this block instead of an anonymous function per enumerable iteration
  7023.     @ecatb_hotkey_block =
  7024.     -> hotkey { return call_handler(hotkey) if Input.trigger?(hotkey) }
  7025.     #
  7026.   end # init_ecatb_block
  7027.  
  7028. end # Window_ActorCommand
  7029.  
  7030. #------------------------------------------------------------------------------|
  7031. #  * Draws the atb, charge and cooldown bars of all actors                     |
  7032. #------------------------------------------------------------------------------|
  7033. class Window_BattleStatus < Window_Selectable # New
  7034.  
  7035.   #----------------------------------------------------------------------------|
  7036.   #  (v0.04f+)New public instance variables                                    |
  7037.   #----------------------------------------------------------------------------|
  7038.   attr_writer :ecatb_text_change # The atb bar text format change notifier
  7039.   attr_writer :ecatb_word_change # The atb bar description change notifier
  7040.   attr_writer :ecatb_y_add_change # The atb bar y offset change notifier
  7041.  
  7042.   #----------------------------------------------------------------------------|
  7043.   #  New private instance variables                                            |
  7044.   #----------------------------------------------------------------------------|
  7045.   # @ecatb_draw_bars: The atb bar drawing iteartor block
  7046.   # @last_ecatb_text: The last atb bar fill percentage and action point text
  7047.   # @last_ecatb_w: The last atb bar width
  7048.  
  7049.   #----------------------------------------------------------------------------|
  7050.   #  Initializes all new methods and block as well                             |
  7051.   #----------------------------------------------------------------------------|
  7052.   alias initialize_ecatb initialize
  7053.   def initialize(*argv, &argb)
  7054.     initialize_ecatb(*argv, &argb)
  7055.     # Added
  7056.     create_ecatb_defs
  7057.     @last_ecatb_text = {}
  7058.     @last_ecatb_w = {}
  7059.     init_ecatb_block
  7060.     #
  7061.   end # initialize
  7062.  
  7063.   #----------------------------------------------------------------------------|
  7064.   #  Redraws the atb bar and text if the battle started as well                |
  7065.   #----------------------------------------------------------------------------|
  7066.   alias draw_item_ecatb draw_item
  7067.   def draw_item(index, &argb) # Potential Hotspot
  7068.     draw_item_ecatb(index, &argb)
  7069.     # Added
  7070.     return if BattleManager.phase == :init
  7071.     return unless index && BattleManager.btype?(:ecatb)
  7072.     set_ecatb_bar(index, true) unless BattleManager.actor_sprite_ecatb_bar
  7073.     #
  7074.   end # draw_item
  7075.  
  7076.   #----------------------------------------------------------------------------|
  7077.   #  Creates and checks the associated method for each configuration used here |
  7078.   #----------------------------------------------------------------------------|
  7079.   # config: The configuration requesting its associated method
  7080.   # validate: The configuration value validation flag
  7081.   def create_ecatb_def(config, validate = true) # New
  7082.     # Uses the name and value of configuration as its method's name and contents
  7083.     method = config.id2name
  7084.     eval(%Q(
  7085.   def #{method}#{DoubleX_RMVXA::ECATB::WINDOW_BATTLESTATUS[config][0]}
  7086.     #{$game_system.send(config)}
  7087.   end
  7088.     ))
  7089.     #
  7090.     return unless validate
  7091.     check_ecatb_def(method, DoubleX_RMVXA::ECATB::WINDOW_BATTLESTATUS[config])
  7092.   end # create_ecatb_def
  7093.  
  7094.   #----------------------------------------------------------------------------|
  7095.   #  Checks all new methods and resets them to the defaults if they're invalid |
  7096.   #----------------------------------------------------------------------------|
  7097.   module_eval(DoubleX_RMVXA::ECATB::CHECK_RESET_DEF[:WINDOW_BATTLESTATUS]) # New
  7098.  
  7099.   #----------------------------------------------------------------------------|
  7100.   #  Initializes the new block to trade memory usage for time performance      |
  7101.   #----------------------------------------------------------------------------|
  7102.   def init_ecatb_block # New
  7103.     # Calls this block instead of an anonymous function per enumerable iteration
  7104.     @ecatb_draw_bars = -> index { set_ecatb_bar(index) }
  7105.     #
  7106.   end # init_ecatb_block
  7107.  
  7108.   def ecatb_bar_refresh # New; Hotspot
  7109.     item_max.times(&@ecatb_draw_bars)
  7110.   end # ecatb_bar_refresh
  7111.  
  7112.   #----------------------------------------------------------------------------|
  7113.   #  Sets the color, length, width and y position of the actor's atb bar       |
  7114.   #----------------------------------------------------------------------------|
  7115.   # redrawn: The status window redrawn flag
  7116.   def set_ecatb_bar(index, redrawn = false) # New; Hotspot
  7117.     return if $game_troop.all_dead?
  7118.     return unless actor = $game_party.battle_members[index]
  7119.     battler_change = actor.ecatb_battler_change?(type = actor.ecatb_bar_type)
  7120.     # Redraws atb bar and text only if they're changed or window's redrawn
  7121.     return unless draw_ecatb_bar?(actor, redrawn, type, battler_change)
  7122.     draw_ecatb_bar(actor, (rect = item_rect(index)).x + 2, line_height +
  7123.     YEA::BATTLE::BATTLESTATUS_HPGAUGE_Y_PLUS + actor_ecatb_bar_y_add,
  7124.     rect.width - 4, actor.ecatb_bar_type, battler_change)
  7125.     #
  7126.   end # set_ecatb_bar
  7127.  
  7128.   #----------------------------------------------------------------------------|
  7129.   #  Draws the actor's atb bar with its description and details text           |
  7130.   #----------------------------------------------------------------------------|
  7131.   # type: The atb bar type to be drawn
  7132.   # change: The atb bar color change flag
  7133.   def draw_ecatb_bar(actor, dx, dy, width, type, change) # New; Hotspot
  7134.     actor.set_ecatb_bar_colors(type) if change
  7135.     draw_gauge(dx, dy, width, actor.ecatb_val[type] % 100.0 / 100.0,
  7136.     (colors = actor.ecatb_notes[type])[0], colors[1])
  7137.     change_color(system_color)
  7138.     draw_text(dx + 2, dy + (Font.default_size - contents.font.size) / 2 + 1,
  7139.     30, line_height, actor_ecatb_bar_word)
  7140.     return if @last_ecatb_text[actor].empty?
  7141.     draw_ecatb_text(actor, dx, dy, width, type)
  7142.   end # draw_ecatb_bar
  7143.  
  7144.   # type: The atb bar type to be drawn
  7145.   def draw_ecatb_text(actor, dx, dy, width, type) # New; Hotspot
  7146.     dw = text_size(text = actor_ecatb_bar_text(@last_ecatb_text[actor][0],
  7147.     @last_ecatb_text[actor][1])).width + 2
  7148.     draw_text(dx + width - dw, dy + (Font.default_size - contents.font.size) /
  7149.     2 + 1, dw, line_height, text)
  7150.   end # draw_ecatb_text
  7151.  
  7152.   # redrawn: The status window redrawn flag
  7153.   def draw_ecatb_bar?(actor, redrawn, type, battler_change) # v0.04f+; New;
  7154.   # Hotspot
  7155.     w_change = @last_ecatb_w[actor] != @last_ecatb_w[actor] =
  7156.     actor.ecatb_val[type] % 100.0 * (item_rect(index).width - 4) / 100.0
  7157.     text_change = @last_ecatb_text[actor] != @last_ecatb_text[actor] = [
  7158.     actor.ecatb_val[type].to_i.to_s, actor.ecatb_act_times.to_s]
  7159.     # Lets users notifies that the atb bar text format's changed instead
  7160.     return false unless redrawn || battler_change || w_change || text_change ||
  7161.     @ecatb_text_change || @ecatb_word_change || @ecatb_y_add_change
  7162.     !(@ecatb_text_change = @ecatb_word_change = @ecatb_y_add_change = false)
  7163.     #
  7164.   end # set_ecatb_bar
  7165.  
  7166. end # Window_BattleStatus
  7167.  
  7168. #------------------------------------------------------------------------------|
  7169. #  * Adds actor selection hotkeys and lets directional commands cycle          |
  7170. #------------------------------------------------------------------------------|
  7171. class Window_BattleActor < Window_BattleStatus # Edit
  7172.  
  7173.   #----------------------------------------------------------------------------|
  7174.   #  New private instance variable                                             |
  7175.   #----------------------------------------------------------------------------|
  7176.   # @ecatb_hotkey_block: The hotkey handling block
  7177.  
  7178.   #----------------------------------------------------------------------------|
  7179.   #  Always allow cyclic directional navigations in the ecatb battle system    |
  7180.   #----------------------------------------------------------------------------|
  7181.   alias horizontal_ecatb? horizontal?
  7182.   def horizontal? # Hotspot
  7183.     BattleManager.btype?(:ecatb) || horizontal_ecatb? # Rewritten
  7184.   end # horizontal?
  7185.  
  7186.   #----------------------------------------------------------------------------|
  7187.   #  Always allow cyclic directional navigations in the ecatb battle system    |
  7188.   #----------------------------------------------------------------------------|
  7189.   alias cursor_right_ecatb cursor_right
  7190.   def cursor_right(wrap = false) # Hotspot
  7191.     cursor_right_ecatb(wrap || BattleManager.btype?(:ecatb)) # Rewritten
  7192.   end # cursor_right
  7193.  
  7194.   #----------------------------------------------------------------------------|
  7195.   #  Always allow cyclic directional navigations in the ecatb battle system    |
  7196.   #----------------------------------------------------------------------------|
  7197.   alias cursor_left_ecatb cursor_left
  7198.   def cursor_left(wrap = false) # Hotspot
  7199.     cursor_left_ecatb(wrap || BattleManager.btype?(:ecatb)) # Rewritten
  7200.   end # cursor_left
  7201.  
  7202.   #----------------------------------------------------------------------------|
  7203.   #  Calls the hotkey handler methods if the hotkey's pressed                  |
  7204.   #----------------------------------------------------------------------------|
  7205.   module_eval(DoubleX_RMVXA::ECATB::ACTOR_HOTKEY) # Alias; Hotspot
  7206.  
  7207.   #----------------------------------------------------------------------------|
  7208.   #  Initializes the new block to trade memory usage for time performance      |
  7209.   #----------------------------------------------------------------------------|
  7210.   def init_ecatb_block # New
  7211.     super
  7212.     # Calls this block instead of an anonymous function per enumerable iteration
  7213.     @ecatb_hotkey_block =
  7214.     -> hotkey { return call_handler(hotkey) if Input.trigger?(hotkey) }
  7215.     #
  7216.   end # init_ecatb_block
  7217.  
  7218. end # Window_BattleActor
  7219.  
  7220. #------------------------------------------------------------------------------|
  7221. #  * Adds enemy selection hotkeys and fixes bugs and edge cases                |
  7222. #------------------------------------------------------------------------------|
  7223. class Window_BattleEnemy < Window_Selectable # Edit
  7224.  
  7225.   #----------------------------------------------------------------------------|
  7226.   #  New private instance variable                                             |
  7227.   #----------------------------------------------------------------------------|
  7228.   # @ecatb_hotkey_block: The hotkey handling block
  7229.  
  7230.   #----------------------------------------------------------------------------|
  7231.   #  Updates only when the enemies has changed                                 |
  7232.   #----------------------------------------------------------------------------|
  7233.   def update # Rewrite; Hotspot
  7234.     super
  7235.     # Added
  7236.     return unless active && (!BattleManager.btype?(:ecatb) || ecatb_update?)
  7237.     #
  7238.     return enemy.sprite_effect_type = :whiten unless select_all?
  7239.     @data.each(&DoubleX_RMVXA::ECATB::BLOCKS[:window_battleenemy_update])
  7240.   end # update
  7241.  
  7242.   #----------------------------------------------------------------------------|
  7243.   #  Initializes the new block used by process_handling as well                |
  7244.   #----------------------------------------------------------------------------|
  7245.   alias initialize_ecatb initialize # v0.04d+
  7246.   def initialize(info_viewport, &argb)
  7247.     initialize_ecatb(info_viewport, &argb)
  7248.     init_ecatb_block # Added
  7249.   end # initialize
  7250.  
  7251.   #----------------------------------------------------------------------------|
  7252.   #  Prevents division by 0 error                                              |
  7253.   #----------------------------------------------------------------------------|
  7254.   alias col_max_ecatb col_max
  7255.   def col_max # Hotspot
  7256.     # Added
  7257.     return ((max = col_max_ecatb) < 1 ? 1 : max) if BattleManager.btype?(:ecatb)
  7258.     #
  7259.     col_max_ecatb
  7260.   end # col_max
  7261.  
  7262.   #----------------------------------------------------------------------------|
  7263.   #  Calls the hotkey handler methods if the hotkey's pressed                  |
  7264.   #----------------------------------------------------------------------------|
  7265.   module_eval(DoubleX_RMVXA::ECATB::ACTOR_HOTKEY) # v0.04d+; Alias; Hotspot
  7266.  
  7267.   #----------------------------------------------------------------------------|
  7268.   #  Checks if the enemies has changed and updates their data accordingly      |
  7269.   #----------------------------------------------------------------------------|
  7270.   def ecatb_update? # New; Hotspot
  7271.     return false if (alive_members = $game_troop.alive_members).empty?
  7272.     if @data.size != alive_members.size
  7273.       @data = alive_members
  7274.       @data.sort!(&DoubleX_RMVXA::ECATB::BLOCKS[:sort_screen_x])
  7275.       @index = @data.size - 1 if @index >= @data.size
  7276.     end
  7277.     true
  7278.   end # ecatb_update?
  7279.  
  7280.   #----------------------------------------------------------------------------|
  7281.   #  Initializes the new block to trade memory usage for time performance      |
  7282.   #----------------------------------------------------------------------------|
  7283.   def init_ecatb_block # v0.04d+; New
  7284.     # Calls this block instead of an anonymous function per enumerable iteration
  7285.     @ecatb_hotkey_block =
  7286.     -> hotkey { return call_handler(hotkey) if Input.trigger?(hotkey) }
  7287.     #
  7288.   end # init_ecatb_block
  7289.  
  7290. end # Window_BattleEnemy
  7291.  
  7292. #------------------------------------------------------------------------------|
  7293. #  * Fixes bugs and edge cases                                                 |
  7294. #------------------------------------------------------------------------------|
  7295. class Window_BattleHelp < Window_Help # v0.04a+; Edit
  7296.  
  7297.   #----------------------------------------------------------------------------|
  7298.   #  Only lets valid battlers have their names retrieved                       |
  7299.   #----------------------------------------------------------------------------|
  7300.   alias battler_name_ecatb battler_name
  7301.   def battler_name(battler) # Hotspot
  7302.     battler ? battler_name_ecatb(battler) : nil # Rewritten
  7303.   end # battler_name
  7304.  
  7305.   alias refresh_battler_name_ecatb refresh_battler_name
  7306.   def refresh_battler_name(battler) # v0.05a+; Hotspot
  7307.     refresh_battler_name_ecatb(battler) if battler # Rewritten
  7308.   end # refresh_battler_name
  7309.  
  7310. end # Window_BattleHelp
  7311.  
  7312. #------------------------------------------------------------------------------|
  7313. #  * Handles the battle atb clock and turn number window                       |
  7314. #------------------------------------------------------------------------------|
  7315. class ECATB_Clock_Window < Window_Base # New
  7316.  
  7317.   #----------------------------------------------------------------------------|
  7318.   #  Public instance variables                                                 |
  7319.   #----------------------------------------------------------------------------|
  7320.   attr_reader :clock_bar # The atb clock bar
  7321.   attr_writer :cur_clock # The current atb clock
  7322.   attr_writer :max_clock # The atb clock maximum
  7323.  
  7324.   #----------------------------------------------------------------------------|
  7325.   #  Private instance variables                                                |
  7326.   #----------------------------------------------------------------------------|
  7327.   # @last_text_x: The last text x position
  7328.   # @last_text_y: The last text y position
  7329.  
  7330.   # cur_clock: The number of frames passed in the current turn
  7331.   # max_clock: The number of frames of the current turn
  7332.   def initialize(cur_clock, max_clock)
  7333.     create_ecatb_defs
  7334.     xyz = ecatb_clock_window_xyz
  7335.     super(xyz[0], xyz[1], (wh = ecatb_clock_window_wh)[0], wh[1])
  7336.     self.z = xyz[2]
  7337.     @clock_bar = ECATB_Clock_Bar.new
  7338.     @cur_clock = cur_clock
  7339.     @max_clock = max_clock
  7340.     update_text_font
  7341.     update_text_xy
  7342.     refresh
  7343.   end # initialize
  7344.  
  7345.   #----------------------------------------------------------------------------|
  7346.   #  Creates and checks the associated method for each configuration used here |
  7347.   #----------------------------------------------------------------------------|
  7348.   # config: The configuration requesting its associated method
  7349.   # validate: The configuration value validation flag
  7350.   def create_ecatb_def(config, validate = true) # New
  7351.     # Uses the name and value of configuration as its method's name and contents
  7352.     method = config.id2name
  7353.     eval(%Q(
  7354.   def #{method}#{DoubleX_RMVXA::ECATB::ECATB_CLOCK_WINDOW[config][0]}
  7355.     #{$game_system.send(config)}
  7356.   end
  7357.     ))
  7358.     #
  7359.     return unless validate
  7360.     check_ecatb_def(method, DoubleX_RMVXA::ECATB::ECATB_CLOCK_WINDOW[config])
  7361.   end # create_ecatb_def
  7362.  
  7363.   #----------------------------------------------------------------------------|
  7364.   #  Checks all new methods and resets them to the defaults if they're invalid |
  7365.   #----------------------------------------------------------------------------|
  7366.   module_eval(DoubleX_RMVXA::ECATB::CHECK_RESET_DEF[:ECATB_CLOCK_WINDOW])
  7367.  
  7368.   def dispose
  7369.     @clock_bar.dispose if @clock_bar
  7370.     super
  7371.   end # dispose
  7372.  
  7373.   #----------------------------------------------------------------------------|
  7374.   #  Updates the window positions, width and height, and text font             |
  7375.   #----------------------------------------------------------------------------|
  7376.   module_eval(DoubleX_RMVXA::ECATB::WINDOW_DEFS[:clock])
  7377.  
  7378.   #----------------------------------------------------------------------------|
  7379.   #  Updates the atb clock text x and y positions only if they change          |
  7380.   #----------------------------------------------------------------------------|
  7381.   def update_text_xy # Potential Hotspot
  7382.     xy = ecatb_clock_text_xy
  7383.     @last_text_x = xy[0] if @last_text_x != xy[0]
  7384.     @last_text_y = xy[1] if @last_text_y != xy[1]
  7385.   end # update_text_xy
  7386.  
  7387.   #----------------------------------------------------------------------------|
  7388.   #  Refreshes the atb clock window bar and text                               |
  7389.   #----------------------------------------------------------------------------|
  7390.   def refresh # Hotspot
  7391.     contents.clear
  7392.     @clock_bar.update_bar(@cur_clock, @max_clock)
  7393.       draw_text(@last_text_x, @last_text_y, contents.width, contents.height,
  7394.     ecatb_clock_text(@cur_clock, @max_clock, $game_troop.turn_count), 0)
  7395.   end # refresh
  7396.  
  7397. end # ECATB_Clock_Window
  7398.  
  7399. #------------------------------------------------------------------------------|
  7400. #  * Handles the atb force status window                                       |
  7401. #------------------------------------------------------------------------------|
  7402. class ECATB_Force_Window < Window_Base # New
  7403.  
  7404.   #----------------------------------------------------------------------------|
  7405.   #  Private instance variables                                                |
  7406.   #----------------------------------------------------------------------------|
  7407.   # @last_text_x: The last text x position
  7408.   # @last_text_y: The last text y position
  7409.  
  7410.   # force: The atb force status
  7411.   def initialize(force)
  7412.     create_ecatb_defs
  7413.     xyz = ecatb_force_window_xyz
  7414.     super(xyz[0], xyz[1], (wh = ecatb_force_window_wh)[0], wh[1])
  7415.     self.z = xyz[2]
  7416.     update_text_font
  7417.     update_text_xy
  7418.     draw_text(force ||= :nil)
  7419.   end # initialize
  7420.  
  7421.   #----------------------------------------------------------------------------|
  7422.   #  Creates and checks the associated method for each configuration used here |
  7423.   #----------------------------------------------------------------------------|
  7424.   # config: The configuration requesting its associated method
  7425.   # validate: The configuration value validation flag
  7426.   def create_ecatb_def(config, validate = true) # New
  7427.     # Uses the name and value of configuration as its method's name and contents
  7428.     method = config.id2name
  7429.     eval(%Q(
  7430.   def #{method}#{DoubleX_RMVXA::ECATB::ECATB_FORCE_WINDOW[config][0]}
  7431.     #{$game_system.send(config)}
  7432.   end
  7433.     ))
  7434.     #
  7435.     return unless validate
  7436.     check_ecatb_def(method, DoubleX_RMVXA::ECATB::ECATB_FORCE_WINDOW[config])
  7437.   end # create_ecatb_def
  7438.  
  7439.   #----------------------------------------------------------------------------|
  7440.   #  Checks all new methods and resets them to the defaults if they're invalid |
  7441.   #----------------------------------------------------------------------------|
  7442.   module_eval(DoubleX_RMVXA::ECATB::CHECK_RESET_DEF[:ECATB_FORCE_WINDOW])
  7443.  
  7444.   #----------------------------------------------------------------------------|
  7445.   #  Updates the window positions, width and height, and text font             |
  7446.   #----------------------------------------------------------------------------|
  7447.   module_eval(DoubleX_RMVXA::ECATB::WINDOW_DEFS[:force])
  7448.  
  7449.   #----------------------------------------------------------------------------|
  7450.   #  Updates the atb force text x and y positions only if they change          |
  7451.   #----------------------------------------------------------------------------|
  7452.   def update_text_xy # Potential Hotspot
  7453.     xy = ecatb_force_text_xy
  7454.     @last_text_x = xy[0] if @last_text_x != xy[0]
  7455.     @last_text_y = xy[1] if @last_text_y != xy[1]
  7456.   end # update_text_xy
  7457.  
  7458.   # force: The atb force status
  7459.   def draw_text(force)
  7460.     contents.clear
  7461.     text = if force == :nil
  7462.       ecatb_force_nil_text
  7463.     elsif force == :run
  7464.       ecatb_force_run_text
  7465.     else
  7466.       ecatb_force_stop_text
  7467.     end
  7468.       super(@last_text_x, @last_text_y, contents.width, contents.height, text, 0)
  7469.   end # draw_text
  7470.  
  7471. end # ECATB_Force_Window
  7472.  
  7473. #------------------------------------------------------------------------------|
  7474. #  * Handles the atb battler icon order window                                 |
  7475. #------------------------------------------------------------------------------|
  7476. class ECATB_Order_Window < Window_Base # v0.01a+; New
  7477.  
  7478.   #----------------------------------------------------------------------------|
  7479.   #  Private instance variable                                                 |
  7480.   #----------------------------------------------------------------------------|
  7481.   # @battler_icons: All atb order battler icons
  7482.  
  7483.   def initialize
  7484.     create_ecatb_defs
  7485.     xyz = ecatb_order_window_xyz
  7486.     super(xyz[0], xyz[1], (wh = ecatb_order_window_wh)[0], wh[1])
  7487.     self.z = xyz[2]
  7488.     draw_bars
  7489.     @battler_icons = {}
  7490.     ($game_party.all_members + $game_troop.members).each { |mem|
  7491.       @battler_icons[mem] = ECATB_Order_Battler_Icon.new(mem, self)
  7492.     }
  7493.   end # initialize
  7494.  
  7495.   #----------------------------------------------------------------------------|
  7496.   #  Creates and checks the associated method for each configuration used here |
  7497.   #----------------------------------------------------------------------------|
  7498.   # config: The configuration requesting its associated method
  7499.   # validate: The configuration value validation flag
  7500.   def create_ecatb_def(config, validate = true) # New
  7501.     # Uses the name and value of configuration as its method's name and contents
  7502.     method = config.id2name
  7503.     eval(%Q(
  7504.   def #{method}#{DoubleX_RMVXA::ECATB::ECATB_ORDER_WINDOW[config][0]}
  7505.     #{$game_system.send(config)}
  7506.   end
  7507.     ))
  7508.     #
  7509.     return unless validate
  7510.     check_ecatb_def(method, DoubleX_RMVXA::ECATB::ECATB_ORDER_WINDOW[config])
  7511.   end # create_ecatb_def
  7512.  
  7513.   #----------------------------------------------------------------------------|
  7514.   #  Checks all new methods and resets them to the defaults if they're invalid |
  7515.   #----------------------------------------------------------------------------|
  7516.   module_eval(DoubleX_RMVXA::ECATB::CHECK_RESET_DEF[:ECATB_ORDER_WINDOW])
  7517.  
  7518.   def dispose
  7519.     @battler_icons.each_value(&DoubleX_RMVXA::ECATB::BLOCKS[:dispose])
  7520.     super
  7521.   end # dispose
  7522.  
  7523.   #----------------------------------------------------------------------------|
  7524.   #  Updates the window positions, width and height, and text font             |
  7525.   #----------------------------------------------------------------------------|
  7526.   module_eval(DoubleX_RMVXA::ECATB::WINDOW_DEFS[:order])
  7527.  
  7528.   #----------------------------------------------------------------------------|
  7529.   #  Adding and removing some battler icons as well as updating existing ones  |
  7530.   #----------------------------------------------------------------------------|
  7531.   def update_battler_icons # Hotspot
  7532.     update_battler_icon_list
  7533.     @battler_icons.each_value(&DoubleX_RMVXA::ECATB::BLOCKS[:update])
  7534.   end # update_battler_icons
  7535.  
  7536.   #----------------------------------------------------------------------------|
  7537.   #  Updates the list of battlers having icons showing the orders              |
  7538.   #----------------------------------------------------------------------------|
  7539.   def update_battler_icon_list # v0.02b+; Hotspot
  7540.     # Creates and delete icons for newly added and removed battlers respectively
  7541.     unless (actors = $game_temp.ecatb_add_actors).empty?
  7542.       $game_temp.ecatb_add_actors.clear
  7543.       actors.each { |actor|
  7544.         @battler_icons[actor] ||= ECATB_Order_Battler_Icon.new(actor, self)
  7545.       }
  7546.     end
  7547.     return if (actors = $game_temp.ecatb_remove_actors).empty?
  7548.     $game_temp.ecatb_remove_actors.clear
  7549.     actors.each { |a| @battler_icons[a].dispose if @battler_icons[a] }
  7550.     #
  7551.   end # update_battler_icon_list
  7552.  
  7553.   #----------------------------------------------------------------------------|
  7554.   #  Draws the cooldown, atb and charge bars  from the left to the right       |
  7555.   #----------------------------------------------------------------------------|
  7556.   def draw_bars # Potential Hotspot
  7557.     color = ecatb_order_cooldown_bar_colors
  7558.     contents.gradient_fill_rect((xy = ecatb_order_bar_xy)[0], xy[1],
  7559.     (wh = ecatb_order_bar_wh)[0] / 3, wh[1], color[0], color[1])
  7560.     contents.gradient_fill_rect(xy[0] + wh[0] / 3, xy[1], wh[0] / 3, wh[1],
  7561.     (color = ecatb_order_bar_colors)[0], color[1])
  7562.     contents.gradient_fill_rect(xy[0] + wh[0] * 2 / 3, xy[1], wh[0] / 3, wh[1],
  7563.     (color = ecatb_order_charge_bar_colors)[0], color[1])
  7564.     draw_texts(wh[0] / 3)
  7565.   end # draw_bars
  7566.  
  7567.   #----------------------------------------------------------------------------|
  7568.   #  Draws the cooldown, atb and charge texts from the left to the right       |
  7569.   #----------------------------------------------------------------------------|
  7570.   # dw: The maximum cooldown, atb and charge text width
  7571.   def draw_texts(dw) # Potential Hotspot
  7572.     update_text_font
  7573.     wh = text_size(text = ecatb_order_cooldown_bar_text)
  7574.     xy = ecatb_order_text_xy
  7575.     draw_text(xy[0], xy[1], wh.width + 2, wh.height, text)
  7576.     wh = text_size(text = ecatb_order_bar_text)
  7577.     draw_text(xy[0] + dw, xy[1], wh.width + 2, wh.height, text)
  7578.     wh = text_size(text = ecatb_order_charge_bar_text)
  7579.     draw_text(xy[0] + dw * 2, xy[1], wh.width + 2, wh.height, text)
  7580.   end # draw_texts
  7581.  
  7582. end # ECATB_Order_Window
  7583.  
  7584. #------------------------------------------------------------------------------|
  7585. #  * Handles the pool atb mode window                                          |
  7586. #------------------------------------------------------------------------------|
  7587. class ECATB_Pool_Window < Window_Base # New
  7588.  
  7589.   #----------------------------------------------------------------------------|
  7590.   #  Private instance variables                                                |
  7591.   #----------------------------------------------------------------------------|
  7592.   # @last_party_x: The last party pool text x position
  7593.   # @last_party_y: The last party pool text y position
  7594.   # @last_troop_x: The last troop pool text x position
  7595.   # @last_troop_y: The last troop pool text y position
  7596.  
  7597.   def initialize
  7598.     create_ecatb_defs
  7599.     xyz = ecatb_pool_window_xyz
  7600.     super(xyz[0], xyz[1], (wh = ecatb_pool_window_wh)[0], wh[1])
  7601.     self.z = xyz[2]
  7602.     update_text_font
  7603.     update_text_xy
  7604.     draw_text
  7605.   end # initialize
  7606.  
  7607.   #----------------------------------------------------------------------------|
  7608.   #  Creates and checks the associated method for each configuration used here |
  7609.   #----------------------------------------------------------------------------|
  7610.   # config: The configuration requesting its associated method
  7611.   # validate: The configuration value validation flag
  7612.   def create_ecatb_def(config, validate = true) # New
  7613.     # Uses the name and value of configuration as its method's name and contents
  7614.     method = config.id2name
  7615.     eval(%Q(
  7616.   def #{method}#{DoubleX_RMVXA::ECATB::ECATB_POOL_WINDOW[config][0]}
  7617.     #{$game_system.send(config)}
  7618.   end
  7619.     ))
  7620.     #
  7621.     return unless validate
  7622.     check_ecatb_def(method, DoubleX_RMVXA::ECATB::ECATB_POOL_WINDOW[config])
  7623.   end # create_ecatb_def
  7624.  
  7625.   #----------------------------------------------------------------------------|
  7626.   #  Checks all new methods and resets them to the defaults if they're invalid |
  7627.   #----------------------------------------------------------------------------|
  7628.   module_eval(DoubleX_RMVXA::ECATB::CHECK_RESET_DEF[:ECATB_POOL_WINDOW])
  7629.  
  7630.   #----------------------------------------------------------------------------|
  7631.   #  Updates the window positions, width and height, and text font             |
  7632.   #----------------------------------------------------------------------------|
  7633.   module_eval(DoubleX_RMVXA::ECATB::WINDOW_DEFS[:pool])
  7634.  
  7635.   #----------------------------------------------------------------------------|
  7636.   #  Updates party and troop atb pool mode text x, y positions if they change  |
  7637.   #----------------------------------------------------------------------------|
  7638.   def update_text_xy # Potential Hotspot
  7639.     xy = ecatb_pool_party_text_xy
  7640.     @last_party_x = xy[0] if @last_party_x != xy[0]
  7641.     @last_party_y = xy[1] if @last_party_y != xy[1]
  7642.     xy = ecatb_pool_troop_text_xy
  7643.     @last_troop_x = xy[0] if @last_troop_x != xy[0]
  7644.     @last_troop_y = xy[1] if @last_troop_y != xy[1]
  7645.   end # update_text_xy
  7646.  
  7647.   #----------------------------------------------------------------------------|
  7648.   #  Draws the party and troop atb mode text on the window                     |
  7649.   #----------------------------------------------------------------------------|
  7650.   def draw_text # Potential Hotspot
  7651.     contents.clear
  7652.       super(@last_party_x, @last_party_y, contents.width, contents.height,
  7653.     ecatb_pool_party_actor_text[$game_party.ecatb_pool ? 0 : 1], 0)
  7654.       super(@last_troop_x, @last_troop_y, contents.width, contents.height,
  7655.     ecatb_pool_troop_enemy_text[$game_troop.ecatb_pool ? 0 : 1], 0)
  7656.   end # draw_text
  7657.  
  7658. end # ECATB_Pool_Window
  7659.  
  7660. #------------------------------------------------------------------------------|
  7661. #  * Reconstructs the the whole battle flow to control the atb system          |
  7662. #------------------------------------------------------------------------------|
  7663. class Scene_Battle < Scene_Base # Edit
  7664.  
  7665.   #----------------------------------------------------------------------------|
  7666.   #  New public instance variables                                             |
  7667.   #----------------------------------------------------------------------------|
  7668.   attr_accessor :ecatb_clock_window # The atb clock window
  7669.   attr_accessor :ecatb_force_window # The atb force window
  7670.   attr_accessor :ecatb_order_window # The atb order window
  7671.   attr_accessor :ecatb_pool_window # The atb pool window
  7672.  
  7673.   #----------------------------------------------------------------------------|
  7674.   #  New private instance variables                                            |
  7675.   #----------------------------------------------------------------------------|
  7676.   # @ecatb_act_block: The action execution iterator block
  7677.   # @ecatb_cancel_help_window: The atb cancel help window
  7678.   # @ecatb_clock: The global atb clock
  7679.   # @ecatb_force_clock: The atb force status
  7680.   # @ecatb_refresh_block: The window refresh iterator block
  7681.  
  7682.   #----------------------------------------------------------------------------|
  7683.   #  Creates new methods, window command handlers, variables and blocks as well|
  7684.   #----------------------------------------------------------------------------|
  7685.   alias start_ecatb start
  7686.   def start(*argv, &argb)
  7687.     start_ecatb(*argv, &argb)
  7688.     ecatb_start # Added
  7689.   end # start
  7690.  
  7691.   #----------------------------------------------------------------------------|
  7692.   #  Updates the atb cancel window and force clock for the ecatb battle system |
  7693.   #----------------------------------------------------------------------------|
  7694.   alias update_basic_ecatb update_basic
  7695.   def update_basic # Hotspot
  7696.     update_basic_ecatb
  7697.     # Added
  7698.     return unless BattleManager.btype?(:ecatb)
  7699.     update_ecatb_cancel_window if update_ecatb_cancel_window?
  7700.     update_ecatb_force_clock
  7701.     #
  7702.   end # update_basic
  7703.  
  7704.   #----------------------------------------------------------------------------|
  7705.   #  Run the atb frame update if the wait conditions aren't met as well        |
  7706.   #----------------------------------------------------------------------------|
  7707.   alias update_for_wait_ecatb update_for_wait
  7708.   def update_for_wait # Hotspot
  7709.     update_for_wait_ecatb
  7710.     # Added
  7711.     return unless BattleManager.phase != :init && BattleManager.btype?(:ecatb)
  7712.     ecatb_update if ecatb_update?
  7713.     #
  7714.   end # update_for_wait
  7715.  
  7716.   #----------------------------------------------------------------------------|
  7717.   #  Moves the info viewport according to which windows are active as well     |
  7718.   #----------------------------------------------------------------------------|
  7719.   alias update_info_viewport_ecatb update_info_viewport
  7720.   def update_info_viewport # Hotspot
  7721.     update_info_viewport_ecatb
  7722.     ecatb_update_info_viewport if BattleManager.btype?(:ecatb) # Added
  7723.   end # update_info_viewport
  7724.  
  7725.   #----------------------------------------------------------------------------|
  7726.   #  Open the active status, actor command and party command windows as well   |
  7727.   #----------------------------------------------------------------------------|
  7728.   alias update_message_open_ecatb update_message_open
  7729.   def update_message_open # Hotspot
  7730.     update_message_open_ecatb
  7731.     # Added
  7732.     return if $game_message.busy?
  7733.     return unless @status_window.close?
  7734.     return if $game_troop.all_dead? || $game_party.all_dead?
  7735.     ecatb_update_message_open if BattleManager.btype?(:ecatb)
  7736.     #
  7737.   end # update_message_open
  7738.  
  7739.   #----------------------------------------------------------------------------|
  7740.   #  Create new windows in the ecatb battle system as well                     |
  7741.   #----------------------------------------------------------------------------|
  7742.   alias create_all_windows_ecatb create_all_windows
  7743.   def create_all_windows(*argv, &argb)
  7744.     create_all_windows_ecatb(*argv, &argb)
  7745.     create_ecatb_windows if BattleManager.btype?(:ecatb) # Added
  7746.   end # create_all_windows
  7747.  
  7748.   alias start_actor_command_selection_ecatb start_actor_command_selection
  7749.   def start_actor_command_selection # v0.05a+; Potential Hotspot
  7750.     start_actor_command_selection_ecatb
  7751.     @actor_command_window.show if BattleManager.btype?(:ecatb) # Added
  7752.   end # start_actor_command_selection
  7753.  
  7754.   #----------------------------------------------------------------------------|
  7755.   #  Processes unison attacks as well                                          |
  7756.   #----------------------------------------------------------------------------|
  7757.   alias command_attack_ecatb command_attack
  7758.   def command_attack(*argv, &argb)
  7759.     # Added
  7760.     return unless actor = BattleManager.actor
  7761.     if BattleManager.btype?(:ecatb)
  7762.       ecatb = DoubleX_RMVXA::ECATB
  7763.       actors = ecatb.send($data_skills[actor.attack_skill_id].
  7764.       ecatb_unison_actor, actor).collect!(&ecatb::BLOCKS[:usable?])
  7765.       return command_ecatb_unison_attack(actors) if actors.size > 1
  7766.     end
  7767.     #
  7768.     command_attack_ecatb(*argv, &argb)
  7769.     @status_window.draw_item(actor.index) # Added
  7770.   end # command_attack
  7771.  
  7772.   #----------------------------------------------------------------------------|
  7773.   #  Fixes bugs and edge cases                                                 |
  7774.   #----------------------------------------------------------------------------|
  7775.   alias command_skill_ecatb command_skill
  7776.   def command_skill(*argv, &argb)
  7777.     return if BattleManager.btype?(:ecatb) && !BattleManager.actor # Added
  7778.     command_skill_ecatb(*argv, &argb)
  7779.   end # command_skill
  7780.  
  7781.   #----------------------------------------------------------------------------|
  7782.   #  Confirms the guard and processes unison guards as well                    |
  7783.   #----------------------------------------------------------------------------|
  7784.   alias command_guard_ecatb command_guard
  7785.   def command_guard(*argv, &argb)
  7786.     # Added
  7787.     return unless actor = BattleManager.actor
  7788.     if ecatb = BattleManager.btype?(:ecatb)
  7789.       ecatb = DoubleX_RMVXA::ECATB
  7790.       actors = ecatb.send($data_skills[actor.guard_skill_id].
  7791.       ecatb_unison_actor, actor).collect!(&ecatb::BLOCKS[:usable?])
  7792.       return command_ecatb_unison_attack(actors) if actors.size > 1
  7793.     end
  7794.     actor.input.set_guard
  7795.     if ecatb
  7796.       actor.confirm_ecatb_item
  7797.       @status_window.draw_item(actor.index)
  7798.     end
  7799.     #
  7800.     command_guard_ecatb(*argv, &argb)
  7801.   end # command_guard
  7802.  
  7803.   #----------------------------------------------------------------------------|
  7804.   #  Confirms the skill/item and processes unison confirmation as well         |
  7805.   #----------------------------------------------------------------------------|
  7806.   alias on_actor_ok_ecatb on_actor_ok
  7807.   def on_actor_ok(*argv, &argb)
  7808.     # Added
  7809.     return unless actor = BattleManager.actor
  7810.     if BattleManager.btype?(:ecatb) && on_ecatb_unison?(:ok, @actor_window)
  7811.       return
  7812.     elsif BattleManager.btype?(:ecatb)
  7813.       actor.confirm_ecatb_item
  7814.       @status_window.draw_item(actor.index)
  7815.     end
  7816.     #
  7817.     on_actor_ok_ecatb(*argv, &argb)
  7818.   end # on_actor_ok
  7819.  
  7820.   #----------------------------------------------------------------------------|
  7821.   #  Confirms the skill/item and processes unison confirmation as well         |
  7822.   #----------------------------------------------------------------------------|
  7823.   alias on_enemy_ok_ecatb on_enemy_ok
  7824.   def on_enemy_ok(*argv, &argb)
  7825.     # Added
  7826.     return unless (actor = BattleManager.actor) && @enemy_window.ecatb_update?
  7827.     if BattleManager.btype?(:ecatb) && on_ecatb_unison?(:ok, @enemy_window)
  7828.       return
  7829.     elsif BattleManager.btype?(:ecatb)
  7830.       actor.confirm_ecatb_item
  7831.       @status_window.draw_item(actor.index)
  7832.     end
  7833.     #
  7834.     on_enemy_ok_ecatb(*argv, &argb)
  7835.   end # on_enemy_ok
  7836.  
  7837.   #----------------------------------------------------------------------------|
  7838.   #  Processes unison skill/item target cancellation as well                   |
  7839.   #----------------------------------------------------------------------------|
  7840.   # Alias
  7841.   DoubleX_RMVXA::ECATB::ON_TARGET_CANCEL.each_value { |val| module_eval(val) }
  7842.   #
  7843.  
  7844.   #----------------------------------------------------------------------------|
  7845.   #  Processes unison skill/item selection as well                             |
  7846.   #----------------------------------------------------------------------------|
  7847.   # Alias
  7848.   DoubleX_RMVXA::ECATB::ON_SKILL_ITEM_OK.each_value { |val| module_eval(val) }
  7849.   #
  7850.  
  7851.   #----------------------------------------------------------------------------|
  7852.   #  Closes all input windows right after finishing inputting actions          |
  7853.   #----------------------------------------------------------------------------|
  7854.   alias turn_start_ecatb turn_start
  7855.   def turn_start(*argv, &argb)
  7856.     return ecatb_turn_start if BattleManager.btype?(:ecatb) # Added
  7857.     turn_start_ecatb(*argv, &argb)
  7858.   end # turn_start
  7859.  
  7860.   #----------------------------------------------------------------------------|
  7861.   #  Triggers the atb frame update and executes forced actions as well         |
  7862.   #----------------------------------------------------------------------------|
  7863.   alias process_action_ecatb process_action
  7864.   def process_action # Hotspot
  7865.     return process_action_ecatb unless BattleManager.btype?(:ecatb) # Rewritten
  7866.     # Added
  7867.     ecatb_update if ecatb_update?
  7868.     return unless BattleManager.action_forced?
  7869.     exec_ecatb_act(@subject, true) if exec_ecatb_act?(@subject, true)
  7870.     #
  7871.   end # process_action
  7872.  
  7873.   #----------------------------------------------------------------------------|
  7874.   #  Refreshes all active command, item and target selection windows as well   |
  7875.   #----------------------------------------------------------------------------|
  7876.   alias status_redraw_target_ecatb status_redraw_target
  7877.   def status_redraw_target(target, &argb)
  7878.     # Added
  7879.     return if $game_party.all_dead? || $game_troop.all_dead?
  7880.     return unless BattleManager.phase
  7881.     #
  7882.     status_redraw_target_ecatb(target, &argb)
  7883.     # Added
  7884.     return unless BattleManager.btype?(:ecatb) && target.actor?
  7885.     refresh_ecatb_windows(true)
  7886.     #
  7887.   end # status_redraw_target
  7888.  
  7889.   def ecatb_start # v0.04d+; New
  7890.     create_ecatb_defs
  7891.     if BattleManager.btype?(:ecatb)
  7892.       set_ecatb_battler_window_handlers
  7893.       set_ecatb_actor_command_window_handlers
  7894.     end
  7895.     @ecatb_clock = { tick: 0, act: 0, battler: 0, force: 0 }
  7896.     @ecatb_force_clock = :nil
  7897.     init_ecatb_act_block
  7898.     init_ecatb_actor_refresh_block
  7899.   end # ecatb_start
  7900.  
  7901.   #----------------------------------------------------------------------------|
  7902.   #  Creates and checks the associated method for each configuration used here |
  7903.   #----------------------------------------------------------------------------|
  7904.   # config: The configuration requesting its associated method
  7905.   # validate: The configuration value validation flag
  7906.   def create_ecatb_def(config, validate = true) # New
  7907.     # Uses the name and value of configuration as its method's name and contents
  7908.     method = config.id2name
  7909.     eval(%Q(
  7910.   def #{method}#{DoubleX_RMVXA::ECATB::SCENE_BATTLE[config][0]}
  7911.     #{$game_system.send(config)}
  7912.   end
  7913.     ))
  7914.     #
  7915.     return unless validate
  7916.     check_ecatb_def(method, DoubleX_RMVXA::ECATB::SCENE_BATTLE[config])
  7917.   end # create_ecatb_def
  7918.  
  7919.   #----------------------------------------------------------------------------|
  7920.   #  Checks all new methods and resets them to the defaults if they're invalid |
  7921.   #----------------------------------------------------------------------------|
  7922.   module_eval(DoubleX_RMVXA::ECATB::CHECK_RESET_DEF[:SCENE_BATTLE]) # New
  7923.  
  7924.   #----------------------------------------------------------------------------|
  7925.   #  Initializes the new block to trade memory usage for time performance      |
  7926.   #----------------------------------------------------------------------------|
  7927.   def init_ecatb_act_block # New
  7928.     # Calls this block instead of an anonymous function per enumerable iteration
  7929.     @ecatb_act_block = -> battler {
  7930.       if battler.actor? && battler.input
  7931.         if !battler.input.last_ecatb_confirm && battler.input.ecatb_confirm
  7932.           battler.make_actions
  7933.         end
  7934.       end
  7935.       exec_ecatb_act(battler) if !@subject && exec_ecatb_act?(battler)
  7936.     }
  7937.     #
  7938.   end # init_ecatb_act_block
  7939.  
  7940.   #----------------------------------------------------------------------------|
  7941.   #  Initializes the new block to trade memory usage for time performance      |
  7942.   #----------------------------------------------------------------------------|
  7943.   def init_ecatb_actor_refresh_block # New
  7944.     # Calls this block instead of an anonymous function per enumerable iteration
  7945.     @ecatb_actor_refresh_block = -> mem {
  7946.       next unless mem.ecatb_refresh
  7947.       @actor_window.draw_item(mem.index) if @actor_window.active
  7948.       if @ecatb_cancel_window && @ecatb_cancel_window.active
  7949.         @ecatb_cancel_window.draw_item(mem.index)
  7950.       end
  7951.       @status_aid_window.refresh if @status_aid_window.visible
  7952.       @status_window.draw_item(mem.index) unless @status_window.close?
  7953.       mem.ecatb_refresh = false
  7954.       @ecatb_refresh = true
  7955.     }
  7956.     #
  7957.   end # init_ecatb_actor_refresh_block
  7958.  
  7959.   def create_ecatb_windows # New
  7960.     create_ecatb_cancel_window
  7961.     create_ecatb_clock_window
  7962.     create_ecatb_force_window
  7963.     create_ecatb_order_window
  7964.     create_ecatb_pool_window
  7965.   end # create_ecatb_windows
  7966.  
  7967.   #----------------------------------------------------------------------------|
  7968.   #  Closes all windows upon battle end                                        |
  7969.   #----------------------------------------------------------------------------|
  7970.   def close_ecatb_windows # New
  7971.     @ecatb_cancel_window.hide.deactivate.close if @ecatb_cancel_window
  7972.     close_ecatb_clock_window if @ecatb_clock_window
  7973.     close_ecatb_force_window if @ecatb_force_window
  7974.     close_ecatb_order_window if @ecatb_order_window
  7975.     close_ecatb_pool_window if @ecatb_pool_window
  7976.     [@actor_window, @enemy_window, @skill_window, @item_window, @help_window,
  7977.      @actor_command_window, @party_command_window, @status_aid_window].each(
  7978.     &DoubleX_RMVXA::ECATB::BLOCKS[:close_ecatb_windows])
  7979.   end # close_ecatb_windows
  7980.  
  7981.   #----------------------------------------------------------------------------|
  7982.   #  Sets the battler window selection hotkeys and their handlers              |
  7983.   #----------------------------------------------------------------------------|
  7984.   def set_ecatb_battler_window_handlers # New
  7985.     battler_hotkeys = ecatb_battler_hotkeys
  7986.     create_ecatb_battler_hotkey_defs(battler_hotkeys, "actor", "actor")
  7987.     create_ecatb_battler_hotkey_defs(battler_hotkeys, "enemy", "enemy")
  7988.     battler_hotkeys.each_with_index { |hotkey, index|
  7989.       @actor_window.set_handler(hotkey, method(
  7990.       :"ecatb_actor_hotkey_#{index = index.to_s}"))
  7991.       @enemy_window.set_handler(hotkey, method(:"ecatb_enemy_hotkey_#{index}"))
  7992.     }
  7993.   end # set_ecatb_battler_window_handlers
  7994.  
  7995.   #----------------------------------------------------------------------------|
  7996.   #  Sets actor command window directional inputs and hotkeys and handlers     |
  7997.   #----------------------------------------------------------------------------|
  7998.   def set_ecatb_actor_command_window_handlers # New
  7999.     @actor_command_window.set_handler(:dir4, method(:prior_ecatb_actor))
  8000.     @actor_command_window.set_handler(:dir6, method(:next_ecatb_actor))
  8001.     actor_hotkeys = ecatb_battler_hotkeys
  8002.     create_ecatb_actor_command_hotkey_defs(actor_hotkeys)
  8003.     actor_hotkeys.each_with_index { |hotkey, index|
  8004.       @actor_command_window.set_handler(hotkey, method(
  8005.       :"ecatb_actor_command_hotkey_#{index.to_s}"))
  8006.     }
  8007.   end # set_ecatb_actor_command_window_handlers
  8008.  
  8009.   #----------------------------------------------------------------------------|
  8010.   #  Creates methods used by the actor command hotkey handlers                 |
  8011.   #----------------------------------------------------------------------------|
  8012.   def create_ecatb_actor_command_hotkey_defs(actor_hotkeys) # New
  8013.     actor_hotkeys.each_index { |index|
  8014.       next if respond_to?(:"ecatb_actor_command_hotkey_#{index = index.to_s}")
  8015.       eval(%Q(
  8016.     def ecatb_actor_command_hotkey_#{index}
  8017.       return if @ecatb_cancel_window && @ecatb_cancel_window.active
  8018.       return unless BattleManager.ecatb_input_list(true).include?(#{index})
  8019.       BattleManager.actor_index = #{index}
  8020.       start_actor_command_selection
  8021.     end
  8022.       ))
  8023.     }
  8024.   end # create_ecatb_actor_command_hotkey_defs
  8025.  
  8026.   def create_ecatb_cancel_window # New
  8027.     (@ecatb_cancel_help_window = Window_Help.new).visible = false
  8028.     (@ecatb_cancel_window = Window_BattleActor.new(@info_viewport)).x = 64
  8029.     @ecatb_cancel_window.set_handler(:ok, method(:on_ecatb_cancel_ok))
  8030.     @ecatb_cancel_window.set_handler(:cancel, method(:on_ecatb_cancel_back))
  8031.     battler_hotkeys = eval($game_system.ecatb_battler_hotkeys)
  8032.     create_ecatb_battler_hotkey_defs(battler_hotkeys, "cancel", "ecatb_cancel")
  8033.     battler_hotkeys.each_with_index { |hotkey, index|
  8034.       @ecatb_cancel_window.set_handler(hotkey, method(
  8035.       :"ecatb_cancel_hotkey_#{index.to_s}"))
  8036.     }
  8037.   end # create_ecatb_cancel_window
  8038.  
  8039.   #----------------------------------------------------------------------------|
  8040.   #  Creates methods used by the battler target selection hotkey handlers      |
  8041.   #----------------------------------------------------------------------------|
  8042.   def create_ecatb_battler_hotkey_defs(battler_hotkeys, type, window) # New
  8043.     battler_hotkeys.each_index { |index|
  8044.       eval(%Q(
  8045.     def ecatb_#{type}_hotkey_#{index = index.to_s}
  8046.       @#{window}_window.select(#{index})
  8047.     end
  8048.       )) unless respond_to?(:"ecatb_#{type}_hotkey_#{index}")
  8049.     }
  8050.   end # create_ecatb_battler_hotkey_defs
  8051.  
  8052.   def update_ecatb_cancel_window # New; Hotspot
  8053.     if @ecatb_cancel_window.active
  8054.       unless BattleManager.actor_sprite_ecatb_bar
  8055.         @ecatb_cancel_window.ecatb_bar_refresh
  8056.       end
  8057.       return
  8058.     end
  8059.     activate_ecatb_cancel_window if Input.trigger?(ecatb_cancel_key)
  8060.   end # update_ecatb_cancel_window
  8061.  
  8062.   def activate_ecatb_cancel_window # New
  8063.     @status_window.hide
  8064.     @actor_command_window.close if @actor_command_window.active
  8065.     @party_command_window.close if @party_command_window.active
  8066.     select_ecatb_cancel_selection
  8067.   end # activate_ecatb_cancel_window
  8068.  
  8069.   def on_ecatb_cancel_ok # New
  8070.     # Picks the actor and cancels that actor's action if it can be cancelled
  8071.     actor = $game_party.battle_members[@ecatb_cancel_window.index]
  8072.     return select_ecatb_cancel_selection unless actor.inputable?
  8073.     if actor.ecatb_val[:charge] <= 0.0 || actor.ecatb_val[:charge] >= 100.0
  8074.       return select_ecatb_cancel_selection unless actor.ecatb_esc
  8075.     end
  8076.     ecatb_cancel_act(actor)
  8077.     #
  8078.   end # on_ecatb_cancel_ok
  8079.  
  8080.   #----------------------------------------------------------------------------|
  8081.   #  Asks the actor to pay the action costs and clears that action             |
  8082.   #----------------------------------------------------------------------------|
  8083.   def ecatb_cancel_act(actor) # New
  8084.     # Asks all unison invokees to do those as well if the skill/item is unison
  8085.     if actor.ecatb_unison_actors.size < 2
  8086.       actor.ecatb_reset
  8087.       @status_window.draw_item(actor.index)
  8088.       @ecatb_cancel_window.draw_item(actor.index)
  8089.     else
  8090.       ecatb_cancel_unison_act(actor.ecatb_unison_actors)
  8091.     end
  8092.     #
  8093.     select_ecatb_cancel_selection
  8094.   end # ecatb_cancel_act
  8095.  
  8096.   #----------------------------------------------------------------------------|
  8097.   #  Pays the action costs and clears that action for unison skills/items      |
  8098.   #----------------------------------------------------------------------------|
  8099.   # actors: The unison actors
  8100.   def ecatb_cancel_unison_act(actors) # New
  8101.     actors.each { |actor|
  8102.       actor.ecatb_reset
  8103.       @status_window.draw_item(actor.index)
  8104.       @ecatb_cancel_window.draw_item(actor.index)
  8105.     }
  8106.   end # ecatb_cancel_unison_act
  8107.  
  8108.   def select_ecatb_cancel_selection # New
  8109.     @ecatb_cancel_window.show.activate.refresh
  8110.     @ecatb_cancel_help_window.show.activate.set_text(ecatb_cancel_text)
  8111.   end # select_ecatb_cancel_selection
  8112.  
  8113.   def on_ecatb_cancel_back # New
  8114.     @ecatb_cancel_window.hide.deactivate
  8115.     @ecatb_cancel_help_window.hide.deactivate
  8116.     @status_window.show
  8117.     @actor_command_window.open if @actor_command_window.active
  8118.     @party_command_window.open if @party_command_window.active
  8119.   end # on_ecatb_cancel_back
  8120.  
  8121.   def create_ecatb_clock_window # New
  8122.     return if @ecatb_clock_window
  8123.     return unless eval($game_system.show_ecatb_clock_window)
  8124.     @ecatb_clock_window = ECATB_Clock_Window.new(@ecatb_clock ?
  8125.     @ecatb_clock[eval($game_system.ecatb_turn_type)] : 0, ecatb_max_clock)
  8126.   end # create_ecatb_clock_window
  8127.  
  8128.   def ecatb_max_clock # New
  8129.     if (type = eval($game_system.ecatb_turn_type)) == :tick
  8130.       return eval($game_system.ecatb_tick_count) * Graphics.frame_rate
  8131.     elsif type == :act
  8132.       return eval($game_system.ecatb_after_act)
  8133.     end
  8134.     eval($game_system.ecatb_battler_count) *
  8135.     eval($game_system.ecatb_battler_scale)[0]
  8136.   end # ecatb_max_clock
  8137.  
  8138.   #----------------------------------------------------------------------------|
  8139.   #  Creates the atb force, order and pool windows                             |
  8140.   #----------------------------------------------------------------------------|
  8141.   # v0.01b+; New
  8142.   DoubleX_RMVXA::ECATB::CREATE_WINDOW.each_value { |val| module_eval(val) }
  8143.   #
  8144.  
  8145.   #----------------------------------------------------------------------------|
  8146.   #  Closes the atb clock, force, order and pool windows                       |
  8147.   #----------------------------------------------------------------------------|
  8148.   # v0.01b+; New
  8149.   DoubleX_RMVXA::ECATB::CLOSE_WINDOW.each_value { |val| module_eval(val) }
  8150.   #
  8151.  
  8152.   #----------------------------------------------------------------------------|
  8153.   #  Moves the info viewport according to which windows are active             |
  8154.   #----------------------------------------------------------------------------|
  8155.   def ecatb_update_info_viewport # New; Hotspot
  8156.     return move_info_viewport(128) if @actor_command_window.active ||
  8157.     @actor_window.active || @enemy_window.active
  8158.     move_info_viewport(0) if @party_command_window.active ||
  8159.     update_msg_open_ecatb_compatibility?
  8160.   end # ecatb_update_info_viewport
  8161.  
  8162.   #----------------------------------------------------------------------------|
  8163.   #  Opens the status, command, item and target windows if they're active      |
  8164.   #----------------------------------------------------------------------------|
  8165.   def ecatb_update_message_open # New; Hotspot
  8166.     @status_window.open
  8167.     return @actor_command_window.open if @skill_window.active ||
  8168.     @item_window.active || @actor_window.active || @enemy_window.active ||
  8169.     @actor_command_window.active
  8170.     @party_command_window.open if @party_command_window.active ||
  8171.     update_msg_open_ecatb_compatibility?
  8172.   end # ecatb_update_message_open
  8173.  
  8174.   #----------------------------------------------------------------------------|
  8175.   #  Closes all input windows right after finishing inputting actions          |
  8176.   #----------------------------------------------------------------------------|
  8177.   def ecatb_turn_start # New
  8178.     @party_command_window.close
  8179.     @actor_command_window.close
  8180.     @status_window.unselect
  8181.     @log_window.wait
  8182.     @log_window.clear
  8183.   end # ecatb_turn_start
  8184.  
  8185.   def update_ecatb_force_clock # New; Hotspot
  8186.     if Input.trigger?(ecatb_force_run_key)
  8187.       @ecatb_force_clock = @ecatb_force_clock == :stop ? :nil : :run
  8188.       @ecatb_force_window.draw_text(@ecatb_force_clock) if @ecatb_force_window
  8189.     elsif Input.trigger?(ecatb_force_stop_key)
  8190.       @ecatb_force_clock = @ecatb_force_clock == :run ? :nil : :stop
  8191.       @ecatb_force_window.draw_text(@ecatb_force_clock) if @ecatb_force_window
  8192.     end
  8193.   end # update_ecatb_force_clock
  8194.  
  8195.   #----------------------------------------------------------------------------|
  8196.   #  Runs the atb frame update                                                 |
  8197.   #----------------------------------------------------------------------------|
  8198.   def ecatb_update # New; Hotspot
  8199.     pre_ecatb_update
  8200.     ecatb_ctb_update
  8201.     return unless BattleManager.phase
  8202.     refresh_ecatb_windows
  8203.     ecatb_update_actors
  8204.     unless @party_command_window.active || @status_window.index >= 0
  8205.       unless @ecatb_cancel_window && @ecatb_cancel_window.active
  8206.         start_actor_command_selection if BattleManager.ecatb_update_act_actor?
  8207.       end
  8208.     end
  8209.     BattleManager.action_battlers.each(&@ecatb_act_block)
  8210.     post_ecatb_update
  8211.   end # ecatb_update
  8212.  
  8213.   #----------------------------------------------------------------------------|
  8214.   #  Runs the battle and all battlers' atb clocks until any of them has to stop|
  8215.   #----------------------------------------------------------------------------|
  8216.   def ecatb_ctb_update # v0.04d+; New; Hotspot
  8217.     begin
  8218.       ecatb_update_tick_battler_count
  8219.       BattleManager.ecatb_update
  8220.     end until BattleManager.ecatb_ctb_break?
  8221.     @ecatb_clock_window.refresh if @ecatb_clock_window
  8222.   end # ecatb_ctb_update
  8223.  
  8224.   #----------------------------------------------------------------------------|
  8225.   #  Refreshes all windows used by actors if at least 1 of them has refreshed  |
  8226.   #----------------------------------------------------------------------------|
  8227.   # redrawn: Whether the whole status window has been redrawn
  8228.   def refresh_ecatb_windows(redrawn = false) # New; Hotspot
  8229.     $game_party.alive_members.each(&@ecatb_actor_refresh_block)
  8230.     @ecatb_order_window.update_battler_icons if @ecatb_order_window
  8231.     if @ecatb_refresh
  8232.       [@skill_window, @item_window, @actor_command_window,
  8233.       @party_command_window].each(
  8234.       &DoubleX_RMVXA::ECATB::BLOCKS[:refresh_ecatb_windows])
  8235.       refresh_ecatb_windows_compatibility
  8236.       return @ecatb_refresh = false
  8237.     end
  8238.     return if BattleManager.actor_sprite_ecatb_bar
  8239.     @status_window.ecatb_bar_refresh unless redrawn && @status_window.close?
  8240.     @actor_window.ecatb_bar_refresh if @actor_window.active
  8241.   end # refresh_ecatb_windows
  8242.  
  8243.   #----------------------------------------------------------------------------|
  8244.   #  Resets non-actable selected actor's atb and updates all windows           |
  8245.   #----------------------------------------------------------------------------|
  8246.   def ecatb_update_actors # New; Hotspot
  8247.     if @status_window.index >= 0
  8248.       return if BattleManager.ecatb_input_list(true).include?(
  8249.       @status_window.index)
  8250.       ecatb_update_windows
  8251.     elsif BattleManager.ecatb_input_list.empty?
  8252.       @party_command_window.deactivate.close if @party_command_window.active
  8253.     end
  8254.   end # ecatb_update_actors
  8255.  
  8256.   def ecatb_update_windows # New; Hotspot
  8257.     if @skill_window.visible || @item_window.visible ||
  8258.     @actor_window.visible || @enemy_window.visible
  8259.       @status_window.open.show
  8260.       @status_aid_window.hide
  8261.     end
  8262.     [@actor_window, @enemy_window, @skill_window, @item_window,
  8263.      @actor_command_window].each(
  8264.      &DoubleX_RMVXA::ECATB::BLOCKS[:ecatb_update_windows])
  8265.     @status_window.unselect
  8266.   end # ecatb_update_windows
  8267.  
  8268.   def ecatb_update_tick_battler_count # New; Hotspot
  8269.     return ecatb_update_tick_count if (type = ecatb_turn_type) == :tick
  8270.     return if type != :battler || ecatb_battler_scale[1] != :tick
  8271.     ecatb_update_battler_count
  8272.   end # ecatb_update_tick_battler_count
  8273.  
  8274.   def ecatb_update_tick_count # New; Hotspot
  8275.     max_clock = ecatb_tick_count * Graphics.frame_rate
  8276.     if (@ecatb_clock[:tick] += 1) >= max_clock
  8277.       @ecatb_clock[:tick] = 0
  8278.       ecatb_turn_add
  8279.     end
  8280.     return unless @ecatb_clock_window
  8281.     @ecatb_clock_window.cur_clock = @ecatb_clock[:tick]
  8282.     @ecatb_clock_window.max_clock = max_clock
  8283.   end # ecatb_update_tick_count
  8284.  
  8285.   # forced: The action force flag
  8286.   def exec_ecatb_act(subject, forced = false) # New
  8287.     # Disables party escape during action executions
  8288.     BattleManager.ecatb_can_esc = false
  8289.     force_act_cost = nil
  8290.     if @subject.current_action
  8291.       force_act_cost = exec_ecatb_act_loop(forced)
  8292.       exec_ecatb_act_clock(forced)
  8293.       process_action_end
  8294.     end
  8295.     BattleManager.ecatb_can_esc = true
  8296.     #
  8297.     return if BattleManager.judge_win_loss
  8298.     exec_ecatb_act_reset(forced, force_act_cost) if BattleManager.phase
  8299.   end # exec_ecatb_act
  8300.  
  8301.   #----------------------------------------------------------------------------|
  8302.   #  Executes all the battler's valid actions and sets their costs             |
  8303.   #----------------------------------------------------------------------------|
  8304.   # forced: The action force flag
  8305.   def exec_ecatb_act_loop(forced) # New
  8306.     while @subject.current_action.valid?
  8307.       @subject.current_action.prepare
  8308.       execute_action
  8309.       force_act_cost = @subject.exec_ecatb_act_cost(forced)
  8310.       process_event
  8311.       @subject.remove_current_action
  8312.       return if force_act_cost = exec_ecatb_act_loop_compatibility?(forced)
  8313.     end
  8314.     force_act_cost
  8315.   end # exec_ecatb_act_loop
  8316.  
  8317.   # forced: The action force flag
  8318.   def exec_ecatb_act_clock(forced) # New
  8319.     return exec_ecatb_act_update(forced) if (type = ecatb_turn_type) == :act
  8320.     return if type != :battler || ecatb_battler_scale[1] != :act
  8321.     ecatb_update_battler_count(forced)
  8322.   end # exec_ecatb_act_clock
  8323.  
  8324.   # forced: The action force flag
  8325.   def exec_ecatb_act_update(forced) # New
  8326.     @ecatb_clock[:act] += 1 if !forced || ecatb_force_act_count
  8327.     if @ecatb_clock[:act] >= (after_act = ecatb_after_act)
  8328.       @ecatb_clock[:act] = 0
  8329.       ecatb_turn_add
  8330.     end
  8331.     return unless @ecatb_clock_window
  8332.     @ecatb_clock_window.cur_clock = @ecatb_clock[:act]
  8333.     @ecatb_clock_window.max_clock = after_act
  8334.     @ecatb_clock_window.refresh
  8335.   end # exec_ecatb_act_update
  8336.  
  8337.   # forced: The action force flag
  8338.   def ecatb_update_battler_count(forced = false) # New; Hotspot
  8339.     @ecatb_clock[:battler] += 1 if !forced || ecatb_force_act_count
  8340.     max_clock = ecatb_battler_count * ecatb_battler_scale[0]
  8341.     if @ecatb_clock[:battler] >= (max_clock *= Graphics.frame_rate)
  8342.       @ecatb_clock[:battler] = 0
  8343.       ecatb_turn_add
  8344.     end
  8345.     return unless @ecatb_clock_window
  8346.     @ecatb_clock_window.cur_clock = @ecatb_clock[:tick]
  8347.     @ecatb_clock_window.max_clock = max_clock
  8348.   end # ecatb_update_battler_count
  8349.  
  8350.   #----------------------------------------------------------------------------|
  8351.   #  Resets the battler's atb and refreshes the actor in the status window     |
  8352.   #----------------------------------------------------------------------------|
  8353.   # forced: The action force flag
  8354.   def exec_ecatb_act_reset(forced, force_act_cost) # New
  8355.     if !forced || force_act_cost
  8356.       if @subject.ecatb_unison_actors.size > 1
  8357.         (@subject.ecatb_unison_actors & $game_party.alive_members).each { |a|
  8358.           a.ecatb_reset
  8359.           @status_window.draw_item(a.index)
  8360.         }
  8361.       else
  8362.         @subject.ecatb_reset
  8363.         @status_window.draw_item(@subject.index) if @subject.actor?
  8364.       end
  8365.     end
  8366.     @subject = nil
  8367.   end # exec_ecatb_act_reset
  8368.  
  8369.   def ecatb_turn_add # New
  8370.     BattleManager.turn_end if BattleManager.phase
  8371.     ecatb_turn_add_compatibility
  8372.     BattleManager.ecatb_on_turn_end
  8373.     $game_troop.increase_turn
  8374.   end # ecatb_turn_add
  8375.  
  8376.   #----------------------------------------------------------------------------|
  8377.   #  Picks and setups the prior inputable actor if any                         |
  8378.   #----------------------------------------------------------------------------|
  8379.   def prior_ecatb_actor # New; Potential Hotspot
  8380.     return if @ecatb_cancel_window && @ecatb_cancel_window.active
  8381.     start_actor_command_selection if BattleManager.change_ecatb_actor?(-1)
  8382.   end # prior_ecatb_actor
  8383.  
  8384.   #----------------------------------------------------------------------------|
  8385.   #  Picks and setups the next inputable actor if any                          |
  8386.   #----------------------------------------------------------------------------|
  8387.   def next_ecatb_actor # New; Potential Hotspot
  8388.     return if @ecatb_cancel_window && @ecatb_cancel_window.active
  8389.     start_actor_command_selection if BattleManager.change_ecatb_actor?(1)
  8390.   end # next_ecatb_actor
  8391.  
  8392.   # actors: The unison actors
  8393.   def command_ecatb_unison_attack(actors) # New
  8394.     $game_temp.battle_aid = $data_skills[BattleManager.actor.attack_skill_id]
  8395.     actors.each { |actor|
  8396.       actor.input.set_attack
  8397.       @status_window.draw_item(actor.index)
  8398.     }
  8399.     select_enemy_selection
  8400.   end # command_ecatb_unison_attack
  8401.  
  8402.   # actors: The unison actors
  8403.   def command_ecatb_unison_guard(actors) # New
  8404.     $game_temp.battle_aid = $data_skills[BattleManager.actor.guard_skill_id]
  8405.     confirm_ecatb_unison_item(actors)
  8406.     next_command
  8407.   end # command_ecatb_unison_guard
  8408.  
  8409.   # actors: The unison actors
  8410.   # window: The window having the unison item
  8411.   def on_ecatb_unison_target_ok(actors, window) # New
  8412.     $game_temp.battle_aid = nil
  8413.     unless BattleManager.actor.usable?(BattleManager.actor.input.item)
  8414.       return on_ecatb_unison_target_cancel(actors, window)
  8415.     end
  8416.     confirm_ecatb_unison_item(actors, window)
  8417.     window.hide
  8418.     @skill_window.hide
  8419.     @item_window.hide
  8420.     next_command
  8421.   end # on_ecatb_unison_target_ok
  8422.  
  8423.   # actors: The unison actors
  8424.   # window: The window having the unison item
  8425.   def confirm_ecatb_unison_item(actors, window = nil) # New
  8426.     actors.each { |actor|
  8427.       window ? actor.input.target_index = window.index : actor.input.set_guard
  8428.       actor.ecatb_unison_invoker = actor == BattleManager.actor
  8429.       actor.confirm_ecatb_item
  8430.       @status_window.draw_item(actor.index)
  8431.     }
  8432.   end # confirm_ecatb_unison_item
  8433.  
  8434.   # actors: The unison actors
  8435.   # window: The window having the unison item
  8436.   def on_ecatb_unison_target_cancel(actors, window) # New
  8437.     # Clears the unison item from all unison actors and backs to the last window
  8438.     clear_ecatb_unison_item(actors)
  8439.     @status_aid_window.refresh
  8440.     $game_temp.battle_aid = nil
  8441.     window.hide
  8442.     on_ecatb_unison_target_cancel_compatibility
  8443.     #
  8444.   end # on_ecatb_unison_target_cancel
  8445.  
  8446.   # actors: The unison actors
  8447.   def clear_ecatb_unison_item(actors) # New
  8448.     (actors & BattleManager.ecatb_input_list).each { |actor|
  8449.       actor.input.clear if actor.input
  8450.       @status_window.draw_item(actor.index)
  8451.     }
  8452.   end # on_ecatb_unison_target_cancel
  8453.  
  8454.   # actors: The unison actors
  8455.   # window: The window having the unison item
  8456.   def on_ecatb_unison_item_ok(actors, window) # New
  8457.     $game_temp.battle_aid = item = window.item
  8458.     $game_party.last_item.object = item if item.is_a?(RPG::Item)
  8459.     skill = item.is_a?(RPG::Skill)
  8460.     actors.each { |actor|
  8461.       actor.input.set_skill(item.id)
  8462.       actor.last_skill.object = item if skill
  8463.       @status_window.draw_item(actor.index)
  8464.     }
  8465.     return select_enemy_selection if item.for_opponent?
  8466.     select_actor_selection if item.for_friend?
  8467.   end # on_ecatb_unison_item_ok
  8468.  
  8469.   # actors: The unison actors
  8470.   # window: The window using the command
  8471.   def on_ecatb_unison_command(actors, command, window) # New
  8472.     return on_ecatb_unison_target_ok(actors, window) if command == :ok
  8473.     on_ecatb_unison_target_cancel(actors, window)
  8474.   end # on_ecatb_unison_command
  8475.  
  8476.   #----------------------------------------------------------------------------|
  8477.   #  Checks if the unison skill/item can be inputted                           |
  8478.   #----------------------------------------------------------------------------|
  8479.   def on_ecatb_unison_item_ok?(window) # New
  8480.     # Checks if the skill/item is an unison one and all unison actors' present
  8481.     return false unless BattleManager.btype?(:ecatb)
  8482.     ecatb = DoubleX_RMVXA::ECATB
  8483.     actors = ecatb.send(window.item.ecatb_unison_actor, BattleManager.actor)
  8484.     actors.collect!(&ecatb::BLOCKS[:usable?])
  8485.     return false if actors.size < 2
  8486.     on_ecatb_unison_item_ok(actors, window)
  8487.     true
  8488.     #
  8489.   end # on_ecatb_unison_item_ok?
  8490.  
  8491.   def update_ecatb_cancel_window? # New; Hotspot
  8492.     # Checks if no window that can interfere the atb cancel window is shown
  8493.     return false if @actor_window.active || @enemy_window.active
  8494.     return false if @skill_window.active || @item_window.active
  8495.     return false if $game_message.busy?
  8496.     !update_msg_open_ecatb_compatibility?
  8497.     #
  8498.   end # update_ecatb_cancel_window?
  8499.  
  8500.   #----------------------------------------------------------------------------|
  8501.   #  Checks if the atb frame update should be run                              |
  8502.   #----------------------------------------------------------------------------|
  8503.   def ecatb_update? # New; Hotspot
  8504.     # Checks if atb frame update can be updated and the wait condition isn't met
  8505.     return false if scene_changing? || BattleManager.phase == :init
  8506.     return false if $game_party.all_dead? || $game_troop.all_dead?
  8507.     return false if $game_message.visible
  8508.     BattleManager.phase && !ecatb_wait_cond
  8509.     #
  8510.   end # ecatb_update?
  8511.  
  8512.   #----------------------------------------------------------------------------|
  8513.   #  Checks if the battler's actions should be executed                        |
  8514.   #----------------------------------------------------------------------------|
  8515.   # forced: The action force flag
  8516.   def exec_ecatb_act?(subject, forced = false) # New; Hotspot
  8517.     # Checks if the battler's valid and has a fully charged valid input
  8518.     if subject
  8519.       return false unless forced || subject.exec_ecatb_act?
  8520.       @subject = subject
  8521.     end
  8522.     @subject
  8523.     #
  8524.   end # exec_ecatb_act?
  8525.  
  8526.   #----------------------------------------------------------------------------|
  8527.   #  Checks if the unison item command handlers should be called               |
  8528.   #----------------------------------------------------------------------------|
  8529.   # window: The window using the command
  8530.   def on_ecatb_unison?(command, window) # New
  8531.     # Checks if the input is an unison item and calls unison handlers if so
  8532.     return false unless (actor = BattleManager.actor).input && actor.input.item
  8533.     ecatb = DoubleX_RMVXA::ECATB
  8534.     actors = ecatb.send(actor.input.item.ecatb_unison_actor, actor)
  8535.     actors.collect!(&ecatb::BLOCKS[:usable?])
  8536.     return false if actors.size < 2
  8537.     on_ecatb_unison_command(actors, command, window)
  8538.     true
  8539.     #
  8540.   end # on_ecatb_unison?
  8541.  
  8542.   #----------------------------------------------------------------------------|
  8543.   #  (New)Lets the compatibility fix deals with compatibility issues           |
  8544.   #----------------------------------------------------------------------------|
  8545.  
  8546.   def refresh_ecatb_windows_compatibility # Potential Hotspot
  8547.   end # refresh_ecatb_windows_compatibility
  8548.  
  8549.   def update_msg_open_ecatb_compatibility? # Hotspot
  8550.   end # update_msg_open_ecatb_compatibility?
  8551.  
  8552.   # forced: The action force flag
  8553.   def exec_ecatb_act_loop_compatibility?(forced)
  8554.     forced || !@subject.current_action
  8555.   end # exec_ecatb_act_loop_compatibility?
  8556.  
  8557.   def ecatb_turn_add_compatibility
  8558.   end # ecatb_turn_add_compatibility
  8559.  
  8560.   def on_ecatb_unison_target_cancel_compatibility
  8561.     # Shows the last window upon cancelling picking targets of unison skill/item
  8562.     if @actor_command_window.current_symbol == :skill
  8563.       return @skill_window.activate.show
  8564.     elsif @actor_command_window.current_symbol == :item
  8565.       return @item_window.activate.show
  8566.     end
  8567.     @actor_command_window.activate.show
  8568.     #
  8569.   end # on_ecatb_unison_target_cancel_compatibility
  8570.  
  8571. end # Scene_Battle
  8572.  
  8573.   # Aliases all methods using unison method rules
  8574.   DoubleX_RMVXA::ECATB::UNISON_DEFS.each { |klass, defs|
  8575.     klass_def = %Q(
  8576. class #{klass[0].id2name}#{klass[1] ? " < #{klass[1].id2name}" : ""}
  8577.     )
  8578.     defs.each { |name|
  8579.       klass_def += %Q(
  8580.   alias #{name = name.id2name}_ecatb #{name}
  8581.   def #{name}(*argv, &argb)
  8582.     return #{name}_ecatb(*argv, &argb) unless @ecatb_unison_item
  8583.     defs = @ecatb_unison_item.ecatb_unison_actor_def[:#{name}]
  8584.     return #{name}_ecatb(*argv, &argb) unless defs
  8585.     ecatb = DoubleX_RMVXA::ECATB
  8586.     defs = [#{name}_ecatb(*argv, &argb)] + (ecatb.send(defs, self) - [id]).
  8587.     collect! { |i| $game_actors[i].#{name}(*argv, &argb) }
  8588.     rule = ecatb.send(@ecatb_unison_item.ecatb_unison_def_rule[:#{name}], self)
  8589.     ecatb_unison_rules(defs, rule)
  8590.   end
  8591.      )
  8592.     }
  8593.     eval(klass_def + %Q(
  8594. end
  8595.     ))
  8596.   }
  8597.  
  8598. #------------------------------------------------------------------------------|
  8599.  
  8600. else
  8601.  
  8602.   # Informs users that they didn't place YEA-BattleEngine above this script
  8603.   msgbox("To use DoubleX RMVXA Enhanced YSA Battle System: Classical ATB, put it
  8604.          below:\n" +
  8605.          "Yanfly Engine Ace - Ace Battle Engine\n" +
  8606.          "but above Main") unless $imported["YEA-BattleEngine"]
  8607.  
  8608.   # Informs users that they used YSA-CATB with this script
  8609.   msgbox("DoubleX RMVXA Enhanced YSA Battle System: Classical ATB can't be used
  8610.          with:\n" +
  8611.          "YSA Battle System: Classical ATB") if $imported["YSA-CATB"]
  8612.  
  8613. end # if $imported["YEA-BattleEngine"] && !$imported["YSA-CATB"]
  8614.  
  8615. #==============================================================================|
Advertisement
Add Comment
Please, Sign In to add comment