vJass Help Syntax Error

Fire-Wolf

S.P.D Smoke Pot Daily, Legalize It!
Ok I need some help with this. I'm making my first vJass spell. Its a basic one, it is just a chain lightning spell. And I'm only getting one syntax error. Here is the code:
JASS:
scope LW

    local Caster = GetSpellAbilityUnit()
    local array Target[0] = GetSpellTargetUnit()
    local array Target[1] = GetSpellTargetUnit()
    local group Targets

private function Trig_LW_Func008Func001002003001 takes nothing returns boolean
    return ( GetFilterUnit() != Caster )
endfunction

private function Trig_LW_Func008Func001002003002001 takes nothing returns boolean
    return ( GetFilterUnit() != Target[0] )
endfunction

private function Trig_LW_Func008Func001002003002002 takes nothing returns boolean
    return ( IsUnitAliveBJ(GetFilterUnit()) == true )
endfunction

private function Trig_LW_Func008Func001002003002 takes nothing returns boolean
    return GetBooleanAnd( Trig_LW_Func008Func001002003002001(), Trig_LW_Func008Func001002003002002() )
endfunction

private function Trig_LW_Func008Func001002003 takes nothing returns boolean
    return GetBooleanAnd( Trig_LW_Func008Func001002003001(), Trig_LW_Func008Func001002003002() )
endfunction

private function Trig_LW_Actions takes nothing returns nothing
    call AddLightningLoc( "CLPB", GetUnitLoc(Caster), GetUnitLoc(Target[0]) )
    call UnitDamageTargetBJ( Caster, Target[0], 100.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
    call TriggerSleepAction( 0.10 )
    call DestroyLightningBJ( GetLastCreatedLightningBJ() )
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 3
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set local group Targets = GetUnitsInRangeOfLocMatching(500.00, GetUnitLoc(Target[0]), Condition(function Trig_LW_Func008Func001002003))
        set local array Target[0] = GroupPickRandomUnit(Targets)
        call AddLightningLoc( "CLPB", GetUnitLoc(udg_Target[1]), GetUnitLoc(udg_Target[0]) )
        call UnitDamageTargetBJ( udg_Caster, udg_Target[0], 100.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
        call TriggerSleepAction( 0.10 )
        call DestroyLightningBJ( GetLastCreatedLightningBJ() )
        set udg_Target[1] = udg_Target[0]
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
    call DestroyGroup( udg_Targets )
endfunction

//===========================================================================
function InitTrig_LW takes nothing returns nothing
    set gg_trg_LW = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_LW, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_LW, function Trig_LW_Actions )
endfunction

endscope
The syntax error is:
set local group Targets = GetUnitsInRangeOfLocMatching(500.00, GetUnitLoc(Target[0]), Condition(function Trig_LW_Func008Func001002003))

Please help!
 

_whelp

New Member
Man, you can't make locals out of functions. Use globals:
JASS:
globals
    <VISIBILITY> <TYPE> <NAME> <INITIAL VALUE>
endglobals


Oh, and you can't use 'set local group bla =' syntax, you use 'set bla ='.

EDIT: Aww, you beat me to it.
 

_whelp

New Member
Uhh... stop using GUI coding habits, bj_forLoopAIndex and bj_forLoopAIndexEnd?
Use locals, not blizzard's useless globals for Jass... and remove the GUI generated globals.

One last thing, don't use those useless BJ's like UnitDamageTargetBJ. All it does is removes weapontype and boolean arguments.
For the DestroyLightningBJ, use DestroyLightning(bj_lastCreatedLightning).
 

Romek

Super Moderator
Staff member
This is quite obviously converted GUI.
You'll find writing it from scratch much easier to be honest.

Converted GUI is uglier than Paris Hilton.
 

Fire-Wolf

S.P.D Smoke Pot Daily, Legalize It!
Sorry I'm still just learning vJass so i just made a spell in Gui converted it to Jass then tried to convert it to vJass. But I fail.

EDIT: Here is the new trigger. Im getting 10 Compile errors now though. I think I made the script a bit better.
JASS:
scope LW initializer InitTrig_LW

private function Trig_LW_Func008Func001002003001 takes nothing returns boolean
    return ( GetFilterUnit() != Caster )
endfunction

private function Trig_LW_Func008Func001002003002001 takes nothing returns boolean
    return ( GetFilterUnit() != Target[0] )
endfunction
private function Trig_LW_Func008Func001002003002002 takes nothing returns boolean
    return ( IsUnitAliveBJ(GetFilterUnit()) == true )
endfunction

private function Trig_LW_Func008Func001002003002 takes nothing returns boolean
    return GetBooleanAnd( Trig_LW_Func008Func001002003002001(), Trig_LW_Func008Func001002003002002() )
endfunction

private function Trig_LW_Func008Func001002003 takes nothing returns boolean
    return GetBooleanAnd( Trig_LW_Func008Func001002003001(), Trig_LW_Func008Func001002003002() )
endfunction

private function Trig_LW_Actions takes nothing returns nothing
    local integer l = 1
    local unit Caster = GetSpellAbilityUnit()
    local unit array Target
    local group Targets
    set Target[0]  = GetSpellTargetUnit()
    set Target[1] = GetSpellTargetUnit()
    call AddLightningLoc( "CLPB", GetUnitLoc(Caster), GetUnitLoc(Target[0]) )
    call UnitDamageTargetBJ( Caster, Target[0], 100.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
    call TriggerSleepAction( 0.10 )
    call DestroyLightning( bj_lastCreatedLightning)
    loop
        exitwhen l > 3
        set Targets = GetUnitsInRangeOfLocMatching(500.00, GetUnitLoc(Target[0]), Condition(function Trig_LW_Func008Func001002003))
        set Target[0] = GroupPickRandomUnit(Targets)
        call AddLightningLoc( "CLPB", GetUnitLoc(udg_Target[1]), GetUnitLoc(udg_Target[0]) )
        call UnitDamageTargetBJ( udg_Caster, udg_Target[0], 100.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
        call TriggerSleepAction( 0.10 )
        call DestroyLightning(bj_lastCreatedLightning)
        set udg_Target[1] = udg_Target[0]
        set l = l + 1
    endloop
    call DestroyGroup( Targets )
endfunction

//===========================================================================
private function InitTrig_LW takes nothing returns nothing
    set gg_trg_LW = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_LW, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddAction( gg_trg_LW, function Trig_LW_Actions )
endfunction

endscope
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Jesus4Lyf Jesus4Lyf:
    Hmm, how to summarize... Moved to the USA and got married. Became a professional software engineer and solution lead. Learning Godot for game dev. :)
  • jonas jonas:
    So you are pursuing game dev as a hobby? What industry is your dayjob in?
  • jonas jonas:
    FAANG?
  • Jesus4Lyf Jesus4Lyf:
    Not quite FAANG, less pay for a less hours/stress. Yeah, game dev as a hobby.
  • jonas jonas:
    makes sense. Do we have a hobby game dev subforum to showcase some work?
  • Blackveiled Blackveiled:
    Happy Thursday
    +1
  • The Helper The Helper:
    Happy Thursday!
  • The Helper The Helper:
    TGIF!
  • The Helper The Helper:
    hey tom_mai please do not archive anymore news
  • Ghan Ghan:
    AMD Ryzen 7000 next week :D
    +1
  • The Helper The Helper:
    noice!
  • tom_mai78101 tom_mai78101:
    "hey tom_mai please do not archive anymore news" ----> Got it. What should we do with the "News Archive" subforum?
  • The Helper The Helper:
    I think leave it for real old news that cannot be sorted the reason we had it in the first place was a server issue that we do not have anymore. I don't want to get rid of the archive just not put anything in it for now until we figure it out more
  • The Helper The Helper:
    The side chat has nothing on the discord. it is not possible but the biggest thing on my wish list right now is a sidechat channel on the disord that hooks up to this...
  • Ghan Ghan:
    I've been selected for the Diablo IV beta.
    +1
  • Ghan Ghan:
    Woo!
    +1
  • The Helper The Helper:
    that is so cool
  • V-SNES V-SNES:
    Eh just noticed the new discord section on the side. Looks great!
    +1
  • Blackveiled Blackveiled:
    :( feels bad I can't ever get selected for any beta I sign up for. It's annoying as heck.
    +1
  • The Helper The Helper:
    Hello mgarcia! Happy Monday everyone!
  • The Helper The Helper:
    Happy Tuesday! :)

    The Helper Discord

    Members online

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top