Hello there
I'll just go straight to the problem.
I want my trigger to run whenever a unit loses energy. Therefore I've written a unit property change trigger, set property to energy and in conditions I've set triggering property change < 0
That works just fine, but then in the trigger debugger I noticed that the trigger runs like bagilion times and fails due to conditions for like 90%+ of that time.
Figured out that it's because of energy regen on my unit and tried to do something about it but couldn't make it work without turning regen to 0.
Sooo... Is there a way to make it work? I really need to store amount of energy that unit uses
Depending on the application, a periodic check on the unit itself would do the trick. You can specify the accuracy yourself (if you run it at 16 FPS you should be just as accurate as your current trigger but probably still need way less actions; if you encounter problems you can easily set it to like 4 times per second; should not matter that much depending on your application)
Another way would be keeping track of all skills and get their mana costs; this could become quite an amount of work, though.
I found that when you try to use energy change as an event it fires extremely fast because the game is seemingly adding energy every game cycle or so in tiny increments rather than once every second. If you have a lot of units with energy then you're going to be calling that trigger several times per second per unit.
For my map no units actually use energy and I just wanted to use their natural energy regen as a timer to activate other things without having to create triggers to control it. So what I did was set the event to "percent energy", and jacked up their energy to 1,000. That way it only triggers every time they reach a multiple of 10 energy, and I adjust that with their regen rate.
Doesn't do much to fix your problem, but that seems to be the root cause of why your trigger went crazy. You could potentially still use percent energy to do what you want since everytime a spell is cast it will change the energy by a large percent. However, it will still likely cause some decent overhead with many units.
Hello there I'll just go straight to the problem. I want my trigger to run whenever a unit loses energy. Therefore I've written a unit property change trigger, set property to energy and in conditions I've set triggering property change < 0 That works just fine, but then in the trigger debugger I noticed that the trigger runs like bagilion times and fails due to conditions for like 90%+ of that time. Figured out that it's because of energy regen on my unit and tried to do something about it but couldn't make it work without turning regen to 0.
Sooo... Is there a way to make it work? I really need to store amount of energy that unit uses
Regards Sigma
Depending on the application, a periodic check on the unit itself would do the trick. You can specify the accuracy yourself (if you run it at 16 FPS you should be just as accurate as your current trigger but probably still need way less actions; if you encounter problems you can easily set it to like 4 times per second; should not matter that much depending on your application)
Another way would be keeping track of all skills and get their mana costs; this could become quite an amount of work, though.
Thanks a lot, periodic check worked. And yeah I was trying to avoid tracking all the spells and their mana cost
@sigmapl: Go
I found that when you try to use energy change as an event it fires extremely fast because the game is seemingly adding energy every game cycle or so in tiny increments rather than once every second. If you have a lot of units with energy then you're going to be calling that trigger several times per second per unit.
For my map no units actually use energy and I just wanted to use their natural energy regen as a timer to activate other things without having to create triggers to control it. So what I did was set the event to "percent energy", and jacked up their energy to 1,000. That way it only triggers every time they reach a multiple of 10 energy, and I adjust that with their regen rate.
Doesn't do much to fix your problem, but that seems to be the root cause of why your trigger went crazy. You could potentially still use percent energy to do what you want since everytime a spell is cast it will change the energy by a large percent. However, it will still likely cause some decent overhead with many units.