I made a custom armor system for my map. It uses the Warcraft 3 template, so it's working with damage reduction in % instead of an absolute value per armor point.
For it to work, I've built a trigger that checks on each units' armor value and allocates behaviors (buffs, damage response modification) accordingly.
In some custom armor thread, I've read about it not being recommended using more than 256 behaviors simultaneously. Problem is, each unit gets 1 behavior according to the specific armor value, but it's possible (not frequently the case, but possible) that there are up to one thousand units on the map. So there can be up to one thousand behaviors in game, instead at 256. When a certain number of units is living, the game starts to lag, just what I expected.
But how can I get this armor system to work when I cannot use buffs for that purpose (because the performance crashes down)?
The 256 refers to stacks of the same behavior, the amount of different behaviors per unit is capped at 64, I believe.
I realized a WC3 armor system before, using one behavior with 200 stacks and triggers to apply the appropriate amount of stacks depending on the amount of armor, but the latest patch changed, how damage reduction by behavior damage responses get calculated, so my system is not functioning anymore and needs some changes ;)
However, if you don't need the exact formula from WC3, you can just use a stacking behavior, which reduces the damage by 6% or something, the new calculation will cause the damage reduction to never pass 100%.
Thing is, there is only one behavior active for each unit. All units start with no behaviors. Then, if they have more than 0 armor, a trigger determines (out of like 45 behaviors) the right one that fits to the specific armor value of that unit type. So the trigger finally adds the behavior to the unit, and removes all other behaviors (in the case there are old ones still active).
Each unit, therefore, has one behavior at maximum. Normally you use this system with heroes, and there aren't hundreds of heroes running around, so it doesn't really matter. But I use this system for all units, and just as I experienced, too many units with 1 behavior each slow down the game. Even if I misunderstood the thing with the 256 stacks, it's lagging like this.
So how can I change it to run smoothly? A trigger-only solution would also work, it doesn't really matter to me, but I don't know how to approach this one.
Actually I have a 5 secs periodic event running that checks on the armor value atm. I wanted to replace it by triggers that run when upgrading armor, or when a new unit comes into play.
Actually I have a 5 secs periodic event running that checks on the armor value atm. I wanted to replace it by triggers that run when upgrading armor, or when a new unit comes into play.
How can you be sure its not the units or your video card...
If you were able to show us any triggers involved in your map.....
are you testing with debug window open?
if you want I could look at your map if you host it.....
games get laggy as they go on when you have a lot of units spawning and dying.......
Also, do you need the exact WC3 formula? Otherwise, you could make use of the new stacking mechanisms and just use one single stacking behavior.
If you would use a behavior with, lets say, 4% damage reduction per stack, your total damage reduction would be calculated with:
DR = 1 - 0.96 ^ Armor
as opposed to:
DR = (x*0.06)/(0.06*x+1)
which is the original WC3 formula. If we compare both of them, we get this picture:
Of course, it is a little off, but it would be very easy to realize, only one behavior with as many stacks as the maximum amount of armor, and without any trigger usage at all.
Also, it matches quite well for the first 15 to 20 points of armor, which is the most relevant area for most maps anyway.
Honestly, I don't even know about the debug window. Where can I activate it?
I'm 100% sure it's neither the units' nor the video cards' fault. I tested out various things to be absolutely sure it's a result of those behaviors. For example: I watched the replay again and didn't have any lags, it was absolutely lag free, but I had them when I was playing. Additionally, I tested out a much more complex scenario with twice as many units and effects, and it ran perfectly.
Maybe I got a clue about how to solve this. Seems like something was broken with the remove of the "old" behavior when a new one is added, so there were way more behaviors in game than normally. Like about 2000... this is a legitimate reason to have lags I think. I'm having this fixed now and then I'm going to report if it was successful.
This sounds really well-suited for my map. So basically it's okay to have hundreds of units and a dozen times stacking behavior on each? It sounds awfully cruel for me, but if you say it works performance-wise, then I'd definitely give it a shot.
Apart from that, how would I approach this? I've never worked with behaviors very much and don't know how to stack them either. Let's say I want a unit type to make use of this new stacking mechanism, what am I to do first? How would the behavior look like?
This sounds really well-suited for my map. So basically it's okay to have hundreds of units and a dozen times stacking behavior on each? It sounds awfully cruel for me, but if you say it works performance-wise, then I'd definitely give it a shot.
From my own tests, SC2 can support a crapton of behaviors on different units without any performance issues (same for effects and stuff). Only too many stacks (<=256 is usually recommended) cause noticeable lag; but as you can see in the graph, for about 50 stacks we are nearing 90% damage reduction, so we wouldn't go that much higher anyway.
You can easily test this as well. You can just place a huge amount of units, then apply something like 50 stacks of the same behavior to all units on the map and see, how it affects performance.
Quote:
Apart from that, how would I approach this? I've never worked with behaviors very much and don't know how to stack them either. Let's say I want a unit type to make use of this new stacking mechanism, what am I to do first? How would the behavior look like?
You create a new damage reducing behavior as usual, using the damage response. Then you set the Maximum Stack Count to your desired maximum amount of armor. Stacking is done, by applying the behavior multiple times, either via trigger, or with an Apply Behavior effect, which can specify an amount of stacks to be applied. Same goes for a Remove Behavior effect, which can remove specific amounts.
How you handle the system in detail is up to you. You can use triggers to always apply the correct amount of charges. You can also do this in data; for example, when creating a temporary armor buff, you create a dummy buff, which increases life armor by 5 (all damage effects should be set to not be affected by the default armor, of course) and which initially applies 5 stacks of the armor buff and removes 5 stacks when expiring.
Thanks very much, I'm going to try this out! One question left: how would I set the damage response options in order to get it working according to the formula you posted? How can I use this formula to begin with? (4% reduction each stack would mean it's a linear progression, not a degressive) Or does the second stack affect also the first stack of the behavior, and not only the basis value? And of course the third then affects the second and first and basis value so it'd be according to your formula...
You can easily test this as well. You can just place a huge amount of units, then apply something like 50 stacks of the same behavior to all units on the map and see, how it affects performance.
I made a custom armor system for my map. It uses the Warcraft 3 template, so it's working with damage reduction in % instead of an absolute value per armor point.
For it to work, I've built a trigger that checks on each units' armor value and allocates behaviors (buffs, damage response modification) accordingly.
In some custom armor thread, I've read about it not being recommended using more than 256 behaviors simultaneously. Problem is, each unit gets 1 behavior according to the specific armor value, but it's possible (not frequently the case, but possible) that there are up to one thousand units on the map. So there can be up to one thousand behaviors in game, instead at 256. When a certain number of units is living, the game starts to lag, just what I expected.
But how can I get this armor system to work when I cannot use buffs for that purpose (because the performance crashes down)?
The 256 refers to stacks of the same behavior, the amount of different behaviors per unit is capped at 64, I believe.
I realized a WC3 armor system before, using one behavior with 200 stacks and triggers to apply the appropriate amount of stacks depending on the amount of armor, but the latest patch changed, how damage reduction by behavior damage responses get calculated, so my system is not functioning anymore and needs some changes ;)
However, if you don't need the exact formula from WC3, you can just use a stacking behavior, which reduces the damage by 6% or something, the new calculation will cause the damage reduction to never pass 100%.
@Kueken531: Go
Thing is, there is only one behavior active for each unit. All units start with no behaviors. Then, if they have more than 0 armor, a trigger determines (out of like 45 behaviors) the right one that fits to the specific armor value of that unit type. So the trigger finally adds the behavior to the unit, and removes all other behaviors (in the case there are old ones still active).
Each unit, therefore, has one behavior at maximum. Normally you use this system with heroes, and there aren't hundreds of heroes running around, so it doesn't really matter. But I use this system for all units, and just as I experienced, too many units with 1 behavior each slow down the game. Even if I misunderstood the thing with the 256 stacks, it's lagging like this.
So how can I change it to run smoothly? A trigger-only solution would also work, it doesn't really matter to me, but I don't know how to approach this one.
@Ranuglin: Go
im pretty sure its not your behaviors lagging....
its prolly your units....
and when you say "lag" what are you actually experiencing?
As SouLCarverRR said, it's not the behaviors themselves lagging.
It might be the units themselves, or make sure you aren't doing something like updating the behavior armor type of all units every X seconds.
@SouLCarveRR: Go
It's definitely not the units, because I haven't changed anything to the numbers of units in game and it worked perfectly before.
@StragusMapster: Go
Actually I have a 5 secs periodic event running that checks on the armor value atm. I wanted to replace it by triggers that run when upgrading armor, or when a new unit comes into play.
How can you be sure its not the units or your video card...
If you were able to show us any triggers involved in your map.....
are you testing with debug window open?
if you want I could look at your map if you host it.....
games get laggy as they go on when you have a lot of units spawning and dying.......
Also, do you need the exact WC3 formula? Otherwise, you could make use of the new stacking mechanisms and just use one single stacking behavior.
If you would use a behavior with, lets say, 4% damage reduction per stack, your total damage reduction would be calculated with:
DR = 1 - 0.96 ^ Armor
as opposed to:
DR = (x*0.06)/(0.06*x+1)
which is the original WC3 formula. If we compare both of them, we get this picture:
Of course, it is a little off, but it would be very easy to realize, only one behavior with as many stacks as the maximum amount of armor, and without any trigger usage at all.
Also, it matches quite well for the first 15 to 20 points of armor, which is the most relevant area for most maps anyway.
@SouLCarveRR: Go
Honestly, I don't even know about the debug window. Where can I activate it?
I'm 100% sure it's neither the units' nor the video cards' fault. I tested out various things to be absolutely sure it's a result of those behaviors. For example: I watched the replay again and didn't have any lags, it was absolutely lag free, but I had them when I was playing. Additionally, I tested out a much more complex scenario with twice as many units and effects, and it ran perfectly.
Maybe I got a clue about how to solve this. Seems like something was broken with the remove of the "old" behavior when a new one is added, so there were way more behaviors in game than normally. Like about 2000... this is a legitimate reason to have lags I think. I'm having this fixed now and then I'm going to report if it was successful.
@Kueken531: Go
This sounds really well-suited for my map. So basically it's okay to have hundreds of units and a dozen times stacking behavior on each? It sounds awfully cruel for me, but if you say it works performance-wise, then I'd definitely give it a shot.
Apart from that, how would I approach this? I've never worked with behaviors very much and don't know how to stack them either. Let's say I want a unit type to make use of this new stacking mechanism, what am I to do first? How would the behavior look like?
Thanks for your help so far!
From my own tests, SC2 can support a crapton of behaviors on different units without any performance issues (same for effects and stuff). Only too many stacks (<=256 is usually recommended) cause noticeable lag; but as you can see in the graph, for about 50 stacks we are nearing 90% damage reduction, so we wouldn't go that much higher anyway.
You can easily test this as well. You can just place a huge amount of units, then apply something like 50 stacks of the same behavior to all units on the map and see, how it affects performance.
You create a new damage reducing behavior as usual, using the damage response. Then you set the Maximum Stack Count to your desired maximum amount of armor. Stacking is done, by applying the behavior multiple times, either via trigger, or with an Apply Behavior effect, which can specify an amount of stacks to be applied. Same goes for a Remove Behavior effect, which can remove specific amounts.
How you handle the system in detail is up to you. You can use triggers to always apply the correct amount of charges. You can also do this in data; for example, when creating a temporary armor buff, you create a dummy buff, which increases life armor by 5 (all damage effects should be set to not be affected by the default armor, of course) and which initially applies 5 stacks of the armor buff and removes 5 stacks when expiring.
@Kueken531: Go
Thanks very much, I'm going to try this out! One question left: how would I set the damage response options in order to get it working according to the formula you posted? How can I use this formula to begin with? (4% reduction each stack would mean it's a linear progression, not a degressive) Or does the second stack affect also the first stack of the behavior, and not only the basis value? And of course the third then affects the second and first and basis value so it'd be according to your formula...
Ok, now I answered my own question :)
Exactly. Pre-Patch 1.4, the progression used to be linear, but now they changed it to work just the way you explained.
@Kueken531: Go
Works fine! Don't know about the lags though. But I believe in your opinion on that :)
:)