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: 4406
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 structure:
Now, to start out with, let's create our building. This tutorial does not cover creating a new structure from scratch, or modelling your own. I am simply using a clone of an existing structure for the purposes of this tutorial.
Firstly, make a copy of GDIGolumCannon.xml, this is the GDI Guardian Cannon. Make sure to place it within your <ModName>\data folder or whatever your folder structure is, and reference it in mod.xml. Rename this copy "GDIComponentTower.xml" (minus the quote marks of course :P).

There are some values we need to change in this file before we can apply any sort of upgrade logic to it. First off, there's the basic changes that must be made if you make a clone of any object XML file.
Open GDIComponentTower.xml, and scroll to the GameObject section.
Now change the id tag property to "GDIComponentTower".
Since we'll be giving this structure its own CommandSet, change the property of the CommandSet tag to "GDIComponentTowerCommandSet".
Change the EditorName to "GDIComponentTower" as well.
In this tutorial, we will be creating new strings for our building, so we can differentiate it from the Guardian Cannon. Change the TypeDescription and Description to "Type:GDIComponentTower" and "Desc:GDIComponentTower" respectively.
Likewise, change the DisplayName to "Name:GDIComponentTower" (not including quote marks - this tag is slightly different).

Now, scroll down until you see a StatusBitsUpgrade section. The one listed in the file already is a leftover from an unused feature where the Guardian Cannon would gain a railgun from the Rail Guns upgrade at the Tech Centre. Comment out or remove it, but it must not be parsed by the game. You're probably saying something now about how removing it will create problems. It won't, and besides, according to the Schema files, only three WEAPON_UPGRADED statuses are recognised, and this leftover happens to be sitting in one of them.

We'll need to add our own StatusBitsUpgrade sections - one for each weapon of the Component Tower. I'm not going to give you code for all three sections, but I'll give you a base for each one.
              
Code

            <StatusBitsUpgrade
                id="ModuleTag_UpgradeWeaponX"
                StatusToSet="WEAPON_UPGRADED_0Y">
                <TriggeredBy>Upgrade_TheWeapon</TriggeredBy>
            </StatusBitsUpgrade>


Now, do not put that exactly as it is into the XML. It must be changed for each weapon.
X = the weapon number (i.e. ModuleTag_UpgradeWeapon1)
Y = the weapon number again (i.e. WEAPON_UPGRADED_01)
TheWeapon = the name of the weapon upgrade. For example, my first StatusBitsUpgrade module has Upgrade_VulcanCannon as its TriggeredBy. Remember what you put in each slot - you'll need to reference these later.
In my XMLs, I have Upgrade_VulcanCannon as my first upgrade, Upgrade_RPG as my second, and Upgrade_SAM as my third.

Technically, you can have anything for the id tag, so long as it's unique in that file, but for organisational purposes, you should use the example described above.

Locate the WeaponSetUpdate module. This contains the weapon data for the structure. With the Guardian Cannon, you will find two weapons here - the standard, and unused upgraded one. Remove or comment out both. Now, you'll need to add a Weapon for each of the upgrades. Ensure that you have the ObjectStatus on each weapon set to "WEAPON_UPGRADED_0X" where X is the upgrade slot. Now, you can either create your own weapons here, use ones you have already created, or use existing ingame ones. This tutorial does not cover creating new weapons, so I'm using ingame weapons that are as close to the Component Tower's as possible.
IMPORTANT NOTE: All three weapons must be ordered as "PRIMARY_WEAPON". If they are not ordered as primary, they will not fire ingame. In my XMLs, I have used GDIWatchTowerGun as the first upgraded weapon (WEAPON_UPGRADED_01), GDIGolemCannon as the second, and NODRocketBunketSpawnWeapon as the third (this is following my previous example of the StatusBitsUpgrades).

Return to top