Changing the recipe

Changing the recipe


There is a tradition amongst computer game aficionados which may be little known to people accustomed to proprietary games. This activity is called mod’ing—making small changes to a game to customize the play experience. Without a game’s source code, such changes are extremely difficult to implement. Games licensed as free software, on the other hand, are quite amenable to mods. This article presents two example mods for single-player games and proceeds to discuss mod’ing in general.

It may be news to you that it is usually easy to tinker with the source code for games

If you haven’t done much programming then it may be news to you that it is usually easy to tinker with the source code for games. Typically there are a few crucial variables like score and powerup. There is a main loop which reads keyboard and mouse events. Adding a special cheat key and recompiling can entail as little time as an hour or two.

It may sound impractical for mere reflex gamers to make source code changes for cheat keys and the like. Examine the following examples to decide whether you’ll need any help.

Mods for single-player games

Before jumping into source code, understand that most software is developed through independent projects. Gathering all these projects and making them work together is the primary motive of distributions like Red Hat, Gentoo, and Debian. If you use the packaging tools which come with your distribution then you will have an easier time because the myriad of integration problems are already solved. I use the Debian toolset here.

# Some preparation: apt-src automates the process of
# downloading source code. We'll keep track of our
# changes with GIT, just like the pros.
#
$ apt-get install apt-src git-core

# You may have to add a deb-src line to your
# /etc/apt/sources.list.
#
$ apt-src install gnome-games

# This tutorial uses version 2.12.3.  Other versions
# hopefully differ little.
#
$ cd gnome-games-*

# Take a snapshot of the original version.
#
$ git init-db
$ git add .
$ git repo-config user.name "John Doe" # your name here
$ git commit -m original

# Edit the code such that git diff show the following
# changes. Add lines prefixed with plus and remove
# lines prefixed with minus. It's probably OK if the
# line numbers turn out slightly different.
#
$ git diff
--- a/gnometris/blockops.h
+++ b/gnometris/blockops.h
@@ -44,10 +44,10 @@ public:
        GnomeCanvasItem *generateItem(int x, int y, ..

        const Block * const getFieldAt(int x, int y) ..
+       void eliminateLine(int l);

 private:
        bool blockOkHere(int x, int y, int b, int r);
-       void eliminateLine(int l);
        Block **field;
        bool field_initialized;
        Field *fieldDisplay;
--- a/gnometris/tetris.cpp
+++ b/gnometris/tetris.cpp
@@ -1132,6 +1132,10 @@ Tetris::keyReleaseHandler ..
        } else if (keyval == t->moveDrop) {
                t->dropBlock = false;
                res = TRUE;
+       } else if (keyval == 'c') {
+               t->ops->putBlockInField(true);
+               t->ops->eliminateLine(LINES-1);
+               t->ops->putBlockInField(false);
        }

        return res;

# Build a new deb package with your mod.  This can take
# a long time depending on the speed of your machine.
# You need about 100M of free disk space.
#
$ dpkg-buildpackage -b -uc -rfakeroot

# If all goes well, install it on your box.
#
$ su -c 'dpkg -i ../gnome-games*.deb'

Now while you are playing gnometris, you can press ‘c’ to remove the bottom line of blocks. As you can see, mods are not much more difficult than designing new levels for Rocks-n-Diamonds or KGoldRunner. Moreover, you can mod games which have a trivial conception of levels (like Tetris). Let’s take another example.

$ apt-src install supertux
$ cd supertux-*            # version 0.1.3
$ git init-db
$ git add .
$ git repo-config user.name "John Doe" # your name here
$ git commit -m original

# The man page for supertux has a clue: the
# --debug-mode command line option. The following
# patch enables parts of the debug_mode
# unconditionally.
#
$ git diff
--- a/src/gameloop.cpp
+++ b/src/gameloop.cpp
@@ -334,7 +334,7 @@ GameSession::process_events()
                           }
                         break;
                       case SDLK_TAB:
-                        if(debug_mode)
+                        if(1)
                           {
                             tux.size = !tux.size;
                             if(tux.size == BIG)
@@ -346,15 +346,15 @@ GameSession::process_events()
                           }
                         break;
                       case SDLK_END:
-                        if(debug_mode)
+                        if(1)
                           player_status.distros += 50;
                         break;
                       case SDLK_DELETE:
-                        if(debug_mode)
+                        if(1)
                           tux.got_coffee = 1;
                         break;
                       case SDLK_INSERT:
-                        if(debug_mode)
+                        if(1)
                           tux.invincible_timer ..
                         break;
                       case SDLK_l:
@@ -362,7 +362,7 @@ GameSession::process_events()
                           --player_status.lives;
                         break;
                       case SDLK_s:
-                        if(debug_mode)
+                        if(1)
                           player_status.score += 1000;
                       case SDLK_f:
                         if(debug_fps)

# Build a new deb package with your mod. If all
# goes well, install it on your box.
#
$ dpkg-buildpackage -b -uc -rfakeroot
$ su -c 'dpkg -i ../supertux*.deb'

Making mods is a more profound activity than you might assume. Changing the rules of a game invites a provocative series of questions: Why was I working so hard to achieve what I now understand is an arbitrary goal? Who determined the original rules and why? These questions transcend the limits of the original game design. Mods are empowering. Mods encourage authoring in preference to submissive consumption.

Thinking beyond video games, are there game-like structures in our social system? Who set up the rules for these social games? For what purpose? Ultimately, thinking about mods leads to The Matrix like insights:

What you must learn is that these rules are no different than the rules of a computer system. Some of them can be bent. Others can be broken.

Multi-player doppelganger

Some games are designed from the ground up to involve multiple players. Even games which were originally single-player often add facilities for involving multiple players within the same playground. Since changing the rules of a multi-player game entails discussion and consensus among all the potential participants, the mod procedure outlined here is more difficult to implement for multi-player games. Also, modding can sometimes have ethical implications if the modifications are created purely to give an specific player an unfair advantage over other human players who are not aware of it.

Have fun mod'ing!

Category: 
License: 

Comments

Anonymous visitor's picture
Submitted by Anonymous visitor (not verified) on

Also a good note, be very VERY careful what you mod... game modding has gotten myself and my friends sued in the past. I kid you not: http://www.worthplaying.com/article.php?sid=23629

Most forwarded

Interview with Dave Mohyla, of DTIDATA

Dave Mohyla is the president and founder of dtidata.com, a hard drive recovery facility based in Tampa, Florida.

TM: Where are you based? What does your company do?
DTI Data recovery is based in South Pasadena, Florida which is a suburb of Tampa. We have been here for over 10 years. We operate a bio-metrically secured class 100 clean room where we perform hard drive recovery on all types of hard disks, from laptop hard drives to multi drive RAID systems.

Anybody up to writing good directory software?

Since the very beginning, directories (of any kind) have had a very central role in the internet. (I have recently grown fond of Free Web Directory. Even Slashdot can be considered a directory: a collection of great news and invaluable user-generated comments. As far as software is concerned, doing a quick search on Google about software directories will return the free (as in freedom) software directories like Savannah, SourceForge, Freshmeat and so on, followed by shareware and freeware sites such as FileBuzz, PCWin Download Center and All Freeware (great if you're looking for shareware and freeware, but definitely less comprehensive than their free-as-in-freedom counterparts).

Interview with Mark Shuttleworth

Mark Shuttleworth is the founder of Thawte, the first Certification Authority to sell public SSL certificates. After selling Thawte to Verisign, Mark moved on to training as an astronaut in Russia and visiting space. Once he got back he founded Ubuntu, the leading GNU/Linux distribution. He agreed on releasing a quick interview to Free Software Magazine.

Is better education the key to finding better software?

I read David Jonathon's article Anybody Up To Writing Good Directory Software? the other day, which got me thinking about software directories in general. As David mentioned, many of the software directories one finds when doing a quick google search are free as in beer, not as in freedom. But what interests me is the software directories that already exist, providing a combination of both free as in beer software, and open source software. Sites such as Freeware Downloads and Shareware Download don't advertise themselves as providing free as in liberty software, but each of them have a good selection of open source software available... if you know where to look.

Most emailed

Free Open Document label templates

If you’ve ever spent hours at work doing mailings, cursed your printer for printing outside the lines on your labels, or moaned “There has got to be a better way to do this,” here’s the solution you’ve been looking for. Working smarter, not harder! Worldlabel.com, a manufacture of labels offers Open Office / Libre Office labels templates for downloading in ODF format which will save you time, effort, and (if you want) make really cool-looking labels

Creating a user-centric site in Drupal

A little while ago, while talking in the #drupal mailing list, I showed my latest creation to one of the core developers there. His reaction was "Wow, I am always surprised what people use Drupal for". His surprise is somehow justified: I did create a site for a bunch of entertainers in Perth, a company set to use Drupal to take over the world with Entertainers.Biz.

Update: since writing this article, I have updated the system so that the whole booking process happens online. I will update the article accordingly!

So, why, why do people and companies develop free software?

More and more people are discovering free software. Many people only do so after weeks, or even months, of using it. I wonder, for example, how many Firefox users actually know how free Firefox really is—many of them realise that you can get it for free, but find it hard to believe that anybody can modify it and even redistribute it legally.

When the discovery is made, the first instinct is to ask: why do they do it? Programming is hard work. Even though most (if not all) programmers are driven by their higher-than-normal IQs and their amazing passion for solving problems, it’s still hard to understand why so many of them would donate so much of their time to creating something that they can’t really show off to anybody but their colleagues or geek friends.

Sure, anybody can buy laptops, and just program. No need to get a full-on lab or spend thousands of dollars in equipment. But... is that the full story?

Fun articles

Santa Claus - the most successful open source project

It dawned on me the other day, as I was shopping for the dozens of gifts it seems I have to buy every December, that Santa Claus is the most successful open source project in history. (Bridget @ Illiterarty would agree with that). Santa Claus is essentially a marketing development that is embodied by everyone who stuffs a sock, gives a gift, hosts a dinner or wishes Merry Christmas over the holiday season.

Most emailed

Editorial

When I first started thinking about Free Software Magazine, I was feeling enthusiastic about the dream. I had Dave, Gianluca, and Alan willing to help me, I had established members of the free software community willing to help me out, I had writers volunteering their time and energy for free, and I had a generous offer from OpenHosting for servers, all before I'd proved myself. There was a sense of excitement in the air, and I thought maybe, just maybe, I could make this work.

Free Software Magazine uses Apollo project management software and CRM for its everyday activities!