How to MUI my spell

Sooda

Diversity enchants
Reaction score
318
"whichUnit" was in my example local unit variable name. You totally have forgotten that if you use local variable you first have to declare it at the start of your function.
"whichUnit" is just a variable name, it could have been "thisIsVariableName" and it would give you same result.
How much JASS you know after all ?
JASS:
function Trig_Ion_Shield_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A001'
endfunction

function Trig_Ion takes nothing returns nothing
    local integer i = GetTriggerExecCount(GetTriggeringTrigger())
    local real x = GetUnitX(udg_ShieldCaster<i>)
    local real y = GetUnitY(udg_ShieldCaster<i>)

    call SetUnitPosition(udg_ShieldDummies<i>,x,y)
endfunction

function Trig_Ion_Shield_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local integer i = GetTriggerExecCount(GetTriggeringTrigger())
    set udg_ShieldCaster<i> = GetSpellAbilityUnit() // Same as GetTriggerUnit() but only worse.

    local unit whichUnit = GetTriggerUnit()

    local player whichPlayer = GetOwningPlayer(whichUnit)

    call DisplayTextToForce( GetForceOfPlayer(whichPlayer) ), &quot;|cffffcc00YOU HAVE ENABLED ION SHIELD|r.&quot; )
    
    call RemoveUnit(bj_lastCreatedUnit)

    <b>set udg_ShieldDummies<i> = CreateUnit(whichPlayer,&#039;h001&#039;,GetLocationX(udg_ShieldCasterLoc),GetLocationY(udg_ShieldCasterLoc),GetUnitFacing(whichUnit))</i></b><i>
    set bj_lastCreatedUnit = udg_ShieldDummies<i>
    
    call TimerStart(t,0.03,true,function Trig_Ion)

    set whichUnit = null
endfunction


//===========================================================================
function InitTrig_Ion_Shield takes nothing returns nothing
    set gg_trg_Ion_Shield = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Ion_Shield, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Ion_Shield, Condition( function Trig_Ion_Shield_Conditions ) )
    call TriggerAddAction( gg_trg_Ion_Shield, function Trig_Ion_Shield_Actions )
endfunction</i></i></i></i></i></i>
 

Sim

Forum Administrator
Staff member
Reaction score
534
> local timer t = CreateTimer()
> local integer i = GetTriggerExecCount(GetTriggeringTrigger())
> set udg_ShieldCaster = blablabla
> local unit whichUnit = GetTriggerUnit()

Ouch. Local variable declaration must always come in first in a function ;)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top