Hi Everyone! (I should I just say, "Hi, Griatch"?)A couple of my friends and I are interested in creating a small MUD using Evennia.We are still in the planning stage now, and I will have a lot of work ahead of me, as I'm the only Python programmer on the team. (Which consists of about 3 people...)I have read through most of the Evennia documentation, and have looked through some of the source code. (A massive thank you to everyone who helps with Evennia! You all have created beautifully written documentation and source code!)I am trying to work out the best way to implement some sort of combat system, and I've come here to ask for some direction on this.These are the features I want this combat system to have:In theory, a bare bones version of this without any cool features, just the underlying system, shouldn't be too hard to create. The coding might take a while though.
- Turn based.
- Easily extendable. New commands and features should be easy to implement without rewriting the system.
- Characters in battle should have a limited "combat command set".
- If a mob or character attacks someone in battle, the combat system should register them as also in combat, and bring them into the battle too.
- Characters should have a limited amount of time to choose who to attack and how they will attack. If they run out of time their turn should be skipped.
- Having multiple battles across the world, and even in the same location simultaneously should be possible.
Do you have any idea's for how I would go about implementing this? Would I use a global ticker, or scripts that are destroyed as soon as the battle is over? Should their be one script per battle, or something else? Would the same script that handles characters, also handle mobs? Or would there be different scripts for each?I'm not very confident in my skills with the Evennia system yet, and I don't want to start on something in the completely wrong direction and have to rewrite it later.Thank you for any input that you give.P.S. I read through Griatch's notes on a combat system for Battle for Evennia. The upcoming tutorial describes how to create your own hack 'n' slash MUD. A queue holding the commands of the players in combat sounds very interesting, and would definitely allow for some advanced features if it was extended.
The combat queues (all over the entire game) are handled by some sort of combat handler. This object, which should be instanced when you start the server, holds all queues and has an API for adding/removing new ones (such as when starting/ending combat). If you want combats to survive a server reboot you need to figure out a way to store these in the database (using attributes). Just remember that database objects (such as characters) mustn't be hidden away inside an arbitrary, non-iterable object (such as combat queues) - easiest way to handle this is to set up a state-script to hold all the data, and use the at_server_shutdown() hooks to store everything safely (using, say dbrefs instead of full objects).
You don't specify exactly what you really mean by a "Queue". I will assume you mean that you can enter a list of combat commands and those will execute automatically in order as they complete. There are a few different ways to do this.
- A subscription script (to which all combatants in the same battle subscribes) could make queued actions happen simultaneously (each tick a command is triggered or progresses according to a fixed time measure, a given command would take a certain number of ticks to complete).
- Each command triggers a callback chain and sets a state while it is executing. This makes all commands in combat independent from each other. This is an advanced functionality described here.
- In a turn-based combat system queuing requires no timer beyond a timeout for taking too long. For example - players enter their commands (such as parry, feint, attack etc) then these are played out simultaneously and results are shown. Next round they enter new commands and so on. This can be done completely on-demand.