Thread: ABuff System
View Single Post
Old 07-27-2007, 07:15 PM   #30
Procrastination Incarnate

Development Director
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner


Good points, rain9441.

There's plenty of reasons why GetABuffFromUnitByType should return buffs in the process of being destroyed, for example if you have a buff that has a specific effect when it is destroyed or expires if another specific buff is on the unit at that time, if a spell was cast that destroys all buffs on the unit then that specific buff may already be in the process of being destroyed by the time this buff's destroy response runs.

As far as your first question goes, the fastest solution would be to have an additional check for the buff's .beingDestroyed boolean, I realize now that it is undocumented, but I'll keep it that way for safety reasons because there's a better solution:

Make your function RecalculateHitpoints take an additional aBuff parameter. Then you can call it in three ways:
RecalculateHitpoints(, eventBuff) from the buff's create and refresh functions. This is also faster than a GetABuffFromUnitByType call which uses gamecache.
RecalculateHitpoints(, 0) from the cleanup function.
RecalculateHitpoints(u, GetABuffFromUnitByType(u, id)) from anywhere else.
Should work exactly as you want it to, unless the hit points can depend on multiple buffs, then you would have to check the .beingDestroyed boolean for each of them or, instead of recalculating life, simply add (create) or subtract (cleanup) from it as much as the buff should add.

As for your second problem, this is an obvious lack of functionality in the refresh and cleanup function, the refresh function should set the .beingDestroyed back to false and the cleanup then shouldn't cleanup if .beingDestroyed does not equal true. Never try to apply a buff from a cleanup function though! I will add this feature in 1.2 which should be out in a few days.

Thanks for the feedback.
Anitarf is offline   Reply With Quote