Plan for queueable attacks

From OHRRPGCE-Wiki

Jump to: navigation, search

Right now, each hero and enemy can have only one attack selected at a time. Attacks can be chained together with a delay, but the hero (or enemy) cannot act while the chain is in progress.

It should be possible have an attacker queue an attack with a delay that does not interrupt their normal actions. For example, a time-limited stat-boost could do a queued chain to an attack that removes the stat boost after a certain number of ticks has passed, while allowing the attacker to continue to do other attacks in the meantime.

Contents

[edit] The way things work now

Each attacker has a turn counter and a delay counter. When the turn counter is full, they can choose and target an attack. Each attacker has a data member for the attack they are currently doing, and a list of targets for the current attack. Then the delay counter starts. When it is finished, the attack animates. If a chain occurs, it gets loaded, and the delay counter starts again. When no more chains are going to happen, the turn counter starts over.

[edit] The way things should work

Ideally, each attacker could have a growable list of perpared attacks and targets, each with data for whether or not they should block the start of the attacker's next turn.

But FreeBasic doesn't have a data structure that can do that, and I don't want to hack it together with pointers.

[edit] Another decent way of doing it

Maintain a list of queued attack data. It would include data for which attack, which targets, and which attacker is doing the attack, as well as data for whether or not it blocks their next turn.

  • Create an AttackQueue object
    • who's attack
    • attack id
    • target list
    • normal/nonblocking attack
    • queue slot in use (for recycling them)
  • Create an array of AttackQueues
  • Make code for adding a targeted attack to the queue
    • recycle an empty slot if possible, otherwise resize the array
  • Make code to search the attack queue for attacks belonging to a given attacker
    • Make code to check if an attacker has any blocking attacks queued
  • Make battle system use AttackQueues instead of the .attack and .t() members of bslot()
  • Make sure everything works the way it did before
  • Maybe remove .attack and .t() from battleslot?
    • Does it make sense to keep them just for interactive targeting?
    • Perhaps targeting should continue to use bslot() right up until the target is finalized, at which point the targeted attack gets copied into the attack queue
  • Add support for non-blocking attacks
    • Not only should non-blocking attacks not block other actions wile their delay counter is going, they also should not reset the attacker's turn counter when the attack animates.

Also, it would probably be constructive to add a debug tool to visualize the attack queue.

[edit] Other Uses

Having an attack queue implemented would make real counterattacks a snap to implement.