Version 3 (modified by jo, 15 years ago) (diff) |
---|
How to create a new gametype
I just want to share my experiences from creating Dynamicmatch as a c++ and orxonox newbie. Creating a new gametype is not very difficult - although you produce valuable content for Orxonox.
Where are the concerning source files?
../src/orxonox/gametypes
All gametypes are stored in this folder. The most important source files are Gametype.<cc/h> All gametypes inherit the Gametype class. So most of your coding work is just to rewrite some functions.
Strategy
Don't reinvent the wheel - try to copy and modify as much code from other gametypes as possible.
- Know what kind of gametype you want to create.
- Play existing gametypes and check which parts you want to adopt.
- Search in the concerning source files for code you can adopt.
- Start with the basic concept and add features later. (A Todo-List for the features would be nice.)
Gametype-Level
- Level are stored in ../data/levels. You need a level to test your gametype.
- For testing purposes just copy an existing level and rename it.
- Don't forget to set gametype = YourGameType in the <level> tag.
- Put "create a level for my new gametype" on your todo list Later you should try to create a level that is optimized for your new gametype.
Change the AI-behaviour
- The concerning file is in ../src/orxonox/controllers, called "ArtificialController.cc".
- You can make the bots stop shooting at certain targets by adding some lines of code in the bool ArtificialController::sameTeam-function as displayed above. The function should return true, if a bot shouldn't attack a certain target. (Since the AI-player is in the same "team".)
Miscellaneous tips - Useful at the beginning
- Don't forget to add your gametype to the CMakeLists.txt or it won't compile.
- Compiling with the terminal. Go to the folder of your orxonox branch. The command for compiling is cmake -j3.
- Don't forget to backup your code via svn. Open a terminal, go to your orxonox branch-folder and type svn ci -m "reason for commitment or summary of latest changes .
- Gamecommands: to add 2 new bots enter addbots 2, to remove one of them enter killbots 1. To display the scoreboard hit F2.
- Have a look at enhanced datatypes provided by the std library - especially the map.
Important functions inherited from Gametype
Function name | Effect |
allowPawnHit | Whenever a player would recieve a hit this function is called - if the function returns false a hit is not possible |
allowPawnDamage | Whenever a player would recieve damage this function is called - if the function returns false damage is not possible |
allowPawnDeath | Whenever a player would die this function is called - if the function returns false death is not possible |
playerEntered | what should happen, when a player entered the "battefield"? |
playerLeft | what should happen, when a player left the "battefield"? |
setConfigValues | interface for menue - to set the config values; ConfigValues are stored in a config file |
tick | this function is called whenever a new frame is rendered; dt is the value how much time has passed since the last frame |
Timer
- A timer is a object of the Timer class that call a function after a certain time.
- You can find a short tutorial in /src/libraries/tools/Timer.h or a more detailed one in the wiki.
- If the second argument is true, you create a timer-loop: The function is called periodically. Else the timer is only called once.