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, 69327 views, last view: 06/26/2024 10:35, 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   

#68: Re: distribution

by ezombie on 03/16/2008 20:48, refers to #67

If you want to use the repo manually, the index file presented is structured like this:

[MD5 hash]:[size in bytes]:[filename with path relative to base directory]

To retrieve an index file, simply pass the module name to the repo:

http://master.usef-et.org/repo/?sauer

You can filter the results by adding a relative path:

http://master.usef-et.org/repo/?sauer/bin

Notice no slashes on the beginning or end of the request (part after the '?'). To grab a file, simply specify the file with relative path:

http://master.usef-et.org/repo/?sauer/src/readme_source.txt

It will download as normal.

If you want the file stream to be compressed, simply add a '.lzo' to the end of the name. Though you will not want *that*, unless you have a LZO stream decompressor handy.

reply to this message

#69: Sauer Compiling on Mac

by Oh No Ghost! on 03/18/2008 05:10

Can somebody point me in the right direction with compiling Sauer using XCode, and the .xcodeproj file in the Linux release of Assassin Edition?

Whenever I compile and run Sauer, the screen goes dark for a second, then back to normal with the following feedback:

[Session started at 2008-03-17 20:49:07 -0700.]
2008-03-17 20:49:08.706 sauerbraten[1105] LCC Scroll Enhancer loaded
init: sdl
init: enet
init: video: mode
init: video: misc
init: gl
Renderer: NVIDIA NV34MAP OpenGL Engine (NVIDIA Corporation)
Driver: 1.5 NVIDIA-1.4.18
Rendering using the OpenGL 1.5 GLSL shader path.
WARNING: Using Apple GLSL depth bug workaround. (use "/apple_glsldepth_bug 0" to disable if unnecessary
WARNING: Non-power-of-two textures not supported!
could not load texture data/notexture.png
could not find core textures

sauerbraten has exited with status 1.

The compilation apparently doesn't have any errors, but it gives this warning:

warning: no rule to process file '$(PROJECT_DIR)/../shared/sbtrace.d' of type text for architecture ppc

Whenever I compile the Launcher, it comes up no problem, but warns me about "placing sauer in a directory without any weird symbols" whenever I try to press play, and I get the following feedback:

[Session started at 2008-03-17 20:56:05 -0700.]
2008-03-17 20:56:07.243 launcher[1120] Missing sauebraten?!
2008-03-17 20:56:07.627 launcher[1120] LCC Scroll Enhancer loaded

launcher has exited with status 0.

I'm at a loss as to what to do here. I hear people say that you need to download things like SDL, SDL_mixer, OpenGL, etc- but I'm confident that I did download those, and even if I didn't, they were included in the XCode developer's kit. Where should these files be, so I can check to see if they are there?

reply to this message

#70: Re: Sauer Compiling on Mac

by MovingTarget on 03/18/2008 13:16, refers to #69

When it says "can't find core textures" it means you're either running the .exe from the bin/ folder, or you're running it and/or have it in a different folder. You must always have it in the bin/ folder but run it from it's parent directory.

reply to this message

#71: Re: Sauer Compiling on Mac

by Oh No Ghost! on 03/18/2008 14:58, refers to #70

Ahahaha, that worked perfectly. Thanks!

reply to this message

#72: Re: distribution

by ezombie on 03/18/2008 19:13, refers to #68

FYI - it has now been named YODA (Yet Another Download Application)

I changed the server component so it only hands out one directory at a time. This gives three big benefits:

1) It scales MUCH better
2) Client code is even simpler
3) You can now have *empty* directories get created on the client.

It is working great BTW - I tested it on flaky wireless connection (33% strength, constant packet loss, usually only get 40-70Kbps rates and big downloads freeze up). It ran through nice and steady, with an effective speed of 90Kpbs!.

Effectively slicing a large package it into many small downloads works extremely well on bad connections. I even canceled it a couple times, then restarted it a few minutes later.

Now I just need to add the module list to the server and client, and then I will whip up and test the Linux version.

My current thought is that you install YODA (like steam, but ours only takes 4MB -> pwnd), then you simply 'add' one or more repo URLs. This is like the way Eclipse does package installation. Each repo can hold one or more 'modules', or software packages.

Each module has a conf file written in Lua - which is downloaded and executed. This way you can optionally override/add to the built-in functions and fully script the client functionality if you want.

A simple one would be this:


module = {
title = "ET:CE"
desc = [[
ET:CE - A World At War

This is a team-based multiplayer online fps game,
inspired by Wolfenstein:Enemy Territory.
]]
prologue = nil
epilogue = [[
You have finished installing/updating ET:CE.

Thank you for playing and check out etce.usef-et.org for
more information!
]]
exclude = {"^update", "profiles/.*$", "downloads/.*$"}
clean = {"^data", "^bin", "^packages/et"}
}

This will be branched into a seperate project at some point (likely when someone else wants to use it). BTW, We are offering free repo hosting for any opensource application that asks.

reply to this message

#73: I'm not sure what went wrong...

by tman_elite on 03/19/2008 00:48

I can compile sauer fine in Linux now, but I tried porting an early version of my mod to my windows computer (to see if it worked) and when I tried to run it, it complained about not finding a bunch of dll's, (sdl, verify, java, jpeg, and some more) and when I downloaded them all, it complained about (something) 50 could not be located in direct link library jpeg.dll. I tried messing around with the codeblocks compiler but it kept doing the same thing.

reply to this message

#74: Re: I'm not sure what went wrong...

by tman_elite on 03/24/2008 20:58, refers to #73

It was "Ordinal 50 could not be located in the direct link library jpeg.dll."

Has anyone else had this problem?

reply to this message

#75: Not dieing

by )FC($k!llz_ on 06/29/2010 05:21

I might not get any help with this, but i made the mod th ammo counts up, and i also made the guns shoot faster. Me and another dude were playing online, but i wasted over 300 bullets on him standing still, and he wouldnt die. What did i do wrong? They die fine with only bots.

reply to this message

#76: Re: Not dieing

by SheeEttin on 06/29/2010 06:33, refers to #75

Probably, his client and/or the server decided you hadn't finished shooting, so you weren't allowed to shoot again. So he only saw the first shot.

Also, cheating is generally frowned upon...

reply to this message

#77: Re: Not dieing

by )FC($k!llz_ on 06/29/2010 07:30, refers to #76

I see.

And i wouldnt call it cheating. We were both testing the mods we made. We both said it was ok.

reply to this message

Go to first 20 messagesGo to previous 20 messages    Board Index   


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
55269833 visitors requested 73123232 pages
page created in 0.079 seconds using 10 queries
hosted by Boost Digital