- A special gift from AvP2 Team Fortress
- A special gift from AvP2 Team Fortress - part 2
- A special gift from AvP2 Team Fortress - part 3
Don't hold your breath if you're waiting for some cool T-Shirts or some new games. Instead we decided to share some of the knowledge built while working on our AvP2 Team Fortress mod. The following articles will focus on something most mods would love to have:
A mod launcher that also checks for updates!
You've heared it right, our gift to you consists in a tutorial on how to create your own mod launcher and update uitility! And to sweeten things even more, we're throwing in and an already usable utility. With just a few changes to an .ini file this component can launch UT, Quake and even Source based mods!
The last part of the tutorial (yes, there is more! Plus, we get to pimp out our mod for another day ...) will contain the actual finished product and it will be released shortly after this one, 4-5 days maximum. Meanwhile, here are the feature that the launcher has:
- Version checking against a simple text file hosted on a web server. The location of that file is arbitrary. Heck, it can be configured in an .ini file to point to your mod's web server.
- The update/patch/installer is downloaded automatically from a web server. Just as above, it can be you mod's web server.
- The launcher/updater is a sepparate component. This means ANY mod can use it without having to recompile its code. Further more, because it is an external component, it does not conflict with any other update mechanisms. Basically, if your mod is being handled through Steam, you can add this mechanism without one interfering with the other!
- It doesn't chew up resources! This is possible because the program is launched into memory before the mod starts, and it also unloads from memory immediately as the mod fires up. Neat, huh?
- Because the component is used for just one mod, there's no need to update the launcher itself. Although you can use the launcher/update component to actually update itself, by preparing a 'patch' for your mod that patches just the launcher.
Because all the key issues of the update mechanism can be set up to use your mod's web site, this tiny (under 100K) component gives you, the modder, full control over the update mechanism of your mod. No third party entities involved, just you and your community.
All the examples that will be listed below are based on just one program, called Nullsoft Scriptable Installer System. Go ahead and download it, and while waiting for the download to finish, read on.
Made by the very same people that also made WinAmp, NSIS is a tool that is intended to build installers. However, because of it's plug-in friendly architecture, NSIS aquired new capabilities, including an HTTP client and the possibility to launch external applications. Just what we need.
Now that your download has finished, install it. Sellect 'Full' as install option.
With the following examples we're hoping that you'll get yourself aquainted with how NSIS is being used. You'll also see bits of scripting that are then re-used in the final product.
Simple, browser-based, update
Without further ado, here's a very, very simple update mechanism. Granted that it just launches your default web browser to the URL of your latest patch, and it doesn't actually starts up the mod, the lesson here is that you can have the user reach the patch very, very easy:
Save the text above as "simple_update.nsi", right click on it and select to compile it:
You'll then get a small .exe; in the picture above I used a different name, but yours should be named exactly as stated in the .nsi file, "Update.exe". And now, the magic part: double click the exe.
Wallah! The user is directed to the update page of your mod's web site! Further more, you can set up the update page to automatically redirect you to the latest installer of your mod.
A stand-alone update mechanism
This one uses the HTTP client that I mentioned a couple of sections ago. It comes in the shape of the "NSISdl::download" plugin. The usage is straight forward:
You'll notice that we didn't set out a path for the local file. In our case, the .zip file gets downloaded to the same folder as the update executable.
There's a reason why I wanted to show the renaming capability: instead of .zip files, you can download self extracting archives, or even better, installers. In this case, the last command (ExecShell) launches the installer, providing a seamless installation of the update.
A bit about launching other applications
If the second update example didn't tip you off, here's how you can launch an external application.
That's it, really. Just that "ExecShell" command again. But that very command is all that we need to launch any game executable with just the right command line parameters. Command line parameters that basically tell "Hey you, game engine! Run this mod for me!".
This concludes the first article. In the following days we'll go even deeper, and we'll build a launcher&update utility that will give you, the modder, a reliable way to launch and patch up your mod. Stay tuned!