- Joined
- Jan 18, 2012
- Messages
- 92
I made spell that applies a buff to a unit, and it worked as it should so I went into my triggers to figure out a way to detect buffs. I've found this BJ function:
So I figured that I can detect buffs same as abilities but it won't work.
Here's my code:
Everything else works, but that if never returns true. I really have no idea as to what might be the problem.
JASS:
function UnitHasBuffBJ takes unit whichUnit, integer buffcode returns boolean
return (GetUnitAbilityLevel(whichUnit, buffcode) > 0)
endfunction
So I figured that I can detect buffs same as abilities but it won't work.
Here's my code:
JASS:
function Trig_RuneSpawn_Actions takes nothing returns nothing
local unit triggerer = GetTriggerUnit()
if GetUnitAbilityLevel(triggerer, 'B000') > 0 then
// Even if a unit has this buff this if will return false
if GetUnitLevel(triggerer) <= 3 then
call CreateItem('I003', GetUnitX(triggerer), GetUnitY(triggerer))
else
call CreateItem('I004', GetUnitX(triggerer), GetUnitY(triggerer))
endif
endif
endfunction
//===========================================================================
function InitTrig_RuneSpawn takes nothing returns nothing
local integer i = 0
set gg_trg_RuneSpawn = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(gg_trg_RuneSpawn, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH, null)
loop
if (IsPlayerEnemy(Player(0), Player(i))) == true then
call TriggerRegisterPlayerUnitEvent(gg_trg_RuneSpawn, Player(i), EVENT_PLAYER_UNIT_DEATH, null)
endif
set i = i + 1
exitwhen i == bj_MAX_PLAYERS
endloop
call TriggerAddAction( gg_trg_RuneSpawn, function Trig_RuneSpawn_Actions )
endfunction
Everything else works, but that if never returns true. I really have no idea as to what might be the problem.