Jump to content


[RA3] Purchasable Upgrades Tutorial


No replies to this topic

#1 R3ven

    Veteran

  • Project Team
  • 468 posts

Posted 18 July 2010 - 22:38

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:

	<UpgradeTemplate
		id=&#34;Upgrade_AlliedTech2&#34; <!--The name this upgrade uses, pretty basic-->
		inheritFrom=&#34;BasePurchasableUpgrade&#34; <!--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=&#34;UpgradeName&#58;AlliedTech2&#34; <!--This does nothing, as it is specified elsewhere, this is probably leftover code from Tiberium Wars that EALA replaced-->
		AcquireHint=&#34;UpgradePrereq&#58;AlliedTech2&#34; <!--This does nothing, as it is specified elsewhere, this is probably leftover code from Tiberium Wars that EALA replaced-->
		TypeDescription=&#34;UpgradeType&#58;AlliedTech2&#34; <!--This does nothing, as it is specified elsewhere, this is probably leftover code from Tiberium Wars that EALA replaced-->
		Description=&#34;UpgradeDesc&#58;AlliedTech2&#34; <!--This does nothing, as it is specified elsewhere, this is probably leftover code from Tiberium Wars that EALA replaced-->
		Type=&#34;OBJECT&#34; <!--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=&#34;15.0s&#34; <!--The amount of time needed to research the upgrade-->
		BuildCost=&#34;1500&#34; <!--Simple, this is the cost of the upgrade.-->
		IconImage=&#34;Button_UpgradeMortar&#34; <!--This tag doesn&#39;t matter, as the picture is specified elsewhere-->
		Options=&#34;OBJECT_UPGRADE_PROJECTED&#34;> <!--The Options attribute has a lot of tags to use, so you&#39;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-->
		<GameDependency>
			<RequiredObject>AlliedRefinery</RequiredObject> <!--Pretty straight forward, this is what the upgrade requires, in this upgrade, it needs the Allied Refinery-->
		</GameDependency>
		<GameDependency
			ForbiddenModelConditions=&#34;STRUCTURE_UNPACKING&#34;/><!--This and the above module could actually be combined, but I&#39;ll explain them seperately, the ForbiddenModelConditions means that this upgrade can&#39;t be used while a specific Model or Animation is playing on this Structure or Unit, in this instance, this can&#39;t be researched while the MCV is deploying into the ConYard-->
	</UpgradeTemplate>


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 :P.

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).

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


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.

	<UnitAbilityButtonTemplate
		id=&#34;ButtonUpgradeAlliedTech2&#34; <!--Just the name, like earlier-->
		LogicCommand=&#34;Command_PurchaseAlliedTech2&#34;> <!--The LogicCommand this is linked to, the first part of the connection between the UpgradeTemplate and the ButtonSingleStateData-->
		<Data>
			<ObjectUpgrade
				StateData=&#34;ButtonStateUpgradeAlliedTech2&#34;/> <!--The ButtonSingleStateData that is used for the Upgrade, this is the other half of the connection-->
		</Data>
	</UnitAbilityButtonTemplate>
	
	<LogicCommand
		Type=&#34;OBJECT_UPGRADE&#34; <!--For purchased upgrades&#40;which is what this whole tutorial is about, this HAS to be set to OBJECT_UPGRADE or else it will NOT work, ti doesn&#39;t matter whether the upgrade itself is OBJECT or PLAYER&#40;they will still do that&#41; this is to trick the game into letting it be purchased-->
		id=&#34;Command_PurchaseAlliedTech2&#34;> <!--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=&#34;UPGRADE&#34; Manager=&#34;BUILDER&#34;/> <!--This is to tell the AI how to use the Ugrade, these are the best settings, and is used for all purchased RA3 upgrades-->
	</LogicCommand>


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



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users