Loop not going through

n[u]ll

You can change this now in User CP.
Reaction score
93
JASS:
function Trig_Set_SnowballRect_Actions takes nothing returns nothing
local integer i=1
    set udg_SnowballRect[1] = gg_rct_S1
    set udg_SnowballRect[2] = gg_rct_S2
    set udg_SnowballRect[3] = gg_rct_S3
    set udg_SnowballRect[4] = gg_rct_S4
    set udg_SnowballRect[5] = gg_rct_S5
    set udg_SnowballRect[6] = gg_rct_S6
    set udg_SnowballRect[7] = gg_rct_S7
    set udg_SnowballRect[8] = gg_rct_S8
    set udg_SnowballRect[9] = gg_rct_S9
    set udg_SnowballRect[10] = gg_rct_S10
    set udg_SnowballRect[11] = gg_rct_S11
    set udg_SnowballRect[12] = gg_rct_S12
    set udg_SnowballRect[13] = gg_rct_S13
    set udg_SnowballRect[14] = gg_rct_S14
    set udg_SnowballRect[15] = gg_rct_S15
    set udg_SnowballRect[16] = gg_rct_S16
    set udg_SnowballRect[17] = gg_rct_S17
    set udg_SnowballRect[18] = gg_rct_S18
    set udg_SnowballRect[19] = gg_rct_S19
    set udg_SnowballRect[20] = gg_rct_S20
    set udg_SnowballRect[21] = gg_rct_S21
    set udg_SnowballRect[22] = gg_rct_S22
    set udg_SnowballRect[23] = gg_rct_S23
    set udg_SnowballRect[24] = gg_rct_S24
    loop
        exitwhen i>24
        call TriggerRegisterEnterRectSimple( gg_trg_SnowballSend, udg_SnowballRect<i> )
        set i=i+1
    endloop
endfunction

function InitTrig_Set_SnowballRect takes nothing returns nothing
    set gg_trg_Set_SnowballRect = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Set_SnowballRect, function Trig_Set_SnowballRect_Actions )
endfunction</i>


JASS:
function Trig_SnowballSend_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == &#039;Snbl&#039; ) ) then
        return false
    endif
    return true
endfunction

function Trig_SnowballSend_Actions takes nothing returns nothing
local integer i=1
local integer r=0
local unit u = GetTriggerUnit()
local location p
    if ( RectContainsUnit(udg_SnowballRect[24], u ) == true ) then
        call DisplayTextToPlayer(Player(0), 0, 0, &quot;Reached last region of &quot; + I2S(i))
        call KillUnit(u)
    else
        loop
            exitwhen i&gt;23
            if ( RectContainsUnit(udg_SnowballRect<i>, u ) == true ) then
                set r=i + 1
                call DisplayTextToPlayer(Player(0), 0, 0, &quot;In region &quot; + I2S(i)) 
                exitwhen true
            else
                call DisplayTextToPlayer(Player(0), 0, 0, &quot;Not in region &quot; + I2S(i))
                set i=i+1
            endif
        endloop
        call DisplayTextToPlayer(Player(0), 0, 0, &quot;Going to region &quot; + I2S(r))
        set p = (GetRectCenter(udg_SnowballRect[(r)]))
        call IssuePointOrderLocBJ(u, &quot;move&quot;, p)
    endif
endfunction


function InitTrig_SnowballSend takes nothing returns nothing
    set gg_trg_SnowballSend = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_SnowballSend, Condition( function Trig_SnowballSend_Conditions ) )
    call TriggerAddAction( gg_trg_SnowballSend, function Trig_SnowballSend_Actions )
endfunction

</i>


So between these two triggers and the regions(1-24) that I've set up, what should happen is that when a unit enters the first region, hes sent through all of them and gets killed at the last one.

Well, when i test it, the snowball gets to the 7th region he turns around back to the 6th, which sends him in a loop.

I added a couple message displays to help the debugging process:

If you wanna look at the map just ask and I'll PM it to you.

Edit: Btw, +rep, huge props, and eternal gratitude to anyone who can find the solution.
 

Eyonix

TH.net Regular
Reaction score
16
Could I see the map please? Im not good at triggering but im trying to learn jass.... who knows maybe i'll get lucky and find it.

EDIT: Any ideas why it sometimes gets to 6 then goes to a point in the map waaaaaay off of the maze? I checked theres no regions or anything out there, but eventally they all end up there, some sooner than others.

Also something similar happened to me when I made a TD, I just cheated and instead of changing the custom value of the trigger each time when it got to the "problem region" I made a seperate trigger for when it enters that region to move to the next region, instead of doing it with the system you are. You could try that I guess? other than that I have no ideas for you :(

EDIT2: I just added that seperate trigger like i said and i got it to go to region 8 but then it started to do the same thing there instead. I guess I wasn't much help lol.
 

n[u]ll

You can change this now in User CP.
Reaction score
93
Could I see the map please? Im not good at triggering but im trying to learn jass.... who knows maybe i'll get lucky and find it.

EDIT: Any ideas why it sometimes gets to 6 then goes to a point in the map waaaaaay off of the maze? I checked theres no regions or anything out there, but eventally they all end up there, some sooner than others.

Also something similar happened to me when I made a TD, I just cheated and instead of changing the custom value of the trigger each time when it got to the "problem region" I made a seperate trigger for when it enters that region to move to the next region, instead of doing it with the system you are. You could try that I guess? other than that I have no ideas for you :(

EDIT2: I just added that seperate trigger like i said and i got it to go to region 8 but then it started to do the same thing there instead. I guess I wasn't much help lol.

That's actually a pretty good idea, I'll do that as a workaround. Tyvm!

However, I still want to get the trigger working so if anyone else wants to give it a try that'd be appreciated:D.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top