• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Loops are exiting without a cause

Status
Not open for further replies.
Level 8
Joined
Aug 2, 2006
Messages
346
...either that or I'm doing something stupid...

What this trigger is supposed to do is take a small plot of land (all stone, so unbuildable) and make it buildable. It is an area 96 by 56 (each of these is a pathing tile, so the area in WC3 units is 3072x1792 as each pathing tile is 32x32)

96*56 is 5376, so the gold (which I am incrementing every step of the way) SHOULD be at 5376 when the loop finishes, but instead it only makes it up to 1618, and not all of the area is buildable. It goes along the y axis and then by the x axis (so it goes across the row, moves down, then repeats). What's odd is that the pathing changes end in the middle of a row.

I can't see any reason for this happening except maybe Warcraft 3 is ending the loop prematurely because it thinks it's going to be an infinite loop or something. Is anyone else thinking this? And if so, what can I do to avoid this?

  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: local integer x = 0
      • Custom script: local integer y = 0
      • Custom script: local location tempPoint
      • Visibility - Create an initially Enabled visibility modifier for Player 1 (Red) emitting Visibility across (Playable map area)
      • Custom script: loop
        • Custom script: exitwhen y>95
        • Custom script: set x = 0
        • Custom script: loop
          • Custom script: exitwhen x>55
          • Player - Set Player 1 (Red) Current gold to ((Player 1 (Red) Current gold) + 1)
          • Custom script: set tempPoint = Location((x*32) - 7024 , 6384 - (y*32))
          • Custom script: call SetTerrainPathableBJ( tempPoint, PATHING_TYPE_BUILDABILITY, true )
          • Custom script: call RemoveLocation(tempPoint)
          • Custom script: set x = x + 1
        • Custom script: endloop
        • Custom script: set y = y + 1
      • Custom script: endloop
 
Level 7
Joined
Jul 18, 2009
Messages
272
1) Why don't you use Jass instead of 90% custom script? :ugly:

2) WC3 Triggers have the annoying characteristic to stop running after a certain amount of actions for no appearant reason. Afaik, that amount isn't even constant.
This limit applies to each trigger seperately, so you could try to split your trigger in 4 (5376/4 = 1344 < 1618), and make each trigger make a 48*28 area buildable. If that doesn't work, I don't know where the problem is.
 
WC3 Triggers have the annoying characteristic to stop running after a certain amount of actions for no appearant reason. Afaik, that amount isn't even constant.

That's called hitting the OP limit. It usually only happens in infinite loops.

And agreed, STOP USING GUI. You're trigger is 90% jass anyways.

Anyways, you may be hitting the OP limit, those are some pretty big nested loops (if my math is right, over 5000 iterations).
 
Last edited:
Level 7
Joined
Jul 18, 2009
Messages
272
That's called hitting the OP limit. It usually only happens in infinite loops.
OP = operation?
You don't need an infinite loop for that. The trigger that sets up, sorts and colors the "alphabet" for the save/load-codes in my Orpg also hits the limit when I don't split it. (It has ~5000 loop actions too ^^)
 
Level 8
Joined
Aug 2, 2006
Messages
346
lol, I am using JASS, that was just something I threw together real quick to post up here.

Dammit... It's always something else with WC3 isn't it!

Alright I guess I'll break it up into several loops... grrr....

So would it work if I just have it do 1000 in one loop, copy the code, and have it just continue on that way?

I'm just going to split it up so I call the function 5 times but it only has 1/5th of the workload.
 
Level 8
Joined
Aug 2, 2006
Messages
346
Or... hmm... I've just thought of something else.

Can I use recursion in warcraft 3?

ie:

function FUNKY takes integer y returns boolean
if y > 1 then
return false
endif
return FUNKY(y + 1)
endfunction

EDIT: Even if I can, does this suffer from the OP limit?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,286
WC3 can only execute so many actions in one batch, this was to prevent game breaking loops. Each event or timer expiring starts a new execution batch, just like some actions do. TriggerSleepAction resets the counter so also can equivently be used to start a new batch.

You could try splitting it into quarters, each quarter being run on its own execution chain (one after each other as WC3 is single threaded) thus removing the limit. You could also add TriggerSleepAction after ever upper loop, which would add hedious delay to the effect but garuntee that the limit will never be reached.
 
Level 8
Joined
Aug 2, 2006
Messages
346
I'll just go ahead and tell you all what I'm doing.

I'm making a tower wars map. What I'm trying to do with all this looping is make it so it will stop construction of a tower if the tower is blocking.

I would much rather do it this way rather than just give units an attack because it ALWAYS happens to where a unit will randomly start attacking my towers, and that pisses me off to no end.

If you guys have any better ideas as to how I could detect walling, please let me know.
 
Status
Not open for further replies.
Top