[[TOC]] = How to create a new gametype = I just want to share my experiences from creating [wiki:Dynamicmatch 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__[[BR]] All gametypes are stored in this folder. The most important source files are Gametype. 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.[[BR]] 1. Know what kind of gametype you want to create.[[BR]] 2. Play existing gametypes and check which parts you want to adopt.[[BR]] 3. Search in the concerning source files for code you can adopt.[[BR]] 4. Start with the basic concept and add features later. (A Todo-List for the features would be nice.)[[BR]] == Testing-Level Creation == * 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 ____ 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 [wiki:howto/STL 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"?|| ||[wiki:howto/ConfigValue setConfigValues]||interface for menue - to set the config values; ConfigValues are stored in a [wiki:howto/ConfigFile config file]|| ||[wiki:howto/Tickable tick]||this function is called whenever a new frame is rendered; dt is the value how much time has passed since the last frame|| == Already implemented functions == ||'''Function Effect'''||'''Examples'''||'''Additional Info'''|| || Scoring|| Deathmatch, TeamBaseMatch|| in gametype.h : struct Player->frags_|| || Change Colour||TeamDeathmatch, Dynamicmatch ||Dynamicmatch::setPlayerColour, Dynamicmatch::setConfigValues() || || Countdown|| UnderAttack||UnderAttack::tick, float gameTime_, int timesequence_ || == Text Output == There are two configurable ways how to display text in a gametype. You can display a line of text via sendStaticMessage() or sendFadingMessage(). * In constructor: __setHUDTemplate("yourgametypeHUD")__ * Use __sendStaticMessage()__ or __sendFadingMessage()__ functions in your gametype to display text * Define the look of the text via a __../data/overlays/yourgametypehhud.oxo__ file. Example: dynamicmatchhud.oxo * Include the template in your level file via __include("yourgametypehud.oxo")__ == [wiki:LevelHowTo Level Creation] == * add spawnpoints or teamspawnpoints * add comments to structure your level file or to comment out code: ____ * Basic objects: static entity and movable (rotating) entity * add 3D-objects ( with mesh) and its physical form () * randomness, loops -> lua script * Examples: * '''linear movement''': tansporter in __gametype_underattack.oxw__ * '''circular movement''': rotating satellite in __gametype_dynamicmatch.oxw__ * ''' force fields, deadly asteroids, in-game bots''': __gametype_asteroids.oxw__ == [wiki:howto/Timer The Timer object] == * 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 [wiki:howto/Timer 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.