Wc3C.net

Wc3C.net (http://www.wc3c.net/forums.php)
-   Systems (http://www.wc3c.net/forumdisplay.php?f=648)
-   -   Intuitive Buff System (http://www.wc3c.net/showthread.php?t=107613)

Fledermaus 10-07-2010 02:13 PM

I had a similar problem when I was using a "on death" event from within my damage system (checking their life after they take damage, if it's below 0 they're going to die so run on death events) to clear buffs on death. Are you doing that at all?

Quillraven 10-07-2010 06:05 PM

hm no not really. the buffs on enemy units are only handled by the buffsystem itself since i am only calling unitaddbuff and never call unitremovebuff or sthg like that.

i wonder why dead units end up in a double free? maybe i m going to check through dusk's system tomorrow. if i cant find anything there, then it must be the spell code itself.

edit:
found something out already.
when u call unitaddbuff twice on the same unit (in my map, when the hero attacks twice) the doublefree appears. f it is only called once it works.
maybe there is something wrong with the check of already existing buffs inside the system?

edit2:
k and it comes to an endless double free. seems like it periodically tries to destroy dbuffs.

edit3:
nevertheless the following fixes the problem for me atm:

i change this line

Collapse JASS:
call UnitAddBuff( .tempthis.caster, u, BUFF_TYPE_NEG, DURATION[.tempthis.lvl-1], .tempthis.lvl )

to

Collapse JASS:
if( GetUnitAbilityLevel( u, AURA_ID_NEG ) <= 0 )then
                    call UnitAddBuff( .tempthis.caster, u, BUFF_TYPE_NEG, DURATION[.tempthis.lvl-1], .tempthis.lvl )
                endif

you can maybe use not UnitHasBuff( u, BUFF_TYPE_NEG ) instead of GetUnitAbilityLevel.

Fledermaus 10-07-2010 11:58 PM

Ok, figured it out and explained it to Dusk who says he'll fix it this weekend.

Despite how nasty it looks, it's completely harmless (unless you did something silly like getting a NewTimer, setting its TimerData and then never starting it. And even then it'd still need a big coincidence to bug).

Quillraven 10-10-2010 07:26 PM

weekend is over sonn ;)

fix done?

Rising_Dusk 10-10-2010 10:02 PM

I have to fix that; Fled brought it up to me the other day and I have been incredibly busy lately. I will get to it soon. Please be patient.

Fledermaus 10-11-2010 12:36 AM

Incase you really need it now, I'll post the fix that I've been using

Expand JASS:

Quillraven 10-11-2010 02:30 PM

sry i didn't want to act unpatient. actually i was just a little bit joking. i know there are other things than wc3, and it may take some time until it gets fixed.

just wanted to be sure, that it WILL GET fixed in some way and doesn't get graveyarded.

wishing you a less busy time dusk :)

@fledermaus: thx

Av3n 12-09-2010 03:58 AM

Is it possible to somehow use Ammorth's LinkedList instead of using Stack?
If so... what need to be changed to make it work?

-Av3n

rogueteddybear 12-09-2010 06:29 AM

I cannot open the map in my editor. I am using the editor with jasshelper, UMS 5.0 (The latest version to my knowledge).

I get an error stating: Unable to open map File... main map file could not be opened

Fledermaus 12-09-2010 10:24 PM

Seems the testmap is corrupted or something, I'll get Dusk to re-upload it at some point.

Av3n: you'd obviously need to replace the stack create and destroy stuff with list ones. Also change how the dubff's struct id is added to the list in the create and onDestroy methods. You would then need to rewrite UnitRemoveAllBuffs and GetRandomBuff, and change GetLastAppliedBuff and GetFirstAppliedBuff. I think you could also remake GetRandomBuffSigned. Everything else should be fine.

Fledermaus 12-10-2010 01:19 AM

I was bored so decided to change it all for you

Expand JASS:

I haven't tested GetRandomBuff or GetRandomBuffSigned but I'm pretty sure they should work.

rogueteddybear 12-10-2010 06:13 AM

Could i get some help with this:

I added an effect variable to dbuff struct.
When the buffs onAdd callback is triggered, I set the effect to something (like continuous fire) and attach it to a point on the target.

when onEnd is triggered i destroy and set the effect to null.

However the fire effect stays attached to the target. I also put the destroy/set to null code for the effect in the onDestroy for dbuff, but to no avail.

here is the specific code for the custom burn buff i made:

Collapse JASS:
//---------------------------------------------------------------------//
//                              Burn Buff
//---------------------------------------------------------------------//
    
private function BurnBuffAdd takes nothing returns nothing
    local dbuff db = GetEventBuff()
    set db.tempEffect = AddSpecialEffectTarget("Environment\\LargeBuildingFire\\LargeBuildingFire2.mdl",db.target,"chest")
    
endfunction
    
private function BurnBuffRemove takes nothing returns nothing
    local dbuff db = GetEventBuff()
    call DestroyEffect(db.tempEffect)
    set db.tempEffect = null
endfunction

//deal 10 * level burn damage
private function BurnBuffPeriodic takes nothing returns nothing
    local dbuff db = GetEventBuff()
    call UnitDamageTargetEx(db.source, db.target, baseBurnDamage * db.level, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_FIRE_D, false)
endfunction


//======================================================
function Init_BurnBuff takes nothing returns nothing
    set BurnBuff = DefineBuffType('A07W', 'B004', baseBurnInterval, true, false, BurnBuffAdd, BurnBuffPeriodic, BurnBuffRemove)
endfunction

So when the buff runs out of time and is destroyed, the fire effect stays instead of being removed. Anyone know why?

Fledermaus 12-10-2010 09:44 AM

Is it only staying if the target had the BurnBuff applied more than once before it expired (aka the buff is refreshed)? Because the OnEnd isn't called when a buff is refreshed but the OnAdd is (so the AddSpecialEffectTarget is called twice and the first effect is overwritten so only the second one can be destroyed in the OnEnd).

There are 2 ways to fix this: If you're using a Tornado Slow Aura's for your buffs "abilid", you can use that to attach the effect instead. Otherwise you need to change your OnAdd to this
Expand JASS:

I would recommend the first option.

Av3n 12-10-2010 08:28 PM

Thanks Fled. It's not that I use those two functions specifically yet.

-Av3n

rogueteddybear 12-10-2010 10:01 PM

Thank you for the reply Fledermaus.

Adding it to the aura worked off the bat so I'll just go with that.


All times are GMT. The time now is 09:15 AM.

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services