Total servers: 3
Who's still around? (Forum Discussion ) by miri September 15, 2019, 01:01:25 pm
Backup server NL
Modern Warfare1.0 – 20lt
IP: 95.46.198.26
Game Mode: Death Match
Lives: 0
Max Kills: 15
Version: OpenLieroX 0.58 rc5
Players:
baSE ReALiTy
Liero v2.0 – 100lt
IP: 80.186.160.80
Game Mode: Death Match
Lives: 0
Max Kills: 15
Version: OpenLieroX 0.58 rc5
Players:
M0rtsHeaven
Modern Warfare1.0 – 20lt
IP: 84.251.82.159
Game Mode: Death Match
Lives: 0
Max Kills: 12
Version: OpenLieroX 0.58 rc5
Players:
Pages: [1]   Go Down

Author Topic: [HowTo] Develop your own game mode  (Read 2124 times)

albert

[HowTo] Develop your own game mode
« on: March 16, 2009, 05:02:06 pm »
What is a gamemode
The game mode defines the game logic, e.g. what happens when a worm get killed, is shooting possible, do respawning, beam a worm somewhere else, make worms invisiblem, give them more power, make them slower and stuff like that. Current implemented game modes are Death Match, Team Death Match, Tag Game, Demolitions Match, Hide&Seek and Capture The Flag.

But don't confuse a game mode with some game settings. If you got an idea and you think that this idea can be realised already by just setting the right game settings, it's not a game mode.

Also, don't confuse it with a game mod (this was also called game script, perhaps an even more confusing name). A game mod defines the weapons and their behaviour in the game and some other physical constants. There are other good tutorials about this.

This thread here though is about  game modes. Game modes are implemented right now in C++ and belong directly to the source code of OpenLieroX.

Requirements
- Very basic knowledge of C++
- Be able to compile OpenLieroX from Git (see other threads about this)

Starting
We have an easy interface for the gamemode. That is a class with some virtual functions. If you want to write your own gamemode, just extend from this base class and overwrite the functions as needed.

The base class CGameMode is defined in the file include/CGameMode.h. Some default behaviour is defined in the file src/server/CGameMode.cpp. You can take a look at these files also online:
http://openlierox.svn.sourceforge.net/viewvc/openlierox/include/CGameMode.h?view=markup
http://openlierox.svn.sourceforge.net/viewvc/openlierox/src/server/CGameMode.cpp?view=markup

As an example, take a look at the demolitions-gamemode implementation in the file src/server/CDemolitionsMatch.cpp or online here:
http://openlierox.svn.sourceforge.net/viewvc/openlierox/src/server/CDemolitionsMatch.cpp?view=markup
Another example is the Capture The Flag gamemode:
http://openlierox.svn.sourceforge.net/viewvc/openlierox/src/server/CaptureTheFlag.cpp?view=markup

To tryout your gamemode, add it like the other gamemodes in the function InitGameModes() in the file src/server/CGameMode.cpp.

Some probably usefull methods you could use in a gamemode:
GameServer::SetWormSpeedFactor() - gives a worm a custom speed factor, i.e. makes him slower or faster
GameServer::SetWormDamageFactor() - makes a worm stronger or weaker, e.g. a factor 2 means all damage by him will be counted twice
GameServer::SetWormCanUseNinja() - enables or disables the ninja rope for a specific worm
GameServer::SetWormCanAirJump() - if enabled, the worm can jump in air, i.e. he can fly
GameServer::flagInfo() and related - you can create flags (always together with flagspawnpoints), attach them to player, etc.
...

If you think that it's not possible with that interface to implement your gamemode right now (that is very probable for most new and nice ideas), please contact us. Do that as early as possible, so perhaps we can add the specific changes to OLX and the network protocol already now. That has the advantage that all OLX versions from now on would support your gamemode in the future, even if it is not ready now.

If you have any questions, just ask.
« Last Edit: January 31, 2010, 04:55:37 am by albert »

joni

Re: [HowTo] Develop your own game mode
« Reply #1 on: March 31, 2009, 06:53:31 am »
Cool, helpful guide for people who would like to try make their own mods.

albert

Re: [HowTo] Develop your own game mode
« Reply #2 on: March 31, 2009, 01:55:01 pm »
Cool, helpful guide for people who would like to try make their own mods.

A mod is not a game mode. :) But probably you mean it right.

I extended the description a bit as we had some further development in this area. CTF is ready now (and a good example for game mode devs) and there are some new possibilities to use, e.g. wormspeedfactor or wormdamagefactor and so on.
Pages: [1]   Go Up