| 07-15-2008, 01:00 AM | #1 |
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. 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 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 |
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 |
do not allow cast if unit already cursed |
| 07-15-2008, 01:32 AM | #4 |
@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 |
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 | ||
Quote:
Quote:
|
| 07-15-2008, 10:04 AM | #7 |
You could also use unit indexing (PUI / DUI) and use a global array. |
| 07-15-2008, 12:32 PM | #8 |
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 |
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 | |
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.
|
| 07-15-2008, 02:38 PM | #11 |
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. |
