Total servers: 1
Modern Warfare1.0 – 20lt
Game Mode: Death Match
Lives: 0
Max Kills: 12
Version: OpenLieroX 0.58 rc5
Pages: [1]   Go Down

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


[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.

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

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:

As an example, take a look at the demolitions-gamemode implementation in the file src/server/CDemolitionsMatch.cpp or online here:
Another example is the Capture The Flag gamemode:

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 »


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.


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