| 1 | =How to create a new gametype= |
| 2 | |
| 3 | 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. |
| 4 | |
| 5 | ==Where are the concerning source files?== |
| 6 | ../src/orxonox/gametypes[[BR]] |
| 7 | 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. |
| 8 | |
| 9 | ==Strategy== |
| 10 | Don't reinvent the wheel - try to copy and modify as much code from other gametypes as possible. |
| 11 | #Know what kind of gametype you want to create. |
| 12 | #Play existing gametypes and check which parts you want to adopt. |
| 13 | #Search in the concerning source files for code you can adopt. |
| 14 | #Start with the basic concept and add features later. (A Todo-List for the features would be nice.) |
| 15 | |
| 16 | ==Gametype-Level== |
| 17 | *Level are stored in "../data/levels". You need a level to test your gametype. |
| 18 | *For testing purposes just copy an existing Level and rename it. |
| 19 | *Don't forget to set "gametype = YourGameType" in the <level> tag. |
| 20 | *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. |
| 21 | |
| 22 | ==Change the AI-behaviour== |
| 23 | *The concerning file is in "../src/orxonox/controllers", called "ArtificialController.cc". |
| 24 | *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".) |
| 25 | |
| 26 | ==Miscellaneous== |
| 27 | *Don't forget to add your gametype to the CMakeLists.txt or it won't compile. |
| 28 | *Compiling with the terminal. Go to the folder of your orxonox branch. The command for compiling is |
| 29 | {{{ |
| 30 | cmake -j3} |
| 31 | }}. |
| 32 | *Don't forget to backup your code via svn. Open a terminal, go to your orxonox branch-folder and type |
| 33 | {{{ |
| 34 | svn ci -m "reason for commitment or summary of latest changes" |
| 35 | }}} . |
| 36 | *Gamecommands: to add 2 new bots enter "addbots 2", to remove one of them enter "killbots 1". To display the scoreboard hit "F2". |
| 37 | |
| 38 | == Important functions inherited from Gametype == |
| 39 | ||'''Function name'''||'''Effect'''|| |
| 40 | ||allowPawnHit||Whenever a player would recieve a hit this function is called - if the function returns false a hit is not possible|| |
| 41 | ||allowPawnDamage||Whenever a player would recieve damage this function is called - if the function returns false damage is not possible|| |
| 42 | ||allowPawnDeath||Whenever a player would die this function is called - if the function returns false death is not possible|| |
| 43 | ||playerEntered||what should happen, when a player entered the "battefield"?|| |
| 44 | ||playerLeft||what should happen, when a player left the "battefield"?|| |
| 45 | ||setConfigValues||interface for menue - to set the config values; ConfigValues are stored in a log file|| |
| 46 | ||tick||this function is called whenever a new frame is rendered; dt is the value how much time has passed since the last frame|| |