I want to create an effect that adds +2 to a units max vital health / shields every second for 20 seconds.
I don't want to use behavior stacks because I'm concerned about having too many stacks on one unit. The unit will use this ability alot during the game to give itself increased max health. (NOT HEALING HEALTH) Imagine using the ability 20 or 30 times in a game and having a ridiculous amount of behavior stacks which could bog down the game or hit certain limits on how many behaviors a unit can have. I can't have that. After the unit dies however, its max health will default back to normal upon respawn. Triggers would be an easy method as I could simply modify the units max health on a repeat action which occurs 20 times. This would prevent crazy stacking behaviors, but could create lag running so many actions every time its used.
I want a clean Data solution.
My original thought was to use a 20 second duration behavior with a 1 second periodic effect using the "modify unit" effect. I was shut down when I noticed I cannot modify the units max vital using "modify unit".
Unless I have missed something or am mistaken, would appreciate any help or ideas.
Stacking a buff many times won't lag your game inherently. If all the buff does is raise max vitals it should be fine to go up to near the max stack count, which is about 65535 or so. Alternatively you could use the trigger editor's set unit property function.
Thanks for the info. Yeah I use buff stacks alot but I was scared of what it might do considering each stack is going to raise the max vital by 1 hp. Which means its going to have ALOT ALOT of stacks over time!
If the vital per stack is 1, and the limit to the units bonus is 500, thats 500 buff stacks. However, I got more creative in my thinking and wanted to do a percentage of the targets health rather then just a flat amount so I used triggers and data combined (with some clever manipulating of decimal points) to create a system where it increased the max vital every second based on percentage of the targets health. Problem was, (and was not the trigger part) but the buff stacks do lag the game, even if they are just max vitals. I maxed out the buff stacks for both life and shields to 60,000. Game was completely unplayable. Once I killed the unit, lag was gone!
So lesson for me and hopefully for others is this: Buff Stacks WILL lag the game if you start to get into the thousands. Even if its only on a single unit., regardless of your triggers.
Seems to me that in this case, triggers is actually a much cleaner solution because it modifies your unit with 0 stacks or upgrades and you have all the temporary modifications you need. To limit the HP you simple set a unit property condition into the trigger. Then set a while behavior is on every second modify max vital based on % of target max vital.
You could use a Modify Player effect to modify the catalog for the unit but that would affect all instances of that unit.
Last I checked it was much worse to modify data than it was to use buffs due to a resource leak. Each time data is modified it made a duplicate of that data leaving the previous copy in memory, unused. Thanks to efficient algorithms it did not slow the game down but it did mean exiting the game could take several minutes due to some inefficiency with freeing the extra allocated copies. Additionally if several million such modifications were made it is possible some clients may crash due to out of memory errors.
I recommend looking at how Rexar does this for his one trait in Heroes of the Storm. He might use a method compatible with Heroes of the Storm. I suspect it was done with stacking buffs.