Possession 2: Speed Systems in Roguelikes
Speed is a problem in turn-based games. It’s much easier to just have everyone move once per turn. Anything else just gets complicated, both from a programming and a gameplay standpoint. But given that the differences between bodies are such a big deal in Possession, I really want there to be some creatures that are weak but fast, and some that are strong and slow. Not to mention the possibilities of spells or obstacles that speed/up slow down creatures, and let the player (or their enemies!) run away or escape more quickly.
(I’m going to warn you right now, this post is a bit more in-depth in the development process than other posts have been. If you’re not really interested in game dev it might not be that interesting, but I’m putting it up so hopefully someone facing the same problems might be helped by it).
At first I tried a simple system where certain creatures either got an extra turn or lost a turn every X number of turns, but implementing it got kind of ugly and annoying. I decided to look into what other people had already done. I found this post, detailing a wide variety of time systems used in roguelikes, and decided to go with an energy-based system, which is apparently what Angband uses, which is somewhat appropriate I guess because even though I don’t really like it much now, it was the first roguelike I ever played.
Anyway, the basic way it works is, every creature has a “speed” rating that is added to their “energy” stat every turn. If their energy stat is above 100, they can move, and 100 is subtracted from it. If it’s above 200 they can move twice, above 300 three times, etc. Most creatures just have speed 100, meaning they move once a turn.
|Creature||Speed||Energy, Turn 1||Energy, Turn 2||Energy, Turn 3|
|Bat||150||150 (moves once, reduces to 50)||200 (moves twice, reduces to 0)||150 (moves once, reduces to 50)|
|Zombie||50||50 (doesn’t move)||100 (moves once, reduces to 0)||50 (doesn’t move)|
|Caretaker||100||100 (moves once, reduces to 0)||100 (moves once, reduces to 0)||100 (moves once, reduces to 0)|
Same goes for the player, of course. If they have above 100 energy, they can move, if not, a turn happens without them. If they have above 200 energy, their move is an “extra” move. They still move, as does any creature with more than 100 energy, but nobody’s energy increases that turn.
This system worked pretty well as-is, but it does run into a weird problem. I had bats and ghosts both faster than normal, but the ghost was slightly faster than the bat. It got an extra turn every two turns, and the bat got an extra turn every three. This resulted in, one turn, the ghost would move twice and the bat wouldn’t move, the next turn the bat would move twice and the ghost wouldn’t move. It didn’t make much sense.
So, the get around that, I made it so that if the player is faster than a creature, the creature saves up enough energy to take an extra turn, it doesn’t actually take its extra turn until the player takes their extra turn. That seems to work pretty well so far. Might take some more tweaking as things continue, but we’ll see.