HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How to get buffs' level ?

09-17-2009, 01:43 AM#1
DanThanh
My map uses many custom auras which effects based on the owner's ability level. So i use this to define the level of the buff:
Collapse JASS:
GetUnitAbilityLevel(target, bufID)
but it does not work, is there anyway to solve this issue ?
09-17-2009, 01:52 AM#2
Rising_Dusk
If you use a custom aura, then do:
Collapse JASS:
GetUnitAbilityLevel(target, AuraID)
Moved to the right forum, btw.
09-17-2009, 02:08 AM#3
DanThanh
Hi brother, thanks for your reply
So i can do something like this ?


Collapse JASS:
scope ThornAura 

private function con takes nothing returns boolean
    return GetTriggerDamageType() == DAMAGE_TYPE_ATTACK and GetUnitAbilityLevel(GetTriggeringTrigger(), bufID) >0
endfunction

private function act takes nothing returns nothing
    local unit u = GetTriggerDamageSource()
    local unit t = GetTriggerDamageTarget()
    local integer lvl = GetUnitAbilityLevel(t, auraID)
    
   call UnitDamageTargetEx(t, u, I2R(lvl)*10, ATTACK_TYPE_HERO, DAMAGE_TYPE_EXTRA, true)
    set u = null
    set t = null
endfunction

private function InitTrig takes nothing returns nothing
    local trigger trg = CreateTrigger()
    call TriggerAddAction(trg, function act)
    call TriggerAddCondition(trg, Condition(function con))
    call TriggerRegisterDamageEvent(trg, 1)
    set trg = null
endfunction
endscope
09-17-2009, 02:27 AM#4
Rising_Dusk
Okay, so you mean that the aura is not being used on the target for the buff. The aura is used on a source, which extends to a target. In that case you cannot use the Aura's raw ID.

What you will need to do is create a list of the instances of the aura. In that sense, you need to be able to get the source of the aura in the damage trigger callback, okay? Unfortunately, there isn't an easy way to do this, so to do what you are trying to do, your spell code will become bloated with excess stuff.

You can do this a few ways. You can trigger the aura behavior with a custom buff system such as ABuff (and thereby know in the buff itself who the source of the buff is). Outside of that and some very obscure methods of coding the spell, I can't think of anything that would work. Thorns aura is way more difficult to code in its entirety than it should be.
09-17-2009, 02:48 AM#5
DanThanh
Nah, it's much more complicated than i thought :)
I will try above ways you suggested, thanks anyway !