* 2015-11-28-1906: Cast motion should now finish at the proper time.
* 2015-11-26-1052: Added the option of mid-battle escape.
* 2015-11-22-1515: Fixed a bug with Confusion/Enrage effects and casting times.
* 2015-11-22-0925: Made enemy gauges compatible with Yanfly's sprite sideviews for enemies (and possible other similar SV sprites).
* 2015-11-22-0453: Can now also use <atb_duration_param:PARAM> on states. See HELP.
* 2015-11-20-1808: Added <haste> notetag for states, actors, classes, equips and enemies, and <atb_duration:> notetag for states.
* 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.
* 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:>.
* 2015-11-14-1405: Separated a few stuff into their own method, like casting stop/starting and atb ratio.
* 2015-11-14-0154: Made step back when casting compatible with Yanfly's.
* 2015-11-14-0134: Turn prediction now predicts casting times when hovering over a skill with cast_time.
* 2015-11-11-2339: Fixed an issue with Turn Timer and Instant ATB.
* 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.
* 2015-11-09-2317: Enemies now also use the different interruptible cast gauge color.
* 2015-11-09-2317: Separated the drawActorATBGauge method for better compatibility with interface and gauges plugins. (Thanks for the suggestion, Bobstah!)
* 2015-11-09-0119: Characters with restricted movement (stun, for example) have their cast interrupted and their gauge display stays empty.
* 2015-11-08-2354: Fixed casting actors staying forward until the next action.
* 2015-11-08-2354: Added Imported.Ellye_ATB for compatibility.
* 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.
* 2015-11-08-2157: Can now add custom <cast_motion:MOTION> and <cast_animation:NUMBER> per skill. See help.
* 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).
* 2015-11-08-1557: Added a Default Cast Motion parameter.
* 2015-11-08-1557: Added the option of using reversed cast gauges.
* 2015-11-07-1722: Fixed a bug with lingering enemy cast bars depending on how it finished casting.
* 2015-11-07-1722: Improved performance of enemy gauges slightly.
* 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.
* 2015-11-07-0222: Added parameters for positioning actor name and state icons.
* 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.
* 2015-11-07-0036: Fixed an issue with the Turn Predction not working properly with skills that delayed the caster turn.
* 2015-11-07-0036: The cast bar remains visible while the actors executes their skill.
* 2015-11-06-1036: Fixed an issue when casting time finished at the same time as an input action.
* 2015-11-05-2319: Added a casting time bar and parameters for it.
* 2015-11-03-0945: Fixed a compatibility issue with my States Damage plugin.
* 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.
* 2015-11-02-1423: Fixed an issue with self affecting ATB not showing up properly.
* 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)
* 2015-11-02-1123: Added option to resize Skill/Item window when using Turn Order Predction, so it stays visible.
* 2015-11-02-1026: Added option to hide ATB gauge.
* 2015-11-02-1026: Added instant ATB mode.
* 2015-11-02-0959: Added configurable opacity gradient for the turn order display.
* 2015-11-02-0959: Added option to invert CTB display to Right-to-Left.
* 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.
* 2015-11-02-0639: Can now use the [Note] field for ATB formulas. SEE HELP.
* 2015-10-31-1416: Fixed a stepping forward bug when multiple actors filled their AT at the same time (they all stepped forward).
* 2015-10-31-1416: Made forward stepping optional.
* 2015-10-31-1254: Added a Average Turn Timer parameter. It overrides the Turn Timer when used. It's ON by default.
* 2015-10-31-1208: Made the stepping forward animation compatible with Yanfly's Battle Core.
* 2015-10-31-0325: Monsters now properly show their name instead of their Battler Image name in CTB.
* 2015-10-31-0325: Characters now step forward when it's their turn.
* 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/
* 2015-10-30-0147: Added parameters for SE playability. Check HELP.
* 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)
* 2015-10-29-2330: Added parameters for gauge positions (thanks, djDarkX)
* 2015-10-28-2300: Implemented iavra's workaround to get parameters without depending on filename.
* 2015-10-28-2300: Added Gauge Color parameters
* 2015-10-28-2300: Added Turn Order Prediction interface (WORK IN PROGRESS)
* Added parameter for random starting ATB bonus.
* Pre-emptive and surprise attack now function properly.
* Added starting ATB parameter based on AGI.
* Fixed battle events set to fire on turn 0+0 not firing (thanks, Kistulot)
* Fixed dead battlers still gaining ATB.
* Added the option to display Fight/Escape window.
* Added a parameter for the gauge name.
* 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)
* Corrected a few bugs regarding monsters with the same agility not attacking;
* Corrected a few bugs regarding Auto-Battle;
* Corrected a few bugs regarding Status Effects that happened per turn.
*
*
* @plugindesc V.2015-11-28-1906. A simple Active Time Battle system.
* @desc Parameters below this one are Gameplay-related options
* @default .
*
* @param Agility Weight
* @desc The higher this integer value, the more noticeable the difference of having high Agility vs. low Agility will be. Default 100.
* @default 100
*
* @param Turn Timer
* @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.
* @default 150
*
* @param Average Turn Timer
* @desc 1 = Create a Turn Timer based on the average agility of all Battlers present. 0 = Use the provided turn timer above. Default: 0
* @default 1
*
* @param Base Fill Speed
* @desc Default: 100. The base speed that the bar fills by itself, also affect Turn Timer in the same way.
* @default 100
*
* @param Display Fight / Escape at beginning of the battle
* @desc 1 = yes; 0 = no. Default: 0
* @default 0
*
* @param Allow Escape During Battle
* @desc 1 = yes; 0 = no. Default: 0
* @default 0
*
* @param Starting ATB
* @desc Multiplied by Agility and Agility Weight/100. Default: 50
* @default 50
*
* @param Starting ATB Random Bonus
* @desc Maximum random bonus for ATB at battle start. Default: 0
* @default 0
*
* @param Full ATB Gauge
* @desc The value of a full ATB Gauge. Default: 50000
* @default 50000
*
* @param Instant ATB
* @desc 1: ON, 0: OFF. Default: 0; Jumps instantly from a turn to the next. Best for CTB style.
* @default 0
*
* @param Battle Event Turn
* @desc 0: Per timer, 1: per action. Advances the Battle Turn for Events and monster AI. Default: 0
* @default 0
*
* @param Battler EndTurn Effects
* @desc 0: per timer, 1: per action. Def: 0. Whether "end of turn" for battlers is at turn timer or after they act.
* @default 0
*
* @param Interrupt Compensation Pct
* @desc What % of the ATB spent in casting is salvaged when interrupted. Default: 25
* @default 25
*
* @param Interrupt Compensation Max
* @default Maximum % of a full ATB gauge that can be given as compensation when interrupted. Default: 50
* @default 50
*
* @param Maximum Delay Percent
* @default Maximum that a skill can be delayed, as a % of its cast time. Default: 100
* @default 100
*
* @param Default Delay
* @default How much % a skill get delayed when hit by a delaying effect. Default: 10
* @default 10
*
* @param Delayable by Default
* @default 0: No, 1: Yes. Whether every skill is delayable by default.
* @default 0
*
* @param Delays by Default
* @default 0: No, 1: Yes. Whether every skill applies delay by default.
* @desc The ID of the default Animation. 0 for none. Suggested (from default DB): 52. Default: 0
* @default 0
*
* @param Interrupt Animation
* @desc Battle animation to be played when a skill is interrupted. Suggestion: create one with flash and sound only. Default: 0
* @default 0
*
* @help Actors will act as frequently as their AGILITY attribute allows them to, instead of taking fixed turns.
* 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.
* Gauges are paused while the player is deciding on a command, or while an animation is being played.
* A full gauge requires 50000 ATB by default (excess ATB is not lost, and the number can be negative).
*
* USING THE [NOTE] FIELD TO SETUP SKILLS THAT INTERACT WITH ATB:
* In each Skill or Combat Usable Item, you can set up [NOTE]s that interact with the ATB system.
* There's the following notes:
* <self_atb:FORMULA>
* <target_atb:FORMULA>
*
* It's important to note that those need to be ARITHMETICAL FORMULAS, not commands.
* The following examples are valid:
* <self_atb:25000> #This would make a quick skill, as your next turn will come faster.
* <self_atb:-25000> #This one would delay your next turn
* <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
* <target_atb:25000> #This would GIVE the target some atb, making his turn come quicker.
* <target_atb:-10000> #This would DELAY the target next turn
* <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
*
* So:
* It needs to be a formula that results in a NUMBER, not a command. Do not use "a.atb+=5000;" or similar assignments.
* 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.
* POSITIVE numbers will always GIVE ATB, no matter if for caster or target.
* NEGATIVE numbers will always REMOVE ATB, no matter if for caster or target.
* 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).
*
* If you use Display Faces, your enemies require to have a face configured in the Database Editor.
* In the [Notes] field, you should add, for example: <face_name:Monster><face_id:2> - this would use the RTP Orc face.
* 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.
*
* 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.
* 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.
*
* CASTING TIMES:
* You can now set up casting times by adding:
* <cast_time:NUMBER>
* 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.
*
* Skills with casting time can also be marked with
* <interruptible>
* (or <interruptable>)
*
* This means that they will be broken when hit by a skill that is marked as:
* <interrupt>
* (or <interrupts>)
*
* By default, interruptable skills have a different cast gauge color.
* You can also set up an Animation to play whenever a skill is successfully interrupted.
* 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).
*
* For the DELAY system, you can set default delay parameters in the Plugin Paramaters, and customize them per skill with the following notes:
*
* <delayable>
* Will mark a skill as delayable, regardless of default settings.
*
* <not_delayable>
* Will mark a skill as not delayable, regardless of default settings.
*
* <delays>
* 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)
*
* <delay_amount:NUMBER>
* 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).
*
*
* Another notes you can have for casting skills:
* <cast_animation:NUMBER>
* This is the number of an Animation (from the Animations tab in the database) to be cast at the start of the cast.
*
* <cast_motion:MOTION>
* The movement your character does while casting. Some valid options are:
* Will use that Param instead of the default (agi, normally) for casting that skill. For example:
* <cast_param:mat> will use MAT instead of AGI.
*
* STATES:
* If you want a State to count down per action taken, you set it up as Action End.
* If you want a State to count down per virtual turn, you set it up as Turn End.
*
* 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)
* This might be the optimal design overall for the ATB system, at least for states that directly affect the ATB gauge:
* To do so, use the following tag:
* <atb_duration:NUMBER>
* For example, 150000 would last the normal duration of three turns for that actor (not taking modifiers like haste in consideration).
* Optionally, you can also specify which parameter is used for the speed at which the state comes out. To do so, use:
* <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>
* You can also use <atb_duration_param:turn> to make it follow Turn Timer and be independent of the target's parameters.
*
*
* STARTING ATB:
* You can use the note-tag
* <start_atb:NUMBER>
* On actors, classes, equips and enemies to set up bonus starting ATB (absolute vlaues).
*
* HASTE:
* You can use the note-tags:
* <haste:NUMBER>
* <haste_atb:NUMBER>
* <haste_cast:NUMBER>
* This is a multiplicative percent change to all speeds, atb-only speed or cast-only speed.
* 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.
* Those tags can be used on Actors, Classes, Equips and Enemies.
*
*/
//Our plugin needs to be inside a function:
var Imported = Imported || {};
Imported.Ellye_ATB = true;
(function() {
var parameters = $plugins.filter(function(p) {
return p.description.contains('<Ellye ATB>');
})[0].parameters; //Thanks to Iavra
var turn_atb = 0;
var ctb_window_width = 90;
var ctb_window_height = 60;
var turns_to_predict = Math.floor((SceneManager._boxWidth / ctb_window_width));
var ctb_window_x_offset = (SceneManager._boxWidth - turns_to_predict * ctb_window_width) / 2;
var full_atb = Number(parameters['Full ATB Gauge'] || 50000);
var agi_weight = Number(parameters['Agility Weight'] || 100);
var turn_timer = Number(parameters['Turn Timer'] || 150);
var av_turn_timer = Number(parameters['Average Turn Timer'] || 1);
var base_atb_increase = Number(parameters['Base Fill Speed'] || 100);
var display_gauges = Number(parameters['Display Gauges'] || 1);
var actor_name_x_offset = Number(parameters['Actor Name X Offset'] || 0);
var actor_icons_x_offset = Number(parameters['Actor Icons X Offset'] || 0);
var actor_name_width = Number(parameters['Actor Name Width'] || 120);
var gauge_name=String%28parameters['Gauge Name'] || "");
var cast_gauge_name=String%28parameters['Cast Gauge Name'] || "");
var use_skill_name_gauge = Number(parameters['Use Skill Name for Cast Gauge'] || 0);
var display_party_command = Number(parameters['Display Fight / Escape at beginning of the battle'] || 0);
var allow_midbattle_escape = Number(parameters['Allow Escape During Battle'] || 0);
if (allow_midbattle_escape === 1)
{
display_party_command = 1;
}
var starting_atb = Number(parameters['Starting ATB'] || 50);
var starting_atb_random = Number(parameters['Starting ATB Random Bonus'] || 0);
var display_turn_order = Number(parameters['Display Predicted Turn Order'] || 0);
var display_as_faces_or_names = Number(parameters['Display as Faces or Names'] || 0);
var invert_turn_order_display = Number(parameters['Invert TO Direction'] || 0);
var ctb_opacity_first = Number(parameters['Opacity First TO'] || 220);
var ctb_opacity_last = Number(parameters['Opacity Last TO'] || 160);
var resize_skill_window = Number(parameters['Resize Skill and Item Window'] || 1);
var atb_gauge_width = Number(parameters['ATB Gauge Width'] || 120);
var atb_gauge_color1 = String(parameters['Gauge Color 1'] || "#505060");
var atb_gauge_color2 = String(parameters['Gauge Color 2'] || "#D5D5E0");
var cast_gauge_color1 = String(parameters['Cast Gauge Color 1'] || "#8E0B8A");
var cast_gauge_color2 = String(parameters['Cast Gauge Color 2'] || "#EA7BD9");
var gauge_area_size = Number(parameters['Gauge Area Size'] || 400);
var gauge_text_width = Number(parameters['ATB Gauge Text Width'] || 120);
var hp_gauge_x_tp = Number(parameters['HP Gauge X Position (with TP)'] || 0);
var mp_gauge_x_tp = Number(parameters['MP Gauge X Position (with TP)'] || 112);
var tp_gauge_x = Number(parameters['TP Gauge X Position'] || 213);
var atb_gauge_x_tp = Number(parameters['ATB Gauge X Position (with TP)'] || 314);
var hp_gauge_width_tp = Number(parameters['HP Gauge Width (with TP)'] || 97);
var mp_gauge_width_tp = Number(parameters['MP Gauge Width (with TP)'] || 86);
var tp_gauge_width = Number(parameters['TP Gauge Width'] || 86);
var atb_gauge_width_tp = Number(parameters['ATB Gauge Width (with TP)'] || 86);
var hp_gauge_x = Number(parameters['HP Gauge X Position'] || 0);
var mp_gauge_x = Number(parameters['MP Gauge X Position'] || 145);
var atb_gauge_x = Number(parameters['ATB Gauge X Position'] || 280);
var hp_gauge_width = Number(parameters['HP Gauge Width'] || 130);
var mp_gauge_width = Number(parameters['MP Gauge Width'] || 120);
var atb_gauge_width = Number(parameters['ATB Gauge Width'] || 120);
var se_enabled = Number(parameters['Play SE'] || 0);
var se_name=String%28parameters['SE Name'] || "Cursor3");
var se_volume = Number(parameters['SE Volume'] || 75);
var se_pitch = Number(parameters['SE Pitch'] || 100);
var se_pan = Number(parameters['SE Pan'] || 0);
var step_forward = Number(parameters['Step Forward When Ready'] || 1);
var instant_atb = Number(parameters['Instant ATB'] || 0);
var battle_event_turn_mode = Number(parameters['Battle Event Turn'] || 0);
var enemy_gauge_position = Number(parameters['Enemy Gauge Position'] || 0);
var enemy_gauge_opacity = Number(parameters['Enemy Gauge Opacity'] || 200);
var enemy_show_cast_name=Number%28parameters['Enemy Show Cast Name'] || 1);
var enemy_show_name=Number%28parameters['Enemy Show Name'] || 1);
var display_enemy_cast_gauges = Number(parameters['Display Enemy Cast Gauges'] || 1);
var display_enemy_atb_gauges = Number(parameters['Display Enemy ATB Gauges'] || 0);
var enemy_gauge_color1 = String(parameters['Enemy Gauge Color1'] || "#F5818B");
var enemy_gauge_color2 = String(parameters['Enemy Gauge Color2'] || "#EBB3C3");
var reversed_cast_gauge = Number(parameters['Reversed Cast Gauge'] || 0);
var default_cast_motion = Number(parameters['Default Cast Motion'] || 1);
var default_cast_vfx = Number(parameters['Default Cast Animation'] || 0);
var interrupt_compensation_pct = Number(parameters['Interrupt Compensation Pct'] || 25);
var interrupt_compensation_max = Number(parameters['Interrupt Compensation Max'] || 50);
var interrupt_vfx = Number(parameters['Interrupt Animation'] || 0);
var interrupt_gauge_color1 = String(parameters['Interruptible Gauge Color 1'] || "#D5D315");
var interrupt_gauge_color2 = String(parameters['Interruptible Gauge Color 2'] || "#EDEE87");
var ctb_bonus = String(parameters['Prediction Bonus'] || "");
var ctb_malus = String(parameters['Prediction Malus'] || "");
var ctb_cast = String(parameters['Prediction Cast'] || "");
var ctb_cast_skill_name=Number%28parameters['Prediction Cast Name'] || 0);
var ctb_bonus_color = String(parameters['Prediction Bonus Color'] || "#42B942");
var ctb_malus_color = String(parameters['Prediction Malus Color'] || "#B94242");
var ctb_cast_color = String(parameters['Prediction Cast Color'] || "#8642B9");
var max_delay_pct = Number(parameters['Maximum Delay Percent'] || 100);
var default_delay_amount = Number(parameters['Default Delay'] || 10);
var default_delayable = Number(parameters['Delayable by Default'] || 0);
var default_delays = Number(parameters['Delays by Default'] || 1);
var battler_end_turn_effects = Number(parameters['Battler EndTurn Effects'] || 0);
var default_cast_parameter = String(parameters['Default Cast Paramater'] || "agi");
var positive_haste_gauge_color1 = String(parameters['Positive Haste Gauge Color 1'] || "#ECAA93");
var positive_haste_gauge_color2 = String(parameters['Positive Haste Gauge Color 2'] || "#E6BA98");
var negative_haste_gauge_color1 = String(parameters['Negative Haste Gauge Color 1'] || "#1D5E86");
var negative_haste_gauge_color2 = String(parameters['Negative Haste Gauge Color 2'] || "#2191A1");
var zero_haste_gauge_color1 = String(parameters['Zero Haste Gauge Color 1'] || "#430F0F");
var zero_haste_gauge_color2 = String(parameters['Zero Haste Gauge Color 2'] || "#4B1618");