Author Topic: [Too Hard?] Upgrades: Effecting Multiple Units Overwrites  (Read 1886 times)

ChupaReaper

  • Guest
Using the new <enhancements> feature I discovered a problem where if you refer to a unit in one <enhancement> and then again in another, the last <enhancement> read will only be applied. For example:
Code: [Select]
<enhancements>
<enhancement>
<affects>
<unit name="werewolf"/>
<unit name="werewolf_ravager"/>
<unit name="werewolf_reaper"/>
</affects>
<effects>
<static-modifiers>
<move-speed value="20"/>
</static-modifiers>
</effects>
</enhancement>
<enhancement>
<affects>
<unit name="werewolf_ravager"/>
</affects>
<effects>
<static-modifiers>
<attack-speed value="20"/>
</static-modifiers>
</effects>
</enhancement>
<enhancement>
<affects>
<unit name="werewolf_reaper"/>
</affects>
<effects>
<static-modifiers>
<attack-strength value="20"/>
</static-modifiers>
</effects>
</enhancement>
</enhancements>
In the xml above, all three werewolf units should get +20 to their move speed, then ravagers will also get +20 attack speed and reapers +20 attack damage. This is not the case however as ravagers only get their attack speed and reapers only get their attack damage where as the standard werewolves get the movement speed. To me it looks like its applying the upgrade to all three units, then overwriting the ravager upgrade with a new one and then the same with the reaper.

This xml fixes the problem:
Code: [Select]
<enhancements>
<enhancement>
<affects>
<unit name="werewolf"/>
</affects>
<effects>
<static-modifiers>
<move-speed value="20"/>
</static-modifiers>
</effects>
</enhancement>
<enhancement>
<affects>
<unit name="werewolf_ravager"/>
</affects>
<effects>
<static-modifiers>
<move-speed value="20"/>
<attack-speed value="20"/>
</static-modifiers>
</effects>
</enhancement>
<enhancement>
<affects>
<unit name="werewolf_reaper"/>
</affects>
<effects>
<static-modifiers>
<move-speed value="20"/>
<attack-strength value="20"/>
</static-modifiers>
</effects>
</enhancement>
</enhancements>
With this, I have instead defined the upgrade for each unit separately.

I'm not sure if this is a bug or intentional as it could be quite useful for large upgrades to have enhancements that overwrite previous enhancements. Perhaps add a flag of some kind like: <enhancement overwrite="true">

Edit by Omega: Renamed thread "[To Hard?]" -> "[Too Hard?]" (hurt my eyes)
« Last Edit: 24 June 2012, 20:08:33 by Omega »

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Upgrades: Effecting Multiple Units Overwrites
« Reply #1 on: 6 March 2012, 00:12:13 »
I think that if a value were to control how different enchantments applied to the same unit act were to be implemented, we'd still at least need a default of trying to "merge" the effects. In this case, the ravager would receive both the attack-speed and move-speed boosts, since they're for entirely different attributes. And in the case of the same attribute, the higher value should triumph.
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

ChupaReaper

  • Guest
Re: Upgrades: Effecting Multiple Units Overwrites
« Reply #2 on: 7 March 2012, 00:44:26 »
I think that if a value were to control how different enchantments applied to the same unit act were to be implemented, we'd still at least need a default of trying to "merge" the effects. In this case, the ravager would receive both the attack-speed and move-speed boosts, since they're for entirely different attributes. And in the case of the same attribute, the higher value should triumph.
Sounds good to me. So a default of merging all enhancements overwriting with the highest value for duplicates, what about an option to merge and add duplicates together and also an option to overwrite all upgrades completely?
I would use the merge and add option for upgrades that effect a lot of units, but for one unit that I don't want say a speed boost, I'd add a negative value to cancel the enhancement out, though that could be messy and inefficient.
The default of merge and overwrite with the highest value is best.

silnarm

  • Local Moderator
  • Behemoth
  • ********
  • Posts: 1,373
    • View Profile
Re: Upgrades: Effecting Multiple Units Overwrites
« Reply #3 on: 24 June 2012, 07:22:59 »
I'm gonna have to throw this on in the to hard basket for now, not that it would be hard to code as such, but because it would be 'finicky' and need a bunch of testing time...

whine some more if you really want it, and it will get done (...eventually), for now you'll have to just specify everything by unit if you need to get that complicated, sorry :'(.
Glest Advanced Engine - Code Monkey

Timeline | Downloads