home home

downloads files

forum forum

docs docs

wiki wiki

faq faq

Cube & Cube 2 FORUM


[MODDING] Your first Sauerbraten MOD, Tutorial 1

by liquido on 11/15/2007 17:05, 77 messages, last message: 06/29/2010 07:30, 67688 views, last view: 05/18/2024 21:19, closed on 06/29/2010 09:29

[MODDING] Your first Sauerbraten MOD, Guide 1
---------------------------------------------
by liquido (jose.tapadas@yahoo.com)

(btw: i'm new to this forum :) ]

»»» [1]: INTRO:
===============

After googlin', searching and looking on the documentation I've noticed that there is a lot of spread information and nothing that a noob (must like me) could get as a platform to start coding for this great game engine, so I decided to write this guide so a modder-to-be could have some base to start on.
ATTENTION: Basic C/C++ knowledge required (if you don't know much don't worry!)

»»» [2]: THE TOOLS:
===================

Well as you know the Sauer is coded in C/C++ so in order to change something on it we need:

1. A C/C++ compiler:
Assuming you are using windows I recommend MinGW - Minimalist GNU for Windows, which has the Linux GNU tools all included on a win32 package
2. A C/C++ IDE (in order to help you browse through the code of Sauer and your mod.
3. Sauerbraten source code and engine (http://sauerbraten.org/)

To get all of this CodeBlocks has a package with all included:

Code::Blocks IDE, with MINGW compiler, Filesize: 13,597,181 Bytes | Version: 1.0rc2
download »» http://prdownloads.sourceforge.net/codeblocks/codeblocks-1.0rc2_mingw.exe?download

Now you need to configure the compiler so you can access it from any location and not only the MiniGW dir, so open Control Panel > System > Enviroment Variables search for "PATH" choose edit and add on the end of it ";C:\Program Files\CodeBlocks\bin".

»»» [3]: YOUR FIRST COMPILED SAUER:
===================================

On Sauer folder we have a well organized dir-structure so, with a little bit of inspection you can easily figure that we have a bi(nary) folder (with the game executable) and a src (source code folder). On this folder we wanna focus on 3 folders engine, fpsgame, rpggame.
It's not hard to figure that "engine" contains the Sauer game-engine (which contains the game physics, graphical rendering, etc..), fpsgame and rpggame contains both the fps and rpg game modes (or MOD's) which are included on Sauerbraten package.
Lets prepare a modding workspace on our engine, start by creating a new folder called "modgame" and copy into it all of the contents of the folder "fpsgame". We are going to mod the fps mode of Sauerbraten. Go inside your new folder and open all the .CPP and .H files with CodeBlocks. Go to "Search > Replace" and replace "fps" for "mod" on ALL FILES of that folder (when i say ALL I say ALL or it won't work!), save your progress and close CodeBlocks.
Still inside "modgame" rename "fps.cpp", "fpsserver.h" and "fpsrender.h" to "mod.cpp", "modserver.h" and "modrender.h".
Go back to the ..\src\ and go into mingw folder. Now create a copy of the "lib" folder and rename it to "lib.mingw", copy this folder into the ..\src\ folder. Copy the "MakeFile.mingw" into ..\src\ and "make.mingw.bat" into your Sauerbraten main dir (i.e. C:\Program Files\Sauerbraten).
Let's take a breath here to explain things:

* as you have noticed we are creating a new gamemode called "mod", based on the fps gamemode included on Sauer.
* on Sauer, fps and rpg modes, the gamemode binary is coded on "gamemode.cpp" (fps.cpp and rpg.cpp) and all the features are divided in something we call module coding, modules, weapons features on weapons.h, client features on client.h, all of them included on fps.cpp or rpg.cpp.
* if you are into the oo programming you will find interesting that all of the entities, actions and stuff on Sauer are divided into C/C++ classes which makes it very simple to develop.
* if you are not realy into OOP just forget (for now) the * above.
* the make file is something very usefull when programming very large projects with multiple files and compiler flags so it's a script who makes it for us.

We have created a mod workbench based on the fps game mode so lets include it on our makefile as a group ou files to compile, open the MakeFile.mingw and add just before of:

rpggame/rpg.o

the line:

modgame/mod.o \

To remove a compiling error on Sauerbraten scroll up and remove the line which adds:

engine/crypto.o \

(a feature removed from the cube time)

Save the MakeFile and close it. You are now ready to compile your mod and Sauer.
Run the "make.mingw.bat" and you should see somthing like this:

------------

C:\Program Files\Sauerbraten>cd src

C:\Program Files\Sauerbraten\src>mingw32-make all -fMakefile.mingw
g++ -O3 -fomit-frame-pointer -Wall -fsigned-char -Ienet/include -Iinclude -Ishar
ed -Iengine -Ifpsgame -o ../bin/sauerbraten-mingw.exe shared/tools.o shared/geom
.o engine/3dgui.o engine/bih.o engine/client.o engine/command.o engine/console.o
engine/cubeloader.o engine/grass.o engine/lightmap.o engine/main.o engine/mater
ial.o engine/menus.o engine/normal.o engine/octa.o engine/octaedit.o engine/octa
render.o engine/physics.o engine/rendergl.o engine/rendermodel.o engine/renderpa
rticles.o engine/rendersky.o engine/rendertext.o engine/renderva.o engine/server
.o engine/serverbrowser.o engine/shader.o engine/sound.o engine/texture.o engine
/water.o engine/world.o engine/worldio.o fpsgame/fps.o modgame/mod.o rpggame/rpg
.o -Lenet -Llib.mingw -lstdc++ -lenet -lmingw32 -lSDLmain -lSDL -lSDL_image -lSD
L_mixer -mwindows -lfmod -lz -lopengl32 -lglu32 -lws2_32 -lwinmm
strip ../bin/sauerbraten-mingw.exe

C:\Program Files\Sauerbraten\src>PAUSE
Press any key to continue . . .

-------------

Which means that everything went right!
Create a .BAT file called "mod.bat" on Sauer's main folder with the line :

bin\sauerbraten-mingw.exe -gmod

Save it.
This -gmod tells Sauer to run the game "mod".
Run it and....voila, your first mod!
Not very exciting because it's exacly the same that the fps mode but just have patience, you have compiled your first early-stage pseudo mod!

»»» [3]: YOUR FIRST MOD:
========================

Ok, lets do a actual MOD to the game.
Go to your mod's source folder (\src\modgame) and find a file called "weapon.h", open it!
As you can see from the first comment line:

// weapon.h: all shooting and effects code, projectile management

So this is the file where you find all the event handling, modeling and mumbojumbo when we are talking about weaponery stuff on Sauer. Search for the function:

void shoot(modent *d, vec &targ)

As you imagine this is the function which handles what to do when you fire your weapon on your game, so let's do some little moding.
On Sauer (and on most game engines, quake, source, doom, you name it!) we have something called entities which is basically everything that is interactive within the game, being it monsters, pick-ups, lights and even yourself the player, and on this shoot function we pass modent *d, which is a pointer to the entity who shoot's the weapon (so *d = (points) to ourselves for what we are concearned) and the vector &targ to the target of our shooting craziness. So lets mess up..cof...mod a little bit, scroll down until you find the line:

if(d->gunselect) d->ammo[d->gunselect]--;

Which is pretty much self explainatory, you d (ourselves) shoot go to the weapon ammo slot and dec. (--) by one ammo piece. Change it to:

if(d->gunselect) d->ammo[d->gunselect]++;

And this obviously will increase the ammo everytime you fire.
Save "weapon.h", run the "make.mingw.bat", then run your "mod.bat" and start shooting...free ammo on every trigger press!
I know this is very basic but it's a very important step on your journey as a modder ;)
Congratulations your first (micro) Sauerbraten MOD is complete.

Cumps, liquido... ;]

[keywords: mod, modding, Sauerbraten, tutorial, coding, develop, guide, noob, compile]

   Board Index    Go to next 20 messagesGo to last 20 messages

#1: ..

by MovingTarget on 11/15/2007 17:36

Hehe, nice tut man! I started out pretty much the same way, except I didn't touch the makefiles! I just open src/mingw/sauerbraten.cbp in code::blocks, and click build/build. Nice little guide though!

reply to this message

#2: ..

by slider on 11/15/2007 18:38

round of applause absolutely superb !!!

reply to this message

#3: THX! xD

by Q009 on 11/15/2007 19:05

THANKS! That's will help me! xD

reply to this message

#4: ..

by phoenixsux on 11/15/2007 20:21

i can't wait for when he gets to exploding barrels. :D

reply to this message

#5: ..

by Julius on 11/15/2007 20:22

Awesome thanks a lot.

It should be added to the wiki and I really hope that there will be more such tutorials from you in the future.

reply to this message

#6: Re: ..

by MovingTarget on 11/15/2007 20:22, refers to #4

How to make them? Download the CVS version, go into edit mode, and type /newent barrel. There are other arguments for barrel, but I think you can find out what they are.

reply to this message

#7: :]

by liquido on 11/15/2007 22:22

thank you so very much for the support and I'll definitely try to release some more tut's as I get more freetime.
i hope this will encourage you guys, who started on modding, on messin' arround the source code and release guides yourselves!

cumps, liquido

reply to this message

#8: ..

by yvfc_cebtenzzre on 11/15/2007 23:59

This tutorial confuses me!

what is this mysterious and unknown language called C/C++ ?!?

Sauerbraten is written in C++, not C.

reply to this message

#9: Re: ..

by MovingTarget on 11/16/2007 00:10, refers to #8

ENet, Sauerbraten's internet library, is coded in C.

reply to this message

#10: ..

by yvfc_cebtenzzre on 11/16/2007 02:20

MovingTarget:

so? It's a library, it's not Sauerbraten.

reply to this message

#11: oh no

by shadow,516 on 11/16/2007 03:04

We have enough problems with 12 year olds making "mods" by changing one line of code and posting the whole thing as their own work. Please don't encourage this behavior.

reply to this message

#12: Re: oh no

by SheeEttin on 11/16/2007 04:50, refers to #11

While I definitely disapprove of the "one-line-mod" you describe, I am highly in support of people--especially younger people--dabbling in coding. The young people of today are the older people of tomorrow.

I can recall when I was a young lad of 10 (I'm 16 now), I messed around with computer programs... Mainly swapping out one thing for another to make it say/display strange stuff. But this is a story for another time. :)

reply to this message

#13: ..

by yvfc_cebtenzzre on 11/16/2007 06:18

SheeEttin:

There is no danger of incompetent people being in charge of making modifications to program code which cause undefined behavior

This is already a widespread problem.

Though.

People should be encouraged to learn how to program and how to reason about programs if they wish to make changes.

I agree with you,

If they do make changes and redistribute them then credit should be given where credit is due or required (due to licensing).

reply to this message

#14: Re: ..

by shadow,516 on 11/16/2007 07:06, refers to #13

That's the thing. People don't give credit. AND they distribute the content files WHICH ARE NOT UNDER THE ZLIB LICENSE. I cannot stress that enough. I'm tired of people changing a few lines of code and saying "I made a game!". They then proceed to distribute "their game" with the textures, models, and maps included in Sauer.

I understand you're new here, liquido, but please lurk before you post. Sauer is NOT a "make your own FPS" kit. You MUST either replace all content, or make it able to be extracted over sauer.

I'm starting to agree with aard about making sauer closed source. It may be drastic, but people just don't understand the amount of time and expertise that goes into a game like this.

reply to this message

#15: Re: ..

by demosthenes on 11/16/2007 07:23, refers to #14

What?! No, please! Or, if that *does* happen, I hope they don't remove the latest open version from the internets. I mean, really, what good is closing the source going to do? People can still steal all the art and use it with, say, what they make with an FPS game kit.

Closing the source doesn't solve the content theft problem.

reply to this message

#16: ..

by yvfc_cebtenzzre on 11/16/2007 07:28

That is a difficult situation.

I can\'t really think of a technical solution to restricting content other than means of obfuscation.

I guess the legal side is something of an annoyance to have to chase people over compliance issues.

reply to this message

#17: ..

by eihrul on 11/16/2007 09:26

Chill people. He's just describing how to compile Sauerbraten. I don't honestly see what you're all bickering about.

reply to this message

#18: huh?

by liquido on 11/16/2007 14:33

I really don't get it...
I've just seen lots and lots of posts on compiling errors and doubts about compiling and the software to use etc..etc..and wrote something concise about it, not trying to write a guide to make a new game or as you said a "one line mod" but trying to show how this engine works and how games work at all..Do you really think that some kid who, by reading this guide, will release some major game based on everything on Sauer package and get credit for it by just changing some lines?
My purpose was good, i was just trying to help and share information, i was not trying to alienate all the licenses and game, engine objective..sorry about that..
and this was a guide intended for people who don't really know anything about C/C++ and maybe this will encourage them on learning, isn't that the objective of all of this?
i recall a tutorial i've read many many years ago about QuakeC source for quake I "moding" just like this one, how to compile it, how to change something to see that all of this is real and changable so don't get angry and chill out i'm just trying to help no create confusion.

greets, liquido

reply to this message

#19: Re: huh?

by slider on 11/16/2007 14:35, refers to #18

yeah and 99.9% of this community appreciate it :)

keep up the great work !!



reply to this message

#20: Re: ..

by MovingTarget on 11/16/2007 14:59, refers to #10

It was coded specifically for Sauerbraten by eihrul...

reply to this message

   Board Index    Go to next 20 messagesGo to last 20 messages


Thread closed!

This thread has been closed, which is why you can't post any more messages in it.


content by Aardappel & eihrul © 2001-2024
website by SleepwalkR © 2001-2024
54039055 visitors requested 71819683 pages
page created in 0.064 seconds using 9 queries
hosted by Boost Digital