Let's say I want to give the player some minerals every 60 seconds a unit is alive. Let's say the unit amount is rather high: 200 units. I see two ways how to do this through triggers.
(1) I can create a repeating 60 seconds timer for each unit when they are created and make the unit keep track which timer it has. It'll add the minerals when the timer expires.
(2) I can also create one repeating 0.1 seconds timer and add units to it that track their time and give them a starting time so you can correct them for starting somewhere between and update.
I could do this specific example through the data editor, but I'd like to know how to do this through triggers for different cases.
Now I wondered what would be the best way to do this and what the reason behind it is. I know this alone might not have so much impact but I think things will stack up with what I'm creating.
Could also use a behavior that lasts 60 seconds for every unit. Once it expires, catch the event via triggers and add minerals, then re-add the behavior to the triggering unit.
Give each unit a Buff Behaviour that has a period of 60 seconds and uses a Modify Player effect in the Effect: Effect - Period field that adds minerals to the owning player.
I tried what Mille suggested and it works really well! I hadn't thought about that hybrid solution yet. I guess if I want the time to be variable I can just do SetUnitBehaviorDuration after I have addded the behavior. So basically I should try to stay away from triggers whenever possible if I want the most performant result?
Thanks for pointing out how to add minerals through a behavior spool, generally I'll have to do the "effect" through triggers though because the data editor just doesn't allow me to give variable outcomes based on variables from the trigger editor.
So basically I should try to stay away from triggers whenever possible if I want the most performant result?
Not necessarily. The best advice would be to do it whatever makes it the most easy for you and makes the most sense.
For example, linking script timers to units is way more difficult than just using a behavior, even though it is actually possible by using data tables and unit tags and other approaches.
One disadvantage of mixing code and data is that it often gets difficult to understand how a system as a whole works together, especially when not looking at that part of code for a couple weeks. Another thing i really dislike about data in general is the fact that it is pretty hard to stay organized and clean.
Hello Everyone,
Let's say I want to give the player some minerals every 60 seconds a unit is alive. Let's say the unit amount is rather high: 200 units. I see two ways how to do this through triggers.
(1) I can create a repeating 60 seconds timer for each unit when they are created and make the unit keep track which timer it has. It'll add the minerals when the timer expires. (2) I can also create one repeating 0.1 seconds timer and add units to it that track their time and give them a starting time so you can correct them for starting somewhere between and update. I could do this specific example through the data editor, but I'd like to know how to do this through triggers for different cases.
Now I wondered what would be the best way to do this and what the reason behind it is. I know this alone might not have so much impact but I think things will stack up with what I'm creating.
Could also use a behavior that lasts 60 seconds for every unit. Once it expires, catch the event via triggers and add minerals, then re-add the behavior to the triggering unit.
Give each unit a Buff Behaviour that has a period of 60 seconds and uses a Modify Player effect in the Effect: Effect - Period field that adds minerals to the owning player.
Thanks for your advises!
I tried what Mille suggested and it works really well! I hadn't thought about that hybrid solution yet. I guess if I want the time to be variable I can just do SetUnitBehaviorDuration after I have addded the behavior. So basically I should try to stay away from triggers whenever possible if I want the most performant result?
Thanks for pointing out how to add minerals through a behavior spool, generally I'll have to do the "effect" through triggers though because the data editor just doesn't allow me to give variable outcomes based on variables from the trigger editor.
Not necessarily. The best advice would be to do it whatever makes it the most easy for you and makes the most sense.
For example, linking script timers to units is way more difficult than just using a behavior, even though it is actually possible by using data tables and unit tags and other approaches.
One disadvantage of mixing code and data is that it often gets difficult to understand how a system as a whole works together, especially when not looking at that part of code for a couple weeks. Another thing i really dislike about data in general is the fact that it is pretty hard to stay organized and clean.