Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Flexible upgrades system for an RTS?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 DvDmanDT   Members   -  Reputation: 280

Like
0Likes
Like

Posted 16 June 2012 - 02:00 AM

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:

[HorseArmors]

Armor/Units/Cavalery/*: +15%


[MilitaryTraining]

Damage/Units/*: +20%

RecruitTime/Units/*: +10%


[SharpArrows]

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?

Sponsor:

#2 bollµ   Members   -  Reputation: 347

Like
0Likes
Like

Posted 17 June 2012 - 08:28 AM

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

a WIP 2d game engine: https://code.google.com/p/modulusengine/

English is not my first language, so do feel free to correct me :)


#3 DvDmanDT   Members   -  Reputation: 280

Like
0Likes
Like

Posted 18 June 2012 - 11:57 AM

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.

#4 Firestryke31   Members   -  Reputation: 350

Like
0Likes
Like

Posted 18 June 2012 - 04:02 PM

I personally think your trees are a bit shuffled. Beyond that, I think the basic idea would work readonably well:

# Upgrade All the units!

[YayHealth]

Units/*/Health: +10%


#Reinforce the castle walls w/ 5 dmg resist

[Architecture]

Buildings/Castle/DmgResist: +5


#Archers get bracers:

[ArcherBracers]

Units/Ranged/Archer/*/Speed: +5%


#Only this one guy gets to fly

[OPguyIsEvenBetter]

Units/Overpowered/"That One Guy"/Flight: =true


#Give the Town Center the ability to upgrade tech level

#Take away tech level 2 'cause that's where we are

[UpgradeToTL3]

Buildings/"Town Center"/Abilities: -TechLevel2, +TechLevel3


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

#5 DvDmanDT   Members   -  Reputation: 280

Like
0Likes
Like

Posted 18 June 2012 - 05:01 PM

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.

#6 TechnoGoth   Members   -  Reputation: 1103

Like
0Likes
Like

Posted 19 June 2012 - 06:25 AM

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.

"Fate and Destiny only give you the opportunity, the rest you have to do on your own."
"The people who don't enjoy life are the ones who don't get the joke."

 

The Aspiring Writer

Current Projects: Day 0 -prototype post apocalyptic survival game - Design V2
Upcoming Projects: Sanctuary Zero - post apocalyptic survival game - Design V2

Non Game Projects:

 





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS