• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Is there an alternative for UnitHasBuffBJ?

Status
Not open for further replies.
Level 14
Joined
Apr 20, 2009
Messages
1,543
Hello everyone,

I've been trying to figure out how to check if a specific unit has a specific buff.
Apparently using UnitHasBuffBJ does not work, why does it not work?

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

Because the native checks for the ability level of the buff.
But this can not be done since buffs don't have ability levels >.>

How can this ever return true at all :S?

If I use this native for an ability code it does work...

So basically blizzard created a native that doesn't work, is there any alternative to this native?
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
GetUnitAbilityLevel(whichUnit, buffcode) > 0

This does work.
Buffs are actually like timed passive abilities internally.

Have you tested this? :O

Yes, if I do this:
JASS:
function something takes nothing returns nothing
   local unit u = CreateUnit(Player(0), 'hpea', 0, 0, 0)
   call UnitAddAbility(u, 'Aakb')
   call SetUnitAbilityLevel(u, 'Aakb', 1)
      if GetUnitAbilityLevel(u, 'BOac') > 0 then
         call DisplayTextToPlayer(Player(0),0,0,"works")
      endif
endfunction
it doesn't show works

War Drums ability -> Command Aura buff

edit

type buff extends ability
There, even MOAR proof :D
lol then y u no work!!!!???
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Add a small delay and see if it works.
And make sure the unit physically has the buff (in the UI)

The unit physically has the buff, and I've already tryed adding delay :(

I guess I'm doing something wrong somewhere else, I'll try to figure it out :S...
Either ways this is the original script I'm using:

some initialization trigger:
JASS:
set udg_buffType[10] = 'BOac'
call UnitAddAbility(udg_unit[1], 'Aakb')
call SetUnitAbilityLevel(udg_unit[1], 'Aakb', 1)
a trigger that runs every 0.2 sec:
JASS:
loop
   exitwhen i > udg_index
   loop
      exitwhen i2 > 10
      if GetUnitAbilityLevel(udg_unit[i], udg_buffType[i2]) > 0 then
         set buffCounter = buffCounter + udg_buff[i2]
         set udg_unitHasBuff[i] = buffCounter
      endif
      set i2 = i2 + 1
   endloop
   set buffCounter = 0
   set i = i + 1
endloop

udg_index = 5 here so that can't be it.

Either ways if I change set udg_buffType[10] = 'BOac' to set udg_buffType[10] = 'Aakb' it does seem to work :S
And yes the buff is in the UI


EDIT: omg I'm so stupid, nvm the buffType should be 'Bakb'

this can be set to solved...

EDIT2:
Did you tested this?
It work for me fine.
Liar! xD It can't work for you since command aura buff != war drum buff :p
The target art however is command aura, but not the buff...
 
Last edited:
Status
Not open for further replies.
Top