In running into issues with writing a new spell I started thinking up a rough version for handling slightly different spells.
I was working on a Chainheal spell that would
determine a list of allies in the map,
heal the targeted player (could be you, or whoever you had targeted / selected), then start a delayTimer
when delayTimer expires, the next ally in the list is healed, and a new delayTimer starts (and some graphical/lighting effects that move between the targets as it 'chains' / 'bounces')
So I learned a timer in the chainheal.kod does not work because only 1 instance of a spell is created so this timer would get reset anytime someone cast the spell (doesn't work if more than 1 player has the spell obviously)
Then it was suggested I check out boon.kod which has a clever way of handling enchantments that last longer than the max duration we can run a timer (as far as I know that is why it is written this way)
which keeps track of how many times it needs to restart its timer and if it should keep the boon active it calls StartEnchantment() inside of the EndEnchantment() function.
I started testing that out and it was easy to StartEnchantment() on the next target in the list, but the issue there is how enchantments overall are handled in the player class. I don't want to have to dissect it for corner cases like Not wanting to pause the 'timer / delay' if someone logs off before it bounces (even leaving the room would cause weird issues).
So it occurred to me that we could make an (not using kod structures for this description) array in the player class that holds queues of timers for a specific Delayed Effect Spell. Each spell class will have an enumerated value into this array so the spell can address it's own queue of timers.
The individual spells would choose how to handle the queue, but chain heal for example - if there were 3 timers in the queue for player A, the player would heal and start the first timer. When it expires, that triggers the 'bounce/chain' to heal the next player (if it is supposed to try and heal another). Expired timers get removed from the queue and again player A is healed, and the next timer starts.
Other spells could do something like check if there are multiple timers queued up and if so, combine their total duration into 1 value - extending some effect or delay. This is slightly different from just a DoT (like poison procs) or Heal over time because we might not necessarily want to pause the timers if a player logs off or leaves the room.
Post feature requests or make suggestions here.
1 post • Page 1 of 1