Plan for turn-based battles
Jump to navigation
Jump to search
Right now, all battles use an Active-Time-Battle (ATB) system like the one used in Final Fantasy >= 4
Many users desire a turn-based battle system like the one used in Final Fantasy <= 3 or Dragon Quest, Earthbound, Pokemon.... pretty much every other SNES/NES/Gameboy RPG.
There are options for stopping time when the player is taking a turn, bu this is not the same thing as turn based.
- ATB turns are handled by ready-meters and attack delays. Clean these up.
- In cleaning up the ready-meter code, organize it as a "Turn Manager"
- Add a second Turn Manager, for Turn-Based battles.
- Turn-Based Turn Manager should present the battle menu for each hero in order
- When all heroes attacks have been chosen, run the AI for all enemies
- Effective attack delay should be calculated differently in Turn-Based mode.
- Come up with a formula for Turn-Based effective attack delay based on attacker speed, modified by attack delay.
- This formula should be customizable in some way.
- Some games may want strict fastest-attacker-goes-first, while others will want some level of randomization.
- Turn-Based turn manager will wait until all heroes and enemies have acted, then start the next round.
- Poison and Regen should happen on a turn-basis instead of a timer basis.
- Turn count should be tracked.
- Track turns per-character. In Turn-based, they will always be in-sync with each other
- There should be a way to queue an attack to happen after X turns have passed.
- This is available in both turn managers
Active-Time Turn Manager[edit]
Is a state machine with the following states:
- wait for a character's turn to come (while advancing meters and delays)
- do attack selection for the current character's turn (possibly advancing meters and delays depending on bitsets)
Other notes[edit]
- Each character chooses action when their menu is full
- Attack delay is interpreted in ticks
- Poison, Regen, Stun and Mute update on tick-based timers
- Attacks queued by turn happen based on the number of turns taken by the attacker
- Attacks queued by tick happen after a tick delay
- Cancelling attack selection goes to the next hero with a full ready-meter
Turn-Based Turn Manager[edit]
Is a state Machine with the following states:
- Do turn selection for each character in order
- Advance meters and delays until the attack queue is empty of all attacks except for those with a turn-delay >0
Other notes[edit]
- All characters choose actions together
- A turn ends when each character has finished animating their entire attack chain (not counting queued attacks)
- Effective attack delay is decided by a formula involving speed and attack delay.
- Chained attacks that are not queued and have a delay > 1 are inserted into the order of attacks based on the chained attacks delay.
- Poison, Regen, Stun and Mute update exactly once per turn
- Attacks queued by turn happen based on the number of battle turns
- Attacks queued by tick happen after a tick delay. It may not be possible to predict in advance how many turns this will be.
- Cancelling attack selection goes back to the previous hero.
Concerns[edit]
- What about chains that chain to themselves endlessly? Should that just be a "Don't do that, silly!" problem, or do we need to have a special feature to limit/prevent that somehow
- In active-mode, counter-attacks are non-blocking. In turn-based mode, they need to happen within the current turn.
- Does that mean they need to be non-blocking? I think so?
- What about endless chains of counterattacks?
Implementation Plan[edit]
- Add a TurnManager type for holding data related to the turn-manager state machines, and other relevant data (done)
- Clean up active time mode (done, slightly)
- Add the turn-based state machine (started)
- Make heroes and enemies pick actions together, in order (done)
- Make a sub-mode to wait for all actions to complete (done)
- Make poison & regen happen once per turn (done)
- Make stun and mute decrement once per turn instead of once per second (done)
- Make delay influenced by speed. Initiative order. (done)
- Start out with a deterministic mode that just sorts by speed, maybe breaking ties randomly. (done)
- Other modes might be desirable later, maybe something that randomly fuzzes speed, or something like that.
- Initiative delay and attack delay are added together, so, for example, and attack with delay 1 would cause the attack to happen after the next-slowest attacker's attack (done)
- Implement the ability to cancel backwards through the heroes when picking attacks and targets. (done)
- Make sure that chained attacks with no delay really happen immediately (done)
- Make sure counterattacks happen in the same turn as the attack that triggers them (done)
- Make sure that battles don't end before on-death spawns happen (done)
- Add a battle mode selector to Custom (done)
- Clearly label it as experimental (done, will remove after some testing)
- Make active-time-only bitsets only show up when active time is selected.
- Write a wiki page describing both modes, comparing and contrasting them.
- Add support for turn-delays in both active and wait modes.
- Figure out what to do about infinite chain and counterattack loops.
- Figure out how to handle running away in turn-mode