Adding new Upgrades

Tutorial for Command & Conquer 3 C&C3

Avatar of Phil

Phil

Category: Code
Level: Beginner
Created: Sunday September 2, 2007 - 10:40
Updated: Monday November 23, 2009 - 9:01
Views: 8068
Summary: Learn how to add new upgrades to C&C3 step by step
Rating
  • Staff-
  • Members-
  • Average-

0 votes

Page 1 2
Adding new Upgrades - by Dark Lord of the Sith

Required tools: Text Editor
Locations: data (in your mod folder), CnC3Xml
Edited Items: Upgrade, LogicCommand, LogicCommandSet, PlayerUpgradeButton, GameObject, mod.str


In this tutorial we are going to learn how to set up a completely new upgrade in C&C3.
I presume you have already set up your modding environment and know how XML files work and how the game treats them. Apart from that, no basic knowledge is required. So, let's start right away:

There are two different types of upgrades: PLAYER upgrades and OBJECT upgrades. The first one is purchased for the player, so once you have it, it's available for all units/structures (objects), even the ones you create after you purchased the upgrade. The Rail Gun upgrade is an example for this type.
The latter, OBJECT upgrades, only affect the one object which purchased it and thus. Normally, you purchase them individually, for each object. The power plant upgrades belong to this category. So much about the theory, let's do some practical work.

Since I like the Pitbull unit (yeah, who doesn't love a rocket launcher on wheels?), I've decided to give it a new fancy rocket weapon ('Nuke Rockets') that replaces the original through an upgrade, like the Rail Guns for the Predator and Mammoth Tank.

So let's start by opening the CnC3Xml folder and the folder \data in your personal mod folder (I'll just call this "mod folder"). Go to the GlobalData folder inside of CnC3Xml and open up upgrade.xml, copy the first two lines paste it into a new file inside your mod folder, called NewUpgrades.xml, for example. Next, find an upgrade similar to your new one in upgrades.xml and copy-paste that into your new file. Also copy the AssetDeclaration closing tag in upgrades.xml. This procedure will be repeated many times, so I will refer to this part again later in the tutorial.
Your new file should now look like this:

              
Code
<?xml version="1.0" encoding="us-ascii"?>
<AssetDeclaration xmlns="uri:ea.com:eala:asset">

    <UpgradeTemplate id="Upgrade_GDIArmoryRailgunTech"
        inheritFrom="BasePurchasableUpgrade"
        DisplayName="UpgradeName:GDIRailGuns"
        AcquireHint="UpgradePrereq:GDIRailGuns"
        TypeDescription="UpgradeType:GDIRailGuns"
        Description="UpgradeDesc:GDIRailGuns"
        Type="PLAYER"
        BuildTime="90.0s"
        BuildCost="5000"
        IconImage="Button_UpgradeRailGun"
    />
    
</AssetDeclaration>

One thing should strike your eye: this upgrade inherits something from another upgrade (in the same file). Watch out for those references, they often lead to errors because one forgets to copy the source and so it tries to inherit from something it cannot find. In our case, we will just copy-paste the BasePurchasableUpgrade from upgrade.xml into our new file aswell and insert it before our new upgrade.

Next we are going to make our modifications, changing everything that needs to be changed. At first we will rename the upgrade, giving it a name that describes its function, in my case Upgrade_GDIArmoryPitbullNukeRocketsTech.
Let's do the same for the String File (STR) references, just replace GDIRailGuns with GDIPitbullNukeRockets. We will add the actual strings later on. Those strings will be shown when you hover over the available upgrades of your unit (the small icons left of the unit portrait).
Adjust the BuildTime and BuildCost to your needs. If you have made a new button or plan to make one, change the IconImage attribute to your new button. I will keep the Rail Gun image for now. Your file should now look like this:

              
Code
<?xml version="1.0" encoding="us-ascii"?>
<AssetDeclaration xmlns="uri:ea.com:eala:asset">
    
    
    <UpgradeTemplate id="BasePurchasableUpgrade"
        LocalPlayerProductionStartedEvaEvent="None"
        ResearchCompleteEvaEvent ="UpgradeComplete"
        LocalPlayerBuildOnHoldEvaEvent="BuildOnHold"
        LocalPlayerBuildCancelledEvaEvent="BuildCancelled"
    />
    
    
    <UpgradeTemplate id="Upgrade_GDIArmoryPitbullNukeRocketsTech"
        inheritFrom="BasePurchasableUpgrade"
        DisplayName="UpgradeName:GDIPitbullNukeRockets"
        AcquireHint="UpgradePrereq:GDIPitbullNukeRockets"
        TypeDescription="UpgradeType:GDIPitbullNukeRockets"
        Description="UpgradeDesc:GDIPitbullNukeRockets"
        Type="PLAYER"
        BuildTime="20.0s"
        BuildCost="500"
        IconImage="Button_UpgradeRailGun"
    />
    
</AssetDeclaration>

Now we have our new upgrade. Unfortunately, it has no effect and cannot be acquired yet. So let's create a way how the player can buy it.
Open up LogicCommand.xml (in the GlobalData folder) and copy this block:

              
Code
    <LogicCommand
        Type="PLAYER_UPGRADE"
        id="Command_PurchaseUpgradeTankRailgun">
        <Upgrade>Upgrade_GDIArmoryRailgunTech</Upgrade>
    </LogicCommand>

Paste it into a new LogicCommand file in your mod folder (keep in mind to copy the XML prologue and AssetDeclaration tags), called NewLogicCommand.xml. Then, adjust the name (id) of the command and the reference to the upgrade, so that your new command looks like this:

              
Code
    <LogicCommand
        Type="PLAYER_UPGRADE"
        id="Command_PurchaseUpgradePitbullNukeRockets">
        <Upgrade>Upgrade_GDIArmoryPitbullNukeRocketsTech</Upgrade>
    </LogicCommand>

The next item on our list is LogicCommandSet.xml. Since we need a structure where we can purchase the upgrade, we will need to edit a commandset.
I've chosen to buy my upgrade at the radar building (known as GDI Command Post). Once again, make a new file, called NewLogicCommandSet.xml, make sure you have the required XML prologue and AssetDeclaration start-tag and end-tag. Then copy this commandset block into your new file:

              
Code
    <LogicCommandSet
        id="GDICommandPostCommandSet">
        <Cmd>Command_CommandPostRadarScan</Cmd>
        <Cmd>Command_TogglePower</Cmd>
        <Cmd>Command_SelfRepair</Cmd>
        <Cmd>Command_Sell</Cmd>
    </LogicCommandSet>

The next step is simple, just insert your new command at the top of the command list, so that it looks like this:

              
Code
    <LogicCommandSet
        id="GDICommandPostCommandSet">
        <Cmd>Command_PurchaseUpgradePitbullNukeRockets</Cmd>
        <Cmd>Command_CommandPostRadarScan</Cmd>
        <Cmd>Command_TogglePower</Cmd>
        <Cmd>Command_SelfRepair</Cmd>
        <Cmd>Command_Sell</Cmd>
    </LogicCommandSet>


My choice leaves us with a small problem though: the Command Post wasn't intended to create upgrades, it lacks a certain block of code. To fix this, copy the GDICommandPost.xml (found under CnC3Xml\GDI\Structures) into your mod folder, open the file, and just insert this block:

              
Code
    <ProductionUpdate
        id="ModuleTag_ProductionUpdate"
        Type="UPGRADE"
        GiveNoXP="true" />

right in the Behaviors block, under the <Behaviors> tag.
If you want your upgrade to be bought at the Tech Center or Armory, you don't need to do this step, but can only edit the LogicCommandSets (be aware that the Tech Center is called GDIArmory and the Armory is calledGDIMedicalBay).

Links / Downloads

 HitsAdded
Pitbull Nuke Rockets Weapon and Projectile2179September 2, 2007 - 13:27

Comments

Display order: Newest first

Hostile - Sunday September 16, 2007 - 16:11

I am understanding better why this was written the way it was. Because this is an overview of modding the files to achieve a result. Not explaining what each parameter does.

To do that would take another 10 tutorials. If you simply follow the tutorial as copy/paste, than take each section and closely examine it. It does make sense.

              
Code
<UpgradeTemplate id="Upgrade_GDIArmoryRailgunTech"
inheritFrom="BasePurchasableUpgrade"
DisplayName="UpgradeName:GDIRailGuns"
AcquireHint="UpgradePrereq:GDIRailGuns"
TypeDescription="UpgradeType:GDIRailGuns"
Description="UpgradeDesc:GDIRailGuns"
Type="PLAYER"
BuildTime="90.0s"
BuildCost="5000"
IconImage="Button_UpgradeRailGun"
/>


Take this example, many things are self explanitory.

inherit from: means it's a player upgrade. Once you purchase this upgrade all units will recieve the upgrade.

DisplayName: is the name of the upgrade ON the unit as it shows up in the game. This is a direct reference the "String" file that includes the actual text.

AquireHint/TypeDescription/Description: This is the string text that is referenced to show up when you hover over the actual upgrade you want to purchase. Not sure which is which yet.

Type="Player": Is this upgrade for just one unit or is it a global upgrade.

BuildTime/BuildCost/IconImage: These are self explanitory. How long does it take to complete the upgrade, how much does it cost, and what image should be used for this upgrade.

As you can see how much text it is simply to explain one portion of the code. Imagine explaining all that for each code snippet he quoted.

Stokbrood - Tuesday September 11, 2007 - 6:35

Very unclear, I stopped modding along at the beginning of the second page.

I don't like the method of just copying, pasting and adjusting things without knowing what I'm actually doing.

It would be much easier if you explain why we have to change the specific attributes you tell us to change (I got very confused with the sudden pop ups of the words Upgrade and Purchase). Also, at the beginning of the second page I had like 5 .xml files open.

Some very good tips:

- Replace the words containing PitbullRocketSomething with "NameOfYourMod"

- We, or at least I, I don't mind using Ctrl + F in Notepad. I wanna learn to mod, simply copying your text isn't sufficient.

I will absolutely try your tutorial again if you can make it understandable, cause there's no doubt you put quite some effort in making this tutorial, and I think you're halfway there, so thumb up for that :)

Hostile - Sunday September 2, 2007 - 16:10

I find this to be very striaghtfoward and easy to understand. Good work...

Return to top