Today's post is about speed! Not only is it the first R-rated movie I ever watched (and haven't seen since), trying to account for it is also a pretty big issue in roguelikes and other 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.
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.
For example:
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.
The ghost moves faster than most creatures, so the player has a chance to run away.
Click to enlarge.
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.
Player takes extra turns, then bat takes extra turns.
Click to enlarge.
So, to 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.
Bat now takes extra move when player takes extra move.
Click to enlarge.
The other problem with this system is that all actions take the same amount of time. It's not currently possible to have, for example, a creature who moves slowly but attacks at the same speed. Or a creature that can move 5 spaces per turn but only attack once. I'll have to see if that's something I want to invest the time into making possible.