Ability Problem

Evan1993

Ultra Cool Member
Reaction score
30
I have an ability, quite simple really but I was a bad boy and just made it in GUI and converted it and added locals to make MUI and it gives me 4 “expected a code statement” :(
Here's the code:
Code:
function Trig_Fire_Copy_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Fire_Copy_Actions takes nothing returns nothing
    call UnitAddAbilityBJ( udg_Firea[GetUnitAbilityLevelSwapped('A000', GetTriggerUnit())], GetSpellTargetUnit() )
    call TriggerSleepAction( 2 )
    call UnitRemoveAbilityBJ( udg_Firea[GetUnitAbilityLevelSwapped('A000', GetSpellAbilityUnit())], GetSpellTargetUnit() )
endfunction

//===========================================================================
function InitTrig_Fire_Copy takes nothing returns nothing
    set gg_trg_Fire_Copy = CreateTrigger(  )
    local TU unit
    Set TU = GetTriggerUnit()
    local CU unit
    Set CU = GetSpellAbilityUnit()
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Fire_Copy, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Fire_Copy, Condition( function Trig_Fire_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_Fire_Copy, function Trig_Fire_Copy_Actions )
endfunction
 

Sim

Forum Administrator
Staff member
Reaction score
534
Well first you need to set the locals in the actions part, not in the Init_Trig.

Second, ALWAYS the locals first. You set a local, then you reset a local. Wrong. Create the locals (and set them at the same time) and after this only you can work on the actions.

Code:
function Trig_Fire_Copy_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Fire_Copy_Actions takes nothing returns nothing
    local unit TU=GetTriggerUnit()
    local unit CU= GetSpellAbilityUnit()
    call UnitAddAbilityBJ( udg_Firea[GetUnitAbilityLevelSwapped('A000', TU)], CU )
    call TriggerSleepAction( 2 )
    call UnitRemoveAbilityBJ( udg_Firea[GetUnitAbilityLevelSwapped('A000', CU)], GetSpellTargetUnit() )
endfunction

//======================================================================  =====
function InitTrig_Fire_Copy takes nothing returns nothing
    set gg_trg_Fire_Copy = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Fire_Copy, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Fire_Copy, Condition( function Trig_Fire_Copy_Conditions ) )
    call TriggerAddAction( gg_trg_Fire_Copy, function Trig_Fire_Copy_Actions )
endfunction
 

Evan1993

Ultra Cool Member
Reaction score
30
That’s what I did the first I must have make a typo then or something because It didn’t work. Oh well a lest I got a working version even if I made a fool out of myself :eek: :eek:
Yeah I know that but I was going really fast because someone was waiting for me.
 

SFilip

Gone but not forgotten
Reaction score
634
also take note that all locals except boolean, integer, string and real leak unless you set them to null.
therefore you need to add these 2 lines as your last 2 lines in actions:
Code:
    set TU = null
    set CU = null
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top