2.1. Setting Up
There are a few things to know before you make your first mod. Most importantly, AVALANCHE includes various "user" files under the rcgame folder, which are intended for user mods. If you make all of your changes in these files alone, you will not need to worry about updating or having your mod broken by future versions of AVALANCHE. These files are:
objects/invitems.rci - You can add up to 20 user-defined inventory items in this file, anything from potions to new melee weapons.
objects/usermod.rco - Use this to define your own game objects. You can place custom game objects in your map with the editor, or by spawning them in R-Script code.
particles/usermod.rpl - Add all of your custom particle effects in here.
rscript/usermod.rsc - This is your very own R-Script module. You can add all of your custom logic and routines in here.
texshd/usermod.rsh - This allows you to define texture shaders for your custom meshes, particles, or anything else that uses textures.
Next, you will want to turn on developer mode. Open up your rcgame/engine.cfg file in a text editor like notepad.exe, and change the developer field to "1". Additionally, you will probably find the logwindow very handy. However, the log window disables mouse focus, so hopefully you are using a gamepad in your development. If not, you should really consider picking one up. That aside, from here, you're all ready to get straight into development. Read on.
As you may have noticed, an example mod is included with the regular AVALANCHE distribution. In order for your mod to visible for selection in the R-Cube intro dialog, the folder the mod is in must begin with mod_ and the folder must contain a mod.cfg file. Here is a sample mod.cfg file:
usermod
{
name "Example Mod"
author "Rich Whitehouse"
website "http://www.telefragged.com/thefatal/"
descr "Example mod."
}
Pretty straight-forward. So, if you wanted to play the example mod, you'd just rename that rcgame/examplemod folder to rcgame/mod_example, and the "Load Mod" button would show up in the R-Cube intro dialog for you activate it.
2.2. Tutorial
As a short tutorial example in making a mod, we'll walk through the steps in creating a new inventory item. First, create a new folder under rcgame called "mod_mymod". Now in that folder, create a file called mod.cfg, and make the contents something like this:
usermod
{
name "My First Mod"
author "Mr. Sniffles"
website "http://www.mrsniffles.com/"
descr "My mod!"
}
That is assuming your name is Mr. Sniffles. Now that you've done that, create another tree of folders under rcgame/mod_mymod, leading to "rcgame/mod_mymod/assets/objects/", and copy the provided invitems.rci from the normal game tree in rcgame/assets/objects to rcgame/mod_mymod/assets/objects/. Now, finally, open up rcgame/mod_mymod/assets/objects/invitems.rci in a text editor.
We can see a couple useritem definitions here already, let's replace that first one with this:
useritem1
{
name "SniffleBomb"
icon "assets/textures/items/item_sack"
desc "Sniffle explosion!"
useFX "other/bombblow"
itemBehavior "8"
itemValue "500"
usable "1"
cost "100"
secret "0"
maxAmount "99"
}
The itemBehavior value corresponds to the list of values at the top of the invitems.rci file, so you can see we have specified INVITEM_BEHAVIOR_RADIUSDMG in this case.
Now, start up rcube.exe. You'll notice there is a Load Mod option on the main dialog, if you set your folder and mod.cfg file up correctly. Click it, and load "My First Mod". Now start up a game as usual, and you will be able to forge SniffleBombs at the Mako Forge for 100 mako each.
Several types of items specify a game object instead of FX. These types are swords, guns, and flashlights. If you look at the invitems.rci file in the examplemod which comes with AVALANCHE, you will see that it has specified "*obj_bpin" as the useFX. obj_bpin is then defined in the mod's usermod.rco file.
That's all there is to it. You've created your first mod.