• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Fault in For Each Integer loop indexing

Status
Not open for further replies.
Level 6
Joined
May 15, 2009
Messages
191
Hello Hive, and welcome to another session of "Battlehound's a noob"

In short, I tried to make a 'smart' system to add several indexed units into different Unit Group Arrays.
I need 14 units to be divided into 7 different groups (sometimes these groups consist of just one individual).
The trigger should be fairly self-explanatory, so I won't drown it (but ask questions if anything is unclear!).

The first group of 3 indexed units gets added to a group well enough, but it doesn't work for the remaining 6 groups in the trigger.

  • Unit Variables
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Group1=[1,2,3] --------
      • Set VerdantCounter_i2 = 1
      • Set VerdantSpiritUnits_uArray[1] = Verdant Spirit 1234 <gen>
      • Set VerdantSpiritUnits_uArray[2] = Verdant Spirit 1235 <gen>
      • Set VerdantSpiritUnits_uArray[3] = Verdant Spirit 1236 <gen>
      • For each (Integer VerdantCounter_i) from 1 to 3, do (Actions)
        • Loop - Actions
          • Unit Group - Add VerdantSpiritUnits_uArray[VerdantCounter_i] to VerdantUnits_ugArray[VerdantCounter_i2]
          • Game - Display to (All players) the text: ((String((Number of units in VerdantUnits_ugArray[VerdantCounter_i2]))) + units in Counter Group)
          • Game - Display to (All players) the text: ((String((Number of units in VerdantUnits_ugArray[1]))) + units in Value=1 Group)
      • -------- Group2=[4,5,6] --------
      • Set VerdantCounter_i2 = 2
      • Set VerdantSpiritUnits_uArray[4] = Verdant Spirit 1246 <gen>
      • Set VerdantSpiritUnits_uArray[5] = Verdant Spirit 1247 <gen>
      • Set VerdantSpiritUnits_uArray[6] = Verdant Spirit 1248 <gen>
      • For each (Integer VerdantCounter_i) from 4 to 6, do (Actions)
        • Loop - Actions
          • Unit Group - Add VerdantSpiritUnits_uArray[VerdantCounter_i] to VerdantUnits_ugArray[VerdantCounter_i2]
          • Game - Display to (All players) the text: ((String((Number of units in VerdantUnits_ugArray[VerdantCounter_i2]))) + units in Counter Group)
          • Game - Display to (All players) the text: ((String((Number of units in VerdantUnits_ugArray[2]))) + units in Value=2 Group)
      • -------- Group3=[7] + patrol --------
      • Set VerdantCounter_i2 = 3
      • Set VerdantSpiritUnits_uArray[7] = Verdant Ancient 1249 <gen>
      • Unit Group - Add VerdantSpiritUnits_uArray[7] to VerdantUnits_ugArray[VerdantCounter_i2]
      • Set VerdantPatrolPoint_Tempp1 = (Center of PrimalLushPatrol p1 <gen>)
      • Unit - Order VerdantSpiritUnits_uArray[7] to Patrol To VerdantPatrolPoint_Tempp1
      • Custom script: call RemoveLocation(udg_VerdantPatrolPoint_Tempp1)
      • -------- Group4=[8,9,10] --------
      • Set VerdantCounter_i2 = 4
      • Set VerdantSpiritUnits_uArray[8] = Verdant Ancient 1237 <gen>
      • Set VerdantSpiritUnits_uArray[9] = Verdant Spirit 1238 <gen>
      • Set VerdantSpiritUnits_uArray[10] = Verdant Spirit 1239 <gen>
      • For each (Integer VerdantCounter_i) from 8 to 10, do (Actions)
        • Loop - Actions
          • Unit Group - Add VerdantSpiritUnits_uArray[VerdantCounter_i] to VerdantUnits_ugArray[VerdantCounter_i2]
      • -------- Groupp5=[11,12] --------
      • Set VerdantCounter_i2 = 5
      • Set VerdantSpiritUnits_uArray[11] = Verdant Spirit 1250 <gen>
      • Set VerdantSpiritUnits_uArray[12] = Verdant Spirit 1251 <gen>
      • For each (Integer VerdantCounter_i) from 11 to 12, do (Actions)
        • Loop - Actions
          • Unit Group - Add VerdantSpiritUnits_uArray[VerdantCounter_i] to VerdantUnits_ugArray[VerdantCounter_i2]
      • -------- Groupp6=[13] --------
      • Set VerdantCounter_i2 = 6
      • Set VerdantSpiritUnits_uArray[13] = Verdant Ancient 1252 <gen>
      • Unit Group - Add VerdantSpiritUnits_uArray[13] to VerdantUnits_ugArray[VerdantCounter_i2]
      • -------- Groupp7=[14] --------
      • Set VerdantCounter_i2 = 7
      • Set VerdantSpiritUnits_uArray[14] = Verdant Spirit 1253 <gen>
      • Unit Group - Add VerdantSpiritUnits_uArray[14] to VerdantUnits_ugArray[VerdantCounter_i2]
      • Game - Display to (All players) the text: Ran Unit Variables
Edit: Hid the trigger in some nice tags to appease the Great Forum Gods/admins.
 
Level 6
Joined
May 15, 2009
Messages
191
What number is your unit group array set to in the variable editor ? If you use 14 it needs to be at 14.

Right, thx. I'll try that (I always forget about Variables Values)
Will report back in a bit (editing this post)

Edit: Works! Thanks alot (rep awarded already) - Set the Unit Variable Value to 14, and the Group Variable Value to 7. Thanks for the tip.
 
Last edited:
Level 29
Joined
Oct 24, 2012
Messages
6,543
Right, thx. I'll try that (I always forget about Variables Values)
Will report back in a bit (editing this post)

Edit: Works! Thanks alot (rep awarded already) - Set the Unit Variable Value to 14, and the Group Variable Value to 7. Thanks for the tip.

unit variables should only be set to 1. Unit groups need to be set to 7 unless you create them in the triggers.
 
Status
Not open for further replies.
Top