StuntGP – An Attempt to read the File Structure #1

Setup

StuntGP has been a game of my childhood. My mother obtained it for whatever reason. I’ve never seen the game in shelves, though. Still, I definitely knew this game way before Re-Volt.

The game runs well on modern versions of Windows as well as Wine on Linux. Don’t be fooled by the Arcade mode, your unlocked cars and tracks are in the Exhibition mode.
My main motivation is to understand the game’s structure and convert tracks and cars to Re-Volt. Until now, I’ve seen little to no attempts to mod StuntGP or rip 3D models from the game.

This is what you’ll find in the game folder:
Screenshot from 2017-04-28 08-00-59.png

You have one folder for textures (graphics24, 24 for the bit depth) which all are .pc files, meshdata with the 3D models of the game (all .pmd files), save for your saved games, wads includes compressed game data (and the rest of the textures and sounds) as well as some plain-text parameter files with metadata for cars, tracks and other things.

Diving into the game files may give you some hope at first. Mesh data and some of the textures are exposed. The rest is packed in .wad files. Within those .wad files, we’ll find the rest of the internal structure of the game. I suspected this due to the paths linked in the game meshes. Those point to the graphics24 folder but the graphics aren’t there.

[yethiel@NX-01 wads]$ pakmount car01.wad ./mnt
not a KenSilverman GRP file
not a pack file
not a wad file
not a wad2 file
not a LGP file
malformed Dune 2 PAK file
format of file 'car01.wad' cannot be recognized

But it’s not what you think! TotalCommander and Game Archive UnPacker 0.6.0.3 PRO to the rescue. I managed to unpack all .wad files at once with it. To install the addon, start up TotalCommander, go to Configuration, Options…
Then select Packer from the sidebar and click on the Configure packer extensions WCXs button. In the top right corner, type .wad and then click on the New type… button. Point it to the extension wcx file you downloaded. Then you’ll be able to open the files with TotalCommander. Select all and click the unpack button.

Screenshot from 2017-04-28 07-52-53

Now let’s restore the game’s internal file structure.

mkdir game
cp -R */* game/

And there you have it:

Screenshot from 2017-04-28 07-58-04.png

The tree.txt is something I made for you to take a look at. It lists all the files and folders:
http://files.re-volt.io/sgp/tree.txt

Let’s go through those folders really quick: config contains the plain text files.

In the config folder, you get four subfolders called cams, levels, overlay and vehicles, as well as some csv and cfg files.
The files in this folder are the game’s strings, score amounts that you get for stunts,  and some level script files (commented as Pete’s SGP Game-Level Scripting File for Level Editing). Those level script files hold information about skyboxes, AI difficulty per track, track background, music, amount of laps, etc.
The cams folder has camera nodes for replays, similar to Re-Volt’s.
The levels folder contains .cfg files that hold information about each track’s fog settings, as  well as a LevelBoxList, perhaps something like Re-Volt’s track zones.
The overlay folder has a file for the demo GUI elements, all values and texture naems exposed.
The vehicles folder has files that are very similar to Re-Volt’s parameter.txt. They contain envelopes for car behavior (acceleration, etc.), weight, offsets and more.

In the graphics24 folder, you’ll find tons of .pc files. I took a look at them in a hex editor and they seem be be some sort of uncompressed bitmaps. Hopefully easy enough to sort out.

The replays folder has replays for some of the tracks, most likely recorded races for the demo mode.

The setup folder contains some .csv files about the game mode setups. That includes track order, AI setup, car tuning info, music tracks per menu and some more.

Lastly, sound/sfx/ has all the sounds in .wav format. Yay!

What’s next? I’ll take a look at the meshes first. Ripping from the game with programs like NinjaRipper didn’t work for me as all of them weren’t able to grab depth information. All I know about the mesh format right now is that all files have a header that reads PMD V.1.83. The textures are also linked as full paths a la cars\misc\tyre1. I can see some information about vertex colors, possibly. That’s it for now, though. After that, I’ll try to read the .pc texture format. If that doesn’t work out (but it should), I can still rip it with ripping programs from the running game.

Doable? Probably. I’m not that experienced with binary formats but I’m sure I can figure something out to at least import some bare models into Blender.

Blender Game Engine: Publishing

At some point you might want to get your game out to more people. You could just export it with the built-in Save As Game Engine Runtime plugin, however, there’s a new alternative since version 2.72 which is especially helpful if you’re looking into publishing to multiple platforms.

bge-publishing-addon

Take a look at its documentation page here.

It’s quite easy to use. When you activated the plugin by clicking the check mark, you’ll find its panel in the Render tab of the Properties panel. This is what it looks like in version 2.78:

publishing-panel

The .blend file I’m looking at right now is at the root directory of my game project (the file that ultimately launches the game).
All paths beginning with // will have the current directory as the starting point.
The settings I used will yield this folder structure:
(BriZide is my game’s project folder, brizide_build is the folder I want my published versions to be in)

publishing-folder

Let’s go through all the fields:

Publish Output:

This is where the addon will place your “compiled” game. In my case, I set it to be outside of my project folder. If the folder doesn’t exist, it will be created. The addon will create folders for the configured platforms inside that folder.

Runtime name:

This will be the name of your binary file (.exe/.app). It will also show up in the window title.

Library path:

This is the path to your blenderplayer executable (e.g. blenderplayer.exe). As you can see, I didn’t set it to anything. I’m not using that option since I unchecked Publish Default Platform.
If you’re going to export to only one platform, feel free to set this one and leave Publish Default Platform checked.
I decided to publish the game to all platforms at once, leaving out the default option.

Make Archive:
If you’re on Windows, check this option (otherwise games exported to Linux or macOS will not run without setting the executable file permissions). It will create a zip file of your game alongside the folder.
If you’re on Linux or macOS, it’s up to you whether you want to zip it up yourself or leave it to the addon.

Asset Paths:

Add folders and files to this list so they will be included in your published version. Don’t add your .blend here, only include things like readme.txt, folders for your textures/sounds and other assets. Make sure you added all necessary files, otherwise your game might not run properly due to missing files.

Overwrite Asset:

Replace the game files (from the asset paths list) every time you build. I’d keep it checked just to ensure that your published builds always have the up-to-date files.

Platforms:

As explained above, Publish Default Platform will use the blenderplayer from the Library path field.

I simply downloaded all current Blender versions (.zip archives, not the installers). I then extracted the folders from the archives to a folder called //lib (you can place that where you want, mine is arbitrarily in the game project folder).
(You’ll need to create a folder for the macOS build within your //lib folder, it doesn’t come with one.)

Click the plus icon several times.

Set the Platform Names according to your preferences.

For each platform entry, set the Player Path by locating a blenderplayer executable. You can either click on the folder icon next to the path field or type it out manually.

The macOS version needs a bit more attention again since the blenderplayer.app is basically a folder. I’d recommend to copy the path from your OS’s file manager or typing it manually in this case. Make sure your Player Path to the macOS version looks similar to this (no slash behind blenderplayer.app):

publishing-osx

Publish Platforms:
Click this button to create folders/archives containing the game with the executable of each platform you set up.

This should make publishing your game to several platforms much easier. If you have any questions, let me know.

Feel free to download my .blend here: https://github.com/Yethiel/BriZide/blob/master/brizide_build.blend
Make sure to activate the addon first.