Hi, last weekend I suddenly started a similar project that I had worked on around 2 years ago (not to mention I called it the exactly same thing). The reason I have for restarting this project is not logical at all, as I haven't played a source game for over a year (but it was surprisingly fun after I got started), anyway I thought I'd release it here. Not exactly sure where I should post this as it's definitely not ready as a new plugin, so I'm assuming this is the best section.
The project is... What's written in the title, Gamma - A game mode manager.
What can it do? Well, it can manage game modes written against it's API, putting the work of handling when it's supposed to start and stop in the hands of Gamma.
Gamma has a few game mode selection modes and can be chosen as you please, there's 3 ways to select a new game mode:
- Select game mode strictly by cvar.
- Select any game mode, simply put the first that is able to start.
- Attempt to select by cvar, if it fails select the first that can start.
What's more, is that Gamma can work as a link between game mode and plugins extending the game mode, by having global forwards telling when game modes starts and stops. But even more awesome, must be the Behaviours, which acts as player modifiers. A behaviour is plugin that fiddles with the player, it can be anything from giving buffs or nerfs to the player or it can completely change how a player is playing the game.
As an example, if we were to write an VSH/FF2-ish game mode against it, a behaviour could be a boss! Behaviours are limited to game modes it has registered it self to, via Behaviour Types. Behaviour types are created by the game mode when it's initializing and are limited to only that game mode, which means that other game modes can't create behaviour types called the same. Behaviour types can also have function requirements, which are functions the behaviours must implement.
As an example of this is MyGameMode creates a behaviour type, MyBehaviourType, and adds the requirement that behaviours must implement MyFunctionRequirement, then when MyBehaviour registers itself as behaviour of type MyBehaviourType it's checked whether or not MyFunctionRequirement is implemented. If not, it will error out and not be created - else it will be created.
The only plugin able to give and take behaviours is the currently active game mode, other plugins will receive an error if they attempt. This is because we don't want other plugins to meddle with the game mode logic. There isn't an upper bound for the amount of behaviours a single player can have at any time, other than the limitation placed by the game mode it self, which should be easy to maintain as other plugins can't meddle.
A single game mode can have as many Behaviour types it wants, and there can be as many behaviours in a behaviour type you wants, the limitation is memory on the machine and limits of handles created (which I doubt you'll hit, but still, it's there).
Now, we can create game modes and behaviours (behaviour types are a part of a game mode plugin), as for limitations there's only a single game mode per plugin and only a single behaviour per game mode per plugin, these restrictions are placed so a single behaviour plugin only represents a single behaviour (but that single behaviour is allowed to be placed onto many game modes, if it's pretty much the same, between those 2 game modes).
Now, there's a few changes I'd like to have done to the round start/end primarily, those are:
- Done, for TF2 using DHooks!
At least for TF2: hook CTeamplayRoundBasedRules:RoundRespawn and PreviousRoundEnd for round start/end as this makes the game mode run the entire round, from before players (and many entities) spawn to just before the start of a new round.
- Add gamedata with the right events (look in the gamedata for TF2, CS:S or CS:GO and look at the keys section) and it should work for that game!
A more cross-game compatible way to listen to round start/end, so it's able to work on as many games as possible.
- Done, works with TF2 (thanks to SetWinningTeam) and CS:S/CS:GO (thanks for CS_TerminateRound), there's an attempt for something game common, doesn't seem to work, but needs testing in other games as well.
Make it possible for game modes to forcefully end themselves, and thus restart/end the round as well. Think of the VSH/FF2-ish game mode if it suddenly loses it's active boss behaviour, that would be no good.
And a feature I'd like to make, but could take some work to get right:
- Concurrent game modes, run 2 (or more?) compatible game modes at the same time to make more game mode variations, without copy/pasting game mode code and creating duplicate behaviours, etc.
Gamma is far from finished, the main portion was written last weekend (5th and 6th April) and there hasn't been made any major changes since then, mostly I've renamed the natives and forwards as well as made sure that the templates could run without errors. Not to mention, added debug messages, I didn't have those to start with as I couldn't test that weekend anyway! (only installed and downloaded both TF2 and the TF2 server after the weekend)
So, after this wall of text we finally come to the link you've probably all been waiting for, oh well can't blame you. Gamma, game mode and behaviours templates (which doubles as simple print-to-server examples) and compiled versions of those are available from this GitHub repo:
https://github.com/CookiesIO/Gamma/
At the moment (April 17th) the rough, simplified feature set is as follows:
- Select active game mode using 1 of 3 methods, listed somewhere ^
- Create game modes and extend them with player behaviours or game mode start/end listeners from other plugins
- Auto detection of new plugins, no need to check if Gamma exists, when it's added an such - Gamma will notify your plugin that is has seen you, and only once during either plugins life time.
- Creation of target filters when a game mode starts, so it's possible to target players that has a behaviour of type, or if the setting allow it - having a certain behaviour.
- Can be totally disabled with gamma_enabled 0
- Not-so-much a feature, but a more complete example of a game mode, Boss Fight Fortress along with a simple sample boss, showcasing some of the features of interaction that can be done between game modes and behaviours.
It REQUIRES DHooks, yeah... wont run without it. Also, as the name implies, tf2 only.
- Support out-of-the-box for TF2, CS:S and CS:GO
The cvar's available are:
- gamma_enabled <0|1>, Sets whether or not gamma is enabled, takes effect on round-to-round basis
- gamma_gamemode "{GameModeName}", Name of the game mode to play, takes effect on round-to-round basis
- gamma_gamemode_selection_mode <1|2|3>, Game mode selection mode, 1=by cvar, 2=first able to start, 3=by cvar then first able to start, takes effect on round-to-round basis
- gamma_target_filters <0|1|2>, Target filter verbosity, 0=no target filters, 1=behaviour types only, 2=behaviour type and behaviour target filters, takes effect on round-to-round basis
Now, to finish off, is this something you'd like to see further improved? If yes, please share your thoughts of improvements and/or additions you'd like to see. Also, feel free to contribute with anything else regarding gamma!