Jump to content
  • Advertisement
Sign in to follow this  

Flexible upgrades system for an RTS?

This topic is 2223 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone!

I'm trying to come up with a nice and flexible way to manage upgrades in my RTS. There are multiple races with different units and buildings, as well as different upgrades. Each upgrade can modify one or more attribute (cost, range, attack speed, damage, ..) on one or more unit/building type. There can also be unit type groups (cavalery, ranged, ..). The game shall be moddable, so modders should be able to add new units and buildings which should work with these upgrades.

Players can form teams which may share upgrades.

Example upgrades:

  • Horse Armors: Cavalery +10% armor
  • Military training: All Units +20% damage, Recruit Time +10%
  • Sharp Arrows: Archer +15% damage

    I though about using some form of tree:


[indent=1]Armor/Units/Cavalery/*: +15%


[indent=1]Damage/Units/*: +20%

[indent=1]RecruitTime/Units/*: +10%


[indent=1]Damage/Units/Ranged/Archer: +15%

Each player would then store his tree of upgrades and whenever a stat was needed, the tree would be traversed and any upgrades encountered would be applied. I see a few problems with this. First, there'll be ALOT of upgrade tree traversal. Second, what about Cavalery Archers?

How would you structure it?

Share this post

Link to post
Share on other sites
I always found that Blizzard's World Editor (the Editor for Warcraft 3) handled upgrades very well. Each upgrade was able to change various properties of a unit, as well has enable / disable abilities. This system was pretty flexible.

One upgrade could be attached to more than one unit class. The upgrade had no idea which units it was affecting. it would just act on the "object". It was the unit's responsibility to list which upgrades it required / used. Thus, a single upgrade could be used to improve multiple unit types, such as increasing the range of an archer as well as another ranged unit , much as you described.

for Cavalry Archers, they would list both the "archer" upgrade as well as the "cavalry" upgrade in their tech tree, thus allowing them to benefit from both of these. Warcraft 3 has ~20 baked upgrades which did most of what you wanted for a normal game mode (range, health, health regen, mana regen...). If you wanted custom upgrades, you could script them with the built in scripting language, JASS.

I found the system very elegant. I imagine it would be trivial to check if an upgrade has been researched or not, a simple hash based on it's name would suffice. I'm not really sure if this model appeals to you, but I encourage you to go ahead and give it a try :)

Share this post

Link to post
Share on other sites
I thought about that (letting units list which upgrades they are affected by) but I'm not really sold. In WC3 there's pretty few upgrades, usually 1-5 per unit/building with pretty low overlap. That won't really be the case in my game. I will have several (20+) upgrades which affect all units and/or all air units (for example). I'm currently thinking about letting all units define a list of 'groups' they belong to ('air', 'land', 'ranged', 'cavalery', 'melee', ..) and allow upgrades to specify a group of affected units.

Share this post

Link to post
Share on other sites
I personally think your trees are a bit shuffled. Beyond that, I think the basic idea would work readonably well:

[indent=1]# Upgrade All the units!


[indent=1]Units/*/Health: +10%

[indent=1]#Reinforce the castle walls w/ 5 dmg resist

[indent=1]Buildings/Castle/DmgResist: +5

[indent=1]#Archers get bracers:
[indent=1]Units/Ranged/Archer/*/Speed: +5%

[indent=1]#Only this one guy gets to fly
[indent=1]Units/Overpowered/"That One Guy"/Flight: =true

[indent=1]#Give the Town Center the ability to upgrade tech level
[indent=1]#Take away tech level 2 'cause that's where we are
[indent=1]Buildings/"Town Center"/Abilities: -TechLevel2, +TechLevel3

Of course you'll have to describe abilities separately...

Share this post

Link to post
Share on other sites
There was actually a reason for that shuffling even though it indeed felt slightly backwards/wierd. Wildcards are nice and easy to place in a resource file/config file/whatever file, but a bit nasty to work with while doing the lookups. With the wierd shuffled way, I could just traverse the tree from root to leaf and apply any found upgrades/values. If a leaf wasn't found, no harm was done. Adding wildcards to that mix makes the lookup much more complex, and I would probably need to store every combination of units/stats where I currently only need to store those actually used.

Share this post

Link to post
Share on other sites
The approach I've used is what I call delta mapping. When an upgrade is unlocked each unit or in your case unit template gets assigned that upgrade, and when making a call to get value for a unit I resolve its current value by taking the base value and apply any deltas that are applicable.

So one way it could work is that you have
Horse Archer -> Types {Unit,Archer,Cavalry}
Calvary -> Upgrades {Horse Armor}
Archer -> Upgrades {Sharp Arrows}

When getting the armor value for a horse archer it would apply any bonuses to armor available to units, archers, and cavalry and then return the final value.

Share this post

Link to post
Share on other sites
Sign in to follow this  


Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!