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

Project1

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

[已经解决] 一个国外的ATB脚本,但是被墙了。谁能打开的帮忙贴出来吧

[复制链接]

Lv1.梦旅人

梦石
0
星屑
61
在线时间
696 小时
注册时间
2011-1-4
帖子
208
跳转到指定楼层
1
发表于 2016-2-26 16:18:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
Ellye's ATB (also includes CTB option)
http://pastebin.com/fhGC2Sn7

Lv1.梦旅人

梦石
0
星屑
61
在线时间
696 小时
注册时间
2011-1-4
帖子
208
2
 楼主| 发表于 2016-2-26 16:20:05 | 只看该作者
找到个在线代理,翻过去了。。
  1. // Place file inside /js/plugins
  2. // Remember to save after adding plugins or changing parameters.
  3. //=============================================================================
  4. // Ellye's Active Time Battle
  5. //=============================================================================
  6. /*:
  7. * Version: 2015-11-28-1906:
  8. *
  9. *
  10. * CHANGE LOG:
  11. *
  12. * 2015-11-28-1906: Cast motion should now finish at the proper time.
  13. * 2015-11-26-1052: Added the option of mid-battle escape.
  14. * 2015-11-22-1515: Fixed a bug with Confusion/Enrage effects and casting times.
  15. * 2015-11-22-0925: Made enemy gauges compatible with Yanfly's sprite sideviews for enemies (and possible other similar SV sprites).
  16. * 2015-11-22-0453: Can now also use <atb_duration_param:PARAM> on states. See HELP.
  17. * 2015-11-20-1808: Added <haste> notetag for states, actors, classes, equips and enemies, and <atb_duration:> notetag for states.
  18. * 2015-11-14-2144: Added the <start_atb:NUMBER> note-tag feature. Can be used on actor, class, equip and enemy to set a starting amount of ATB.
  19. * 2015-11-14-2004: Can now select which parameter to use for casting, instead of it being fixed on Agi. There's a global parameter, and the note <cast_param:>.
  20. * 2015-11-14-1629: Added Battler EndTurn Effects parameter.
  21. * 2015-11-14-1518: Added delay system. See HELP.
  22. * 2015-11-14-1405: Separated a few stuff into their own method, like casting stop/starting and atb ratio.
  23. * 2015-11-14-0154: Made step back when casting compatible with Yanfly's.
  24. * 2015-11-14-0134: Turn prediction now predicts casting times when hovering over a skill with cast_time.
  25. * 2015-11-11-2339: Fixed an issue with Turn Timer and Instant ATB.
  26. * 2015-11-11-1101: Added paramaters for the Turn Order Display to show symbols when hovering over skills that affect the predction. Work in progress, it looks pretty crude still. And it still needs to predict cast on hover too (it only displays after selection for now). Leave those parameters blank to disable the feature.
  27. * 2015-11-09-2317: Enemies now also use the different interruptible cast gauge color.
  28. * 2015-11-09-2317: Separated the drawActorATBGauge method for better compatibility with interface and gauges plugins. (Thanks for the suggestion, Bobstah!)
  29. * 2015-11-09-0119: Characters with restricted movement (stun, for example) have their cast interrupted and their gauge display stays empty.
  30. * 2015-11-08-2354: Fixed casting actors staying forward until the next action.
  31. * 2015-11-08-2354: Added Imported.Ellye_ATB for compatibility.
  32. * 2015-11-08-2307: Can now mark skills as <interruptible> and other skills as <interrupt>. Also added parameters related to the interrupt system. See HELP.
  33. * 2015-11-08-2157: Can now add custom <cast_motion:MOTION> and <cast_animation:NUMBER> per skill. See help.
  34. * 2015-11-08-1557: Added a Default Animation paramter (played at start of cast, defaults to 0 due to compatibility, but I recommend 52 from the default RM MV database).
  35. * 2015-11-08-1557: Added a Default Cast Motion parameter.
  36. * 2015-11-08-1557: Added the option of using reversed cast gauges.
  37. * 2015-11-07-1722: Fixed a bug with lingering enemy cast bars depending on how it finished casting.
  38. * 2015-11-07-1722: Improved performance of enemy gauges slightly.
  39. * 2015-11-07-0519: Added ATB gauges and Cast gauges for enemies, and parameters to configure it. PENDING: Offset per enemy (via [Note]), configurable gauge back color, and a few other optional stuff.
  40. * 2015-11-07-0222: Added parameters for positioning actor name and state icons.
  41. * 2015-11-07-0036: Made the turn prediction understand casting times (work in progress, still needs improvment (and visual indicators)). It doesn't read casting times on hover yet, though.
  42. * 2015-11-07-0036: Fixed an issue with the Turn Predction not working properly with skills that delayed the caster turn.
  43. * 2015-11-07-0036: The cast bar remains visible while the actors executes their skill.
  44. * 2015-11-06-1036: Fixed an issue when casting time finished at the same time as an input action.
  45. * 2015-11-05-2319: Added Battle Turn Event parameter.
  46. * 2015-11-05-2319: Added a casting time bar and parameters for it.
  47. * 2015-11-03-0945: Fixed a compatibility issue with my States Damage plugin.
  48. * 2015-11-02-2336: Very early draft of the Casting Time system is now avaliable. If you want to help test it, use <cast_time:NUMBER> on skill notes.
  49. * 2015-11-02-1423: Fixed an issue with self affecting ATB not showing up properly.
  50. * 2015-11-02-1350: Turn Prediction interface now reacts to the player hovering over skills that interact with the ATB system (as long as they do it via Notes). (Work in Progress)
  51. * 2015-11-02-1123: Added option to resize Skill/Item window when using Turn Order Predction, so it stays visible.
  52. * 2015-11-02-1026: Added option to hide ATB gauge.
  53. * 2015-11-02-1026: Added instant ATB mode.
  54. * 2015-11-02-0959: Added configurable opacity gradient for the turn order display.
  55. * 2015-11-02-0959: Added option to invert CTB display to Right-to-Left.
  56. * 2015-11-02-0639: Fixed CTB bugs related to dead monsters and actors resulting in incorrect predictions. No dead battler will show up on the bar for now, an option will be given to show them if wanted, in the future.
  57. * 2015-11-02-0639: Can now use the [Note] field for ATB formulas. SEE HELP.
  58. * 2015-10-31-1416: Fixed a stepping forward bug when multiple actors filled their AT at the same time (they all stepped forward).
  59. * 2015-10-31-1416: Made forward stepping optional.
  60. * 2015-10-31-1254: Added a Average Turn Timer parameter. It overrides the Turn Timer when used. It's ON by default.
  61. * 2015-10-31-1208: Made the stepping forward animation compatible with Yanfly's Battle Core.
  62. * 2015-10-31-0325: Monsters now properly show their name instead of their Battler Image name in CTB.
  63. * 2015-10-31-0325: Characters now step forward when it's their turn.
  64. * 2015-10-30-0404: Major overhaul on how status are handled. See HELP and/or here: https://ellyeblog.wordpress.com/2015/10/30/status-effects-in-an-atb-system/
  65. * 2015-10-30-0147: Added parameters for SE playability. Check HELP.
  66. * 2015-10-30-0021: Rebalanced the duration of status effects - they last 1 turn longer (this actually puts their duration on par with the expected from default combat, due to the different turn structure)
  67. * 2015-10-29-2330: Added parameters for gauge positions (thanks, djDarkX)
  68. * 2015-10-28-2300: Implemented iavra's workaround to get parameters without depending on filename.
  69. * 2015-10-28-2300: Added Gauge Color parameters
  70. * 2015-10-28-2300: Added Turn Order Prediction interface (WORK IN PROGRESS)
  71. * Added parameter for random starting ATB bonus.
  72. * Pre-emptive and surprise attack now function properly.
  73. * Added starting ATB parameter based on AGI.
  74. * Fixed battle events set to fire on turn 0+0 not firing (thanks, Kistulot)
  75. * Fixed dead battlers still gaining ATB.
  76. * Added the option to display Fight/Escape window.
  77. * Added a parameter for the gauge name.
  78. * Added a parameter that allows the developer to select if At-End-Of-Turn effects should happen after an actor takes its action, or for everyone at the end of Turn Timer. (thanks, atreyoray)
  79. * Corrected a few bugs regarding monsters with the same agility not attacking;
  80. * Corrected a few bugs regarding Auto-Battle;
  81. * Corrected a few bugs regarding Status Effects that happened per turn.
  82. *
  83. *
  84. * @plugindesc  V.2015-11-28-1906. A simple Active Time Battle system.
  85. * <Ellye ATB>
  86. * @author https://ellyeblog.wordpress.com/ || http://steamcommunity.com/id/Ellye
  87. *
  88. * @param ===GAMEPLAY===
  89. * @desc Parameters below this one are Gameplay-related options
  90. * @default .
  91. *
  92. * @param Agility Weight
  93. * @desc The higher this integer value, the more noticeable the difference of having high Agility vs. low Agility will be. Default 100.
  94. * @default 100
  95. *
  96. * @param Turn Timer
  97. * @desc Default: 150. The speed at the virtual "turn" value increases - this is relevant for battles with events that happen on the Nth turn, for example, or for monsters that use skills after the Nth turn, etc. The value entered here will be how much "Agility" the turn timer has. This is invisible to the player.
  98. * @default 150
  99. *
  100. * @param Average Turn Timer
  101. * @desc 1 = Create a Turn Timer based on the average agility of all Battlers present. 0 = Use the provided turn timer above. Default: 0
  102. * @default 1
  103. *
  104. * @param Base Fill Speed
  105. * @desc Default: 100. The base speed that the bar fills by itself, also affect Turn Timer in the same way.
  106. * @default 100
  107. *
  108. * @param Display Fight / Escape at beginning of the battle
  109. * @desc 1 = yes; 0 = no. Default: 0
  110. * @default 0
  111. *
  112. * @param Allow Escape During Battle
  113. * @desc 1 = yes; 0 = no. Default: 0
  114. * @default 0
  115. *
  116. * @param Starting ATB
  117. * @desc Multiplied by Agility and Agility Weight/100. Default: 50
  118. * @default 50
  119. *
  120. * @param Starting ATB Random Bonus
  121. * @desc Maximum random bonus for ATB at battle start. Default: 0
  122. * @default 0
  123. *
  124. * @param Full ATB Gauge
  125. * @desc The value of a full ATB Gauge. Default: 50000
  126. * @default 50000
  127. *
  128. * @param Instant ATB
  129. * @desc 1: ON, 0: OFF. Default: 0; Jumps instantly from a turn to the next. Best for CTB style.
  130. * @default 0
  131. *
  132. * @param Battle Event Turn
  133. * @desc 0: Per timer, 1: per action. Advances the Battle Turn for Events and monster AI. Default: 0
  134. * @default 0
  135. *
  136. * @param Battler EndTurn Effects
  137. * @desc 0: per timer, 1: per action. Def: 0. Whether "end of turn" for battlers is at turn timer or after they act.
  138. * @default 0
  139. *
  140. * @param Interrupt Compensation Pct
  141. * @desc What % of the ATB spent in casting is salvaged when interrupted. Default: 25
  142. * @default 25
  143. *
  144. * @param Interrupt Compensation Max
  145. * @default Maximum % of a full ATB gauge that can be given as compensation when interrupted. Default: 50
  146. * @default 50
  147. *
  148. * @param Maximum Delay Percent
  149. * @default Maximum that a skill can be delayed, as a % of its cast time. Default: 100
  150. * @default 100
  151. *
  152. * @param Default Delay
  153. * @default How much % a skill get delayed when hit by a delaying effect. Default: 10
  154. * @default 10
  155. *
  156. * @param Delayable by Default
  157. * @default 0: No, 1: Yes. Whether every skill is delayable by default.
  158. * @default 0
  159. *
  160. * @param Delays by Default
  161. * @default 0: No, 1: Yes. Whether every skill applies delay by default.
  162. * @default 1
  163. *
  164. * @param Default Cast Paramater
  165. * @default Default: agi. Other options: atk, def, mat, mdf, luk, hp, mp...
  166. * @default agi
  167. *
  168. * @param ===SOUND FX===
  169. * @desc You can override those settings per actor, view HELP.
  170. * @default .
  171. *
  172. * @param Play SE
  173. * @desc Whether to play SE when Actor is ready. 0 = OFF; 1 = ON. Default: 0
  174. * @default 0
  175. *
  176. * @param SE Name
  177. * @desc The name of the default Sound Effect file (inside /audio/se), sans extension.
  178. * @default Cursor3
  179. *
  180. * @param SE Volume
  181. * @desc The default volume for SE (from 0 to 100). Default: 75
  182. * @default 75
  183. *
  184. * @param SE Pitch
  185. * @desc The default pitch for SE (from 50 to 150). Default: 100
  186. * @default 100
  187. *
  188. * @param SE Pan
  189. * @desc The default pan for the SE (from -100 to 100). Default: 0
  190. * @default 0
  191. *
  192. * @param ===GAUGE HUD====
  193. * @desc Parameters below this one are related to the ATB Gauge interface
  194. * @default .
  195. *
  196. * @param Display Gauges
  197. * @desc 1 = ON; 0 = OFF. Default: 1. If off, all gauge settings are ignored.
  198. * @default 1
  199. *
  200. * @param Actor Name Width
  201. * @desc Default: 120.
  202. * @default 120
  203. *
  204. * @param Actor Name X Offset
  205. * @desc Default: 0.
  206. * @default 0
  207. *
  208. * @param Actor State Icons X Offset
  209. * @desc Default: 0.
  210. * @default 0
  211. *
  212. * @param Gauge Name
  213. * @desc What label to show on the ATB gauge.
  214. * @default AT
  215. *
  216. * @param Cast Gauge Name
  217. * @desc What label to show on the cast gauge.
  218. * @default Cast
  219. *
  220. * @param Use Skill Name for Cast Gauge
  221. * @desc 0: OFF, 1: ON. Default: 1
  222. * @default 1
  223. *
  224. * @param Reversed Cast Gauge
  225. * @desc 0: OFF, 1: ON. Default: 0.
  226. * @default 0
  227. *
  228. * @param Gauge Color 1
  229. * @desc First color of the gauge gradient. Default: #505060
  230. * @default #505060
  231. *
  232. * @param Gauge Color 2
  233. * @desc Second color of the gauge gradient. Default: #D5D5E0
  234. * @default #D5D5E0
  235. *
  236. * @param Cast Gauge Color 1
  237. * @desc First color of the cast gauge gradient. Default: #8E0B8A
  238. * @default #8E0B8A
  239. *
  240. * @param Cast Gauge Color 2
  241. * @desc Second color of the cast gauge gradient. Default: #EA7BD9
  242. * @default #EA7BD9
  243. *
  244. * @param Interruptible Gauge Color 1
  245. * @desc First color of the interruptible cast gauge gradient. Default: #D5D315
  246. * @default #D5D315
  247. *
  248. * @param Interruptible Gauge Color 2
  249. * @desc Second color of the interruptible cast gauge gradient. Default: #EDEE87
  250. * @default #EDEE87
  251. *
  252. * @param Positive Haste Gauge Color 1
  253. * @desc ATB Gauge when hasted. Default: #ECAA93
  254. * @default #ECAA93
  255. *
  256. * @param Positive Haste Gauge Color 2
  257. * @desc ATB Gauge when hasted. Default: #E6BA98
  258. * @default #E6BA98
  259. *
  260. * @param Negative Haste Gauge Color 1
  261. * @desc ATB Gauge when slowed. Default: #1D5E86
  262. * @default #1D5E86
  263. *
  264. * @param Negative Haste Gauge Color 2
  265. * @desc ATB Gauge when slowed. Default: #2191A1
  266. * @default #2191A1
  267. *
  268. * @param Zero Haste Gauge Color 1
  269. * @desc ATB Gauge when stopped. Default: #430F0F
  270. * @default #430F0F
  271. *
  272. * @param Zero Haste Gauge Color 2
  273. * @desc ATB Gauge when stopped. Default: #4B1618
  274. * @default #4B1618
  275. *
  276. * @param ATB Gauge Text Width
  277. * @desc Width area for the text. Default: 60
  278. * @default 60
  279. *
  280. * @param Gauge Area Size
  281. * @desc Width of the area for gauges. Default: 400
  282. * @default 400
  283. *
  284. * @param ==POS WITH TP==
  285. * @desc Those affect the positions of gauge when you have TP Display enabled.
  286. * @default .
  287. *
  288. * @param HP Gauge X Position (with TP)
  289. * @desc Default: 0
  290. * @default 0
  291. *
  292. * @param HP Gauge Width (with TP)
  293. * @desc Default: 97
  294. * @default 97
  295. *
  296. * @param MP Gauge X Position (with TP)
  297. * @desc Default: 112
  298. * @default 112
  299. *
  300. * @param MP Gauge Width (with TP)
  301. * @desc Default: 86
  302. * @default 86
  303. *
  304. * @param TP Gauge X Position
  305. * @desc Default: 213
  306. * @default 213
  307. *
  308. * @param TP Gauge Width
  309. * @desc Default: 86
  310. * @default 86
  311. *
  312. * @param ATB Gauge X Position (with TP)
  313. * @desc Default: 314
  314. * @default 314
  315. *
  316. * @param ATB Gauge Width (with TP)
  317. * @desc Default: 86
  318. * @default 86
  319. *
  320. * @param ==POS WITHOUT TP==
  321. * @desc Those affect the positions of gauge when you have TP Display disabled.
  322. * @default .
  323. *
  324. * @param HP Gauge X Position
  325. * @desc Default: 0
  326. * @default 0
  327. *
  328. * @param HP Gauge Width
  329. * @desc Default: 130
  330. * @default 130
  331. *
  332. * @param MP Gauge X Position
  333. * @desc Default: 145
  334. * @default 145
  335. *
  336. * @param MP Gauge Width
  337. * @desc Default: 120
  338. * @default 120
  339. *
  340. * @param ATB Gauge X Position
  341. * @desc Default: 280
  342. * @default 280
  343. *
  344. * @param ATB Gauge Width
  345. * @desc Default: 120
  346. * @default 120
  347. *
  348. * @param ===TURN ORDER HUD===
  349. * @desc Parameters bellow this one are related to the turn order display
  350. * @default .
  351. *
  352. * @param Display Predicted Turn Order
  353. * @desc 1 = yes, 0 = no. Default: 0
  354. * @default 0
  355. *
  356. * @param Display as Faces or Names
  357. * @desc 1 = Faces, 0 = Names. See Help. Default: 0
  358. * @default 0
  359. *
  360. * @param Invert TO Direction
  361. * @desc 0 = Left-to-Right; 1 = Right-to-Left. Default: 0
  362. * @default 0
  363. *
  364. * @param Opacity First TO
  365. * @desc Opacity of the first actor window (from 0 to 255). Default: 220
  366. * @default 220
  367. *
  368. * @param Opacity Last TO
  369. * @desc Opacity of the last actor window (from 0 to 255). Default: 160. To disable gradient, set the same value as above.
  370. * @default 160
  371. *
  372. * @param Resize Skill and Item Window
  373. * @desc 1: ON, 0: OFF. Default: 1. To allow room for the turn prediction interface (only if it's enabled)
  374. * @default 1
  375. *
  376. * @param Prediction Bonus
  377. * @desc String to show when predicting a buff to ATB. Default: ▲. Leave blank for none.
  378. * @default ▲
  379. *
  380. * @param Prediction Malus
  381. * @desc String to show when predicting a buff to ATB. Default: ▼. Leave blank for none.
  382. * @default ▼
  383. *
  384. * @param Prediction Cast
  385. * @desc String to show when predicting a buff to ATB. Default: ♦. Leave blank for none.
  386. * @default ♦
  387. *
  388. * @param Prediction Bonus Color
  389. * @desc Color for the bonus string. Default: #62D962
  390. * @default #62D962
  391. *
  392. * @param Prediction Malus Color
  393. * @desc Color for the malus string. Default: #D96262
  394. * @default #D96262
  395. *
  396. * @param Prediction Cast Color
  397. * @desc Color for the cast string. Default: #8662D9
  398. * @default #8662D9
  399. *
  400. * @param ===ENEMY GAUGES===
  401. *
  402. * @param Display Enemy Cast Gauges
  403. * @desc 0 = off; 1 = on. Default: 1
  404. * @default 1
  405. *
  406. * @param Display Enemy ATB Gauges
  407. * @desc 0 = off, 1 = on. Default: 0
  408. * @default 0
  409. *
  410. * @param Enemy Gauge Opacity
  411. * @desc From 0 to 255 (Default: 200)
  412. * @default 200
  413. *
  414. * @param Enemy Show Cast Name
  415. * @desc 0 = Show no text; 1 = Show skill name; 2 = Show gauge name. Default: 1
  416. * @default 1
  417. *
  418. * @param Enemy Show Name
  419. * @desc 0 = Show no text; 1 = Show enemy name; 2 = Show gauge name. Default: 1
  420. * @default 1
  421. *
  422. * @param Enemy Gauge Color1
  423. * @desc Default: #FA8691
  424. * @default #FA8691
  425. *
  426. * @param Enemy Gauge Color2
  427. * @desc Default: #F0B8C8
  428. * @default #F0B8C8
  429. *
  430. * @param ===MISC UI===
  431. * @desc Other UI related options
  432. * @default .
  433. *
  434. * @param Step Forward When Ready
  435. * @desc Whether actors should step forward when its their time for input. 1: ON. 0: OFF. Default: 1
  436. * @default 1
  437. *
  438. * @param Default Cast Motion
  439. * @desc 0: none, 1: chant, 2: skill, 3: item, 4: spell. Default: 1
  440. * @default 1
  441. *
  442. * @param Default Cast Animation
  443. * @desc The ID of the default Animation. 0 for none. Suggested (from default DB): 52. Default: 0
  444. * @default 0
  445. *
  446. * @param Interrupt Animation
  447. * @desc Battle animation to be played when a skill is interrupted. Suggestion: create one with flash and sound only. Default: 0
  448. * @default 0
  449. *  
  450. * @help Actors will act as frequently as their AGILITY attribute allows them to, instead of taking fixed turns.
  451. * They will have an "AT" Gauge in the interface that goes from 0 to 1000, and they will get a turn to act when it reaches 1000.
  452. * Gauges are paused while the player is deciding on a command, or while an animation is being played.
  453. * A full gauge requires 50000 ATB by default (excess ATB is not lost, and the number can be negative).
  454. *
  455. * USING THE [NOTE] FIELD TO SETUP SKILLS THAT INTERACT WITH ATB:
  456. * In each Skill or Combat Usable Item, you can set up [NOTE]s that interact with the ATB system.
  457. * There's the following notes:
  458. * <self_atb:FORMULA>
  459. * <target_atb:FORMULA>
  460. *
  461. * It's important to note that those need to be ARITHMETICAL FORMULAS, not commands.
  462. * The following examples are valid:
  463. * <self_atb:25000> #This would make a quick skill, as your next turn will come faster.
  464. * <self_atb:-25000> #This one would delay your next turn
  465. * <self_atb:50*a.agi - 20*b.agi> #This would give the user some ATB based on the difference of AGI between him and the target
  466. * <target_atb:25000> #This would GIVE the target some atb, making his turn come quicker.
  467. * <target_atb:-10000> #This would DELAY the target next turn
  468. * <target_atb:-50*(3*a.mat - b.mdf)> #This would DELAY the target next turn based on the difference between the attacker Magic Attack and the target Magic Defense
  469. *
  470. * So:
  471. * It needs to be a formula that results in a NUMBER, not a command. Do not use "a.atb+=5000;" or similar assignments.
  472. * You do can use methods like Math.random or Math.Max; you do can use if-else conditions; just make sure that the end result will be a number and that you aren't executing any action except calculating that number.
  473. * POSITIVE numbers will always GIVE ATB, no matter if for caster or target.
  474. * NEGATIVE numbers will always REMOVE ATB, no matter if for caster or target.
  475. * Important note about SKILL WITH MULTIPLE TARGET: The "self_atb" parameter applies ONCE PER TARGET HIT, so balance accordingly (this was also the case with the Formula field).
  476. *
  477. * If you use Display Faces, your enemies require to have a face configured in the Database Editor.
  478. * In the [Notes] field, you should add, for example: <face_name:Monster><face_id:2> - this would use the RTP Orc face.
  479. * In that example <face_name> receives the name of the file, and face_id the index of the face, counting left-to-right, top first, then bottom. Starts at 0.
  480. *
  481. * You can set up Actor-specific ready Sound Effects (if you enable Play SE). It's similar to the way monster faces are set up.
  482. * In the [Notes] field of an actor, you can enter: <se_name:Bow4><se_volume:100><se_pitch:150> to play the sound "Bow4" at those settings whenever that Actor is ready, for example.
  483. *
  484. * CASTING TIMES:
  485. * You can now set up casting times by adding:
  486. * <cast_time:NUMBER>
  487. * On the [Note] tag of a skill. For example, <cast_time:25000> would require the same time as half of a full default ATB gauge.
  488. *
  489. * Skills with casting time can also be marked with
  490. * <interruptible>
  491. * (or <interruptable>)
  492. *
  493. * This means that they will be broken when hit by a skill that is marked as:
  494. * <interrupt>
  495. * (or <interrupts>)
  496. *
  497. * By default, interruptable skills have a different cast gauge color.
  498. * You can also set up an Animation to play whenever a skill is successfully interrupted.
  499. * SUGGESTION: Create a new Animation with just a flash and some sound effect to use for this, most of the default VFXs are too fancy for that (keep in mind that this plays together with the hit vfx).
  500. *
  501. * For the DELAY system, you can set default delay parameters in the Plugin Paramaters, and customize them per skill with the following notes:
  502. *
  503. * <delayable>
  504. * Will mark a skill as delayable, regardless of default settings.
  505. *
  506. * <not_delayable>
  507. * Will mark a skill as not delayable, regardless of default settings.
  508. *
  509. * <delays>
  510. * Will make a skill apply delay regardless of default settings. If no <delay_amount> is specified, it will use the default delay amount. Will also delay even if it targets ally (by default this doesn't happen)
  511. *
  512. * <delay_amount:NUMBER>
  513. * The amount (a % of the total cast time) of delay to be applied. For example, 25 means that it will bring the casting bar down by 25% of its maximum value. If you set to 0, no delay will be applied (in case you're using Delays by Default parameter).
  514. *
  515. *
  516. * Another notes you can have for casting skills:
  517. * <cast_animation:NUMBER>
  518. * This is the number of an Animation (from the Animations tab in the database) to be cast at the start of the cast.
  519. *
  520. * <cast_motion:MOTION>
  521. * The movement your character does while casting. Some valid options are:
  522. * <cast_motion:spell>, <cast_motion:skill>, <cast_motion:item>, <cast_motion:chant>, <cast_motion:swing>, <cast_motion:thrust>, <cast_motion:missile>, <cast_motion:wait>
  523. *
  524. * <cast_param:PARAM>
  525. * Will use that Param instead of the default (agi, normally) for casting that skill. For example:
  526. * <cast_param:mat> will use MAT instead of AGI.
  527. *
  528. * STATES:
  529. * If you want a State to count down per action taken, you set it up as Action End.
  530. * If you want a State to count down per virtual turn, you set it up as Turn End.
  531. *
  532. * Optionally, you can also opt to use neither of those and instead have your state timed by ATB gauge  (can also be used together with the above, whichever comes first will remove the state)
  533. * This might be the optimal design overall for the ATB system, at least for states that directly affect the ATB gauge:
  534. * To do so, use the following tag:
  535. * <atb_duration:NUMBER>
  536. * For example, 150000 would last the normal duration of three turns for that actor (not taking modifiers like haste in consideration).
  537. * Optionally, you can also specify which parameter is used for the speed at which the state comes out. To do so, use:
  538. * <atb_duration_param:atk>, <atb_duration_param:def>, <atb_duration_param:mat>, <atb_duration_param:mdf>, <atb_duration_param:agi> or <atb_duration_param:luk>
  539. * You can also use <atb_duration_param:turn> to make it follow Turn Timer and be independent of the target's parameters.
  540. *
  541. *
  542. * STARTING ATB:
  543. * You can use the note-tag
  544. * <start_atb:NUMBER>
  545. * On actors, classes, equips and enemies to set up bonus starting ATB (absolute vlaues).
  546. *
  547. * HASTE:
  548. * You can use the note-tags:
  549. * <haste:NUMBER>
  550. * <haste_atb:NUMBER>
  551. * <haste_cast:NUMBER>
  552. * This is a multiplicative percent change to all speeds, atb-only speed or cast-only speed.
  553. * A value of "<haste:100>" means no change. A value of "<haste:200>" would mean double speed, for example, while a value of "<haste:50>" would mean half speed.
  554. * Those tags can be used on Actors, Classes, Equips and Enemies.
  555. *
  556. */

  557. //Our plugin needs to be inside a function:

  558. var Imported = Imported || {};
  559. Imported.Ellye_ATB = true;

  560. (function() {

  561.     var parameters = $plugins.filter(function(p) {
  562.         return p.description.contains('<Ellye ATB>');
  563.     })[0].parameters; //Thanks to Iavra
  564.     var turn_atb = 0;
  565.     var ctb_window_width = 90;
  566.     var ctb_window_height = 60;
  567.     var turns_to_predict = Math.floor((SceneManager._boxWidth / ctb_window_width));
  568.     var ctb_window_x_offset = (SceneManager._boxWidth - turns_to_predict * ctb_window_width) / 2;
  569.     var full_atb = Number(parameters['Full ATB Gauge'] || 50000);
  570.     var agi_weight = Number(parameters['Agility Weight'] || 100);
  571.     var turn_timer = Number(parameters['Turn Timer'] || 150);
  572.     var av_turn_timer = Number(parameters['Average Turn Timer'] || 1);
  573.     var base_atb_increase = Number(parameters['Base Fill Speed'] || 100);
  574.     var display_gauges = Number(parameters['Display Gauges'] || 1);
  575.     var actor_name_x_offset = Number(parameters['Actor Name X Offset'] || 0);
  576.     var actor_icons_x_offset = Number(parameters['Actor Icons X Offset'] || 0);
  577.     var actor_name_width = Number(parameters['Actor Name Width'] || 120);
  578.     var gauge_name=String%28parameters['Gauge Name'] || "");
  579.     var cast_gauge_name=String%28parameters['Cast Gauge Name'] || "");
  580.     var use_skill_name_gauge = Number(parameters['Use Skill Name for Cast Gauge'] || 0);
  581.     var display_party_command = Number(parameters['Display Fight / Escape at beginning of the battle'] || 0);
  582.     var allow_midbattle_escape = Number(parameters['Allow Escape During Battle'] || 0);
  583.     if (allow_midbattle_escape === 1)
  584.     {
  585.         display_party_command = 1;
  586.     }
  587.     var starting_atb = Number(parameters['Starting ATB'] || 50);
  588.     var starting_atb_random = Number(parameters['Starting ATB Random Bonus'] || 0);
  589.     var display_turn_order = Number(parameters['Display Predicted Turn Order'] || 0);
  590.     var display_as_faces_or_names = Number(parameters['Display as Faces or Names'] || 0);
  591.     var invert_turn_order_display = Number(parameters['Invert TO Direction'] || 0);
  592.     var ctb_opacity_first = Number(parameters['Opacity First TO'] || 220);
  593.     var ctb_opacity_last = Number(parameters['Opacity Last TO'] || 160);
  594.     var resize_skill_window = Number(parameters['Resize Skill and Item Window'] || 1);
  595.     var atb_gauge_width = Number(parameters['ATB Gauge Width'] || 120);
  596.     var atb_gauge_color1 = String(parameters['Gauge Color 1'] || "#505060");
  597.     var atb_gauge_color2 = String(parameters['Gauge Color 2'] || "#D5D5E0");
  598.     var cast_gauge_color1 = String(parameters['Cast Gauge Color 1'] || "#8E0B8A");
  599.     var cast_gauge_color2 = String(parameters['Cast Gauge Color 2'] || "#EA7BD9");
  600.     var gauge_area_size = Number(parameters['Gauge Area Size'] || 400);
  601.     var gauge_text_width = Number(parameters['ATB Gauge Text Width'] || 120);
  602.     var hp_gauge_x_tp = Number(parameters['HP Gauge X Position (with TP)'] || 0);
  603.     var mp_gauge_x_tp = Number(parameters['MP Gauge X Position (with TP)'] || 112);
  604.     var tp_gauge_x = Number(parameters['TP Gauge X Position'] || 213);
  605.     var atb_gauge_x_tp = Number(parameters['ATB Gauge X Position (with TP)'] || 314);
  606.     var hp_gauge_width_tp = Number(parameters['HP Gauge Width (with TP)'] || 97);
  607.     var mp_gauge_width_tp = Number(parameters['MP Gauge Width (with TP)'] || 86);
  608.     var tp_gauge_width = Number(parameters['TP Gauge Width'] || 86);
  609.     var atb_gauge_width_tp = Number(parameters['ATB Gauge Width (with TP)'] || 86);
  610.     var hp_gauge_x = Number(parameters['HP Gauge X Position'] || 0);
  611.     var mp_gauge_x = Number(parameters['MP Gauge X Position'] || 145);
  612.     var atb_gauge_x = Number(parameters['ATB Gauge X Position'] || 280);
  613.     var hp_gauge_width = Number(parameters['HP Gauge Width'] || 130);
  614.     var mp_gauge_width = Number(parameters['MP Gauge Width'] || 120);
  615.     var atb_gauge_width = Number(parameters['ATB Gauge Width'] || 120);
  616.     var se_enabled = Number(parameters['Play SE'] || 0);
  617.     var se_name=String%28parameters['SE Name'] || "Cursor3");
  618.     var se_volume = Number(parameters['SE Volume'] || 75);
  619.     var se_pitch = Number(parameters['SE Pitch'] || 100);
  620.     var se_pan = Number(parameters['SE Pan'] || 0);
  621.     var step_forward = Number(parameters['Step Forward When Ready'] || 1);
  622.     var instant_atb = Number(parameters['Instant ATB'] || 0);
  623.     var battle_event_turn_mode = Number(parameters['Battle Event Turn'] || 0);
  624.     var enemy_gauge_position = Number(parameters['Enemy Gauge Position'] || 0);
  625.     var enemy_gauge_opacity = Number(parameters['Enemy Gauge Opacity'] || 200);
  626.     var enemy_show_cast_name=Number%28parameters['Enemy Show Cast Name'] || 1);
  627.     var enemy_show_name=Number%28parameters['Enemy Show Name'] || 1);
  628.     var display_enemy_cast_gauges = Number(parameters['Display Enemy Cast Gauges'] || 1);
  629.     var display_enemy_atb_gauges = Number(parameters['Display Enemy ATB Gauges'] || 0);
  630.     var enemy_gauge_color1 = String(parameters['Enemy Gauge Color1'] || "#F5818B");
  631.     var enemy_gauge_color2 = String(parameters['Enemy Gauge Color2'] || "#EBB3C3");
  632.     var reversed_cast_gauge = Number(parameters['Reversed Cast Gauge'] || 0);
  633.     var default_cast_motion = Number(parameters['Default Cast Motion'] || 1);
  634.     var default_cast_vfx = Number(parameters['Default Cast Animation'] || 0);
  635.     var interrupt_compensation_pct = Number(parameters['Interrupt Compensation Pct'] || 25);
  636.     var interrupt_compensation_max = Number(parameters['Interrupt Compensation Max'] || 50);
  637.     var interrupt_vfx = Number(parameters['Interrupt Animation'] || 0);
  638.     var interrupt_gauge_color1 = String(parameters['Interruptible Gauge Color 1'] || "#D5D315");
  639.     var interrupt_gauge_color2 = String(parameters['Interruptible Gauge Color 2'] || "#EDEE87");
  640.     var ctb_bonus = String(parameters['Prediction Bonus'] || "");
  641.     var ctb_malus = String(parameters['Prediction Malus'] || "");
  642.     var ctb_cast = String(parameters['Prediction Cast'] || "");
  643.     var ctb_cast_skill_name=Number%28parameters['Prediction Cast Name'] || 0);
  644.     var ctb_bonus_color = String(parameters['Prediction Bonus Color'] || "#42B942");
  645.     var ctb_malus_color = String(parameters['Prediction Malus Color'] || "#B94242");
  646.     var ctb_cast_color = String(parameters['Prediction Cast Color'] || "#8642B9");
  647.     var max_delay_pct = Number(parameters['Maximum Delay Percent'] || 100);
  648.     var default_delay_amount = Number(parameters['Default Delay'] || 10);
  649.     var default_delayable = Number(parameters['Delayable by Default'] || 0);
  650.     var default_delays = Number(parameters['Delays by Default'] || 1);
  651.     var battler_end_turn_effects = Number(parameters['Battler EndTurn Effects'] || 0);
  652.     var default_cast_parameter = String(parameters['Default Cast Paramater'] || "agi");
  653.     var positive_haste_gauge_color1 = String(parameters['Positive Haste Gauge Color 1'] || "#ECAA93");
  654.     var positive_haste_gauge_color2 = String(parameters['Positive Haste Gauge Color 2'] || "#E6BA98");
  655.     var negative_haste_gauge_color1 = String(parameters['Negative Haste Gauge Color 1'] || "#1D5E86");
  656.     var negative_haste_gauge_color2 = String(parameters['Negative Haste Gauge Color 2'] || "#2191A1");
  657.     var zero_haste_gauge_color1 = String(parameters['Zero Haste Gauge Color 1'] || "#430F0F");
  658.     var zero_haste_gauge_color2 = String(parameters['Zero Haste Gauge Color 2'] || "#4B1618");
  659.    

  660.     //==================================================
  661.     // INTERFACE
  662.     //==================================================

  663.     //All of those changes depend on the Display Gauge Parameter
  664.     if (display_gauges === 1)
  665.     {
  666.         //Let's increase the area for gauges in the battlescreen from the default value of 330 to 400.
  667.         Window_BattleStatus.prototype.gaugeAreaWidth = function() {
  668.             return gauge_area_size;
  669.         };

  670.         Window_BattleStatus.prototype.drawBasicArea = function(rect, actor) {
  671.             this.drawActorName(actor, rect.x + actor_name_x_offset, rect.y, actor_name_width);
  672.             this.drawActorIcons(actor, rect.x + actor_name_width + 4 + actor_icons_x_offset, rect.y, rect.width - actor_name_width - actor_icons_x_offset);
  673.         };

  674.         //let's change the DrawGaugeArea methods, to include our ATB gauge.
  675.         //The version with TP:
  676.         Window_BattleStatus.prototype.drawGaugeAreaWithTp = function(rect, actor) {
  677.             this.drawActorHp(actor, rect.x + hp_gauge_x_tp, rect.y, hp_gauge_width_tp);
  678.             this.drawActorMp(actor, rect.x + mp_gauge_x_tp, rect.y, mp_gauge_width_tp);
  679.             this.drawActorTp(actor, rect.x + tp_gauge_x, rect.y, tp_gauge_width);
  680.             this.drawActorATB(actor, rect.x + atb_gauge_x_tp, rect.y, atb_gauge_width_tp);
  681.         };

  682.         //The version without TP:
  683.         Window_BattleStatus.prototype.drawGaugeAreaWithoutTp = function(rect, actor) {
  684.             this.drawActorHp(actor, rect.x + hp_gauge_x, rect.y, hp_gauge_width);
  685.             this.drawActorMp(actor, rect.x + mp_gauge_x, rect.y, mp_gauge_width);
  686.             this.drawActorATB(actor, rect.x + atb_gauge_x, rect.y, atb_gauge_width);
  687.         };

  688.         //Let's create the method that prepares and calls for the drawing of the ATB or Cast gauge:
  689.         Window_Base.prototype.drawActorATB = function(actor, x, y, width) {
  690.             //Cast:
  691.             var color1;
  692.             var color2;
  693.             if (actor.target_cast_atb !== 0)
  694.             {
  695.                 if (actor.CastHaste() <= 0)
  696.                 {
  697.                     color1 = zero_haste_gauge_color1;
  698.                     color2 = zero_haste_gauge_color2;
  699.                 }
  700.                 else if (actor.IsCastInterruptible())
  701.                 {
  702.                     color1 = interrupt_gauge_color1;
  703.                     color2 = interrupt_gauge_color2;
  704.                 }
  705.                 else
  706.                 {
  707.                     color1 = cast_gauge_color1;
  708.                     color2 = cast_gauge_color2;
  709.                 }
  710.                 this.drawActorATBGauge(x, y, width, actor.castRatio(), color1, color2, actor.castName(), x, y, gauge_text_width);
  711.             }
  712.             //ATB:
  713.             else
  714.             {
  715.                 if (actor.ATBHaste() <= 0)
  716.                 {
  717.                     color1 = zero_haste_gauge_color1;
  718.                     color2 = zero_haste_gauge_color2;
  719.                 }
  720.                 else if (actor.ATBHaste() < 100)
  721.                 {
  722.                     color1 = negative_haste_gauge_color1;
  723.                     color2 = negative_haste_gauge_color2;
  724.                 }
  725.                 else if (actor.ATBHaste() > 100)
  726.                 {
  727.                     color1 = positive_haste_gauge_color1;
  728.                     color2 = positive_haste_gauge_color2;
  729.                 }
  730.                 else
  731.                 {
  732.                     color1 = atb_gauge_color1;
  733.                     color2 = atb_gauge_color2;
  734.                 }
  735.                 this.drawActorATBGauge(x, y, width, actor.atbRatio(), color1, color2, gauge_name, x, y, gauge_text_width);
  736.             }
  737.         };

  738.         //The method that handles the actual gauge drawing:
  739.         Window_Base.prototype.drawActorATBGauge = function(x, y, width, ratio, color1, color2, text, text_x, text_y, text_width)
  740.         {
  741.             this.drawGauge(x, y, width, ratio, color1, color2);
  742.             this.changeTextColor(this.systemColor());
  743.             if (typeof text !== 'undefined' && text !== null && text !== "")
  744.             {
  745.                 this.drawText(text, text_x, text_y, text_width);
  746.             }
  747.         };
  748.     }

  749.     //If we are going to display ATB Gauges or Cast gauges for enemies
  750.     if (display_enemy_atb_gauges === 1 || display_enemy_cast_gauges === 1)
  751.     {
  752.         //We initialize a _gaugeWindow var.
  753.         _alias_spriteenemy_init = Sprite_Enemy.prototype.initMembers;
  754.         Sprite_Enemy.prototype.initMembers = function() {
  755.             _alias_spriteenemy_init.call(this);
  756.             this._gaugeWindow = null;
  757.         };

  758.         //The method that populates it:
  759.         _alias_spre_updatebitmap = Sprite_Enemy.prototype.updateBitmap;
  760.         Sprite_Enemy.prototype.updateBitmap = function() {
  761.             _alias_spre_updatebitmap.call(this);
  762.             //Creates it once the bitmap finishes loading, for width and height information
  763.             if (this._gaugeWindow === null && typeof this.bitmap !== 'undefined' && this.bitmap !== null && this.bitmap.height !== 0)
  764.             {
  765.                 this._gaugeWindow = new Window_Base();
  766.                 var y = (enemy_gauge_position === 0) ? 0 : -this.bitmap.height - 36;
  767.                 var bmpwidth = this.bitmap.width;
  768.                 if (bmpwidth <= 1)
  769.                 {
  770.                     bmpwidth = atb_gauge_width;
  771.                     this._gaugeWindow.initialize(bmpwidth / 2, y, bmpwidth + 36, this._gaugeWindow.lineHeight() + 2 * this._gaugeWindow.standardPadding() + 26);
  772.                     this._gaugeWindow.scale.x *= -1;
  773.                 }
  774.                 else
  775.                 {
  776.                     this._gaugeWindow.initialize(-bmpwidth / 2, y, bmpwidth + 36, this._gaugeWindow.lineHeight() + 2 * this._gaugeWindow.standardPadding() + 26);
  777.                 }
  778.                 this._gaugeWindow.padding = 0;
  779.                 this._gaugeWindow.margin = 0;
  780.                 this._gaugeWindow.backOpacity = 0;
  781.                 this._gaugeWindow.opacity = 0;
  782.                 this._gaugeWindow.hideBackgroundDimmer();
  783.                 this._gaugeWindow.contents.paintOpacity = enemy_gauge_opacity;
  784.                 this.addChild(this._gaugeWindow);
  785.             }
  786.             //Updates it when conditions are met:
  787.             if (this._gaugeWindow !== null && this._battler !== null && BattleManager._phase === 'atb')
  788.             {
  789.                 var gaugeWidth = this.bitmap.width;
  790.                 var mirroredGauge = false;
  791.                 if (gaugeWidth <= 1)
  792.                 {
  793.                     gaugeWidth = atb_gauge_width;
  794.                 }
  795.                 this._gaugeWindow.contents.clear();
  796.                 if (this._battler.isDead() || this._battler.isHidden())
  797.                 {
  798.                     //Do not draw.
  799.                 }
  800.                 else if (this._battler.target_cast_atb !== 0 && display_enemy_cast_gauges === 1)
  801.                 {
  802.                     var color1 = (this._battler.IsCastInterruptible()) ? interrupt_gauge_color1 : cast_gauge_color1;
  803.                     var color2 = (this._battler.IsCastInterruptible()) ? interrupt_gauge_color2 : cast_gauge_color2;
  804.                     if (this._battler.CastHaste() <= 0)
  805.                     {
  806.                         color1 = zero_haste_gauge_color1;
  807.                         color2 = zero_haste_gauge_color2;
  808.                     }
  809.                     this._gaugeWindow.drawGauge(0, 0, gaugeWidth, this._battler.castRatio(), color1, color2);
  810.                     if (enemy_show_cast_name=%3D%3D 1)
  811.                     {
  812.                         this._gaugeWindow.drawText(this._battler.castName(), 0, 0, gaugeWidth);
  813.                     }
  814.                     else if (enemy_show_cast_name=%3D%3D 2)
  815.                     {
  816.                         this._gaugeWindow.drawText(cast_gauge_name, 0, 0, gaugeWidth);
  817.                     }
  818.                 }
  819.                 else if (display_enemy_atb_gauges === 1)
  820.                 {
  821.                     var color1;
  822.                     var color2;
  823.                     if (this._battler.ATBHaste() <= 0)
  824.                     {
  825.                         color1 = zero_haste_gauge_color1;
  826.                         color2 = zero_haste_gauge_color2;
  827.                     }
  828.                     else if (this._battler.ATBHaste() < 100)
  829.                     {
  830.                         color1 = negative_haste_gauge_color1;
  831.                         color2 = negative_haste_gauge_color2;
  832.                     }
  833.                     else if (this._battler.ATBHaste() > 100)
  834.                     {
  835.                         color1 = positive_haste_gauge_color1;
  836.                         color2 = positive_haste_gauge_color2;
  837.                     }
  838.                     else
  839.                     {
  840.                         color1 = enemy_gauge_color1;
  841.                         color2 = enemy_gauge_color2;
  842.                     }
  843.                     this._gaugeWindow.drawGauge(0, 0, gaugeWidth, this._battler.atbRatio(), color1, color2);
  844.                     if (enemy_show_name=%3D%3D 1)
  845.                     {
  846.                         this._gaugeWindow.drawText(this._battler.originalName(), 0, 0, gaugeWidth);
  847.                     }
  848.                     else if (enemy_show_name=%3D%3D 2)
  849.                     {
  850.                         this._gaugeWindow.drawText(gauge_name, 0, 0, gaugeWidth);
  851.                     }
  852.                 }
  853.             }
  854.         };
  855.     } //End of enemy-gauge related block.

  856.     //Let's create the method for calculating ATB percent for the gauge:
  857.     Game_BattlerBase.prototype.atbRatio = function() {
  858.         if (typeof this.atb !== 'undefined' && this.canMove()) {
  859.             if (this.atb / full_atb >= 1)
  860.             {
  861.                 return 1;
  862.             }
  863.             if (this.atb <= 0)
  864.             {
  865.                 return 0;
  866.             }
  867.             return this.atb / full_atb;
  868.         }
  869.         return 0;
  870.     };

  871.     Game_BattlerBase.prototype.castname=function%28%29 {
  872.         if (use_skill_name_gauge === 0)
  873.         {
  874.             return cast_gauge_name;
  875.         }
  876.         if (this.casting_action !== null && typeof this.casting_action.item() !== 'undefined' && typeof this.casting_action.item().name !== 'undefined')
  877.         {
  878.             return this.casting_action.item().name;
  879.         }
  880.         return cast_gauge_name;
  881.     };

  882.     //And one for calculating Cast Ratio for th gauge:
  883.     Game_BattlerBase.prototype.castRatio = function() {
  884.         if (this.target_cast_atb !== 0 && this.canMove())
  885.         {
  886.             if (this.current_cast_atb / this.target_cast_atb >= 1)
  887.             {
  888.                 return (reversed_cast_gauge === 1) ? 0 : 1;
  889.             }
  890.             if (this.current_cast_atb <= 0)
  891.             {
  892.                 return (reversed_cast_gauge === 1) ? 1 : 0;
  893.             }
  894.             var value = this.current_cast_atb / this.target_cast_atb;
  895.             return (reversed_cast_gauge === 1) ? 1 - value : value;
  896.         }
  897.         return 0;
  898.     };


  899.     //Some of our interface options use faces for enemies. We use metadata for that. Let's create the method that access it:
  900.     Game_Enemy.prototype.getFacename=function%28%29 {
  901.         if (typeof $dataEnemies[this._enemyId].meta.face_name !== 'undefined')
  902.         {
  903.             return $dataEnemies[this._enemyId].meta.face_name;
  904.         }
  905.         return false;
  906.     };
  907.     Game_Enemy.prototype.getFaceID = function() {
  908.         if (typeof $dataEnemies[this._enemyId].meta.face_id !== 'undefined')
  909.         {
  910.             return $dataEnemies[this._enemyId].meta.face_id;
  911.         }
  912.         return false;
  913.     };

  914.     //Turn Order Window (if selected to be displayed):
  915.     if (display_turn_order)
  916.     {
  917.         //Let's move the Battle Log window down:
  918.         Window_BattleLog.prototype.initialize = function() {
  919.             var width = this.windowWidth();
  920.             var height = this.windowHeight();
  921.             Window_Selectable.prototype.initialize.call(this, 0, ctb_window_height, width, height);
  922.             this.opacity = 0;
  923.             this._lines = [];
  924.             this._methods = [];
  925.             this._waitCount = 0;
  926.             this._waitMode = '';
  927.             this._baseLineStack = [];
  928.             this._spriteset = null;
  929.             this.createBackBitmap();
  930.             this.createBackSprite();
  931.             this.refresh();
  932.         };

  933.         //Correcting a minor mistake in the backdrop of the log window.
  934.         //It works fine for the default position, but not for different positions like we use:
  935.         Window_BattleLog.prototype.createBackSprite = function() {
  936.             this._backSprite = new Sprite();
  937.             this._backSprite.bitmap = this._backBitmap;
  938.             this._backSprite.y = 0;
  939.             this.addChildToBack(this._backSprite);
  940.         };

  941.         //Resize item and skill window if we want to:
  942.         if (resize_skill_window === 1)
  943.         {
  944.             Window_Help.prototype.initialize = function(numLines) {
  945.                 var width = Graphics.boxWidth;
  946.                 var height = this.fittingHeight(numLines || 2);
  947.                 var y = ($gameParty.inBattle()) ? ctb_window_height : 0;
  948.                 Window_Base.prototype.initialize.call(this, 0, y, width, height);
  949.                 this._text = '';
  950.             };

  951.             _alias_scenebattle_createdisplayobjects = Scene_Battle.prototype.createDisplayObjects;
  952.             Scene_Battle.prototype.createDisplayObjects = function() {
  953.                 $gameParty._inBattle = true; //Otherwise the party wouldn't still be consided in battle when we check for the help window
  954.                 _alias_scenebattle_createdisplayobjects.call(this);
  955.             };
  956.         }

  957.         //We need to modify the Select method of the BattleSkill and BattleItem windows so that they may predict ATB changes:
  958.         Window_BattleSkill.prototype.select = function(index) {
  959.             Window_SkillList.prototype.select.call(this, index);
  960.             this.predictChanges(this.item());
  961.         };

  962.         //Same for BattleItem
  963.         Window_BattleItem.prototype.select = function(index) {
  964.             Window_ItemList.prototype.select.call(this, index);
  965.             this.predictChanges(this.item());
  966.         };

  967.         //For the enemy selecting window, we also need to get our action. Same for actor selecting one later.
  968.         _alias_battle_enemy = Window_BattleEnemy.prototype.select;
  969.         Window_BattleEnemy.prototype.select = function(index) {
  970.             _alias_battle_enemy.call(this, index);
  971.             var action = BattleManager.inputtingAction();
  972.             var item = (action === null) ? null : action.item();
  973.             this.predictChanges(item, this.enemy());
  974.         };

  975.         //And for actors
  976.         _alias_battle_actor = Window_BattleActor.prototype.select;
  977.         Window_BattleActor.prototype.select = function(index) {
  978.             _alias_battle_actor.call(this, index);
  979.             var action = BattleManager.inputtingAction();
  980.             var item = (action === null) ? null : action.item();
  981.             this.predictChanges(item, this.actor());
  982.         };

  983.         //Affects prediction based on selectable option
  984.         Window_Selectable.prototype.predictChanges = function(item, target) {
  985.             if (item === null || typeof item === 'undefined' || !$gameParty.inBattle())
  986.             {
  987.                 return;
  988.             }
  989.             var a = BattleManager._subject;
  990.             if (typeof target !== 'undefined' && target !== null)
  991.             {
  992.                 var b = target;
  993.             }
  994.             else if (item.scope === 11)
  995.             {
  996.                 var b = a;
  997.             }
  998.             else if ([7, 8, 9, 10].contains(item.scope))
  999.             {
  1000.                 var b = $gameParty.smoothTarget();
  1001.             }
  1002.             else
  1003.             {
  1004.                 var b = $gameTroop.smoothTarget();
  1005.             }
  1006.             var v = $gameVariables._data;
  1007.             var selfATB = (typeof item.meta.self_atb !== 'undefined') ? Number(eval(item.meta.self_atb) || 0) : 0;
  1008.             var targetATB = (typeof item.meta.target_atb !== 'undefined') ? Number(eval(item.meta.target_atb) || 0) : 0;
  1009.             var castingTime = (typeof item.meta.cast_time !== 'undefined') ? Number(eval(item.meta.cast_time) || 0) : 0;
  1010.             var battlersAffected = [];
  1011.             var values = [];
  1012.             var battlerCasting = a;
  1013.             if (selfATB !== 0)
  1014.             {
  1015.                 battlersAffected.push(a);
  1016.                 values.push(selfATB);
  1017.             }
  1018.             if (targetATB !== 0)
  1019.             {
  1020.                 if (typeof target !== 'undefined' && target !== null)
  1021.                 {
  1022.                     battlersAffected.push(target);
  1023.                     values.push(targetATB);
  1024.                 }
  1025.                 else if ([1, 3, 7].contains(item.scope))
  1026.                 {
  1027.                     //Still hasen't clicked the single target skill
  1028.                 }
  1029.                 else if ([2, 4, 5, 6].contains(item.scope))
  1030.                 {
  1031.                     $gameTroop.aliveMembers().forEach(function(enemy) {
  1032.                         battlersAffected.push(enemy);
  1033.                         values.push;
  1034.                     }, this);
  1035.                 }
  1036.                 else if (item.scope === 8)
  1037.                 {
  1038.                     $gameParty.aliveMembers().forEach(function(ally) {
  1039.                         battlersAffected.push(ally);
  1040.                         values.push;
  1041.                     }, this);
  1042.                 }
  1043.                 else if (item.scope === 10)
  1044.                 {
  1045.                     $gameParty.deadMembers().forEach(function(ally) {
  1046.                         battlersAffected.push(ally);
  1047.                         values.push;
  1048.                     }, this);
  1049.                 }
  1050.             }
  1051.             BattleManager.predictTurnOrder(battlersAffected, values, battlerCasting, castingTime);
  1052.         };

  1053.         //Reload Turn Order Predction when we cancel windows:
  1054.         _alias_skill_cancel = Scene_Battle.prototype.onSkillCancel;
  1055.         Scene_Battle.prototype.onSkillCancel = function() {
  1056.             BattleManager.predictTurnOrder();
  1057.             _alias_skill_cancel.call(this);
  1058.         };
  1059.         _alias_item_cancel = Scene_Battle.prototype.onItemCancel;
  1060.         Scene_Battle.prototype.onItemCancel = function() {
  1061.             BattleManager.predictTurnOrder();
  1062.             _alias_item_cancel.call(this);
  1063.         };
  1064.         _alias_enemy_cancel = Scene_Battle.prototype.onEnemyCancel;
  1065.         Scene_Battle.prototype.onEnemyCancel = function() {
  1066.             BattleManager.predictTurnOrder();
  1067.             _alias_enemy_cancel.call(this);
  1068.         };

  1069.         //We will add some new windows to Scene Battle:
  1070.         //We will have an array of Turn Order windows.
  1071.         _Scene_Battle_prototype_createAllWindows = Scene_Battle.prototype.createAllWindows;
  1072.         Scene_Battle.prototype.createAllWindows = function() {
  1073.             this._turnOrderWindows = [];
  1074.             var diff = Math.round((ctb_opacity_first - ctb_opacity_last) / (turns_to_predict - 1));
  1075.             var opacity = (invert_turn_order_display !== 1) ? ctb_opacity_first : ctb_opacity_last;
  1076.             for (index = 0; index < turns_to_predict; index++)
  1077.             {
  1078.                 this._turnOrderWindows.push(new Window_CTB(ctb_window_x_offset + index * ctb_window_width, opacity));
  1079.                 this.addWindow(this._turnOrderWindows[index]);
  1080.                 opacity = (invert_turn_order_display !== 1) ? opacity - diff : opacity + diff;
  1081.             }
  1082.             BattleManager.setCTBWindowsArray(this._turnOrderWindows);
  1083.             _Scene_Battle_prototype_createAllWindows.call(this);
  1084.         };

  1085.         //Create a new Window for turn order (there will be an array of those)
  1086.         function Window_CTB() {
  1087.             this.initialize.apply(this, arguments);
  1088.         }

  1089.         Window_CTB.prototype = Object.create(Window_Base.prototype);
  1090.         Window_CTB.prototype.constructor = Window_CTB;

  1091.         Window_CTB.prototype.initialize = function(x, opacity) {
  1092.             Window_Base.prototype.initialize.call(this, x, 0, ctb_window_width, ctb_window_height);
  1093.             this.contents.paintOpacity = opacity;
  1094.             this.contentsWidth = function() {
  1095.                 return this.width - this.padding * 2;
  1096.             };
  1097.             this.contentsHeight = function() {
  1098.                 return this.height - this.padding * 2;
  1099.             };
  1100.             if (display_as_faces_or_names === 1)
  1101.             {
  1102.                 this.layoutForFace();
  1103.             }
  1104.             else
  1105.             {
  1106.                 this.layoutForText();
  1107.             }
  1108.         };

  1109.         //Window layout for face:
  1110.         Window_CTB.prototype.layoutForFace = function() {
  1111.             this.padding = 2;
  1112.             this.opacity = 0;
  1113.             this.hideBackgroundDimmer();
  1114.             this.layoutApply();
  1115.         };

  1116.         //Window layout for text:
  1117.         Window_CTB.prototype.layoutForText = function() {
  1118.             this.padding = 12;
  1119.             this.layoutApply();
  1120.         };

  1121.         //Window layout apply:
  1122.         Window_CTB.prototype.layoutApply = function() {
  1123.             var opacity = this.contents.paintOpacity;
  1124.             this.createContents();
  1125.             this.resetTextColor();
  1126.             this.contents.fontSize = 12;
  1127.             this.contents.paintOpacity = opacity;
  1128.         };


  1129.         //We need to be able to assign a reference to the array of CTB windows to the Battle Manager, so that it can populate it.
  1130.         BattleManager.setCTBWindowsArray = function(ctbWindowsArray) {
  1131.             this._ctbWindowsArray = ctbWindowsArray;
  1132.         };

  1133.         //The function that displays turn order:
  1134.         BattleManager.displayTurnOrder = function() {
  1135.             var predictedTurnOrder = this._predictedTurnOrder;
  1136.             var symbols = this._predictedTurnSymbols;
  1137.             if (invert_turn_order_display === 1)
  1138.             {
  1139.                 predictedTurnOrder.reverse();
  1140.             }
  1141.             if (typeof this._ctbWindowsArray === 'undefined' || this._ctbWindowsArray.constructor !== Array)
  1142.             {
  1143.                 return;
  1144.             }
  1145.             for (index = 0; index < predictedTurnOrder.length; index++)
  1146.             {
  1147.                 if (index >= this._ctbWindowsArray.length)
  1148.                 {
  1149.                     break;
  1150.                 }
  1151.                 var ctbWindow = this._ctbWindowsArray[index];
  1152.                 ctbWindow.resetTextColor();
  1153.                 ctbWindow.contents.fontSize = 12;
  1154.                 var battler = predictedTurnOrder[index];

  1155.                 //Case text:
  1156.                 if (display_as_faces_or_names !== 1)
  1157.                 {
  1158.                     var nameToDisplay = battler.isActor() ? battler._name : battler.originalName() + " " + battler._letter;
  1159.                     ctbWindow.contents.clear();
  1160.                     ctbWindow.drawText(nameToDisplay, 0, 0, ctb_window_width);
  1161.                 }
  1162.                 //Faces:
  1163.                 else
  1164.                 {
  1165.                     ctbWindow.contents.clear();
  1166.                     //For actors, we can just draw faces easily:
  1167.                     if (battler.isActor())
  1168.                     {
  1169.                         ImageManager.loadFace(battler.faceName());
  1170.                         ctbWindow.layoutForFace();
  1171.                         ctbWindow.drawActorFace(battler, 0, 0, ctb_window_width, ctb_window_height);
  1172.                     }
  1173.                     //For enemies, we need to check if they have a face set up
  1174.                     else if (battler.getFaceName() !== false && battler.getFaceID() !== false)
  1175.                     {
  1176.                         ImageManager.loadFace(battler.getFaceName());
  1177.                         ctbWindow.layoutForFace();
  1178.                         ctbWindow.drawFace(battler.getFaceName(), battler.getFaceID(), 0, 0, ctb_window_width, ctb_window_height);
  1179.                         ctbWindow.drawText(battler._letter, ctb_window_width / 2, 0, ctb_window_width);
  1180.                     }
  1181.                     //If they don't, display text:
  1182.                     else
  1183.                     {
  1184.                         ctbWindow.layoutForText();
  1185.                         var nameToDisplay = battler.originalName() + " " + battler._letter;
  1186.                         ctbWindow.drawText(nameToDisplay, 0, 0, ctb_window_width);
  1187.                     }
  1188.                 }
  1189.                 if (typeof symbols[index] !== 'undefined' && symbols[index] !== null && symbols[index] !== false && symbols[index] !== "")
  1190.                 {

  1191.                     if (symbols[index] === ctb_bonus)
  1192.                     {
  1193.                         ctbWindow.contents.textColor = ctb_bonus_color;
  1194.                     }
  1195.                     else if (symbols[index] === ctb_malus)
  1196.                     {
  1197.                         ctbWindow.contents.textColor = ctb_malus_color;
  1198.                     }
  1199.                     else if (symbols[index] === ctb_cast)
  1200.                     {
  1201.                         ctbWindow.contents.textColor = ctb_cast_color;
  1202.                     }
  1203.                     if (display_as_faces_or_names !== 1)
  1204.                     {
  1205.                         ctbWindow.contents.fontSize = 16;
  1206.                         var y = ctb_window_height / 5;
  1207.                     }
  1208.                     else
  1209.                     {
  1210.                         ctbWindow.contents.fontSize = 24;
  1211.                         var y = ctb_window_height / 2;
  1212.                     }
  1213.                     ctbWindow.drawText(symbols[index], 0, y, ctb_window_width);
  1214.                 }
  1215.             }
  1216.         };
  1217.     } //End of turn-order-display dependent stuff.

  1218.     //Play Sound Effect when ATB bar is full, if enabled:
  1219.     AudioManager.playFullATB = function(actor) {
  1220.         if (se_enabled !== 1)
  1221.         {
  1222.             return;
  1223.         }
  1224.         var se = {name: actor.getSEName(), volume: actor.getSEVolume(), pitch: actor.getSEPitch(), pan: actor.getSEPan()};
  1225.         AudioManager.playStaticSe(se);
  1226.     };

  1227.     //Get data related to Actor-specific sound, if it exists:
  1228.     Game_Actor.prototype.getSEname=function%28%29 {
  1229.         if (typeof $dataActors[this._actorId].meta.se_name !== 'undefined')
  1230.         {
  1231.             return $dataActors[this._actorId].meta.se_name;
  1232.         }
  1233.         return se_name;
  1234.     };
  1235.     Game_Actor.prototype.getSEVolume = function() {
  1236.         if (typeof $dataActors[this._actorId].meta.se_volume !== 'undefined')
  1237.         {
  1238.             return $dataActors[this._actorId].meta.se_volume;
  1239.         }
  1240.         return se_volume;
  1241.     };
  1242.     Game_Actor.prototype.getSEPitch = function() {
  1243.         if (typeof $dataActors[this._actorId].meta.se_pitch !== 'undefined')
  1244.         {
  1245.             return $dataActors[this._actorId].meta.se_pitch;
  1246.         }
  1247.         return se_pitch;
  1248.     };
  1249.     Game_Actor.prototype.getSEPan = function() {
  1250.         if (typeof $dataActors[this._actorId].meta.se_pan !== 'undefined')
  1251.         {
  1252.             return $dataActors[this._actorId].meta.se_pan;
  1253.         }
  1254.         return se_pan;
  1255.     };
  1256.     //End of Sound Effect related stuff

  1257.     //Cast motion
  1258.     Game_Battler.prototype.performCastMotion = function() {
  1259.         if (this.target_cast_atb > 0 && defaultCastMotion() !== false && BattleManager.actor() !== this && BattleManager._subject !== this)
  1260.         {
  1261.             if (this.casting_action !== null && typeof this.casting_action.item() !== 'undefined' && typeof this.casting_action.item().meta !== 'undefined' && typeof this.casting_action.item().meta.cast_motion !== 'undefined')
  1262.             {
  1263.                 this.requestMotion(this.casting_action.item().meta.cast_motion);
  1264.             }
  1265.             else
  1266.             {
  1267.                 this.requestMotion(defaultCastMotion());
  1268.             }
  1269.         }
  1270.     };

  1271.     //Ask cast motion for all:
  1272.     BattleManager.requestAllCastMotions = function() {
  1273.         this.aliveBattleMembers().forEach(function(battler) {
  1274.             battler.performCastMotion();
  1275.         });
  1276.     };

  1277.     _alias_sb_updateBattleProcess = Scene_Battle.prototype.updateBattleProcess;
  1278.     Scene_Battle.prototype.updateBattleProcess = function() {
  1279.         if (!BattleManager.isBattleEnd() && !BattleManager.isAborting())
  1280.         {
  1281.             BattleManager.requestAllCastMotions();
  1282.         }
  1283.         _alias_sb_updateBattleProcess.call(this);
  1284.     };

  1285.     defaultCastMotion = function() {
  1286.         switch (default_cast_motion)
  1287.         {
  1288.             case 1:
  1289.                 return 'chant';
  1290.             case 2:
  1291.                 return 'skill';
  1292.             case 3:
  1293.                 return 'item';
  1294.             case 4:
  1295.                 return 'spell';
  1296.             default:
  1297.                 return false;
  1298.         }
  1299.     };

  1300.     //==================================================
  1301.     // SYSTEM
  1302.     //==================================================

  1303.     //Let's add a new property for battlers, called "atb", and two properties for the casting time system:
  1304.     Object.defineProperties(Game_BattlerBase.prototype, {
  1305.         atb: {
  1306.             writable: true,
  1307.             value: 0,
  1308.             configurable: true,
  1309.             enumerable: true
  1310.         },
  1311.         target_cast_atb: {
  1312.             writable: true,
  1313.             value: 0,
  1314.             configurable: true,
  1315.             enumerable: true
  1316.         },
  1317.         current_cast_atb: {
  1318.             writable: true,
  1319.             value: 0,
  1320.             configurable: true,
  1321.             enumerable: true
  1322.         },
  1323.         casting_action: {
  1324.             writable: true,
  1325.             value: null,
  1326.             configurable: true,
  1327.             enumerable: true
  1328.         },
  1329.         finished_casting: {
  1330.             writable: true,
  1331.             value: false,
  1332.             configurable: true,
  1333.             enumerable: true
  1334.         },
  1335.         cast_delay_current: {
  1336.             writable: true,
  1337.             value: 0,
  1338.             configurable: true,
  1339.             enumerable: true
  1340.         },
  1341.         cast_delay_max: {
  1342.             writable: true,
  1343.             value: 0,
  1344.             configurable: true,
  1345.             enumerable: true
  1346.         },
  1347.         _cast_rate: {
  1348.             writable: true,
  1349.             value: 0,
  1350.             configurable: true,
  1351.             enumerable: true
  1352.         },
  1353.         _states_atb_current: {
  1354.             writable: true,
  1355.             value: [],
  1356.             configurable: true,
  1357.             enumerable: true
  1358.         },
  1359.         _states_atb_duration: {
  1360.             writable: true,
  1361.             value: [],
  1362.             configurable: true,
  1363.             enumerable: true
  1364.         },
  1365.         _states_atb_rate: {
  1366.             writable: true,
  1367.             value: [],
  1368.             configurable: true,
  1369.             enumerable: true
  1370.         },
  1371.         _haste_all: {
  1372.             writable: true,
  1373.             value: 100,
  1374.             configurable: true,
  1375.             enumerable: true
  1376.         },
  1377.         _haste_atb: {
  1378.             writable: true,
  1379.             value: 100,
  1380.             configurable: true,
  1381.             enumerable: true
  1382.         },
  1383.         _haste_cast: {
  1384.             writable: true,
  1385.             value: 100,
  1386.             configurable: true,
  1387.             enumerable: true
  1388.         }
  1389.     });

  1390.     //A generic function for determining if there's bonus ATB rate to be had (used in class, item and enemy check)
  1391.     CheckForBonusStartingATB = function(item) {
  1392.         if (typeof item !== 'undefined' && item !== null && typeof item.meta !== 'undefined' && typeof item.meta.start_atb !== 'undefined' && !isNaN(item.meta.start_atb))
  1393.         {
  1394.             return Number(item.meta.start_atb);
  1395.         }
  1396.         return 0;
  1397.     };

  1398.     //A generic function to calculate ATB rate, used both by battlers and turn timer:
  1399.     CalculateATBRate = function(agi, haste) {
  1400.         if (typeof haste === 'undefined')
  1401.         {
  1402.             var haste = 100;
  1403.         }
  1404.         return (base_atb_increase + agi * (agi_weight / 100)) * haste / 100;
  1405.     };

  1406.     //Checks class, equips and self for bonus starting ATB:
  1407.     Game_Battler.prototype.bonusStartingATB = function()
  1408.     {
  1409.         var bonus = 0;
  1410.         if (this.isActor())
  1411.         {
  1412.             bonus += CheckForBonusStartingATB(this.actor());
  1413.             bonus += CheckForBonusStartingATB(this.currentClass());
  1414.             this.equips().forEach(function(equip)
  1415.             {
  1416.                 bonus += CheckForBonusStartingATB(equip);
  1417.             }, this);
  1418.         }
  1419.         else
  1420.         {
  1421.             bonus += CheckForBonusStartingATB(this.enemy());
  1422.         }
  1423.         return bonus;
  1424.     };

  1425.     //A method to reset all cast related stuff:
  1426.     Game_Battler.prototype.resetCast = function() {
  1427.         this.setActionState('undecided');
  1428.         this.clearMotion();
  1429.         $gameParty.requestMotionRefresh();
  1430.         this.target_cast_atb = 0;
  1431.         this.current_cast_atb = 0;
  1432.         this.casting_action = null;
  1433.         this.finished_casting = false;
  1434.         this.cast_delay_current = 0;
  1435.         this.cast_delay_max = 0;
  1436.         this.calculateCastRate();
  1437.     };

  1438.     //And one to start cast:
  1439.     Game_Battler.prototype.startCast = function(castAction, castTime) {
  1440.         this.casting_action = castAction;
  1441.         this.target_cast_atb = castTime;
  1442.         this.current_cast_atb = 0;
  1443.         this.cast_delay_max = 0;
  1444.         this.calculateCastRate();
  1445.         if (this.IsCastDelayable())
  1446.         {
  1447.             this.cast_delay_max = this.target_cast_atb * max_delay_pct / 100;
  1448.         }
  1449.         if (this.casting_action !== null && typeof this.casting_action.item() !== 'undefined' && typeof this.casting_action.item().meta !== 'undefined' && typeof this.casting_action.item().meta.cast_animation !== 'undefined')
  1450.         {
  1451.             this.startAnimation(Number(this.casting_action.item().meta.cast_animation), 0, 0);
  1452.         }
  1453.         else if (default_cast_vfx > 0)
  1454.         {
  1455.             this.startAnimation(default_cast_vfx, 0, 0);
  1456.         }
  1457.     };

  1458.     //Our battlers need a property to calculate their ATB rate
  1459.     Game_Battler.prototype.calculateATBRate = function() {
  1460.         return CalculateATBRate(this.agi, this.ATBHaste());
  1461.     };

  1462.     //Haste for ATB:
  1463.     Game_Battler.prototype.ATBHaste = function() {
  1464.         return this._haste_atb * this._haste_all / 100;
  1465.     };

  1466.     //Haste for Cast:
  1467.     Game_Battler.prototype.CastHaste = function() {
  1468.         return this._haste_cast * this._haste_all / 100;
  1469.     };

  1470.     //At the start of battle, ATB values are reset to 0:
  1471.     _Game_Battler_prototype_onBattleStart = Game_Battler.prototype.onBattleStart;
  1472.     Game_Battler.prototype.onBattleStart = function() {
  1473.         this.resetCast();
  1474.         this._states_atb_current = [];
  1475.         this._states_atb_duration = [];
  1476.         this._states_atb_rate = [];
  1477.         this.CalculateHaste();
  1478.         this.atb = this.bonusStartingATB() + (Math.random() * starting_atb_random) + starting_atb * this.agi * (agi_weight / 100);
  1479.         if (BattleManager._surprise && this.isEnemy() && this.isAppeared())
  1480.         {
  1481.             this.atb += full_atb;
  1482.         }
  1483.         else if (BattleManager._preemptive && this.isActor())
  1484.         {
  1485.             this.atb += full_atb;
  1486.         }
  1487.         _Game_Battler_prototype_onBattleStart.call(this);
  1488.     };

  1489.     //Battle starts in the new phase "atb" (except if we're going to show PartyCommand).
  1490.     //And we calculate the Turn Timer if we're using Average Turn Timer
  1491.     _BattleManager_startBattle = BattleManager.startBattle;
  1492.     BattleManager.startBattle = function() {
  1493.         if (av_turn_timer === 1)
  1494.         {
  1495.             var totalAgi = 0;
  1496.             var numberOfBattlers = this.allBattleMembers().length;
  1497.             for (index = 0; index < numberOfBattlers; index++)
  1498.             {
  1499.                 totalAgi += Number(this.allBattleMembers()[index].agi || 1);
  1500.             }
  1501.             turn_timer = totalAgi / numberOfBattlers;
  1502.         }
  1503.         _BattleManager_startBattle.call(this);
  1504.         $gameParty.makeActions();
  1505.         $gameTroop.makeActions();
  1506.         this.makeActionOrders();
  1507.         this.predictTurnOrder();
  1508.         this._phase = 'start';
  1509.         this._actorIndex = -1;
  1510.         this._pending_atb_removal = false;
  1511.     };

  1512.     //Skip party command if the player so wishes:
  1513.     if (display_party_command !== 1)
  1514.     {
  1515.         Scene_Battle.prototype.startPartyCommandSelection = function() {
  1516.             this.refreshStatus();
  1517.             this.commandFight();
  1518.         };
  1519.     }

  1520.     //Change the end of turn:
  1521.     BattleManager.updateTurnEnd = function() {
  1522.         $gameParty.makeActions();
  1523.         $gameTroop.makeActions();
  1524.         this._phase = 'atb';
  1525.     };

  1526.     //Changing the flow of battle
  1527.     _BattleManager_update = BattleManager.update;
  1528.     BattleManager.update = function() {
  1529.         if (!this.isBusy() && !this.updateEvent())
  1530.         {
  1531.             switch (this._phase)
  1532.             {
  1533.                 case 'atb':
  1534.                     this.increaseAtbGauges();
  1535.                     break;
  1536.                 default:
  1537.                     _BattleManager_update.call(this);
  1538.                     break;
  1539.             }
  1540.         }
  1541.     };

  1542.     //Increases the ATB gauges when idle:
  1543.     BattleManager.increaseAtbGauges = function() {
  1544.         var loopForInstantATB = instant_atb;
  1545.         var
  1546.         //================================================
  1547.         //ATB LOOP
  1548.         //We need to be in a loop here if we're using instant ATB option, but run only once in other cases.
  1549.         //================================================
  1550.         do
  1551.         {
  1552.             //==========================================
  1553.             //Turn Timer
  1554.             //==========================================
  1555.             turn_atb += CalculateATBRate(turn_timer);
  1556.             //Turn timer finished:
  1557.             if (turn_atb >= full_atb)
  1558.             {
  1559.                 turn_atb -= full_atb;
  1560.                 //We advance the troops page (for events and AI) depending on parameter:
  1561.                 if (battle_event_turn_mode === 0)
  1562.                 {
  1563.                     $gameTroop.increaseTurn();
  1564.                 }
  1565.                 //We apply onTurnEnd if paramaters are set so
  1566.                 if (battler_end_turn_effects !== 1)
  1567.                 {
  1568.                     this.allBattleMembers().forEach(function(battler)
  1569.                     {
  1570.                         battler.onTurnEnd();
  1571.                         this.refreshStatus();
  1572.                         this._logWindow.displayAutoAffectedStatus(battler);
  1573.                         this._logWindow.displayRegeneration(battler);
  1574.                     }, this);
  1575.                 }
  1576.             }
  1577.             //========================================
  1578.             //End of turn timer related stuff
  1579.             //========================================

  1580.             this.allBattleMembers().forEach(function(battler)
  1581.             {
  1582.                 //States with ATB duration:
  1583.                 battler._states_atb_duration.forEach(function(duration, stateID)
  1584.                 {
  1585.                     battler._states_atb_current[stateID] += CalculateATBRate(battler._states_atb_rate[stateID], 100);
  1586.                     if (battler._states_atb_current[stateID] >= duration)
  1587.                     {
  1588.                         battler.removeState(stateID);
  1589.                     }
  1590.                 }, this);

  1591.                 //Dead battler has no ATB nor cast:
  1592.                 if (battler.isDead())
  1593.                 {
  1594.                     battler.atb = 0;
  1595.                     battler.resetCast();
  1596.                 }
  1597.                 //====================
  1598.                 //Casting time logic:
  1599.                 //====================
  1600.                 //Cast finished:
  1601.                 else if (battler.finished_casting === true)
  1602.                 {
  1603.                     battler.resetCast();
  1604.                 }
  1605.                 //Currently casting:
  1606.                 else if (battler.target_cast_atb > 0)
  1607.                 {
  1608.                     //Got stunned or similar while casting, auto-interrupt for now:
  1609.                     if (!battler.canMove())
  1610.                     {
  1611.                         battler.BreakCurrentCast(true);
  1612.                     }
  1613.                     else
  1614.                     {
  1615.                         battler.current_cast_atb += battler._cast_rate * (battler.CastHaste() / 100);
  1616.                         if (battler.current_cast_atb >= battler.target_cast_atb &&  false)
  1617.                         {
  1618.                             battler.finished_casting = true;
  1619.                             this.battlerHasFullAtb(battler, true);
  1620.                            
  1621.                             loopForInstantATB = 0;
  1622.                         }
  1623.                     }
  1624.                 }
  1625.                 //===================
  1626.                 //Not casting, ATB INCREASE:
  1627.                 //===================
  1628.                 else
  1629.                 {
  1630.                     battler.atb += battler.calculateATBRate();
  1631.                 }
  1632.                 if (battler.atb >= full_atb &&  false && battler.target_cast_atb <= 0)
  1633.                 {
  1634.                     this.battlerHasFullAtb(battler);
  1635.                     
  1636.                     loopForInstantATB = 0;
  1637.                 }
  1638.             }, this);
  1639.         } while (loopForInstantATB === 1);
  1640.         //==============================
  1641.         //END OF THE ATB LOOP
  1642.         //=============================
  1643.         this.refreshStatus();
  1644.     };

  1645.     //When a Battler (might be party or enemy) has full ATB:
  1646.     BattleManager.battlerHasFullAtb = function(battler, wasCasting)
  1647.     {
  1648.         BattleManager.refreshStatus();
  1649.         if (typeof wasCasting === 'undefined')
  1650.         {
  1651.             wasCasting = false;
  1652.         }
  1653.         this.predictTurnOrder();
  1654.         this._subject = battler;
  1655.         this._turn_end_subject = battler;
  1656.         this._pending_atb_removal = true;
  1657.         //If the character already has an action that he was casting:
  1658.         if (wasCasting)
  1659.         {
  1660.             battler.setAction(0, battler.casting_action);
  1661.             this._phase = 'turn';
  1662.             return;
  1663.         }
  1664.         if (battler.isActor())
  1665.         {
  1666.             battler.makeActions();
  1667.             if (battler.canInput())
  1668.             {
  1669.                 AudioManager.playFullATB(battler);
  1670.                 this._actorIndex = battler.index();
  1671.                 //If the Step_Forward_When_Ready parameter is turned on:
  1672.                 if (step_forward === 1)
  1673.                 {
  1674.                     battler.setActionState('inputting');
  1675.                     if (typeof battler.spriteStepForward === 'function')
  1676.                     {
  1677.                         //This is for compatibility with Yanfly's.
  1678.                         battler.spriteStepForward();
  1679.                     }
  1680.                 }
  1681.                 this._phase = 'input';
  1682.             }
  1683.             else
  1684.             {
  1685.                 this._phase = 'turn';
  1686.             }
  1687.         }
  1688.         else if (battler.isEnemy())
  1689.         {
  1690.             battler.makeActions();
  1691.             if (battler.CheckIfSkillHasCastingTime())
  1692.             {
  1693.                 this._phase = 'atb';
  1694.             }
  1695.             else
  1696.             {
  1697.                 this._phase = 'turn';
  1698.             }
  1699.         }
  1700.     };

  1701.     //Never jumps to another battler, we will control them individually:
  1702.     BattleManager.getNextSubject = function() {
  1703.         return null;
  1704.     };

  1705.     //Process turn when we finish inputing command
  1706.     BattleManager.selectNextCommand = function() {
  1707.         do {
  1708.             if (!this.actor() || !this.actor().selectNextCommand())
  1709.             {
  1710.                 $gameParty.requestMotionRefresh();
  1711.                 if (this.actor() !== null && this.actor().CheckIfSkillHasCastingTime())
  1712.                 {
  1713.                     this.actor().setActionState('waiting');
  1714.                     if (typeof this.actor().spriteStepBack === 'function')
  1715.                     {
  1716.                         //This is for compatibility with Yanfly's.
  1717.                         this.actor().spriteStepBack();
  1718.                     }
  1719.                     this._phase = 'atb';
  1720.                     break;
  1721.                 }
  1722.                 this._phase = 'turn';
  1723.                 break;
  1724.             }
  1725.         } while (!this.actor().canInput());
  1726.     };

  1727.     //Don't let us jump to another character by cancelling.
  1728.     BattleManager.selectPreviousCommand = function() {
  1729.         do {
  1730.             if (!this.actor() || !this.actor().selectPreviousCommand()) {
  1731.                 if (allow_midbattle_escape === 1)
  1732.                 {
  1733.                     this.changeActor(-1, 'undecided');
  1734.                 }
  1735.                 return;
  1736.             }
  1737.         } while (!this.actor().canInput());
  1738.     };

  1739.     //We need to change the OnTurnEnd method, because otherwise it will apply to all battlers whenever anyone acts:
  1740.     BattleManager.endTurn = function() {
  1741.         this._phase = 'turnEnd';
  1742.         this._preemptive = false;
  1743.         this._surprise = false;
  1744.         this.predictTurnOrder();
  1745.         this.clearActor();
  1746.         if (battle_event_turn_mode !== 0)
  1747.         {
  1748.             $gameTroop.increaseTurn();
  1749.         }
  1750.     };


  1751.     //Remove the ATB value when a turn is processed:
  1752.     _BattleManager_processTurn = BattleManager.processTurn;
  1753.     BattleManager.processTurn = function() {
  1754.         if (this._pending_atb_removal === true)
  1755.         {
  1756.             this._subject.atb -= full_atb;
  1757.             this._pending_atb_removal = false;
  1758.         }
  1759.         _BattleManager_processTurn.call(this);

  1760.     };

  1761.     //We need a function that only gets alive battle members
  1762.     BattleManager.aliveBattleMembers = function()
  1763.     {
  1764.         var allAlive = [];
  1765.         this.allBattleMembers().forEach(function(battler)
  1766.         {
  1767.             if (!battler.isDead() && !battler.isHidden())
  1768.             {
  1769.                 allAlive.push(battler);
  1770.             }
  1771.         }, this);
  1772.         return allAlive;
  1773.     };

  1774.     //We'll need a function to predict the turn order for the next few turns, in case the developer wants to display this:
  1775.     BattleManager.predictTurnOrder = function(battlersToApplyModifiersTo, modifiersValues, battlerCasting, castingTime)
  1776.     {
  1777.         if (display_turn_order !== 1)
  1778.         {
  1779.             return null;
  1780.         }
  1781.         if (typeof battlersToApplyModifiersTo === 'undefined')
  1782.         {
  1783.             battlersToApplyModifiersTo = [];
  1784.         }
  1785.         if (typeof modifiersValues === 'undefined')
  1786.         {
  1787.             modifiersValues = [];
  1788.         }
  1789.         if (typeof battlerCasting === 'undefined' || typeof castingTime === 'undefined')
  1790.         {
  1791.             var battlerCasting = null;
  1792.             var castingTime = 0;
  1793.         }
  1794.         var numberOfTurns = turns_to_predict;
  1795.         var mmodifierValue = Number(mmodifierValue) || 0;
  1796.         var arrayOfATBValues = [];
  1797.         var arrayOfCastValues = [];
  1798.         var arrayOfCastingTimes = [];
  1799.         var arrayOfSymbols = [];
  1800.         var predictedTurnOrder = [];
  1801.         var predictedTurnOrderSymbols = [];
  1802.         var validBattlers = this.aliveBattleMembers();
  1803.         var delayedModForActiveActor = 0;
  1804.         var delayedModHasBeenApplied = false;
  1805.         if (numberOfTurns === 0)
  1806.         {
  1807.             return false;
  1808.         }
  1809.         //We cannot work directly on our Battlers for this simulation, or else we would mess their values
  1810.         //So instead we copy the numbers that are necessary, and we use them.
  1811.         validBattlers.forEach(function(battler)
  1812.         {
  1813.             var modIndex = battlersToApplyModifiersTo.indexOf(battler);
  1814.             var modValue = 0;
  1815.             var cast = 0;
  1816.             var symbol = false;
  1817.             if (modIndex >= 0)
  1818.             {
  1819.                 modValue = modifiersValues[modIndex];
  1820.             }
  1821.             //Add the plus, minus or neutral symbol:
  1822.             if (modValue > 0)
  1823.             {
  1824.                 symbol = ctb_bonus;
  1825.             }
  1826.             else if (modValue < 0)
  1827.             {
  1828.                 symbol = ctb_malus;
  1829.             }
  1830.             arrayOfSymbols.push(symbol);
  1831.             //See if it's hovering over a casting skill:
  1832.             if (battlerCasting === battler && castingTime > 0)
  1833.             {
  1834.                 cast += castingTime;
  1835.             }
  1836.             //If the battler is already casting something:
  1837.             cast += battler.target_cast_atb;


  1838.             //Compensate for the full ATB that casting battlers have behind the curtains:
  1839.             if (cast > 0 && battler.atb >= full_atb)
  1840.             {
  1841.                 modValue -= full_atb;
  1842.             }
  1843.             //If we're selecting the action of an actor:
  1844.             if (typeof this.actor() !== 'undefined' && this.actor() === battler)
  1845.             {
  1846.                 arrayOfATBValues.push(battler.atb);
  1847.                 delayedModForActiveActor = modValue;
  1848.             }
  1849.             else
  1850.             {
  1851.                 arrayOfATBValues.push(battler.atb + modValue);
  1852.             }
  1853.             //Add the current cast time as normal:
  1854.             arrayOfCastValues.push(battler.current_cast_atb);
  1855.             //And the target cast time:
  1856.             arrayOfCastingTimes.push(cast);
  1857.         }, this);

  1858.         //Now we simulate until we have enough turns:
  1859.         while (predictedTurnOrder.length < numberOfTurns)
  1860.         {
  1861.             for (index = 0; index < arrayOfATBValues.length; index++)
  1862.             {
  1863.                 var battler = validBattlers[index];
  1864.                 var target_cast = arrayOfCastingTimes[index];
  1865.                 if (typeof this.actor() !== 'undefined' && this.actor() === battler && predictedTurnOrder.length >= 1 && delayedModHasBeenApplied === false)
  1866.                 {
  1867.                     arrayOfATBValues[index] += delayedModForActiveActor;
  1868.                     delayedModHasBeenApplied = true;
  1869.                 }

  1870.                 //If is casting, check by cast time and don't increase virtual atb
  1871.                 if (arrayOfCastValues[index] < target_cast)
  1872.                 {
  1873.                     arrayOfCastValues[index] += battler._cast_rate * (battler.CastHaste() / 100);
  1874.                     if (arrayOfCastValues[index] >= target_cast)
  1875.                     {
  1876.                         predictedTurnOrder.push(battler);
  1877.                         predictedTurnOrderSymbols.push(ctb_cast);
  1878.                     }
  1879.                 }
  1880.                 else
  1881.                 {
  1882.                     arrayOfATBValues[index] += battler.calculateATBRate();
  1883.                     if (arrayOfATBValues[index] >= full_atb)
  1884.                     {
  1885.                         arrayOfATBValues[index] -= full_atb;
  1886.                         predictedTurnOrder.push(battler);
  1887.                         predictedTurnOrderSymbols.push(arrayOfSymbols[index]);
  1888.                     }
  1889.                 }
  1890.             }
  1891.         }
  1892.         predictedTurnOrder = predictedTurnOrder.slice(0, numberOfTurns);
  1893.         //Let's show them in our CTB Windows, if they are being used:
  1894.         this._predictedTurnOrder = predictedTurnOrder;
  1895.         this._predictedTurnSymbols = predictedTurnOrderSymbols;
  1896.         this.displayTurnOrder();
  1897.     };

  1898.     //At the end of Turns Timers, we only reduce the duration of states set to Turn End:
  1899.     _Game_Battler_onTurnEnd = Game_Battler.prototype.onTurnEnd;
  1900.     Game_Battler.prototype.onTurnEnd = function() {
  1901.         this.updateStateTurns(2);
  1902.         _Game_Battler_onTurnEnd.call(this);
  1903.     };

  1904.     //Because we now reduce the duration of states set to Action End on the end of actions (after, not before, checking for removal of previous one):
  1905.     _Game_Battler_On_AllActionsEnd = Game_Battler.prototype.onAllActionsEnd;
  1906.     Game_Battler.prototype.onAllActionsEnd = function() {
  1907.         this.updateStateTurns(1);
  1908.         //We apply end of turn stuff if paramaters are set so
  1909.         if (battler_end_turn_effects === 1)
  1910.         {
  1911.             this.onTurnEnd();
  1912.             BattleManager.refreshStatus();
  1913.             BattleManager._logWindow.displayAutoAffectedStatus(this);
  1914.             BattleManager._logWindow.displayRegeneration(this);
  1915.         }
  1916.         _Game_Battler_On_AllActionsEnd.call(this);
  1917.     };

  1918.     //This now receives a parameter for timing.
  1919.     Game_BattlerBase.prototype.updateStateTurns = function(timing) {
  1920.         if (typeof timing === 'undefined')
  1921.         {
  1922.             return;
  1923.         }
  1924.         this._states.forEach(function(stateId) {
  1925.             if (this._stateTurns[stateId] > 0 && $dataStates[stateId].autoRemovalTiming === timing) {
  1926.                 this._stateTurns[stateId]--;
  1927.             }
  1928.         }, this);
  1929.     };

  1930.     //Our items need new methods, to retrieve ATB-related data from the Note field
  1931.     //To retrive the <self_atb:> field
  1932.     Game_Item.prototype.selfATB = function() {
  1933.         if (typeof this.object() !== 'undefined' && typeof this.object().meta !== 'undefined' && typeof this.object().meta.self_atb !== 'undefined')
  1934.         {
  1935.             return this.object().meta.self_atb;
  1936.         }
  1937.         return 0;
  1938.     };

  1939.     //And one to retrieve the <target_atb:> field:
  1940.     Game_Item.prototype.targetATB = function() {
  1941.         if (typeof this.object() !== 'undefined' && typeof this.object().meta !== 'undefined' && typeof this.object().meta.target_atb !== 'undefined')
  1942.         {
  1943.             return this.object().meta.target_atb;
  1944.         }
  1945.         return 0;
  1946.     };

  1947.     //A formula to eval this ATB:
  1948.     Game_Action.prototype.evalATBFormula = function(formula, target) {
  1949.         try {
  1950.             var item = this.item();
  1951.             var a = this.subject();
  1952.             var b = target;
  1953.             var v = $gameVariables._data;
  1954.             return Number(eval(formula) || 0);
  1955.         } catch (e) {
  1956.             return 0;
  1957.         }
  1958.     };

  1959.     //When we Apply a Game_Action, we now need to check if it had an ATB bonus, so we can apply it too:
  1960.     //We also check for spellcasting interrupts and delays.
  1961.     _alias_ga_apply = Game_Action.prototype.apply;
  1962.     Game_Action.prototype.apply = function(target) {
  1963.         _alias_ga_apply.call(this, target);
  1964.         //Only on hit
  1965.         if (target.result().isHit())
  1966.         {
  1967.             var self_atb = this.evalATBFormula(this._item.selfATB(), target);
  1968.             var target_atb = this.evalATBFormula(this._item.targetATB(), target);
  1969.             this.subject().atb += self_atb;
  1970.             target.atb += target_atb;
  1971.             //Interrupts and delays:
  1972.             var delay_amount = default_delay_amount;
  1973.             if (typeof this.item() !== 'undefined' && typeof this.item().meta !== 'undefined')
  1974.             {
  1975.                 if (this.item().meta.interrupt || this.item().meta.interrupts)
  1976.                 {
  1977.                     target.BreakCurrentCast();
  1978.                 }
  1979.                 if (typeof this.item().meta.delay_amount !== 'undefined' && !isNaN(Number(this.item().meta.delay_amount)))
  1980.                 {
  1981.                     delay_amount = Number(this.item().meta.delay_amount);
  1982.                 }
  1983.                 //Care to not delay twice.
  1984.                 if ((this.item().meta.delay || this.item().meta.delays) && default_delays !== 1)
  1985.                 {
  1986.                     target.delayCast(delay_amount);
  1987.                 }
  1988.             }
  1989.             if (default_delays === 1 && ((target.isActor() && this.subject().isEnemy()) || (target.isEnemy() && this.subject().isActor())))
  1990.             {
  1991.                 target.delayCast(delay_amount);
  1992.             }
  1993.         }
  1994.     };

  1995.     //Check if a skill item (the database element, not the Game_Object classes) has Casting Time metadata
  1996.     Game_Battler.prototype.CheckIfSkillHasCastingTime = function()
  1997.     {
  1998.         if (typeof this._actions[0] === 'undefined' || this._actions[0] === null)
  1999.         {
  2000.             return false;
  2001.         }
  2002.         var item = this._actions[0].item();
  2003.         if (item === null || typeof item.meta.cast_time === 'undefined')
  2004.         {
  2005.             return false;
  2006.         }
  2007.         var castTime = Number(item.meta.cast_time || 0);
  2008.         if (castTime <= 0)
  2009.         {
  2010.             return false;
  2011.         }
  2012.         this.startCast(this._actions[0], castTime);
  2013.         return true;
  2014.     };

  2015.     //See if current casting skill is delayable
  2016.     Game_Battler.prototype.IsCastDelayable = function()
  2017.     {
  2018.         //Meta overrides default:
  2019.         if (this.casting_action !== null && typeof this.casting_action.item() !== 'undefined' && typeof this.casting_action.item().meta !== 'undefined')
  2020.         {
  2021.             var delayable = this.casting_action.item().meta.delayable;
  2022.             var not_delayable = this.casting_action.item().meta.not_delayable;
  2023.             if (delayable)
  2024.             {
  2025.                 return true;
  2026.             }
  2027.             if (not_delayable)
  2028.             {
  2029.                 return false;
  2030.             }
  2031.         }
  2032.         //If we don't have meta, or have meta but nothing about delay on it, we go for defaults:
  2033.         if (default_delayable === 1)
  2034.         {
  2035.             return true;
  2036.         }
  2037.         return false;
  2038.     };

  2039.     //See if current casting skill is interruptible
  2040.     Game_Battler.prototype.IsCastInterruptible = function()
  2041.     {
  2042.         if (this.casting_action !== null && typeof this.casting_action.item() !== 'undefined' && typeof this.casting_action.item().meta !== 'undefined')
  2043.         {
  2044.             var meta = this.casting_action.item().meta;
  2045.             return (meta.interruptible || meta.interruptable || meta.easily_interruptible || meta.easily_interruptable);
  2046.         }
  2047.         return false;
  2048.     };

  2049.     //Delays current skill cast:
  2050.     Game_Battler.prototype.delayCast = function(delay_amount)
  2051.     {
  2052.         var delay_amount = this.cast_delay_max * delay_amount / 100;
  2053.         if (delay_amount > 0 && this.IsCastDelayable() && this.cast_delay_current < this.cast_delay_max)
  2054.         {
  2055.             this.cast_delay_current += delay_amount;
  2056.             this.current_cast_atb -= delay_amount;
  2057.             if (this.current_cast_atb < 0)
  2058.             {
  2059.                 this.current_cast_atb = 0;
  2060.             }
  2061.         }
  2062.     };

  2063.     //Breaks current skill cast:
  2064.     Game_Battler.prototype.BreakCurrentCast = function(forceBreak)
  2065.     {
  2066.         if (typeof forceBreak !== 'undefined')
  2067.         {
  2068.             var force = true;
  2069.         }
  2070.         if (this.IsCastInterruptible() || force)
  2071.         {
  2072.             this.atb += Math.min(this.current_cast_atb * interrupt_compensation_pct / 100, full_atb * interrupt_compensation_max / 100);
  2073.             this.atb -= full_atb;
  2074.             this.resetCast();
  2075.             if (interrupt_vfx > 0)
  2076.             {
  2077.                 this.startAnimation(interrupt_vfx, 0, 0);
  2078.             }
  2079.         }
  2080.     };

  2081.     //Computes the cast parameter
  2082.     //Haste is not applied here to keep it dynamic. Change this to only set up a state so we can use the calcATBRate on other functions.
  2083.     Game_Battler.prototype.calculateCastRate = function()
  2084.     {
  2085.         var param = "this.";
  2086.         if (this.casting_action !== null && typeof this.casting_action.item() !== 'undefined' && typeof this.casting_action.item().meta !== 'undefined'
  2087.                 && typeof this.casting_action.item().meta.cast_param !== 'undefined' && this.casting_action.item().meta.cast_param !== "")
  2088.         {
  2089.             param += this.casting_action.item().meta.cast_param;
  2090.         }
  2091.         else
  2092.         {
  2093.             param += default_cast_parameter;
  2094.         }
  2095.         if (typeof eval(param) !== 'undefined' && !isNaN(eval(param)))
  2096.         {
  2097.             var cs = Number(eval(param));
  2098.             this._cast_rate = CalculateATBRate(cs, 100);
  2099.         }
  2100.         else
  2101.         {
  2102.             this._cast_rate = CalculateATBRate(0, 100);
  2103.         }
  2104.     };

  2105.     //Checks for Haste when adding a state
  2106.     _alias_gbb_p_addNewState = Game_BattlerBase.prototype.addNewState;
  2107.     Game_BattlerBase.prototype.addNewState = function(stateId)
  2108.     {
  2109.         _alias_gbb_p_addNewState.call(this, stateId);
  2110.         var state = $dataStates[stateId];
  2111.         if (typeof state.meta !== 'undefined')
  2112.         {
  2113.             this.AddHaste(state);
  2114.             if (typeof state.meta.atb_duration !== 'undefined' && !isNaN(state.meta.atb_duration))
  2115.             {
  2116.                 this._states_atb_duration[stateId] = Number(state.meta.atb_duration);
  2117.                 this._states_atb_current[stateId] = 0;
  2118.                 this._states_atb_rate[stateId] = this.StateATBRate(state);
  2119.             }
  2120.         }
  2121.     };

  2122.     //Resets ATB Duration when reseting a state that has one:
  2123.     _alias_gbb_p_resetStateCounts = Game_BattlerBase.prototype.resetStateCounts;
  2124.     Game_BattlerBase.prototype.resetStateCounts = function(stateId)
  2125.     {
  2126.         _alias_gbb_p_resetStateCounts.call(this, stateId);
  2127.         var state = $dataStates[stateId];
  2128.         if (typeof state.meta !== 'undefined' && typeof state.meta.atb_duration !== 'undefined' && !isNaN(state.meta.atb_duration))
  2129.         {
  2130.             this._states_atb_current[stateId] = 0;
  2131.         }
  2132.     };

  2133.     //Removes state duration and such when removing a state, and re-calculates haste:
  2134.     _alias_gbb_p_EraseState = Game_BattlerBase.prototype.eraseState;
  2135.     Game_BattlerBase.prototype.eraseState = function(stateId) {
  2136.         _alias_gbb_p_EraseState.call(this, stateId);
  2137.         if (typeof this._states_atb_duration[stateId] !== 'undefined')
  2138.         {
  2139.             delete this._states_atb_duration[stateId];
  2140.         }
  2141.         if (typeof this._states_atb_current[stateId] !== 'undefined')
  2142.         {
  2143.             delete this._states_atb_current[stateId];
  2144.         }
  2145.         if (typeof this._states_atb_rate[stateId] !== 'undefined')
  2146.         {
  2147.             delete this._states_atb_rate[stateId];
  2148.         }
  2149.         var state = $dataStates[stateId];
  2150.         if (typeof state.meta !== 'undefined')
  2151.         {
  2152.             this.CalculateHaste();
  2153.         }
  2154.     };

  2155.     //Calculates all haste ratings based on equips, classes, states, etc:
  2156.     Game_BattlerBase.prototype.CalculateHaste = function() {
  2157.         this._haste_all = 100;
  2158.         this._haste_atb = 100;
  2159.         this._haste_cast = 100;
  2160.         this.states().forEach(function(state) {
  2161.             this.AddHaste(state);
  2162.         }, this);
  2163.         if (this.isActor())
  2164.         {
  2165.             this.AddHaste(this.actor());
  2166.             this.AddHaste(this.currentClass());
  2167.             this.equips().forEach(function(equip)
  2168.             {
  2169.                 this.AddHaste(equip);
  2170.             }, this);
  2171.         }
  2172.         else
  2173.         {
  2174.             this.AddHaste(this.enemy());
  2175.         }
  2176.     };

  2177.     //Add individual state or item haste
  2178.     Game_BattlerBase.prototype.AddHaste = function(item) {
  2179.         if (item !== null && typeof item !== 'undefined' && typeof item.meta !== 'undefined')
  2180.         {
  2181.             if (typeof item.meta.haste !== 'undefined' && !isNaN(item.meta.haste))
  2182.             {
  2183.                 this._haste_all = this._haste_all * Number(item.meta.haste) / 100;
  2184.             }
  2185.             if (typeof item.meta.haste_atb !== 'undefined' && !isNaN(item.meta.haste_atb))
  2186.             {
  2187.                 this._haste_atb = this._haste_atb * Number(item.meta.haste_atb) / 100;
  2188.             }
  2189.             if (typeof item.meta.haste_cast !== 'undefined' && !isNaN(item.meta.haste_cast))
  2190.             {
  2191.                 this._haste_cast = this._haste_cast * Number(item.meta.haste_cast) / 100;
  2192.             }
  2193.         }
  2194.     };


  2195.     Game_BattlerBase.prototype.StateATBRate = function(state)
  2196.     {
  2197.         if (typeof state.meta !== 'undefined' && typeof state.meta.atb_duration_param !== 'undefined' && state.meta.atb_duration_param !== null)
  2198.         {
  2199.             switch (state.meta.atb_duration_param)
  2200.             {
  2201.                 case "turn":
  2202.                 case "turn_timer":
  2203.                 case "timer":
  2204.                     return turn_timer;
  2205.                 case "atk":
  2206.                 case "def":
  2207.                 case "mat":
  2208.                 case "mdf":
  2209.                 case "agi":
  2210.                 case "luk":
  2211.                     return Number(eval("this." + state.meta.atb_duration_param));
  2212.                 case "base":
  2213.                 case "fix":
  2214.                 case "fixed":
  2215.                     return 0;
  2216.             }
  2217.         }
  2218.         return this.agi;
  2219.     };

  2220.     //Breaks casting time when restricted, since restriction clears current action:
  2221.     _alias_gbb_p_onRestrict = Game_BattlerBase.prototype.onRestrict;
  2222.     Game_BattlerBase.prototype.onRestrict = function() {
  2223.         this.BreakCurrentCast(true);
  2224.         _alias_gbb_p_onRestrict.call(this);
  2225.     };

  2226.     //Command Fight by default would send us spiraling to a "turn" end (for nobody), instead let's just send us to the ATB phase:
  2227.     Scene_Battle.prototype.commandFight = function() {
  2228.         BattleManager._phase = 'atb';
  2229.     };
  2230. })();
复制代码
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
497
在线时间
266 小时
注册时间
2015-12-8
帖子
873
3
发表于 2016-2-26 17:49:40 | 只看该作者
這是腳本做甚麼用?
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-12-23 15:29

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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