Code hacks

From Armagetron
Revision as of 13:46, 18 June 2007 by Jonathan (talk | contribs) (Reverted edits by 62.215.3.51 (Talk); changed back to last version by 69.171.11.159)

From time to time people do various hacks to the code or write various scripts and programs to support the game. We'll try to collect them here so you can use them too. If you have a hack you'd like to add, just add it here. For it to format correctly, put

<pre> Copy paste your script here, in the space inbetween the code and pre commands. </pre> </code>

Alternatively just copy and paste the script as it is, but add a space in front of every line.

Note: there is no <code> in front of the script.

Modifications to Armagetron Advanced

These usually require actually applying a patch to Armagetron Advanced source and recompiling. Not for the faint of heart!

Applying a Code Patch

So, how exactly do you apply a code patch? First, you must cd into your directory containing the source code. Next, assuming you have a unix-based server, you must use the patch utility to hack the code. The patch utility is simple to use-- here is its syntax:

patch -p0 < code_hack.patch

now compile as you normally would.

Styball Patch

groundpig's infamous ball games, shooting, CTF, HTF, and many other games types work. Apply this patch to 0.2.8.2 source and build it.

Download the patch

CTF Server

Here are instructions for making a CTF server.

So, where do we start? First, we need to get the armagetron source. The version we need for a CTF server is the 0.2.8 SVN branch. The command I used to get this was:

$ svn co https://armagetronad.svn.sourceforge.net/svnroot/armagetronad/armagetronad/branches/0.2.8/armagetronad armagetronad

Note that the SVN version does not come with a prebuilt configure script so you will have to generate your own using bootstrap.sh which requires automake. Now that we have the code, we must download the pigsty patch. Make sure that the patch is in our armagetronad source folder, and then untar it.

$ tar -xvf pigsty-061021.zip


Now that all the resources and the patch have been unzipped, we will patch our code.

$ patch -p0 < pigsty-061021.patch

Now that we have patched our code, we can begin the build process. First, we will generate a configure script using bootstrap.sh. On FreeBSD, you may need to modify the bootstrap.sh script to point to the location of the automake tools since they may not be in your path, but in /usr/local/libexec/automakeXX and /usr/local/libexec/autoconfXX.

$ ./bootstrap.sh

Once we are notified that we have a working configure script, we can configure. The code given would install in the user's home directory.

$ ./configure --prefix=$HOME --disable-glout --enable-automakedefaults --disable-sysinstall --disable-etc --disable-useradd --disable-initscripts

Finally, the standard make and make install. You will obviously want to su to root if you are installing outside your home folder.

$ make
$ make instal

On FreeBSD, you may need to run this as:

$ gmake
$ gmake install

Next, copy the Your_mom directory from the SOURCE_DIR/resources to your new resource folder in $PREFIX/share/games/armagetronad-dedicated/resource. You can now modify the sample config files given in the SOURCE_DIR/config/examples. Now you should have a functional CTF server. All that's left is tweaking settings!

Hopefully this helps someone :D In case any of you are feeling lazy, I decided to help you by uploading a prepatched version of the code here

Hardcoded teams

Note: In the latest 0.2.8 branch (to become 0.2.8.3) there are settings to control the team colors and names (TEAM_(NAME|RED|GREEN|BLUE)_[1-8]).

eTeam.cpp starts with the team names and colors:

#define TEAMCOLORS 8

static unsigned short se_team_rgb[TEAMCOLORS][3]=
    { {  4,  8, 15 } , // blue
      { 15, 15,  4 } , // gold
      { 15,  4,  4 } , // red
      {  4, 15,  4 } , // green
      { 15,  4, 15 } , // violet
      {  4, 15, 15 } , // ugly green
      { 15, 15, 15 } , // white
      {  7,  7,  7 }   // black
    };

static char* se_team_name[TEAMCOLORS]=
    {
        "$team_name_blue",
        "$team_name_gold",
        "$team_name_red",
        "$team_name_green",
        "$team_name_violet",
        "$team_name_ugly",
        "$team_name_white",
        "$team_name_black"
    };

The colors are just like player colors. See elaborate color explanation for details on how they are merged. The $ means they are taken from the corresponding entry in the language files. Changing the language files is actually a cheap way to change team names without altering the code, although $team_name_blue → "Team yellow" isn't the most elegant solution, not to mention that language files can't make a team look yellow.

A bit further down the file are switches that control the source and can be set using the console commands ALLOW_TEAM_NAME_COLOR and ALLOW_TEAM_NAME_PLAYER.

static bool se_allowTeamNameColor  = true; // allow to name a team after a color
static bool se_allowTeamNamePlayer = true; // allow to name a team after the leader

The team leader is the oldest human player on a team, or the oldest bot if no human is available. Age is simply how long a player has been on a team. Which is used depends on a somewhat slanted democratic process. If there are at least two players and less than 50% of them have "Name Team after Player" set (bots and the leader are an implicit no, but are not excluded from the total when determining the percentage), an entry from the above list is used. Otherwise the team is named and colored after the leader, either as "Leader" if he is the only player, or "Leader's team" (team_owned_by in the language files) if there are more. The two switches can be used to influence the decision. If nothing is allowed an entry from the list is used. Then, finally, the team is forced to be named and colored after the leader if all entries in the list are in use.

External Scripts and Programs

These are programs and scripts people have written that modify the game without requiring compiling the game.

Generators

These are scripts used to generate maps.

Labyrinth Script

This is the script that generates mazes. It requires python and almost certainly requires a Linux installation. It's never been tested in windows. It's also available in Lucifer's private area of the SVN repository. Patches should be made against that and sent to Lucifer.

Download this script

Racer Script

This script generates racer maps with walls and deathzones and obstacles. You can configure the look of the obstacles and the average amount of obstacles to be put onto the map. It requires PHP and probably runs best on linux, though it doesn't use any system- specific calls, it just prints to stdout.

The script is quite hacky and lacking any proper documentation, but not very complex, so it shouldn't be hard to hack it some more. Download the script

Map Rotation

People have worked up good map rotation programs, hopefully they'll put them here.

Lucifer's Map Rotator

This is the rotator that used to power Swamplords on Crack before it was taken down. It includes the mazer.py script listed in Generators on this page. Probably requires Linux, it's not known to work in Windows.

Download the file

Server monitors

ArmaBell

A server monitor written by iF with tons of features for windows. Unfortunately the source code isn't available and it has been discontinued, and it doesn't even work anymore without some quirks.

ArmaSpy

A GTK server monitor written by weip in C. It runs on Linux and most likely other *nix–like operating systems too.

ArmaSpy Advanced

A server monitor written in python using PyKDE with some more features than ArmaSpy. It lets you directly join a server by clicking on a player in it, hilights servers in your server favorites and features a buddy list.

Links

Chat Programs and other Social Stuff

  • If you are Windows user you can try Armachatron, IM software for arma players exclusively.