Syntax Error?

Drenferalis

New Member
Reaction score
0
Heres the whole function after fixing that and the exitwhen = to ==

JASS:
function Trig_Special_Actions takes nothing returns nothing
    local unit array kunit
    local integer key = 0
    loop
         if (IsUnitAliveBJ(kunit[key]) == false ) then
                  set kunit[key] = null
             endif
         if( kunit[key] == GetAttackedUnitBJ() ) then
             
             return
         elseif ( kunit[key] == null) then
             set kunit[key] = GetAttackedUnitBJ()
             
         endif
         exitwhen kunit[key] == GetAttackedUnitBJ()
    set key = key + 1
    endloop
    local integer a = 0
    loop
        exitwhen a > 30
        call CreateTextTagUnitBJ( I2S(( 30 - a )), kunit[key], 0, 10, 100, 0.00, 0.00, 0 )
        call TriggerSleepAction( 1.00 )
        if ( a == 30 ) then
            call KillUnit( kunit[key] )
        else
        endif
        set a = a + 1
    endloop
endfunction


The purpose of this is to make a "doom" spell when a unit is attacked.
Haven't removed floating text yet. The kunit[key] is to make it work on many units at 1 time.
Still getting syntax errors.



EDIT: Moved local 'a' declaration to top of function.
Fixed.
 

_whelp

New Member
Reaction score
54
Locals can only be set at the top of a function so your [ljass]local integer a = 0[/ljass] must be at the top.
 

Drenferalis

New Member
Reaction score
0
Yet now I am stuck, the code still only works for 1 unit at a time. Any help?
While waiting for a response I am going to try to make the end of the function (2nd loop) into a call statement and see if that helps...
 

Drenferalis

New Member
Reaction score
0
You're making it too complicated. :) Locals are MUI, unlike what happens in GUI...

JASS:
function Trig_Special_Actions takes nothing returns nothing
    local unit kunit  =GetAttackedUnit()
    local integer a = 0
    loop
        exitwhen a > 30
        call CreateTextTagUnitBJ( I2S(( 30 - a )), kunit, 0, 10, 100, 0.00, 0.00, 0 )
        call TriggerSleepAction( 1.00 )
        if ( a == 30 ) then
            call KillUnit(kunit)
        else
        endif
        set a = a + 1
    endloop

    set kunit = null
endfunction

Attack a unit twice and see where that gets you... this is designed to work on multiple units within seconds and not work on units with it already. And I do not want to use an orb effect to detect which units have it.

Here is what I have so far and it leaves much less "hanging floating text" but still only works on 1 unit, Attack 3 units and the floating text/kills end up on the last attacked unit.

JASS:
function speckill takes unit kunit1 returns nothing
    local integer a = 0
    loop
        exitwhen a > 30
        call CreateTextTagUnitBJ( I2S(( 30 - a )), kunit1, 0, 10, 100, 0.00, 0.00, 0 )
        call TriggerSleepAction( 1.00 )
        call DestroyTextTagBJ( GetLastCreatedTextTag() )
        if ( a == 30 ) then
            call KillUnit( kunit1 )
        else
        endif
        set a = a + 1
    endloop
endfunction

function Trig_Special_Actions takes nothing returns nothing
    local unit array kunit
    local integer key = 0
    loop
         if (IsUnitAliveBJ(kunit[key]) == false ) then
                  set kunit[key] = null
             endif
         if( kunit[key] == GetAttackedUnitBJ() ) then
             return
         elseif ( kunit[key] == null) then
             set kunit[key] = GetAttackedUnitBJ()
             
         endif
         exitwhen kunit[key] == GetAttackedUnitBJ()
    set key = key + 1
    endloop
    call speckill( kunit[key] )
endfunction
 
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