www.leniwiec.org

In the last days I had a lot of work and, as you probably know, a lot of work means a lot of stress… In order to relieve this stress, I have been playing the Sauerbraten game ;-) . It is the best free linux game and it is open source, so we have the access to the source code of the whole application / game, and hence we can modify it.

The Sauerbraten optimization for network uses the model in which most of the work is done by the client application. This gives us a possibility to make modifications, which I want to show you in this article. My modification is not a typical cheat, where you get super powers and nobody can kill you etc. It is only a minor modification making the game more playable, while we are not disturbing (so much) the other players.

Let’s start!

After we have downloaded the sources which are attached to the game distribution, we can start our modification. What we are interested in is the weapon description structure in the file src/fpsgame/game.h. This structure is responsible for the behavior of all weapons available in the game, and it looks like this:

static const struct guninfo { short sound, attackdelay, damage, projspeed, part,
			      kickamount, range; const char *name, *file;
			    } guns[NUMGUNS] =
 {
 { S_PUNCH1, 250, 50, 0, 0, 0, 14, "fist", "fist" },
 { S_SG, 1400, 10, 0, 0, 20, 1024, "shotgun", "shotg" }, // *SGRAYS
 { S_CG, 100, 30, 0, 0, 7, 1024, "chaingun", "chaing"},
 { S_RLFIRE, 800, 120, 80, 0, 10, 1024, "rocketlauncher", "rocket"},
 { S_RIFLE, 1500, 100, 0, 0, 30, 2048, "rifle", "rifle" },
 { S_FLAUNCH, 500, 75, 80, 0, 10, 1024, "grenadelauncher", "gl" },
 { S_PISTOL, 500, 25, 0, 0, 7, 1024, "pistol", "pistol" },
 { S_FLAUNCH, 200, 20, 50, PART_FIREBALL1, 1, 1024, "fireball", NULL },
 { S_ICEBALL, 200, 40, 30, PART_FIREBALL2, 1, 1024, "iceball", NULL },
 { S_SLIMEBALL, 200, 30, 160, PART_FIREBALL3, 1, 1024, "slimeball", NULL },
 { S_PIGR1, 250, 50, 0, 0, 1, 12, "bite", NULL },
 { -1, 0, 120, 0, 0, 0, 0, "barrel", NULL }
};

The fields which will be interesting for us are:

Number of fields Name Description
2 attackdelay Delay in overload of the gun. This is very troublesome especially for the rifle.
6 kickamount Power of recoil after firing. 0 – no recoil, 1024 – after firing you will fly to the moon ;-)
4 projspeed Projection speed, i.e. the time that is needed for the bullet to hit the target. This is useful especially in the rocket launcher. 0 – bullet hits immediately, 1024 – bullet flies and flies and flies…

I recommend to experiment with these parameters and tune them for your own needs. For example below you can see my own structure that I use sometimes:

static const struct guninfo { short sound, attackdelay, damage, projspeed, part,
			      kickamount, range; const char *name, *file;
			    } guns[NUMGUNS] =
{
    { S_PUNCH1,    250,  50, 0,   0, 0,   4,  "fist",            "fist"  },
    { S_SG,       1400,  10, 0,   0, 0, 1024, "shotgun",         "shotg" },  // *SGRAYS
    { S_CG,        100,  30, 0,   0, 0, 1024,  "chaingun",        "chaing"},
    { S_RLFIRE,    800, 0, 0,  0, 0, 1024, "rocketlauncher",  "rocket"},
    { S_RIFLE,     200, 100, 0,   0, 0, 2048, "rifle",           "rifle" },
    { S_FLAUNCH,   500,  75, 80,  0, 0, 1024, "grenadelauncher", "gl" },
    { S_PISTOL,    500,  25, 0,   0,  0, 1024, "pistol",          "pistol" },
    { S_FLAUNCH,   200,  20, 50,  PART_FIREBALL1,  0, 1024, "fireball",  NULL },
    { S_ICEBALL,   200,  40, 30,  PART_FIREBALL2,  0, 1024, "iceball",   NULL },
    { S_SLIMEBALL, 200,  30, 160, PART_FIREBALL3,  0, 1024, "slimeball", NULL },
    { S_PIGR1,     250,  50, 0,   0,  0,   12, "bite",            NULL },
    { -1,            0, 120, 0,   0,  0,    0, "barrel",          NULL }
};

Accuracy

In addition to the gun properties mentioned above, we can also improve the accuracy of the shotgun. For this we need to modify the file src/fpsgame/weapon.cpp around line 130, it looks like this:

void offsetray(const vec &from, const vec &to, int spread, float range, vec &dest)
   {
       float f = to.dist(from)*spread/1000;
       for(;;)
       {
           #define RNDD rnd(101)-50
           vec v(RNDD, RNDD, RNDD);
           if(v.magnitude()>50) continue;
           v.mul(f);
           v.z /= 2;
           dest = to;
           dest.add(v);
           vec dir = dest;
           dir.sub(from);
           dir.normalize();
           raycubepos(from, dir, dest, range, RAY_CLIPMAT|RAY_ALPHAPOLY);
           return;
       }
   }

Change the line:

#define RNDD rnd(101)-50

for

#define RNDD rnd(2)-1

This will minimize the spread of the shotgun and give it the accuracy of a rifle.

After these modifications we can enjoy the game. But first we need to compile it. The compilation of sauerbraten is very easy and we only need to type the “make” command in the terminal. Of course we need to have the following development packages installed in our system:

  • OpenGL
  • SDL
  • SDL_mixer
  • SDL_image
  • zlib

If you have any additional problems, you can find more precise information about the compilation and the installation in the file src/readme_source.txt.

Other modification possibilities ?

An often modification is the manipulation in the client.cpp file. This trick is to modify the structure which is sent to the server with our current coordination (X,Y,Z), so that the server will see us in a different place than we really are. The effect is that the other players don’t see our true position and can’t kill us. I don’t describe this modification because in my opinion it takes away the joy of the game both for us and for the other players.

2 COMMENTS
Birk
24 December 2013
ad

Very nice.

I have also released my own cheat on http://uuzvlv6hayzquoon.onion.to or http://hackbraten2.ml :)

Gemma
25 December 2015
ad

cheap replica jerseys nfl shop proimo code

Post comment