3
« on: November 24, 2012, 12:27:15 PM »
This system is a variant of the energy based systems presented on the roguebasin wiki. I believe it is the most flexible way to implement an energy system in a roguelike that requires sophisticated timing rules. It is very likely a game out there uses this exact implementation, but I've yet to see it documented.
I shall refer to anything in the game which requires time keeping as a 'timedEntity'. Mostly this will be actors, but sometimes it will be other game objects, or more abstracts things such as tasks performed by actors.
Each timedObject in the game has a cooldown attribute, which begins at 0. When a timedObject acts, its cooldown is increased by the relevant amount for the action, say 100 for moving or 50 for drinking a potion. Each timedObject may have any value for its various cooldown costs and each action may be customised individually. Each time a new action is demanded, the game loops through the timedObjects, and determines the timedObject with the lowest cooldown. All cooldowns are then decremented by the amount of cooldown said timedObject has, and said timedObject takes its action. The process is repeated as the game loops.
This system allows for essentially limitless variety in speed of actions and various ways of modifying speed - individual actions may be slowed by a multplier or fixed amount, or an entire timedObject may have its cooldown increased or decreased by an amount. If you are willing to spend a little more time determining the next timedObject to act (via iterating instead of finding the lowest cooldown) multipliers can be applied to cooldown decrements per tick. There is no ceiling on how lengthy an action may be, and no 'saving up' of actions (unless you allow negative cooldown values).
Other timing based effects, such as damage over time, dissipating gas clouds, traditional interuptible actions such as resting, changing armor, or anything else may be handled under the same system. By creating additional timedObjects which interact with their host timedObject, preventing them from acting while they are in effect, damaging them, etc. In this way sophisticated or lengthy interactions can be modelled, outside of the standard 'act now, pay later' paradigm.
I'm pretty confident this system can handle pretty much any timing situation a roguelike will demand, with a fairly simple system, using the same timing rules for anything that is based on time (players, monsters, status effects, spell cooloffs etc). Does anyone see any flaws? Areas that could be made simpler? Is there a game you know of using this system? A situation that cannot be timed by this system?