• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Buff Detection

Status
Not open for further replies.
Level 4
Joined
Nov 24, 2007
Messages
55
I have a question concerning Buff Detection with JASS (I assume this could also be a problem with GUI...)

I had noticed that Blizz simply did it with the following code

JASS:
function UnitHasBuffBJ takes unit whichUnit, integer buffcode returns boolean
    return (GetUnitAbilityLevel(whichUnit, buffcode) > 0)
endfunction

Since then, I have always, when needing to do buff detection in a trigger, checked to see if my target unit (which had always been not the caster) responded properly with the "GetUnitAbilityLevel" call...

However, I realized this could pose a problem.

To explain a sample problem, let me give an example.

I have a Hero who has two debuffs (one based on Soul Burn and another based on Curse...so a silence and a miss) he can cast on units. A third ability he has is a Direct Damage (based on chain lightning), but I want to trigger it such that if he uses this DD move on a unit that has been Silenced, it does an additional Manaburn. Or, if the unit had been Cursed, it would do a small AoE (a la Frost Nova). Coding this was fine, and fun and happy, until I realized,

"What if my target is a unit of the same type? And the target hero has learned both of these abilities (which would then logically return true for both queries)? Will it then do both the mana burn and AoE?"

I have not tested yet (as I cannot at the moment) and am geniunely curious as to what would happen, and if said scenario did happen, how can I prevent it from happening.

Here is the code I am/was working with in case you want to directly inject an answer in JASS:

JASS:
function Trig_Blast_of_Light_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local integer lvl = GetUnitAbilityLevel( u, 'A05O' )
    local unit t = GetSpellTargetUnit()
    local unit dummy
    if( ( GetUnitAbilityLevel(t, 'A023' ) > 0 ) )then
        // has holy fire...
    endif
    if( ( GetUnitAbilityLevel(t, 'A024' ) > 0 ) ) then
        // has blinding light...
    endif
    set t = null
    set dummy = null
    set u = null
endfunction
 
Status
Not open for further replies.
Top