Problem

simonake

New Member
Reaction score
72
It tells me local not existing ;(

JASS:
function Cond takes nothing returns boolean
  return GetSpellAbilityId() == 'A000'
endfunction

function G takes nothing returns nothing
    call CreateNUnitsAtLoc( 1, 'h000', GetOwningPlayer(GetTriggerUnit()), l, 0.00 )
    call UnitAddAbilityBJ( 'A001', GetLastCreatedUnit() )
    call UnitApplyTimedLifeBJ( 1.00, 'BTLF', GetLastCreatedUnit() )
    call IssueTargetOrderBJ( GetLastCreatedUnit(), "entanglingroots", GetEnumUnit() )
endfunction

function Acts takes nothing returns nothing
    local location udg_l = GetUnitLoc(GetTriggerUnit())
    local real distance = ( 300.00 + ( 50.00 * I2R(GetUnitAbilityLevelSwapped('A000', GetTriggerUnit())) ) )
    set bj_wantDestroyGroup = TRUE
    call ForGroupBJ( GetUnitsInRangeOfLocAll(distance, l), function G )
    call RemoveLocation( l)
endfunction

//===========================================================================
function InitTrig_Root takes nothing returns nothing
    set gg_trg_Root = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Root, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Root, Condition( function Cond ) )
    call TriggerAddAction( gg_trg_Root, function Acts )
endfunction
 

Romek

Super Moderator
Reaction score
963
You can only use locals in the function they're declared in.
Read

There's quite a large section on locals in the Variables section.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
JASS:
scope Root initializer Init
private function Cond takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

private function Acts takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local real X = GetUnitX(caster)
    local real Y = GetUnitY(caster)
    local real distance = ( 300.00 + ( 50.00 * I2R(GetUnitAbilityLevel(caster,'A000')) ) )
    local group g = CreateGroup()
    local unit temp
    local unit dummy
    local player p = GetOwningPlayer(caster)
    call GroupEnumUnitInRange(g,X,Y,distance,null)

    loop
        set temp = FirstOfGroup(g)
    exitwhen temp == null
        set dummy = CreateUnit(p,'h000',GetUnitX(temp),GetUnitY(temp),l,0.)
	call UnitAddAbility(dummy,'A001')
        call UnitApplyTimedLife(dummy, 'BTLF', 1.)
	call IssueTargetOrder(dummy,"entanglingroots",temp)
	call GroupRemoveUnit(temp,g)
    endloop

    call DestroyGroup(g)
    set caster = null
    set g = null
    set temp = null
    set dummy = null
    set p = null
endfunction

private function Init takes nothing returns nothing
    local trigger Root = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ(Root, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(Root, Condition( function Cond ) )
    call TriggerAddAction( Root, function Acts )
    set Root = null
endfunction
endscope


This is faster alternative way.
You need to declare locals with their name and type before start using them. It is no need to put “udg_" prefixes. This prefix is only use in the variables that you created in variables manager. In your script, It is no need to put "udg_l", instead of putting "l".
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top