Changing the recipe

An introduction to basic game mod’ing

Short URL: http://fsmsh.com/1370

Write a full post in response to this!

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'
Don't miss out on the other pages!
12next ›last »

Write a full post in response to this!

-1

Do you like this post?
Vote for it!

Copyright information

Verbatim copying and distribution of this entire article is permitted in any medium without royalty provided this notice is preserved.

Biography

Joshua Pritikin: Joshua is an aspiring researcher in evolutionary anthropology. To participate in his research, visit http://shared1.openheartlogic.org

Anonymous visitor's picture

be careful what you mod

Submitted by Anonymous visitor on Wed, 2006-08-30 21:49.

Vote!
0

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



Other sites

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