Raised This Month: $51 Target: $400
 12% 

Gamma - A game mode manager


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Cookies.net
Senior Member
Join Date: Jan 2011
Old 04-12-2014 , 13:46   Gamma - A game mode manager
Reply With Quote #1

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:
  1. Select game mode strictly by cvar.
  2. Select any game mode, simply put the first that is able to start.
  3. 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!

Last edited by Cookies.net; 04-17-2014 at 19:26. Reason: New information
Cookies.net is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-13-2014 , 09:02   Re: Gamma - A game mode manager
Reply With Quote #2

This sounds awesome, sorry for only skimming through the gist of this, but this caught my eye.
Quote:
Originally Posted by Cookies.net View Post
  • 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.
You can make a stock:
Code:
SetCommandFlags("mp_forcewin", GetCommandFlags("mp_forcewin") & ~FCVAR_CHEAT);
stock ForceTeamWin(team)
{
	ServerCommand("mp_forcewin %i", team);
}
0, ends in a draw
2, RED wins
3, BLU wins

I would also like to know how the whole 'preventing round end' and preventing 'player spawning' works that would help me out in my gamemode too.

EDIT:
holy hell i just went through the gihub, this is amazing.

Last edited by Mitchell; 04-13-2014 at 09:09.
Mitchell is offline
Root_
Veteran Member
Join Date: Jan 2012
Location: ryssland
Old 04-13-2014 , 09:37   Re: Gamma - A game mode manager
Reply With Quote #3

It looks really nice, clean and modular! And I like its name. I'll definitely mess with this
__________________


dodsplugins.com - Plugins and Resources for Day of Defeat
http://twitch.tv/zadroot
Root_ is offline
Cookies.net
Senior Member
Join Date: Jan 2011
Old 04-13-2014 , 11:26   Re: Gamma - A game mode manager
Reply With Quote #4

Quote:
Originally Posted by Mitchell View Post
This sounds awesome, sorry for only skimming through the gist of this, but this caught my eye.

You can make a stock:
Code:
SetCommandFlags("mp_forcewin", GetCommandFlags("mp_forcewin") & ~FCVAR_CHEAT);
stock ForceTeamWin(team)
{
	ServerCommand("mp_forcewin %i", team);
}
0, ends in a draw
2, RED wins
3, BLU wins
It's not so much that I don't know ways to do it, but doing it elegantly would be much better

Quote:
Originally Posted by Mitchell View Post
I would also like to know how the whole 'preventing round end' and preventing 'player spawning' works that would help me out in my gamemode too.
There's no preventing round end or preventing player spawning, that'd be something you'd have to make yourself - at least for now, could be a future feature.

Quote:
Originally Posted by Mitchell View Post
holy hell i just went through the gihub, this is amazing.
Thanks, I'm surprised of the outcome as well. Guess it's because of 2 things:
1. It's not biased towards any particular project, unlike my attempt 2 years ago
and
2. Gotten a lot more experience since then, with all kinds of small projects

Last edited by Cookies.net; 04-13-2014 at 11:27.
Cookies.net is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 04-16-2014 , 13:23   Re: Gamma - A game mode manager
Reply With Quote #5

Quote:
Originally Posted by Mitchell View Post
You can make a stock:
Code:
SetCommandFlags("mp_forcewin", GetCommandFlags("mp_forcewin") & ~FCVAR_CHEAT);
stock ForceTeamWin(team)
{
	ServerCommand("mp_forcewin %i", team);
}
Code:
stock ForceTeamWin( iTeamNum ) {     new iFlags = GetCommandFlags( "mp_forcewin" );     SetCommandFlags( "mp_forcewin", iFlags & ~FCVAR_CHEAT );     ServerCommand( "mp_forcewin %i", iTeamNum );     SetCommandFlags( "mp_forcewin", iFlags ); }

Last edited by Leonardo; 04-16-2014 at 13:23.
Leonardo is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-16-2014 , 13:27   Re: Gamma - A game mode manager
Reply With Quote #6

Quote:
Originally Posted by Leonardo View Post
Code:
stock ForceTeamWin( iTeamNum ) {     new iFlags = GetCommandFlags( "mp_forcewin" );     SetCommandFlags( "mp_forcewin", iFlags & ~FCVAR_CHEAT );     ServerCommand( "mp_forcewin %i", iTeamNum );     SetCommandFlags( "mp_forcewin", iFlags ); }
yeah that.
Mitchell is offline
Cookies.net
Senior Member
Join Date: Jan 2011
Old 04-16-2014 , 18:30   Re: Gamma - A game mode manager
Reply With Quote #7

Added a new example game mode + behaviour to the repo, also updated the first post with the current state of things... Time to sleep *yawn*
Cookies.net is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:06.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode