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, 70542 views, last view: 09/29/2024 00:18, 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]

Go to first 20 messagesGo to previous 20 messages    Board Index    Go to next 20 messagesGo to last 20 messages

#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

#21: Re: oh no

by Aardappel_ on 11/16/2007 22:52, refers to #12

while I highly encourage EVERYONE to learn to program (I know of no more fun hobby), taking a complex game and changing some values in it is not going to teach you anything.

If you really want to learn, your first program should be helloworld.exe, not myfirstpersonshooter.exe. Do what every programmer did, start with the smallest program you can write entirely by yourself, then work your way up.

Once you have done that, and you get to a level of c++ where you can actually read and understand the sauer code, you'll be able to do things worthy of the name "mod", and you'll actually learn lots from it. And you know what, you won't need to ask how to compile it, because any problem you come accross you likely know how to solve yourself.

If you want to be able to create impressive things, you need to learn significant skills. There is no free lunch.

reply to this message

#22: Re: oh no

by MovingTarget on 11/16/2007 23:38, refers to #21

I totally agree! My first program went like this:

int main()
{
}

reply to this message

#23: lol..

by znet on 11/16/2007 23:42

of course but if you intend on start coding on C you won\\\'t search for it at a game engine forum right?
it may be the ingnition but not the main tool ;]

nice tut man! keep on the good work!

reply to this message

#24: ..

by RealNitro on 11/17/2007 15:38

Incredible how even the nicest topics change into bad in this forum...

I'm not new to C/C++ and if I had some time I would definitely give this howto a try. Keep up the good work!

reply to this message

#25: Re: ..

by slider on 11/17/2007 16:05, refers to #24

I agree with RealNitro on this liquido didn't have to take the time to post this mini tut but he put an incredible amount of time and effort into it. Its informative as well as inspiring and could lead to people making that leap into C/C++ we should be encouraging not bitching.

reply to this message

#26: ..

by phoenixsux on 11/17/2007 20:02

perhaps a better thought would be to place a new sticky "How To."

a thread just for posting up things you learned how to modify in the engine and to Q/A those things posted.

reply to this message

#27: ..

by yvfc_cebtenzzre on 11/18/2007 01:00

why does everyone keep saying C/C++?

They're not the same language!

reply to this message

#28: Re: ..

by SheeEttin on 11/19/2007 00:18, refers to #27

One's derived from the other (C++ from C), and they're pretty similar, as far as I know (from my mainly non-coder standpoint)...

reply to this message

#29: ..

by yvfc_cebtenzzre on 11/19/2007 00:42

The only similarity worth noting is that they both have the letter C.

Otherwise, it is completely silly to say C/C++.

reply to this message

#30: Re: learn your material before arguing about it

by tentus_ on 11/19/2007 00:56, refers to #29

Ok, think for a minute. C++ comes from C, Stroustrup wrote it as basically C combined with Simula. It's original name was "C with Classes" for goodness sake. Why are you making such a big deal about something you don't know about?

Hell, Stroustrup himself said that C++ is like saying a double superlative in Newspeak, for those who have read 1984 and know what Newspeak is. If you follow through with that statement, the C++ name means "most C like".

Just... gah. What a silly discussion.

reply to this message

#31: Re: ..

by MovingTarget on 11/19/2007 01:10, refers to #29

Dude, like SheeEttin said, one's derived from the other. C++ has object-oriented stuff, while C doesn't. That's one of the only major differences.

reply to this message

#32: ..

by yvfc_cebtenzzre on 11/19/2007 08:11

tentus:

I do know what I'm talking about - what proof do you have that I don't?

C++ is not C, so people should stop referring to C/C++.

reply to this message

#33: Re: ..

by tentus_ on 11/19/2007 08:56, refers to #32

"The only similarity worth noting is that they both have the letter C."

Yeah. That's a well-educated statement there.

I agree that people should not treat them as interchangeable, but this is way more fuss than the distinction is worth. Particularly since the distinction does not apply to the comments you were reacting to- they could have easily said Java/C++ and their comments would mean the same thing.

reply to this message

#34: ..

by Grinch (has lost his cookie) on 11/19/2007 09:16

We're nitpicking, but the tutorial does seem to use "C/C++" as if it's one language. C and C++ are two different languages, and are strictly incompatible with each other. Sauerbraten is written in C++, not C/C++.

reply to this message

#35: Re: ..

by Grinch (has lost his cookie) on 11/19/2007 12:09, refers to #35

afaik Sauerbraten is compiled entirely in C++. The ENet library is written in C, but can be considered separate from Sauer. You don't say Sauer was written in C/C++ because a dependent library was written in C.

reply to this message

#36: ..

by yvfc_cebtenzzre on 11/19/2007 12:36

yes

Sauerbraten is compiled entirely in C++. The ENet library is written in C, but can be considered separate from Sauer. You don't say Sauer was written in C/C++ because a dependent library was written in C.

reply to this message

Go to first 20 messagesGo to previous 20 messages    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
56731443 visitors requested 74643975 pages
page created in 0.058 seconds using 10 queries
hosted by Boost Digital