Post tutorial RSS Red Alert 3 Tutorials 1: Purchasable Upgrades

The first in a series of tutorials I am writing for more difficult Red Alert 3 coding.

Posted by on - Intermediate Client Side Coding

Upgrades seem to be a more difficult thing to grasp in Red Alert 3 modding, so here is the first in a series of tutorials I will be writing on Red Alert 3 coding.

First off, upgrades take quite a few bits of code to work correctly before you even apply it to an object. To start with, you will need the UpgradeTemplate, which are stored in the Upgrades.xml in the SageXML/GlobalData folder.

Do note that this tutorial is for RESEARCHED upgrades only, meaning like the Dojo Upgrade/Breakthrough or(as used in this tutorial) Heightened Clearance.

To start off, I'll break down Heightened Clearance, and explain what all the tags mean:

		id="Upgrade_AlliedTech2" <!--The name this upgrade uses, pretty basic-->
		inheritFrom="BasePurchasableUpgrade" <!--Most upgrades inherit the BasePurchasableUpgrade for certain tags that tell the game to use certain sounds on certain actions, basically, if your upgrade is purchased, you want to inherit from this-->
		DisplayName="UpgradeName:AlliedTech2" <!--This does nothing, as it is specified elsewhere, this is probably leftover code from Tiberium Wars that EALA replaced-->
		AcquireHint="UpgradePrereq:AlliedTech2" <!--This does nothing, as it is specified elsewhere, this is probably leftover code from Tiberium Wars that EALA replaced-->
		TypeDescription="UpgradeType:AlliedTech2" <!--This does nothing, as it is specified elsewhere, this is probably leftover code from Tiberium Wars that EALA replaced-->
		Description="UpgradeDesc:AlliedTech2" <!--This does nothing, as it is specified elsewhere, this is probably leftover code from Tiberium Wars that EALA replaced-->
		Type="OBJECT" <!--This defines what your upgrade affects, valid tags are OBJECT or PLAYER. OBJECT upgrades affect only the object that had them, PLAYER upgrades are upgrades that go to any and all objects the player who bought the upgrade has-->
		BuildTime="15.0s" <!--The amount of time needed to research the upgrade-->
		BuildCost="1500" <!--Simple, this is the cost of the upgrade.-->
		IconImage="Button_UpgradeMortar" <!--This tag doesn't matter, as the picture is specified elsewhere-->
		Options="OBJECT_UPGRADE_PROJECTED"> <!--The Options attribute has a lot of tags to use, so you'll have to check the xsds to know all of them, this specific one is used in conjunction with a few Behavior modules on the Allied Construction Yard and Deployed Prospector to grant the upgrade to certain structures in their build radius-->
			<RequiredObject>AlliedRefinery</RequiredObject> <!--Pretty straight forward, this is what the upgrade requires, in this upgrade, it needs the Allied Refinery-->
			ForbiddenModelConditions="STRUCTURE_UNPACKING"/><!--This and the above module could actually be combined, but I'll explain them seperately, the ForbiddenModelConditions means that this upgrade can't be used while a specific Model or Animation is playing on this Structure or Unit, in this instance, this can't be researched while the MCV is deploying into the ConYard-->

Now that I've gone through that, I'll move onto the other modules an upgrades needs to work correctly. There are three other modules, and none are nearly as long as that, so don't worry ;).

First of the three we will do is the ButtonSingleStateData, which defines the strings and image the Upgrade uses(rather than those tags from before in the UpgradeTemplate).

		id="ButtonStateUpgradeAlliedTech2"> <!--Again, this is just the 
name this module uses-->
			Image="AUA_Clearance_Upgrade1" <!--This is the actual image the 
Upgrade will use, this one is the one that matters-->
			Title="NAME:UpgradeAlliedTech2" <!--The ingame name of the 
upgrade, must be defined in the mod.str-->
			Description="DESCRIPTION:UpgradeAlliedTech2" /> <!--The ingame 
description of the upgrade, must be defined in the mod.str-->

It might seem like this would do nothing for now, but this will be linked together in the tutorial by another module. This one is rather straight forward, just defines the image and strings the upgrade uses, although it isn't linked to the upgrade just yet, we'll get to that in our next two modules. I'll be doing the last two next, since it makes more sense to me to do these two at the same time.

		id="ButtonUpgradeAlliedTech2" <!--Just the name, like earlier-->
		LogicCommand="Command_PurchaseAlliedTech2"> <!--The LogicCommand this is linked to, the first part of the connection between the UpgradeTemplate and the ButtonSingleStateData-->
		     <StateData="ButtonStateUpgradeAlliedTech2"/> <!--The ButtonSingleStateData that is used for the Upgrade, this is the other half of the connection-->
		Type="OBJECT_UPGRADE" <!--For purchased upgrades(which is what this whole tutorial is about, this HAS to be set to OBJECT_UPGRADE or else it will NOT work, ti doesn't matter whether the upgrade itself is OBJECT or PLAYER(they will still do that) this is to trick the game into letting it be purchased-->
		id="Command_PurchaseAlliedTech2"> <!--Just the name, need I say more?-->
		<Upgrade>Upgrade_AlliedTech2</Upgrade> <!--The Upgrade this LogicCommand is purchasing, ofcourse, it must be linked to the name of the Upgrade you are doing-->
		<AISpecialPowerInfo Heuristic="UPGRADE" Manager="BUILDER"/> <!--This is to tell the AI how to use the Ugrade, these are the best settings, and is used for all purchased RA3 upgrades-->

All of these modules I have explained are required for an Upgrade to be purchased correctly(you ofcourse have to place the LogicCommand into a LogicCommandSet), you can tweak these setting rather easily, and what your upgrade actually does is dependant on how you code it into a unit, which will be explained in the next tutorial.

If you wish to post these tutorials elsewhere, you must have my permission, as I wrote them and would not want someone stealing my work, this will apply to all future tutorials written by me. To contact me send me a private message, asking to post this elsewhere, and telling me where you would like to post it.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.