Replicating TS Component Tower Weapon Logic

Avatar of Nighthawk

Nighthawk

Category: Code
Level: Intermediate
Created: Saturday December 1, 2007 - 15:50
Updated: Saturday July 11, 2009 - 16:29
Views: 4524
Summary: Tutorial on replicating the upgrade weapon logic of the TS Component Tower.
Rating
  • Staff-
  • Members-
  • Average-

0 votes

Page 1 2 3 4 5 6
Creating the Upgrades:
Now, we are going to leave GDIComponentTower.xml and move on to creating the upgrades themselves. Open your NewUpgrades.xml file. You should format it as any other C&C3 XML file, in other words, it must start with:
              
Code
<?xml version="1.0" encoding="us-ascii"?>
<AssetDeclaration xmlns="uri:ea.com:eala:asset">
    <Includes>
    </Includes>


And end with
              
Code
</AssetDeclaration>


To save the trouble of copying several tags for each upgrade that will be the same anyway, we need to copy an UpgradeTemplate out of the existing upgrade.xml.
Open up upgrade.xml and locate BasePurchasableUpgrade. Copy the whole section into your mod's upgrades XML file.

Now, we're going to create an UpgradeTemplate for each of your ComponentTower's weapons. I'll copy the section of my VulcanCannon upgrade here, then you can base your other upgrades on it.
              
Code
<UpgradeTemplate id="Upgrade_VulcanCannon"
        inheritFrom="BasePurchasableUpgrade"
        DisplayName="UPGRADE:GDIVulcanCannon"
        Type="OBJECT"
        BuildCost="150"
        BuildTime="7.2s"
        ResearchCompleteEvaEvent ="None"
        ResearchSound="GDI_PowerPlantUpgraded1HeavyTurbinesMS">
        <GameDependency>
            <ObjectFilter
                Rule="ANY">
                <IncludeThing>GDIConstructionYard</IncludeThing>
                <IncludeThing>GDICrane</IncludeThing>
            </ObjectFilter>
            <RequiredObject>GDIComponentTower</RequiredObject>
            <RequiredObject>GDIBarracks</RequiredObject>
            <ForbiddenUpgrade>Upgrade_RPG</ForbiddenUpgrade>
            <ForbiddenUpgrade>Upgrade_SAM</ForbiddenUpgrade>
        </GameDependency>
    </UpgradeTemplate>


The BuildCosts and Times can be adjusted to your own needs. You may notice the rather complicated Dependencies section at the bottom. I have several rules there to bring the prerequisites for this upgrade as close to the TS ones as possible. To translate it into English, you need either a Construction Yard or Crane, a Component Tower (which kind of goes without saying, but it makes it show up on the ingame prerequisite list), and a Barracks to build this upgrade. Also, if you have Upgrade_RPG or Upgrade_SAM applied to this structure already, you cannot build this upgrade.

There is also a string there - UPGRADE:GDIVulcanCannon, that we will create later on.
Copy that template for each of your upgrades, remembering to change the id and DisplayName tags each time (I used UPGRADE:GDIRPG and UPGRADE:GDISAM for my other strings). Make sure your id tags are the same as what you referenced in the StatusBitsUpgrade sections in GDIComponentTower.xml. To replicate the TS prerequisites, my GameDependency section has <RequiredObject>GDICommandPost</RequiredObject> instead of the Barracks. Remember to change the ForbiddenUpgrades on each copy to the other two upgrades, i.e. on your Vulcan Cannon upgrade, you should have the RPG and SAM as forbidden, whereas on your SAM upgrade, you should have the RPG and VulcanCannon as forbidden. Your RPG upgrade should have the Vulcan Cannon and SAM as forbidden. This is essential for the logic to work correctly.

When you are done with this, open up UnitAbilityButtonTemplates.xml. If you have not changed the id tag's property to something else, do so now. This is imperative. Now, the sections in this file are relatively simple - they only define strings and the button image. Once again, I'll provide you with a template from which to base your own sections on.

              
Code

            <ObjectUpgradeButton
                Id="Command_UpgradeVulcanCannon">
                <State
                    Image="Button_UpgradeLaserCannon"
                    Title="NAME:UpgradeVulcanCannon"
                    Description="DESC:UpgradeVulcanCannon" />
            </ObjectUpgradeButton>


The Id must be the same as what you will call your CommandButton later. For the image, use whatever you want. I used the Nod Laser Capacitors image for my Vulcan Cannon, the Mortar upgrade image for my RPG, and the Rail Guns image for my SAM. The Title and Description string are just aesthetics really, but if you want this to look professional, you need them. The title will show the name of the upgrade, while the description will show what it does.

Return to top