Making it modable

Published October 17, 2005
Advertisement
One of the things I've always kept in mind is making the shooter mod-able, primarily allowing people to add new levels but also to add new enemies and attack patterns. The first part was my revised resource loading and build process mentioned earlier. Recently I've been working on making the actual deployment suitable so people can modify and add files.

I plan to have three ways of running the game: either via Eclipse (for general development), via Webstart (for playing and testing by others) and via an actual installed app (for the final thing).

The Quake Method
Back in the Quake era I used to do lots of modding for both Quake 1 and 2, and the prioritied resource system works really well, so I thought I'd pinch it. [grin] Basically Quake would have 'pak' files, which were custom archives of files complete with a directory structure (like a zip file, and in fact Q3 stopped using a custom format and uses proper zip files). Files get loaded using a relative pathname just like a normal file.

The neat bit comes in the prioritisation - pak0.pak would ship with the game content. pak1.pak would be the first patch, and any resource loaded would first be looked for in pak1, and if not found then loaded from pak0 - effectivly you could replace any resource with a newer one. Better, paks could exist 'unpacked' and just sit as raw files (but in the same directory structure). If a base dir was specified on the command line it would also be used as a source for resources (and take priority over all pak files). You could therefore have a whole bunch of mods installed in seperate directories, and just enable the one you wanted on the command line.

My Implementation
All very nice, but also a large chunk of programming. Fortunatly I've got a whole bunch of tools available in Java to do most of the work for me.

First off, pak files - instead of a custom file format I'm using jar files. Almost exactly the same really; multiple files bundled into one, relative directory structure, good compression and the ability to be signed (needed for webstart distribution). And I don't have to write anything to create, access or view them - all the tools and libraries already do that for me.

Running from Eclipse is trivial - here everything sits 'unpacked' and I simply run the game as if the whole thing was an unpacked mod.

Running as webstart is also easy - up to a point. If I just include the needed jars everything works fine, unfortunatly theres no way to add new content and theres no place for the user to put it. Instead I bundle my data jars within yet another jar, and unpack them at boot. The data jars are then added to my classpath *after* any specified mod dir, and we have our correctly prioritied loading scheme. Running as a standalone app would work the same, except I can unpack the jars at install time.

Sorted. What would have been well over a months work in C++ (at least) is reduced to a single weekends worth by using lots of built-in Java features.
Previous Entry I'm...
Next Entry Dodge This
0 likes 3 comments

Comments

rick_appleton
Quote:Original post by OrangyTang
Sorted. What would have been well over a months work in C++ (at least) is reduced to a single weekends worth by using lots of built-in Java features.


This isn't entirely true. There's a very nifty free library called PhysFS which does exactly all of this. It uses standard zip-files, and you can prioritize the loading order. It's also extremely easy to use.
October 18, 2005 02:40 AM
OrangyTang
Quite possibly, but that doesn't give me all the neat features that webstart does (single click launch, auto update, lazy downloading). And I could probably try and find another library to do that, but then it might not play well with the resource manager.

Ok, I'm being picky here but my general point is using existing libraries == good. And the large range of libraries (which play nice with each other) available 'out of the box' in Java is often overlooked.
October 18, 2005 07:22 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement