So I know triggers with Unit takes damage can be a hit on performance, but is it very significant if you have a condition such as triggering unit has X behavior? If the trigger fires for all units but doesn't run it's actions for many of them does it make a big difference?
When you have a condition, the trigger still runs every time a unit takes damage, but it just goes through a condition check, which actually makes the hit on performance more significance as SC2 has to check one more thing.
It shouldn't be that bad though, unless the map is very large and there's always action going on
Ummm, can't you do a mana shield using a damage response modifier in the data editor?
Something like restoring all the health damage taken from the attack and convert that to energy loss...
EDIT: Ah, just jumped over to data and I see the problem. I need some time to brainstorm on this. It should definitely be possible with triggers without using that "Unit Takes Damage" event.
Here's one idea. Create one trigger using the event "unit uses ability - Mana Shield Activate." Within this trigger, store the unit in a unit variable ("Mana_Shield_Unit") and the unit's HP (or shields or whatever) in a real variable called "Initial HP." Then run another trigger using a while loop, constantly checking the condition "unit has behavior - mana shield." If true, check if the unit's current HP < Initial HP. If true, subtract (Initial HP - current HP) from the unit's energy, then set current hp = Initial HP.
This will encounter problems if the unit heals itself, or if it takes more damage than what it has energy to absorb, but these can perhaps be mitigated with some clever conditional branches and variable changes. Switching from shields to HP could also be problematic.
Wouldn't that be even worse performance, particularly if a large number of units have the buff?
I'm wondering just how much performance impact it would have if your conditions are strict, even using Unit takes damage.. It's not normally an issue on my computer, but lower specs it might.
aslong as your trigger is straight forward, direct, short, simple, it will be fine.
for a long time i freaked out about performance on triggers like this. but aslong as you dont have any loops or large checks/conditions it's fine.
Most of your performance loss will come from events. For some reason, events hog up system resources a lot more than almost anything else (except for very LARGE loops and, of course, nested loops.) This is why I try and avoid using a lot of events by combining triggers and using branching conditions. I also completely avoid periodic events except in special circumstances.
I'm not sure what you mean about the buff. I thought your mana shield ability applied a buff upon use. From my experience, the only buffs that seem to cause significant drops in performance when used on a large quantity of units are pathing buffs (critter movement) and buffs that frequently cause search effects.
Don't worry I've given up on this for the time being, it's not really possible even with triggers without tracking things like the health of each unit constantly.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
So I know triggers with Unit takes damage can be a hit on performance, but is it very significant if you have a condition such as triggering unit has X behavior? If the trigger fires for all units but doesn't run it's actions for many of them does it make a big difference?
When you have a condition, the trigger still runs every time a unit takes damage, but it just goes through a condition check, which actually makes the hit on performance more significance as SC2 has to check one more thing.
It shouldn't be that bad though, unless the map is very large and there's always action going on
On average we are probably talking 50 vs 50 units constantly battling.
I wonder which conditions are quicker to check than others, such as check if a unit has a behavior vs check if a unit has a custom value
@KratsAU: Go
My suggestion is to do it in a way that's easy first; then if you notice it's bad online then think of more efficient ways (if they even exist).
Yeah might do that. Can't beleive you can't do a 1:1 mana shield without triggers. Makes me sad :(
Ummm, can't you do a mana shield using a damage response modifier in the data editor?
Something like restoring all the health damage taken from the attack and convert that to energy loss...
EDIT: Ah, just jumped over to data and I see the problem. I need some time to brainstorm on this. It should definitely be possible with triggers without using that "Unit Takes Damage" event.
Here's one idea. Create one trigger using the event "unit uses ability - Mana Shield Activate." Within this trigger, store the unit in a unit variable ("Mana_Shield_Unit") and the unit's HP (or shields or whatever) in a real variable called "Initial HP." Then run another trigger using a while loop, constantly checking the condition "unit has behavior - mana shield." If true, check if the unit's current HP < Initial HP. If true, subtract (Initial HP - current HP) from the unit's energy, then set current hp = Initial HP.
This will encounter problems if the unit heals itself, or if it takes more damage than what it has energy to absorb, but these can perhaps be mitigated with some clever conditional branches and variable changes. Switching from shields to HP could also be problematic.
Wouldn't that be even worse performance, particularly if a large number of units have the buff?
I'm wondering just how much performance impact it would have if your conditions are strict, even using Unit takes damage.. It's not normally an issue on my computer, but lower specs it might.
@KratsAU: Go
Most of your performance loss will come from events. For some reason, events hog up system resources a lot more than almost anything else (except for very LARGE loops and, of course, nested loops.) This is why I try and avoid using a lot of events by combining triggers and using branching conditions. I also completely avoid periodic events except in special circumstances.
I'm not sure what you mean about the buff. I thought your mana shield ability applied a buff upon use. From my experience, the only buffs that seem to cause significant drops in performance when used on a large quantity of units are pathing buffs (critter movement) and buffs that frequently cause search effects.
Don't worry I've given up on this for the time being, it's not really possible even with triggers without tracking things like the health of each unit constantly.