zondag 21 maart 2010

Our first mod

At this point, you should have installed the mod SDK and placed the dummy files in the Art folder of the mod SDK.

Your mod SDK folder should look a little bit like this:


Now, go into the Mods folder and create a new folder. The name of this folder will be the name of you mod. In this folder, create a folder with the name 'Data' and create a file called mod.xml in that folder. Congrats, your first mod is basically finished! The mod.xml file is the only file that a mod has got to have. Your directory structure should now look like this: RA3 MOD SDK -> Mods -> MyMod (or whatever you might have called it) -> Data -> mod.xml.

Because this is a bit of a nonsense mod, we should probably go edit the mod.xml file, as it is where all the magic happens. Now, open mod.xml in your favorite XML editor (I would recommend Notepad++, because it has syntax highlighting for XML, but plain old notepad is fine too.) and paste the following code:

<?xml version="1.0" encoding="UTF-8"?>
<AssetDeclaration xmlns="uri:ea.com:eala:asset" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Tags></Tags>
    <Includes>
        <!-- These includes need to be in all mod.xml files -->
        <Include type="reference" source="DATA:static.xml" />
        <Include type="reference" source="DATA:global.xml" />
        <Include type="reference" source="DATA:audio.xml" />        
    </Includes>
</AssetDeclaration>


 

Let me give you a basic explanation of what we're doing here. (I sure hope you've read some xml guides by now!) The AssetDeclaration tag is the main tag of RA3 modding. It'elements are Tags and Includes. We are only going to use the second element for this one. The Include element of Includes is pretty self-explanary. The three includes that are already in the file are references to the normal data of the game. If you are interested in these files, you can find them in the RA3 MOD SDK -> SageXml folder (Sage is the engine that RA3, and most other C&C games, uses). These files are filled with references to all of the other standard files. If we make references to our own files below these includes we are able to overwrite values of the standard game files (note that if you would add references to your own files above these standard declarations they would get overwritten by the standard game files and just get the standard game). If we build the mod like this, it would come out as the normal game.

Now we are going to add our new unit. It will basically be a Guardian Tank, but with some modifications. In order to do that, we must add an xml file for the tank. But we also want to be able to actually build the tank. To do that, we have to edit the building options of the Allied Armor Facility. So, let's get cracking.

Go to the SageXml folder (it's inside the RA3 MOD SDK folder) and find the xml files for the Guardian tank and the command sets (for the Armor Facility queue) and copy (do NOT, I repeat, NOT move them, or else you wouldn't be able to create mods with these files, and you don't want that) them to the folder with mod.xml in it.
    Guardian tank:         RA3 MOD SDK\SageXml\Allied\Units\AlliedAntiVehicleVehicleTech1.xml
    Command sets:    RA3 MOD SDK\SageXml\GlobalData\LogicCommand.xml
                RA3 MOD SDK\SageXml\GlobalData\LogicCommandSet.xml

Now go ahead and rename the Guardian Tank file to something like mytank.xml, we don't want to overwrite the original file; we are going to add it as a new file.

We are only going to edit some minimal things. Change AlliedAntiVehicleVehicleTech1 to mytank on lines 38, 51, 52, 53, 56. Don't do this for other lines, as we do want the art and sound of the Guardian Tank. (It does not matter what name you pick here, as long as it's the same as the name you're gonna use in the next step.) The game now knows that it has to look up the name, type and description for a unit called 'mytank'. But we still have to tell the game what those are. You might find that the files you copied are read only, so reset this if you have trouble saving them.

Create a file called 'mod.str' in the data subfolder of your mod. Add the following to the file:
Name:mytank

"My Tank"

END


 

Desc:mytank

"It will kill you if I tell it to"

END


 

Type:mytank

"DON'T CROSS THE STREAMS"

END

Where I used mytank you should fill in the id you chose in the mytank.xml file. (Yes, you could use a different id for the desc and type, as long as you would use the same names in both files, but this makes thing only more complicated.)

We are now going to add the vehicle to the Armor Facility. Open LogicCommand.xml and add the following somewhere in the file:
<LogicCommand

    Type="UNIT_BUILD"

    id="Command_Constructmytank">

    <Object>mytank</Object>

</LogicCommand>

This is just adding the action, it does not have a way to get triggered yet. Command_Constructmytank is the name of the action that should be taken, so remember what you fill in here. The name in the Object tags should be the name as what you set in mod.str and mytank.xml. Save the file.

We are now going to tell the game when the action Command_Constructmytank should be executed. The file that tells this to the game is LogicCommandSet.xml. So why don't you open that up. Find the element

<LogicCommandSet id="AlliedWarFactoryCommandSet">
(hint: line 186). As you can see, these are all the buttons in the Armor Facility. Add
<Cmd>Command_Constructmytank</Cmd> 
at the place where you want the button to be (I placed it after the original Guardian Tank). Then, add the following code to the file under (and outside of) the AlliedWarFactoryCommandSet command set. It should look like this:


Now, go ahead and save it.

One more thing left to do. We still have to tell the game to actually load these modified files. Add the following cod to the mod.xml file (under the standard includes):

<Include type="all" source="DATA:mymod/Data/LogicCommand.xml"/>
<Include type="all" source="DATA:mymod/Data/LogicCommandSet.xml"/>
<Include type="all" source="DATA:mymod/Data/mytank.xml"/>


 

Well, we're done. This is it. In the next post I am going to learn you to build and use the mod you just made. (Congrats, you just really made your first mod.)


My modding adventures

Hi y'all.

Before I start, let me introduce myself. Tim van Dalen, 17 yrs old, Dutch, computer 'enthusiast' (let's just call it that way).

I will post 'my modding adventures' to this blog, hoping that others might learn something from them, since I think there's not so much information on this topic available. I must warn you, I will post everything I learn here, but I am not nearly a professional yet. I am going to join some forums (how web 1.0) on the topic and try to form some sort of tutorial from the stuff I learn.

My ultimate goal will be to add a structure to each faction which will produce an epic unit, of course different for each faction. I have modded and made maps before, but I have not succeeded in adding my own models to the game. I guess that that and adding sound will be the biggest challenge.

If you're reading this and are like: what the hell are you talking about, I'm talking about this game and how to make mods (how to modify it). If you did not know that, I don't think you should read on, unless you like learning about stuff you have no interest in at all, in which case I would encourage you to read on.

One more thing: before you start reading everything, I would advise you to check whether or not the title of the latest post says something like 'success' in capitals and the date it had been posted. Because if the last post doesn't say that I did it and it's over 2 weeks old, you would better believe I couldn't do it and quit, and reading all of my posts would be ridiculous.

Since I am a total computer geek (oh wait, we were gonna call it enthusiast, right?) I have some skills that I think you should have too, because I am not going to explain stuff related to these topics in very much detail:

  • Have some basic understanding of the XML language. (Guide here)
  • Played RA3 and/or RA3: Uprising for a better understanding of the game. (Find it yourself!)
  • Know how to make 3D models. I use Blender because I can't really work with 3ds Max (which you will need to export the models to a format the game understands)
  • Have some basic understanding of computer languages and stuff. I don't think you should learn C++ for this project, but it would definitely help you if you've ever written a website before.

The RA3 mod SDK is available for download over here (you should also download the dummy art. It's just empty files, but it will keep the mod builder from saying it is missing every damn file in the game. I will explain this later on). Although there is barely something in it, I would encourage you to read the documentation for some basic understanding of the file structure.

Next time we are going to make our first mod, in which we will add a new unit based on an existing one, with some modifications that would make the game totally unfair and balanced (If you can trick your friends into playing this one, you just might win!). But first, I'm gonna play a little match on Uhud Battlefield.