HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Stacking Dot --> Non-stacking DoT

07-15-2008, 01:00 AM#1
Castlemaster
In my map I'm making an "effect" that will be used by more than one hero (like DoE's maim, mute, etc.). The effect is "burn" and deals 4% of max hp in damage every 2 seconds. This is the code I currently have.
Collapse JASS:
private function BurnMaxHPPercent takes nothing returns real
    return 0.04 // burns 4% of max hp every 2 seconds
endfunction

function CustomBurnCallback takes nothing returns nothing
    local integer t = ST_GetExpiredTimer()
    local unit caster = ST_GetUnit1(t)
    local unit target = ST_GetUnit2(t)
    local real damage = GetUnitState(target,UNIT_STATE_MAX_LIFE)*BurnMaxHPPercent()
    if GetUnitAbilityLevel(target,'B014')>0 then
        call CustomDamage(caster,target,damage,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_SPELL,false)
    else
        call ST_Destroy(t)
    endif
    set caster = null
    set target = null
endfunction

function CustomBurn takes unit caster, unit target, integer duration returns nothing
    local integer lvl = duration/2
    local real x = GetUnitX(target)
    local real y = GetUnitY(target)
    local unit u = CreateUnit(GetOwningPlayer(caster),'n00G',x,y,270)
    local integer t = ST_StartNew(2,true,function CustomBurnCallback)
    call ST_SetUnit1(t,caster)
    call ST_SetUnit2(t,target)
    call UnitAddAbility(u,CustomBurnID())
    call SetUnitAbilityLevel(u,CustomBurnID(),lvl)
    call IssueTargetOrder(u,"unholyfrenzy",target)
    call UnitApplyTimedLife(u,'BTLF',2)
    set u = null    
endfunction
I'm using safe timers, and "CustomBurnID()" is a dummy ability that applies the "burning buff" ('B014'). The dummy ability level correlates to the duration of the burn. (e.g. A duration of 6 is level 3, which is made to have a duration of 6 seconds. It only does even durations).

My question is, how do I make this so that if the burn is applied more than once it will not stack, since currently it does in this state.

Let me know if more info is needed.

Thanks ahead of time.
07-15-2008, 01:12 AM#2
Dil999
I didn't look through your code much, but you could probably just add effected (?affected?) units to a global unit group when the DoT starts, and remove them when it ends. Then, when you try to begin the DoT a second time, check if it is already in the group.
07-15-2008, 01:19 AM#3
DioD
do not allow cast if unit already cursed
07-15-2008, 01:32 AM#4
Castlemaster
@Dil999 I was thinking of something along those lines, but wanted to check my options

@DioD The problem is that I want larger durations to overwrite shorter ones, which is why I have the ability check for the buff, and let the dummy ability take care of that detail
07-15-2008, 07:18 AM#5
Flame_Phoenix
It is not that hard. To make a spell stack, just read this tutorial made by Moyack:
http://www.wc3campaigns.net/showthread.php?t=100953
07-15-2008, 09:30 AM#6
the-thingy
Quote:
Originally Posted by Flame_Phoenix
It is not that hard. To make a spell stack, just read this tutorial made by Moyack:
http://www.wc3campaigns.net/showthread.php?t=100953
Here's trying to make the spell unstackable

Quote:
how do I make this so that if the burn is applied more than once it will not stack
You can add affected units to a global group, then check if your target is in the group, and if they are, you could stop the cast. Not exactly sure how you would renew the present instance though... since you're not using structs, I don't know how you would reference a previous instance :(
07-15-2008, 10:04 AM#7
Themerion
You could also use unit indexing (PUI / DUI) and use a global array.
07-15-2008, 12:32 PM#8
Flame_Phoenix
OOhhh, lol no problem, the tutorial link I gave ALSO teaches people how to make spells not stack !!
Thx moyack xD

You really should give it a look.
http://www.wc3campaigns.net/showthread.php?t=100953
07-15-2008, 01:45 PM#9
Castlemaster
Structs, hmmm, didn't think about that option. I'll have to read through the tutorial, thanks Phoenix.
07-15-2008, 01:56 PM#10
Flame_Phoenix
It is always a pleasure to help =D
He uses Katana's system on that map, but you can try any other system you may like.
I use CSData and CSSagety 15.2 because together they allow me to recycle timers and groups.
ABC and TT are always good choices, depending on what you want for the spell.

off topic signature

Always remember to give +rep to those who help you =)

07-15-2008, 02:38 PM#11
DioD
you need to pass damage flag for unit, based off global time.

flag must looks like last damage time.

if last damage time less then 1 - unit was damaged by another instance of spell and not need to be damaged again.