Author Topic: [fixed] Improper handeling of Multiple Attack Boosts  (Read 1470 times)

Ishmaru

  • Behemoth
  • *******
  • Posts: 1,071
  • um wat??
    • View Profile
    • DelphaDesign
Hello, While experimenting with the tag:
Code: [Select]
<allow-multiple-boosts value="true" />Gives undesired and counter intuitive effects.

For example: 2 units emitting a boost of production speed +100 should give a reviving unit +200 production speed, however this is not true instead it gives reviving unit +3400 production speed.

I should note that one single boost does give the proper boost effect.

This is the exact code from unit xml:

Code: [Select]
<attack-boosts>
<attack-boost name="energy">
<allow-multiple-boosts value="true" />
<radius value="9" />
<target value="ally"/>
<max-hp value="0" />
<max-ep value="0" regeneration="1"/>
<sight value="0" />
<attack-strenght value="0"/>
<attack-range value="0" />
<armor value="0" />
<move-speed value="0"/>
<production-speed value="100" />
<particles value="true">
<affected-particle-file path="power.xml"/>
</particles>
</attack-boost>
</attack-boosts>
« Last Edit: 19 December 2014, 23:26:32 by titi »
Annex: Conquer the World Release 4 For Pc Mac + Linux
https://forum.megaglest.org/index.php?topic=9570.0
Annex is now on Facebook!
https://www.facebook.com/AnnexConquer

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: Improper handeling of Multiple Attack Boosts
« Reply #1 on: 20 November 2014, 21:35:27 »
The multiple flag is not intended to determine whether or not a boost can work from multiple sources, but rather if 1 units boost can be applied multiple times. It sounds to me that these two units are both applying the boost multiple times, turning off the multiple flag would still allow both units to apply their boost the reviving unit.

Thanks

Ishmaru

  • Behemoth
  • *******
  • Posts: 1,071
  • um wat??
    • View Profile
    • DelphaDesign
Re: Improper handeling of Multiple Attack Boosts
« Reply #2 on: 23 November 2014, 17:49:34 »
Thanks for responding.

However, why is it multiplying by so much? What is the logic that makes having 2 boosting units have X34 and not X2. That's what I don't understand.

Would it be possible to correct this behavior?
Annex: Conquer the World Release 4 For Pc Mac + Linux
https://forum.megaglest.org/index.php?topic=9570.0
Annex is now on Facebook!
https://www.facebook.com/AnnexConquer

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Re: Improper handeling of Multiple Attack Boosts
« Reply #3 on: 24 November 2014, 03:34:09 »
I want this renaming thing to take off, so I'm gonna call them auras instead of attack boosts.

I can confirm that Softcoder is correct (I had to do a double take on that description).

The relevant part of the code is:

Code: [Select]
if(boost->allowMultipleBoosts == false) {
// Check if we already have this boost from this unit type and multiples
// are not allowed
bool alreadyHasAttackBoost = this->unitHasAttackBoost(boost, source);
if(alreadyHasAttackBoost == true) {
shouldApplyAttackBoost = false;
}
}

As we can see, the only thing this variable does is prevent repeated application of the same boost to a unit. Since this check can happen many times per second, the effect quickly piles up and the current way that boosts are applied do not allow a maximum to be specified.

So it may not be a bug in the traditional sense, but I believe this is a serious design bug. As Ishmaru states, there's pretty much no reason for this behavior. I cannot think of a positive way to use this (since anyone receiving the boost will have their stats boosted to infinity). I think it should be changed to:

  • Off: Users can receive a single aura from each unit of each type. For example, if the castle has an aura and a unit is near 2 castles, it should only get the boost from a single castle (doesn't matter which since the boosts are the same, but we should assume that in the future, it may be possible for the same units to have different boost; consider the possible feature of upgrades that boost auras).
  • On: Users can receive an aura from each unit nearby. So if castles have an aura and a unit is near 2 castles, they should receive twice the effects of the castle's aura.

This has a clear and obvious use case: we could have healer units that heal nearby units. More healer units let you heal faster (probably shouldn't be able to heal themselves to prevent abuse). Or powerful generals that enhance their allies stats and more generals mean more stat boosts (but these units are limited enough to not be abuseable).

As an aside, a potential future feature request that may be of use would be the ability to provide maximum and minimum boosts. This would make it easier to prevent abuse of stacking attack boosts. For example, maybe a common enemy reduces enemy attack by 1%. This stacks with the number of this unit up to a minimum penalty of -10%. It makes it useful to have many of these units without allowing that ability to be abused (of course, an alternative is to just limit the range so that you can't have too many in the area of affect -- this limitation makes the above mentioned feature request very low priority).
Edit the MegaGlest wiki: http://docs.megaglest.org/

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

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: Improper handeling of Multiple Attack Boosts
« Reply #4 on: 24 November 2014, 20:55:48 »
I cannot reproduce this problem here. I tested with a boost of armor and a boost of hp, but I saw no such effect.
Is this related to production-speed boosting somehow ?

update:
I cannot reproduce this with production-speed, neither with git or 3.9.1.   Did you test with 3.9.1 or later ishmaru ?
« Last Edit: 24 November 2014, 21:39:27 by titi »
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: Improper handeling of Multiple Attack Boosts
« Reply #5 on: 19 December 2014, 13:21:02 »
OK, I was able to reproduce this now and I already know whats wrong. Its related to units with a size>1. For every field of the unit the effect is done again. So if you have a 4x4 unit like a building you get 16 times the effect on this unit if it is completly in the boost range. This is obviously a bug and I already found the related lines in the code.  I will try to fix it this evening.
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

titi

  • MegaGlest Team
  • Airship
  • ********
  • Posts: 4,240
    • View Profile
    • http://www.titusgames.de
Re: Improper handeling of Multiple Attack Boosts
« Reply #6 on: 19 December 2014, 23:26:03 »
this is fixed now in revision d34e58ccb64c1f4bfe9bda021d5e7b419c76b045 from Dec 15, 2014 please try it.
( this version is no longer beta compatible )
« Last Edit: 19 December 2014, 23:50:03 by titi »
Try Megaglest! Improved Engine / New factions / New tilesets / New maps / New scenarios

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: [fixed please test] Improper handeling of Multiple Attack Boosts
« Reply #7 on: 21 December 2014, 00:39:46 »
Furthermore, attack boosts messed up existing unit upgrades, and did not properly aggregate or remove the boost afterwards. This is now fixed in git.