• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Usage of mana regen systems

Status
Not open for further replies.
Level 4
Joined
Jul 27, 2015
Messages
29
Hey folks!

In my map I track the remaining duration of summons through their mana bar. When they're created they get added to a group which is checked every second, units with 0 mana are killed.

I give them a duration using max/current mana, and give them -1.00 mana regen to tick the timer down.

This lets me manipulate the timers pretty bug free, adding/subtracting flat amounts of time without some annoying bugs I encountered using the summon timer (Including the ability to make stuff temporarily permanent!)

My questions are - Do you know how efficient it is to have the game cycling through the mana regen on all of these units itself?
A trigger which acts on every unit in the summon group every second, reducing their mana by 1 would still be fit for purpouse for my system, and I feel like it would be more resource efficient - does anyone know for sure?
How often does the engine update mana values from regen? Reason for my assumption above is that I assume it does it every .01 seconds :)

Thanks for reading!

-Sad
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
Using native regeneration is more efficient than using triggers. In most cases if you trigger something it gets less efficient.
Almost every unit in the game has health regeneration, do you get any lags from it? I don't think so.
If you add a trigger that cycles through every unit in the game you will get lag, if there are lot of units on the map.

If you use a unit group and only add summoned units to it, the performance depends on the summoned units. In a normal melee map you would have not to many summoned units at the same time, so it would not be bad.
You can also use the event mana of unit becomes equal to and add this event for every summoned unit to a trigger. You would have to rebuild the trigger from time to time to remove events of dead units. This is a common technique you see in most DDS.
 
Level 11
Joined
Jun 2, 2004
Messages
849
Your described method is one of the most efficient ways to do any sort of polling. However, for this specific case there's one better way: the Unit Mana Event.

  • Trigger - Add to (Your Summoned Unit Removal Trigger) the event (Unit - (Summoned unit)'s mana becomes Less than or equal to 0.00)
EDIT: Ninja'd. Oh well, above post gives better info.
 

Jampion

Code Reviewer
Level 15
Joined
Mar 25, 2016
Messages
1,327
You can add events to a trigger as shown above. You will add events for every summoned unit. To prevent performance loss you need to remove the events of units that have been killed.
You cannot remove a single event, so instead you destroy the entire trigger and add the events again, you did not want to remove.

You can store the units in a group, so you know what events need to be added. You should not be recreating the trigger for every unit that is removed, but only once in a while, because rebuilding the trigger is expensive. You can take a look at different DDS on hive.
If you want to rebuild, you should have a group or array of summoned units. Then you destroy the trigger, create a new one and add the unit events for units in the group or array to the trigger.
After rebuilding the trigger will no longer contain events of dead/removed units.
 
Level 4
Joined
Jul 27, 2015
Messages
29
Ahah, so if I call DestroyTrigger, that's only going to remove the events? I was under the impression it would just flush out all the actions and stuff too.

Or do I need to repopulate the trigger with actions as well?

sorry for being slow :(

-Sad
 
Status
Not open for further replies.
Top