I got an implementation question for ya Anitarf!
Is there any reason that GetABuffFromUnitByType returns an abuff that is about to be destroyed?
Suppose an eventCleanup, eventDestroy, or eventExpire occurs, and I have in the code to call a function "recalculatesomething". RecalculateSomething calls GetABuffFromUnitByType to determine a variable... Classic example:
A buff that raises the HP of a unit by 500. on EventCreate I call RecalculateHitpoints(eventBuff.target.u), which will do a bunch of calculations based on stats, level, *AND* the level of the aBuff on the unit of type "MyHitpointsAbuff". This works great, the RecalculateHitpoints() call sets the unit's hitpoints accordingly.
Now the hitpoints buff expires or is dispelled. In my EventCleanup function I again call RecalculateHitpoints(eventBuff.target.u). Unfortunately, It sees that the MyHitpointsAbuff is still active, even though its going to be destroyed in 0.00 seconds.
I'm going even further out on a limb to say that it might be a good idea to make sure GetAbuffFromUnit not return an abuff scheduled to be deleted because of another issue. Suppose in my Cleanup function I have somehow called AbuffApply on the same unit with the same aBuff (Example off the top of my head: A buff that when expires has a 20% chance to reapply itself on the buffed unit, or a buff that when expires has a 20% chance to reapply itself on ALL friendly/enemy units in an area). In these cases the AbuffApply will refresh the buff which is about to be destroyed, then the ABuff module will instantly destroy the buff.
What do you think? I know theres a work-around, by using a Timer to call RecalculateHitpoints/AbuffApply in 0.00 seconds, but it COULD go either way. I'd like to know what you think the best way to approach this problem is.