• 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.

[Solved] UnitHasBuffBJ?

Status
Not open for further replies.
Level 4
Joined
May 23, 2010
Messages
83
Hey guys, I'm kinda new on vJASS (been studing for 3-4 months) and I'm 'cleaning' my scripts, removing all BJ's. I've noticed that some BJ's are better when not removed and I've searched about this specific:

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

and it doesn't seems to be working on my code:

JASS:
scope Spells initializer onInit

    globals
        private trigger DamageT = CreateTrigger()
    endglobals
    
    private function Damage takes nothing returns nothing
    
        local unit t = GetTriggerUnit()
        local unit u = GetEventDamageSource()
        local integer agi = GetHeroAgi(u, true)
        local integer str = GetHeroStr(u, true)
        local integer int = GetHeroInt(u, true)
        local real dmg
        local real dmg2
    
        //======= Firebolt ========
        if (GetUnitAbilityLevel(t, 'B000') > 0) then
            set dmg = int*3
            set dmg2 = dmg*3
            call UnitRemoveAbility(t, 'B000')
            call TextTagSystem_Create( c_red, I2S(R2I(dmg)), t, 12, 90, 64, GetOwningPlayer(u), true)
            call UnitDamageTarget(u, t, dmg, false, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
            call Timers_InitDamage(u, t, dmg2, 10.0, 1.0, "Abilities\\Spells\\Other\\Incinerate\\FireLordDeathExplode.mdl", "origin", null, c_red)
        endif  
        
    endfunction
    
    private function AddEvent takes nothing returns nothing
        local unit u = GetTriggerUnit()
        call TriggerRegisterUnitEvent(DamageT, u, EVENT_UNIT_DAMAGED)
    endfunction
    
    private function AddEventInit takes nothing returns nothing
        local unit u = GetEnumUnit()
        call TriggerRegisterUnitEvent(DamageT, u, EVENT_UNIT_DAMAGED)
    endfunction
    
    private function onInit takes nothing returns nothing
        
        local group g = CreateGroup()
        local trigger t = CreateTrigger()
        local region r = CreateRegion()
        
        call RegionAddRect(r, bj_mapInitialPlayableArea)
        call TriggerRegisterEnterRegion(t, r, null)
        call TriggerAddAction(t, function AddEvent)
        call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, null) 
        call ForGroup(g, function AddEventInit)
        call TriggerAddAction( DamageT, function Damage )
        
    endfunction

endscope

I revised every line and if there's an error I couldn't find it's my fault. Anyone to clear my mind?
 
Level 4
Joined
May 23, 2010
Messages
83
ok, I found the problem guys, it's the buff itself: duration was 0 (i thought it would "last forever" but not, the buff is not even placed) then i changed to 3600 and it worked. Thanks for the tips to improve my code.
 
Status
Not open for further replies.
Top