/*=============================================================================
* Gilgamar - ButtonCast
* By Gilgamar
* G_ButtonCast.js
* Version: 1.05a
* Free for commercial and non commercial use.
*=============================================================================*/
var Imported = Imported || {};
Imported.G_ButtonCast = true;
/*:
* @plugindesc v1.05a Adds ability to instantly cast skills with button.
* @author Gilgamar
*
* @param ---Top Row---
* @default
*
* @param Key ~
* @desc ID of skill to bind to key
* @default 0
*
* @param Key 1
* @desc ID of skill to bind to key
* @default 0
*
* @param Key 2
* @desc ID of skill to bind to key
* @default 0
*
* @param Key 3
* @desc ID of skill to bind to key
* @default 0
*
* @param Key 4
* @desc ID of skill to bind to key
* @default 0
*
* @param Key 5
* @desc ID of skill to bind to key
* @default 0
*
* @param Key 6
* @desc ID of skill to bind to key
* @default 0
*
* @param Key 7
* @desc ID of skill to bind to key
* @default 0
*
* @param Key 8
* @desc ID of skill to bind to key
* @default 0
*
* @param Key 9
* @desc ID of skill to bind to key
* @default 0
*
* @param Key 0
* @desc ID of skill to bind to key
* @default 0
*
* @param Key -
* @desc ID of skill to bind to key
* @default 0
*
* @param Key =
* @desc ID of skill to bind to key
* @default 0
*
* @param ---2nd Row---
* @default
*
* @param Key Q (PageUp)
* @desc ID of skill to bind to key
* @default 0
*
* @param Key W (PageDown)
* @desc ID of skill to bind to key
* @default 0
*
* @param Key E
* @desc ID of skill to bind to key
* @default 0
*
* @param Key R
* @desc ID of skill to bind to key
* @default 0
*
* @param Key T
* @desc ID of skill to bind to key
* @default 0
*
* @param Key Y
* @desc ID of skill to bind to key
* @default 0
*
* @param Key U
* @desc ID of skill to bind to key
* @default 0
*
* @param Key I
* @desc ID of skill to bind to key
* @default 0
*
* @param Key O
* @desc ID of skill to bind to key
* @default 0
*
* @param Key P
* @desc ID of skill to bind to key
* @default 0
*
* @param Key [
* @desc ID of skill to bind to key
* @default 0
*
* @param Key ]
* @desc ID of skill to bind to key
* @default 0
*
* @param Key \
* @desc ID of skill to bind to key
* @default 0
*
* @param ---3rd Row---
* @default
*
* @param Key A
* @desc ID of skill to bind to key
* @default 0
*
* @param Key S
* @desc ID of skill to bind to key
* @default 0
*
* @param Key D
* @desc ID of skill to bind to key
* @default 0
*
* @param Key F
* @desc ID of skill to bind to key
* @default 0
*
* @param Key G
* @desc ID of skill to bind to key
* @default 0
*
* @param Key H
* @desc ID of skill to bind to key
* @default 0
*
* @param Key J
* @desc ID of skill to bind to key
* @default 0
*
* @param Key K
* @desc ID of skill to bind to key
* @default 0
*
* @param Key L
* @desc ID of skill to bind to key
* @default 0
*
* @param Key ;
* @desc ID of skill to bind to key
* @default 0
*
* @param Key "
* @desc ID of skill to bind to key
* @default 0
*
* @param Key Enter (OK)
* @desc ID of skill to bind to key
* @default 0
*
* @param ---4th Row---
* @default
*
* @param Key Shift (Dash)
* @desc ID of skill to bind to key
* @default 0
*
* @param Key Z (OK)
* @desc ID of skill to bind to key
* @default 0
*
* @param Key X (Cancel)
* @desc ID of skill to bind to key
* @default 0
*
* @param Key C
* @desc ID of skill to bind to key
* @default 0
*
* @param Key V
* @desc ID of skill to bind to key
* @default 0
*
* @param Key B
* @desc ID of skill to bind to key
* @default 0
*
* @param Key N
* @desc ID of skill to bind to key
* @default 0
*
* @param Key M
* @desc ID of skill to bind to key
* @default 0
*
* @param Key ,
* @desc ID of skill to bind to key
* @default 0
*
* @param Key .
* @desc ID of skill to bind to key
* @default 0
*
* @param Key /
* @desc ID of skill to bind to key
* @default 0
*
* @param ---Misc---
* @default
*
* @param Key Space (OK)
* @desc ID of skill to bind to key
* @default 0
*
* @param Key Left (Left)
* @desc ID of skill to bind to key
* @default 0
*
* @param Key Up (Up)
* @desc ID of skill to bind to key
* @default 0
*
* @param Key Right (Right)
* @desc ID of skill to bind to key
* @default 0
*
* @param Key Down (Down)
* @desc ID of skill to bind to key
* @default 0
*
* @param Key Insert (Cancel)
* @desc ID of skill to bind to key
* @default 0
*
* @param Key Delete
* @desc ID of skill to bind to key
* @default 0
*
* @param Key Home
* @desc ID of skill to bind to key
* @default 0
*
* @param Key End
* @desc ID of skill to bind to key
* @default 0
*
* @param Key Page Up (PageUp)
* @desc ID of skill to bind to key
* @default 0
*
* @param Key Page Down (PageDown)
* @desc ID of skill to bind to key
* @default 0
*
* @param ---NumPad---
* @default
*
* @param Key NumPad 0 (Cancel)
* @desc ID of skill to bind to key
* @default 0
*
* @param Key NumPad 1
* @desc ID of skill to bind to key
* @default 0
*
* @param Key NumPad 2 (Down)
* @desc ID of skill to bind to key
* @default 0
*
* @param Key NumPad 3
* @desc ID of skill to bind to key
* @default 0
*
* @param Key NumPad 4 (Left)
* @desc ID of skill to bind to key
* @default 0
*
* @param Key NumPad 5
* @desc ID of skill to bind to key
* @default 0
*
* @param Key NumPad 6 (Right)
* @desc ID of skill to bind to key
* @default 0
*
* @param Key NumPad 7
* @desc ID of skill to bind to key
* @default 0
*
* @param Key NumPad 8 (Up)
* @desc ID of skill to bind to key
* @default 0
*
* @param Key NumPad 9
* @desc ID of skill to bind to key
* @default 0
*
* @param Key NumPad .
* @desc ID of skill to bind to key
* @default 0
*
* @param Key NumPad +
* @desc ID of skill to bind to key
* @default 0
*
* @param Key NumPad -
* @desc ID of skill to bind to key
* @default 0
*
* @param Key NumPad *
* @desc ID of skill to bind to key
* @default 0
*
* @param Key NumPad /
* @desc ID of skill to bind to key
* @default 0
*/
/* ============================================================================
* Changelog
* ============================================================================
* Next Version:
* - Menu key assignments and skill bindings
*
* Version 1.05a (Current):
* - Support for multiple actors using same key (experimental)
* - Notetags for actor key assignments
*
* Version 1.04:
* - Target selection for allies and enemies
* - Fixed sprite not moving back if button cast canceled
* - Added nearly full keyboard support excluding keys that shouldn't be altered
* - Renamed runSkill() to checkButtonCast()
* - Improved code efficiency by debouncing checkButtonCast()
* - Checks if user has status effects to prevent casting while sleep/dead etc
* - Improved source code formatting and added references at the end of script
*
* Version 1.03:
* - Enemy target selection after using button cast
*
* Version 1.02:
* - Can now button cast with multiple actors!
* - Assign keys to actors in parameter
*
* Version 1.01:
* - Buttons not activated unless skill assigned
* - Skill assignments now stored in ButtonCast.keyList for easier access
* - Added a,s,d keys
* - Choose actor in parameter
* - Simplified checkInput() function for scalability
* - runSkill() function checks if user has skill and plays buzzer sound if not
* - Cool down timer to prevent overlapping sound effects
*
* Version 1.00:
* - Single actor button cast!
*/
if (Imported.YEP_X_BattleSysATB) {
//=============================================================================
// Parameters
//=============================================================================
var parameters = PluginManager.parameters('G_ButtonCast');
// console.log(parameters)
var ButtonCast = {};
ButtonCast.keyList = {
tilde: Number(parameters['Key ~']),
1: Number(parameters['Key 1']),
2: Number(parameters['Key 2']),
3: Number(parameters['Key 3']),
4: Number(parameters['Key 4']),
5: Number(parameters['Key 5']),
6: Number(parameters['Key 6']),
7: Number(parameters['Key 7']),
8: Number(parameters['Key 8']),
9: Number(parameters['Key 9']),
0: Number(parameters['Key 0']),
minus: Number(parameters['Key -']),
equal: Number(parameters['Key =']),
q: Number(parameters['Key Q (PageUp)']),
w: Number(parameters['Key W (PageDown)']),
e: Number(parameters['Key E']),
r: Number(parameters['Key R']),
t: Number(parameters['Key T']),
y: Number(parameters['Key Y']),
u: Number(parameters['Key U']),
i: Number(parameters['Key I']),
o: Number(parameters['Key O']),
p: Number(parameters['Key P']),
foreBrack: Number(parameters['Key [']),
backBrack: Number(parameters['Key ]']),
backSlash: Number(parameters['Key \\']),
a: Number(parameters['Key A']),
s: Number(parameters['Key S']),
d: Number(parameters['Key D']),
f: Number(parameters['Key F']),
g: Number(parameters['Key G']),
h: Number(parameters['Key H']),
j: Number(parameters['Key J']),
k: Number(parameters['Key K']),
l: Number(parameters['Key L']),
semicolon: Number(parameters['Key ;']),
quote: Number(parameters['Key "']),
enter: Number(parameters['Key Enter (OK)']),
keyShift: Number(parameters['Key Shift (Dash)']),
z: Number(parameters['Key Z (OK)']),
x: Number(parameters['Key X (Cancel)']),
c: Number(parameters['Key C']),
v: Number(parameters['Key V']),
b: Number(parameters['Key B']),
n: Number(parameters['Key N']),
m: Number(parameters['Key M']),
comma: Number(parameters['Key ,']),
period: Number(parameters['Key .']),
foreSlash: Number(parameters['Key /']),
space: Number(parameters['Key Space (OK)']),
dirLeft: Number(parameters['Key Left (Left)']),
dirUp: Number(parameters['Key Up (Up)']),
dirRight: Number(parameters['Key Right (Right)']),
dirDown: Number(parameters['Key Down (Down)']),
ins: Number(parameters['Key Insert (Cancel)']),
del: Number(parameters['Key Delete']),
home: Number(parameters['Key Home']),
end: Number(parameters['Key End']),
pageUp: Number(parameters['Key Page Up (PageUp)']),
pageDown: Number(parameters['Key Page Down (PageDown)']),
num0: Number(parameters['Key NumPad 0 (Cancel)']),
num1: Number(parameters['Key NumPad 1']),
num2: Number(parameters['Key NumPad 2 (Down)']),
num3: Number(parameters['Key NumPad 3']),
num4: Number(parameters['Key NumPad 4 (Left)']),
num5: Number(parameters['Key NumPad 5']),
num6: Number(parameters['Key NumPad 6 (Right)']),
num7: Number(parameters['Key NumPad 7']),
num8: Number(parameters['Key NumPad 8 (Up)']),
num9: Number(parameters['Key NumPad 9']),
numPeriod: Number(parameters['Key NumPad .']),
numPlus: Number(parameters['Key NumPad +']),
numMinus: Number(parameters['Key NumPad -']),
numTimes: Number(parameters['Key NumPad *']),
numDivide: Number(parameters['Key NumPad /'])
}
//=============================================================================
// Input Key Mapper
//=============================================================================
if (ButtonCast.keyList['tilde'] !== 0) Input.keyMapper[192] = 'tilde';
if (ButtonCast.keyList['1'] !== 0) Input.keyMapper[49] = '1';
if (ButtonCast.keyList['2'] !== 0) Input.keyMapper[50] = '2';
if (ButtonCast.keyList['3'] !== 0) Input.keyMapper[51] = '3';
if (ButtonCast.keyList['4'] !== 0) Input.keyMapper[52] = '4';
if (ButtonCast.keyList['5'] !== 0) Input.keyMapper[53] = '5';
if (ButtonCast.keyList['6'] !== 0) Input.keyMapper[54] = '6';
if (ButtonCast.keyList['7'] !== 0) Input.keyMapper[55] = '7';
if (ButtonCast.keyList['8'] !== 0) Input.keyMapper[56] = '8';
if (ButtonCast.keyList['9'] !== 0) Input.keyMapper[57] = '9';
if (ButtonCast.keyList['0'] !== 0) Input.keyMapper[48] = '0';
if (ButtonCast.keyList['minus'] !== 0) Input.keyMapper[189] = 'minus';
if (ButtonCast.keyList['equal'] !== 0) Input.keyMapper[187] = 'equal';
if (ButtonCast.keyList['q'] !== 0) Input.keyMapper[81] = 'q';
if (ButtonCast.keyList['w'] !== 0) Input.keyMapper[87] = 'w';
if (ButtonCast.keyList['e'] !== 0) Input.keyMapper[69] = 'e';
if (ButtonCast.keyList['r'] !== 0) Input.keyMapper[82] = 'r';
if (ButtonCast.keyList['t'] !== 0) Input.keyMapper[84] = 't';
if (ButtonCast.keyList['y'] !== 0) Input.keyMapper[89] = 'y';
if (ButtonCast.keyList['u'] !== 0) Input.keyMapper[85] = 'u';
if (ButtonCast.keyList['i'] !== 0) Input.keyMapper[73] = 'i';
if (ButtonCast.keyList['o'] !== 0) Input.keyMapper[79] = 'o';
if (ButtonCast.keyList['p'] !== 0) Input.keyMapper[80] = 'p';
if (ButtonCast.keyList['foreBrack'] !== 0) Input.keyMapper[219] = 'foreBrack';
if (ButtonCast.keyList['backBrack'] !== 0) Input.keyMapper[221] = 'backBrack';
if (ButtonCast.keyList['backSlash'] !== 0) Input.keyMapper[220] = 'backSlash';
if (ButtonCast.keyList['a'] !== 0) Input.keyMapper[65] = 'a';
if (ButtonCast.keyList['s'] !== 0) Input.keyMapper[83] = 's';
if (ButtonCast.keyList['d'] !== 0) Input.keyMapper[68] = 'd';
if (ButtonCast.keyList['f'] !== 0) Input.keyMapper[70] = 'f';
if (ButtonCast.keyList['g'] !== 0) Input.keyMapper[71] = 'g';
if (ButtonCast.keyList['h'] !== 0) Input.keyMapper[72] = 'h';
if (ButtonCast.keyList['j'] !== 0) Input.keyMapper[74] = 'j';
if (ButtonCast.keyList['k'] !== 0) Input.keyMapper[75] = 'k';
if (ButtonCast.keyList['l'] !== 0) Input.keyMapper[76] = 'l';
if (ButtonCast.keyList['semicolon'] !== 0) Input.keyMapper[186] = 'semicolon';
if (ButtonCast.keyList['quote'] !== 0) Input.keyMapper[222] = 'quote';
if (ButtonCast.keyList['enter'] !== 0) Input.keyMapper[13] = 'enter';
if (ButtonCast.keyList['keyShift'] !== 0) Input.keyMapper[16] = 'keyShift';
if (ButtonCast.keyList['z'] !== 0) Input.keyMapper[90] = 'z';
if (ButtonCast.keyList['x'] !== 0) Input.keyMapper[88] = 'x';
if (ButtonCast.keyList['c'] !== 0) Input.keyMapper[67] = 'c';
if (ButtonCast.keyList['v'] !== 0) Input.keyMapper[86] = 'v';
if (ButtonCast.keyList['b'] !== 0) Input.keyMapper[66] = 'b';
if (ButtonCast.keyList['n'] !== 0) Input.keyMapper[78] = 'n';
if (ButtonCast.keyList['m'] !== 0) Input.keyMapper[77] = 'm';
if (ButtonCast.keyList['comma'] !== 0) Input.keyMapper[188] = 'comma';
if (ButtonCast.keyList['period'] !== 0) Input.keyMapper[190] = 'period';
if (ButtonCast.keyList['foreSlash'] !== 0) Input.keyMapper[191] = 'foreSlash';
if (ButtonCast.keyList['space'] !== 0) Input.keyMapper[32] = 'space';
if (ButtonCast.keyList['dirLeft'] !== 0) Input.keyMapper[37] = 'dirLeft';
if (ButtonCast.keyList['dirUp'] !== 0) Input.keyMapper[38] = 'dirUp';
if (ButtonCast.keyList['dirRight'] !== 0) Input.keyMapper[39] = 'dirRight';
if (ButtonCast.keyList['dirDown'] !== 0) Input.keyMapper[40] = 'dirDown';
if (ButtonCast.keyList['ins'] !== 0) Input.keyMapper[45] = 'ins';
if (ButtonCast.keyList['del'] !== 0)Input.keyMapper[46] = 'del';
if (ButtonCast.keyList['home'] !== 0)Input.keyMapper[36] = 'home';
if (ButtonCast.keyList['end'] !== 0)Input.keyMapper[35] = 'end';
if (ButtonCast.keyList['pageUp'] !== 0) Input.keyMapper[33] = 'pageUp';
if (ButtonCast.keyList['pageDown'] !== 0) Input.keyMapper[34] = 'pageDown';
if (ButtonCast.keyList['num0'] !== 0) Input.keyMapper[96] = 'num0';
if (ButtonCast.keyList['num1'] !== 0)Input.keyMapper[97] = 'num1';
if (ButtonCast.keyList['num2'] !== 0) Input.keyMapper[98] = 'num2';
if (ButtonCast.keyList['num3'] !== 0)Input.keyMapper[99] = 'num3';
if (ButtonCast.keyList['num4'] !== 0) Input.keyMapper[100] = 'num4';
if (ButtonCast.keyList['num5'] !== 0)Input.keyMapper[101] = 'num5';
if (ButtonCast.keyList['num6'] !== 0) Input.keyMapper[102] = 'num6';
if (ButtonCast.keyList['num7'] !== 0)Input.keyMapper[103] = 'num7';
if (ButtonCast.keyList['num8'] !== 0) Input.keyMapper[104] = 'num8';
if (ButtonCast.keyList['num9'] !== 0)Input.keyMapper[105] = 'num9';
if (ButtonCast.keyList['numPeriod'] !== 0)Input.keyMapper[110] = 'numPeriod';
if (ButtonCast.keyList['numPlus'] !== 0)Input.keyMapper[107] = 'numPlus';
if (ButtonCast.keyList['numMinus'] !== 0)Input.keyMapper[109] = 'numMinus';
if (ButtonCast.keyList['numTimes'] !== 0)Input.keyMapper[106] = 'numTimes';
if (ButtonCast.keyList['numDivide'] !== 0)Input.keyMapper[111] = 'numDivide';
ButtonCast.keysActor = {};
//=============================================================================
// Notetags
//=============================================================================
ButtonCast.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
DataManager.isDatabaseLoaded = function() {
if (!ButtonCast.DataManager_isDatabaseLoaded.call(this)) return false;
DataManager.processBUTTONCASTNotetags1($dataActors);
// DataManager.processBUTTONCASTNotetags2($dataSkills);
return true;
};
DataManager.processBUTTONCASTNotetags1 = function(group) {
var note1 = /<(?:BUTTONCAST KEYS):[ ](.+)>/i;
for (var n = 1; n < group.length; n++){
var obj = group[n];
var notedata = obj.note.split(/[\r\n]+/);
for (var i = 0; i < notedata.length; i++) {
var line = notedata[i];
if (line.match(note1)) {
keys = RegExp.$1.trim().toLowerCase().split(' ').map(String)
ButtonCast.keysActor[n] = keys
}
}
}
};
//=============================================================================
// Plugin Commands
//=============================================================================
// var aliasPluginCommand = Game_Interpreter.prototype.pluginCommand;
// Game_Interpreter.prototype.pluginCommand = function(command, args) {
// aliasPluginCommand.call(this, command, args);
// if (command == 'ButtonCast') {
// switch (args[0]) {
// case 'init':
// break;
// }
// }
// }
//=============================================================================
// ButtonCast Functions
//=============================================================================
function checkInput() {
for (var k in ButtonCast.keyList){
if (Input.isPressed(String(k))) return k;
}
return null;
}
function checkButtonCast(k) {
// Cool down timer for checkButtonCast() prevents consecutive function calls
BattleManager['buttonCastCooldown'] = 10;
// Multi actor keys - Multiple actors can use same key
var battlers = [];
for (var i in ButtonCast.keysActor){
// Check if key assigned to battler
if (ButtonCast.keysActor[i].indexOf(k) > -1){
var actor = $gameActors.actor(i);
if (actor.isBattleMember()) {
battlers.push(actor);
}
}
}
// console.log(battlers)
// Check if battler can take action
var queuedBattlers = [];
battlers.forEach(function(battler){
if (!battler) return; // This should never happen but just in case
if (battler.isATBCharging()) return; // Action already queued
if (!battler.canInput()) return; // Check this in case of status effects
console.log(battler.name(), 'checking')
var skillId = ButtonCast.keyList[k];
// Check if battler has skill
if (!battler.isLearnedSkill(skillId)){
SoundManager.playBuzzer();
return;
}
// console.log(skillId);
// battler.spriteStepForward();
// battler.requestMotionRefresh();
battler.makeActions();
battler.forceAction(skillId);
// console.log(battler)
queuedBattlers.push(battler);
});
return queuedBattlers;
}
function prepareButtonCast(battler){
console.log(battler.name(), 'preparing')
BattleManager._actorIndex = battler.index(); // Prepare battler for action
BattleManager.actor().spriteStepForward();
BattleManager.actor().setActionState('inputting');
BattleManager.actor().requestMotionRefresh();
// console.log(battler)
SceneManager._scene.onSelectAction()
BattleManager.playATBReadySound();
battler.setupATBCharge();
battler.setATBCharge(battler.atbChargeDenom()); // Set charge to max
}
function executeButtonCast(battler){
console.log(battler.name(), 'executing')
action = battler._actions[0];
if (!action) return;
if (!action.isValid()){
// Player canceled action
BattleManager.actor().spriteStepBack();
BattleManager.actor().setActionState('waiting');
BattleManager.actor().requestMotionRefresh();
}
battler.setATBCharge(battler.atbChargeDenom()); // Set charge to max
}
//=============================================================================
// Yanfly Overrides
//=============================================================================
BattleManager.updateATBTicks = function() {
if (!SceneManager._scene.isAnyInputWindowActive()){
// Check if button cast needs execution (4)
if (this.buttonCastBattler) {
executeButtonCast(this.buttonCastBattler);
this.buttonCastBattler = undefined;
}
// Check for user input (1)
k = checkInput();
// Check for button cast (2)
if (this.buttonCastCooldown) {
this.buttonCastCooldown -= 1;
} else {
if (k) this['queuedBattlers'] = checkButtonCast(k);
}
// Check for button cast battlers (3)
var battlers = this.queuedBattlers || [];
if (battlers.length > 0) {
this['buttonCastBattler'] = battlers.shift();
prepareButtonCast(this.buttonCastBattler);
}
}
// Yanfly code below
this._atbTicks += 1 * this.tickRate();
if (this._atbTicks < this._atbFullTurn) return;
$gameTroop.increaseTurn();
this._atbTicks = 0;
if (this.isTurnBased()) {
this.endTurn();
} else {
this.endTurn();
}
};
//=============================================================================
// Debugging and References
//=============================================================================
// Game_Battler.prototype.forceAction = function(skillId, targetIndex) {
// this.clearActions();
// var action = new Game_Action(this, true);
// action.setSkill(skillId);
// if (targetIndex === -2) {
// action.setTarget(this._lastTargetIndex);
// } else if (targetIndex === -1) {
// action.decideRandomTarget();
// } else {
// action.setTarget(targetIndex);
// }
// this._actions.push(action);
// };
//
// BattleManager.inputtingAction = function() {
// return this.actor() ? this.actor().inputtingAction() : null;
// };
//
// // Yanfly's
// BattleManager.startATBInput = function(battler) {
// if (battler.isDead()) return;
// battler.makeActions();
// if (battler.isEnemy()) {
// battler.setupATBCharge();
// if (Yanfly.Param.ATBFlashEnemy) battler.requestEffect('whiten');
// var chargedBattler = this.getChargedATBBattler();
// if (chargedBattler) this.startATBAction(chargedBattler);
// } else if (battler.canInput()) {
// this._actorIndex = battler.index();
// this.playATBReadySound();
// battler.setActionState('inputting');
// battler.spriteStepForward();
// this._phase = 'input';
// } else if (battler.isConfused()) {
// battler.makeConfusionActions();
// battler.setupATBCharge();
// } else {
// battler.makeAutoBattleActions();
// battler.setupATBCharge();
// }
// };
//
// // Yanfly's
// BattleManager.startATBAction = function(battler) {
// this._subject = battler;
// battler.onTurnStart();
// var action = this._subject.currentAction();
// if (action && action.isValid()) {
// this.startAction();
// } else {
// this.endAction();
// }
// };
//
// Some reason this doesn't work properly unless I redeclare it here.
Scene_Battle.prototype.onSelectAction = function() {
var action = BattleManager.inputtingAction();
// console.log(action)
this._skillWindow.hide();
this._itemWindow.hide();
if (!action.needsSelection()) {
this.selectNextCommand();
} else if (action.isForOpponent()) {
this.selectEnemySelection();
} else {
this.selectActorSelection();
}
};
BattleManager.selectNextCommand = function() {
do {
if (!this.actor() || !this.actor().selectNextCommand()) {
this.changeActor(this._actorIndex + 1, 'waiting');
if (this._actorIndex >= $gameParty.size()) {
this.startTurn();
break;
}
}
} while (!this.actor().canInput());
};
Yanfly.ATB.BattleManager_selectNextCommand = BattleManager.selectNextCommand;
BattleManager.selectNextCommand = function() {
if (this.isATB()) {
if (!this.actor()) return this.setATBPhase();
this.resetNonPartyActorATB();
this.actor().setupATBCharge();
this.actor().spriteStepBack();
this.actor().requestMotionRefresh();
this._actorIndex = undefined;
var chargedBattler = this.getChargedATBBattler();
if (chargedBattler) {
this.startATBAction(chargedBattler);
} else {
this.setATBPhase();
}
} else {
Yanfly.ATB.BattleManager_selectNextCommand.call(this);
}
};
//=============================================================================
// Item Scope
//=============================================================================
/*
* 0 : None
* 1 : 1 Enemy
* 2 : All Enemies
* 3 : 1 Random Enemy
* 4 : 2 Random Enemies
* 5 : 3 Random Enemies
* 6 : 4 Random Enemies
* 7 : 1 Ally
* 8 : All Allies
* 9 : 1 Ally (Dead)
* 10 : All Allies (Dead)
* 11 : The User
*/
};