diff options
author | Florrie <towerofnix@gmail.com> | 2018-08-12 13:52:26 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-08-12 13:52:26 -0300 |
commit | e2f66f4027367814be6087dbd6b07f11e31da580 (patch) | |
tree | 53bc09c707fdb2fa875581b523248df38de0ff11 | |
parent | 478adbfb07d3ab0fa28b8e437edf47e9174881c9 (diff) |
Space/enter to activate once gauge full, E to activate now
-rw-r--r-- | index.js | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/index.js b/index.js index d02dcf6..ce4cf58 100644 --- a/index.js +++ b/index.js @@ -116,6 +116,12 @@ class ATBBar { // ATB gauge visual update this.visualProgress += 8 * dt * (this.progress - this.visualProgress) + // Start action chain once user has confirmed (willExecuteChain = true) and IP gauge is full enough to execute all actions + if (this.battleCharacter.willExecuteChain && this.progress >= 1 - this.getRemainingSpace() / this.segmentCount) { + this.battleCharacter.willExecuteChain = false + this.battleCharacter.isExecutingChain = true // Will be acknowledged by next if statement + } + // Action chaining if (this.battleCharacter.isExecutingChain && !this.battleCharacter.isExecutingAction) { if (this.queuedActions.length) { @@ -148,12 +154,16 @@ class ATBBar { } this.queuedActions.splice(cutoff) - this.battle.changeMenuAnim = {old: this.battle.currentMenu, direction: 1, time: 1} - this.battle.currentMenu = null + this.battle.hideCurrentMenu() this.battleCharacter.isExecutingChain = true } } + activateOnceGaugeFull() { + this.battle.hideCurrentMenu() + this.battleCharacter.willExecuteChain = true + } + getCutoff() { // Cutoff point in the action queue where ATB does not fill the action let cutoff = 0, segment = 0 @@ -608,6 +618,11 @@ class Battle { this.targetMenu.buildOptions() } + hideCurrentMenu() { + this.changeMenuAnim = {old: this.currentMenu, direction: 1, time: 1} + this.currentMenu = null + } + getAllBattleCharacters() { return this.teams.reduce((acc, team) => acc.concat(team.characters), []) } @@ -724,7 +739,11 @@ canvas.addEventListener('keypress', evt => { } else if (currentMenu === targetMenu) { if (evt.keyCode === 13 || evt.key.toLowerCase() === 'e' || evt.which === 32) { battle.playerCharacter.targetCharacter = currentMenu.getCurrentOption().battleCharacter - atbBar.activate() + if (evt.key.toLowerCase() === 'e') { + atbBar.activate() + } else { + atbBar.activateOnceGaugeFull() + } } else if (evt.keyCode === 8) { battle.currentMenu = actionMenu battle.changeMenuAnim = {old: targetMenu, direction: -1, time: 1} |