• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Spell Question

Status
Not open for further replies.
Level 3
Joined
Sep 9, 2009
Messages
658
Okay, when it comes to auras, I know using a system would be easier but I just wanted to try this out. Anyway, am I doing this right? I'm checking if the unit has the buff before it gets the aura's effects. But since the unit can't be checked if it's no longer within the range of the aura, I gave the unit group check a bigger range than the AoE of the aura.

I also want some comments on the start up. With the way its coded right now, every time I learn or level up the skill, a new timer is created right? Is there a better way to do that?

JASS:
globals
    unit array Hero
    integer AuraCount = 0
    group AuraGroup = CreateGroup()
endglobals

function Arcane_Aura_Actions takes nothing returns nothing
    local integer i = 0
    local unit u
    local real x
    local real y
    
    loop
        exitwhen i == AuraCount
        set x = GetUnitX(Hero[AuraCount])
        set y = GetUnitY(Hero[AuraCount])
        call GroupEnumUnitsInRange(AuraGroup, x, y, 2000, null)
        loop
            set u = FirstOfGroup(AuraGroup)
            exitwhen u == null
            if GetUnitAbilityLevel(u, 'B000') > 0 then
                call UnitAddAbility(u, 'A000')
            else
                call UnitRemoveAbility(u, 'A000')
            endif
            call GroupRemoveUnit(AuraGroup, u)
        endloop
        set i = i + 1
    endloop
endfunction

function Arcane_Aura_Learn takes nothing returns nothing
    local timer t = CreateTimer()
    set AuraCount = AuraCount + 1
    set Hero[AuraCount] = GetTriggerUnit()
    
    call TimerStart(t, 1, true, function Arcane_Aura_Actions)
    
    set t = null
endfunction

function Trig_Arcane_Aura_Conditions takes nothing returns boolean
    if GetLearnedSkill() == 'A001' then
        call Arcane_Aura_Learn()
        call BJDebugMsg("Working!")
    endif
    return false
endfunction


//===========================================================================
function InitTrig_Arcane_Aura takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_HERO_SKILL )
    call TriggerAddCondition( t, Condition( function Trig_Arcane_Aura_Conditions ) )
    set t = null
endfunction
 
Status
Not open for further replies.
Top