Why do these functions not work in a loop.

Linconius

New Member
Reaction score
0
I have had several problems with these functions when in a loop, they just stop the code at that point.

JASS:
<call CreateUnit()>

        loop
            call DisplayTextToForce( GetPlayersAll(), "Stage  1" )
            set Data.Dummy<i> = CreateUnit(Data.TrigPlayer, GraphicDummyID, Data.CastX, Data.CastY, Data.Angle)
            call DisplayTextToForce( GetPlayersAll(), &quot;Stage  2&quot; )
            call UnitApplyTimedLife(Data.Dummy<i>, &#039;BTLF&#039;, 0.5)
            call DisplayTextToForce( GetPlayersAll(), &quot;Stage  3&quot; )
            set i = i + 1
            exitwhen i &gt; NumberOfIllusions[Data.Level]
        endloop</i></i>


Stage 2 is never reached.
JASS:
&lt;call UnitDamageTarget&gt;
            
loop
                call GroupRefresh(g)
                call DisplayTextToForce( GetPlayersAll(), &quot;Stage 1&quot; )
                set u = FirstOfGroup(g)
                call DisplayTextToForce( GetPlayersAll(), &quot;Stage 2&quot; )
                exitwhen u == null
                call DisplayTextToForce( GetPlayersAll(), &quot;Stage 3&quot; )
                if not IsUnitType(u, UNIT_TYPE_STRUCTURE) and /*
                 */not IsUnitType(u, UNIT_TYPE_MECHANICAL) and /*
                 */not IsUnitAlly(u, FFData.TrigPlayer) and /*
                 */not IsUnitAlive(u)  then
                    set h = SquareRoot(Pow(GetUnitX(u) - FFData.TargetX, 2) + Pow(GetUnitY(u) - FFData.TargetY, 2))
                    set i = i + 1
                    if h &lt;= 100.00 then
                        set r = 200 * I2R(FFData.Level + 1)
                    else//           &lt;---------------- here we do the math for each level rather than use ifs
                        set r = ((200 * I2R(FFData.Level + 1)) - (2 * I2R(FFData.Level + 1)) / 3 * (h - 100))
                    endif
                endif
                call DisplayTextToForce(GetPlayersAll(), &quot;Stage 4&quot;)
                call UnitDamageTargetEx(FFData.TrigUnit, u, r, false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS)
                call DisplayTextToForce( GetPlayersAll(), &quot;Stage 5&quot; )
                call GroupRemoveUnit(g, u)
                call DisplayTextToForce( GetPlayersAll(), &quot;Stage 6&quot; )
            endloop


Stage 5 is never reached...

I don't understand why these functions don't work in the loops. Is it because of some setting in world editor, or is it a problem with NewGen?? Or is it UMSWE???? I installed NewGen according to this: http://www.hiveworkshop.com/forums/...ing-up-newgen-we-intro-trigger-editor-188349/ :banghead:
 

UndeadDragon

Super Moderator
Reaction score
447
Are you setting i to 0 before both of the loops? As I may already be over NumberOfIllusions[Data.Level] after the first loop.
 

Linconius

New Member
Reaction score
0
The loops work without these functions, but when these functions are included, the loops freeze at the problem function call :-S

Also, if it may be that I installed vJass incorrectly, can anyone give me a detailed tutorial of how to install it properly.
 

Dirac

22710180
Reaction score
147
Both functions trigger the "Unit enters map" and "Unit takes damage" events, check that none of these events fire something in your map that might be causing the issue
Also, these functions are quite heavy, maybe it's not working anyways, the only difference is that it freezes with the functions because it takes a great deal of processing to fire them 700+ times at once, but if you delete them it only loops 700 times doing nothing.
Please check by spamming [ljass]BJDebugMsg[/ljass] everywhere
 
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