• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Issues with Run trigger/For Each Integer. Actions are executing out of order.

Status
Not open for further replies.

Uncle

Warcraft Moderator
Level 66
Joined
Aug 10, 2018
Messages
6,744
Alright, so I didn't know how to word this one, but basically the issue is with this trigger:
  • Generate Walls
    • Events
      • Time - GenerateTimer expires
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RoomBadPlacement Equal to False
        • Then - Actions
          • Game - Display to (All players) for 5.00 seconds the text: (Room + ((String(RoomCount)) + Created!))
          • -------- - --------
          • Set NextPosition = RoomTL[RoomCount]
          • Trigger - Run Wall Horizontal <gen> (ignoring conditions)
          • Custom script: call RemoveLocation( udg_NextPosition)
          • -------- - --------
          • Set NextPosition = RoomBL[RoomCount]
          • Trigger - Run Wall Horizontal <gen> (ignoring conditions)
          • Custom script: call RemoveLocation( udg_NextPosition)
          • -------- - --------
          • Set NextPosition = RoomBL[RoomCount]
          • Trigger - Run Wall Vertical <gen> (ignoring conditions)
          • Custom script: call RemoveLocation( udg_NextPosition)
          • -------- - --------
          • Set NextPosition = RoomBR[RoomCount]
          • Trigger - Run Wall Vertical <gen> (ignoring conditions)
          • Custom script: call RemoveLocation( udg_NextPosition)
          • -------- - --------
          • Trigger - Run Wall Corners <gen> (ignoring conditions)
Removing the NextPosition point is the culprit. It's as if it's removing the point BEFORE the actions in my Run trigger have finished. Clearly i'm removing the point AFTER I've finished running the trigger, so why is this happening? I even tried removing the NextPosition point at the end of my run trigger but that didn't work either.

Here's what the triggers look like that i'm running:
  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to Wall_CreateCount, do (Actions)
        • Loop - Actions
          • -------- Create Wall --------
          • Destructible - Create a Desert Wall (Horizontal) at (NextPosition offset by (Offset, 0.00)) facing (Random angle) with scale 1.11 and variation 4
          • Destructible - Set max life of (Last created destructible) to (Real(GenerateCount))
          • Set GenerateDestructible[GenerateCount] = (Last created destructible)
          • -------- - --------
          • Destructible - Create a Pathing Blocker Wall at (NextPosition offset by ((Offset - 64.00), 0.00)) facing (Random angle) with scale 1.00 and variation 0
          • Destructible - Set max life of (Last created destructible) to (Real(GenerateCount))
          • -------- - --------
          • Destructible - Create a Pathing Blocker Wall at (NextPosition offset by ((Offset + 64.00), 0.00)) facing (Random angle) with scale 1.00 and variation 0
          • Destructible - Set max life of (Last created destructible) to (Real(GenerateCount))
          • Set Offset = (Offset + 256.00)
      • For each (Integer A) from 1 to Wall_CreateCount, do (Actions)
        • Loop - Actions
          • -------- Create Wall --------
          • Destructible - Create a Desert Wall (Horizontal) at (NextPosition offset by (Offset, 0.00)) facing (Random angle) with scale 1.11 and variation 4
          • Destructible - Set max life of (Last created destructible) to (Real(GenerateCount))
          • Set GenerateDestructible[GenerateCount] = (Last created destructible)
          • -------- - --------
          • Destructible - Create a Pathing Blocker Wall at (NextPosition offset by ((Offset - 64.00), 0.00)) facing (Random angle) with scale 1.00 and variation 0
          • Destructible - Set max life of (Last created destructible) to (Real(GenerateCount))
          • -------- - --------
          • Destructible - Create a Pathing Blocker Wall at (NextPosition offset by ((Offset + 64.00), 0.00)) facing (Random angle) with scale 1.00 and variation 0
          • Destructible - Set max life of (Last created destructible) to (Real(GenerateCount))
          • Set Offset = (Offset + 256.00)
I've had issues before with this. Something about running triggers that have loops in them causes problems. Anyone know a solution?
 

Uncle

Warcraft Moderator
Level 66
Joined
Aug 10, 2018
Messages
6,744
For whatever reason, re-ordering the actions like this fixed the issue:

  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • -------- - --------
      • Trigger - Run Wall Corners <gen> (ignoring conditions)
      • -------- - --------
      • Set NextPosition = RoomTL[RoomCount]
      • Trigger - Run Wall Horizontal <gen> (ignoring conditions)
      • Custom script: call RemoveLocation( udg_NextPosition)
      • -------- - --------
      • Set NextPosition = RoomBL[RoomCount]
      • Trigger - Run Wall Horizontal <gen> (ignoring conditions)
      • Trigger - Run Wall Vertical <gen> (ignoring conditions)
      • Custom script: call RemoveLocation( udg_NextPosition)
      • -------- - --------
      • Set NextPosition = RoomBR[RoomCount]
      • Trigger - Run Wall Vertical <gen> (ignoring conditions)
      • Custom script: call RemoveLocation( udg_NextPosition)
      • -------- - --------
Which is odd, because the Wall Corners trigger has no loops and doesn't use NextPosition so I don't know why running it first instead of last would change anything. I did notice that I could couple the middle two triggers to run using the same point, but that shouldn't make a difference besides efficiency as far as I'm aware.
 

Uncle

Warcraft Moderator
Level 66
Joined
Aug 10, 2018
Messages
6,744
When you set NextPosition variable to RoomTL[index], it means both variables point on the same location object. If you destroy the object, it will be destroyed for both variables the same way, so then, further usage of RoomTL[index] would not work.

Ah, I see. Thanks for the answer. So I'm guessing I should use reals and convert the coordinates to a point?

Like this:
  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • Set X = (X of RoomTL[RoomCount])
      • Set Y = (Y of RoomTL[RoomCount])
      • Set NextPosition = (Point(X, Y))
      • Trigger - Run Wall Horizontal <gen> (ignoring conditions)
      • Custom script: call RemoveLocation( udg_NextPosition)
 
Status
Not open for further replies.
Top