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][HorseArmors]
[indent=1]Armor/Units/Cavalery/*: +15%
[indent=1][MilitaryTraining]
[indent=1]Damage/Units/*: +20%
[indent=1]RecruitTime/Units/*: +10%
[indent=1][SharpArrows]
[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?