HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Stunting Mana Regeneration

02-24-2010, 06:05 PM#1
Ignitedstar
Uugh, the search function is not helpful to me at all. Every thread concerning mana regeneration and "stunting" it come in one of the following flavors:

1) Using Sobi Mask's item mana regeneration. Can't use it because mana regeneration is imperative to survival.
2) Using a negative Brilliance Aura. Can't use it for the same reason above.
3) Triggering it.

This is what I want, but geez, you'd think less than half of the people wanting help on stopping mana regeneration want to actually trigger it.

The steps to do this seem rather simple to me. Store the mana value of every hero (just five, so it shouldn't be a big deal) and keep replacing every hero's mana value with the stored one.

But, I'm not really sure which way is the best method of doing this. I know that I would have to make an event with a periodic event timer via
call TriggerRegisterTimerEventPeriodic(trigger trig, real timeout)
However, I'm not sure at what interval is "safe". To elaborate, making sure that any damage that the periodic event would cause to playing Warcraft. I'm skeptical because I've heard that periodic events start getting shaky at very low intervals.

The other idea was to create a global timer that issues a callback that stores the mana at its current value and replaces the mana values. However, the trigger that stunts mana regeneration needs to be turned on and off at specific moments of the map. Achieving this should be easy with:
call PauseTimer(timer whichTimer)
I hope I'm correct so far. I'm afraid of a few things using a timer like this, though.

1) Does the periodic timer suffer from anything if it is running for a prolonged amount of time? Estimate about 20 minutes.
2) Extending off of the first question (for a different map of sorts), if the periodic timer ran indefinitely, would I eventually run into a problem?
3) If I store a unit's mana value at the same moment that the mana is being replaced, the timer is doing utterly useless work. If I pause the timer and turn it back on, I need to be able to reobtain the mana values of the five heroes. This won't be tedious, will it?
02-25-2010, 05:09 AM#2
Earth-Fury
Don't use periodic triggers. Use timers.

Build a list of units, and the mana value you want to pause them at. Use a periodic timer (experiment to find the timeout that executes the least often while removing the stutter in the UI from mana regen still actually happening.) and iterate over the list of units, setting their mana values to the corresponding entry in the mana array.

If a unit is removed from the list causing it to become empty, pause the timer. If the list is empty when a unit is added, start the timer.

The most basic of such lists are just parallel arrays with a count integer. To remove something, move the last element in all arrays that are parallel to the position of the removed element and reduce the count.

As for the performance of periodic timers: There are almost no performance issues related to the timers themselves. It's attempting to do too much unoptimized work in the callback on a really fast period that causes slowdowns and problems.