• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Solved] Group Arrays

Status
Not open for further replies.
Group arrays are fine, just note you will have to create the groups when units use them and that you need to make sure you don't create them more than once. I assume you are using unit indexing. It is also possible with hashtables.
 
i use a unit indexer. i just thought about 2 options:
option 1: having an array of unit groups
option 2: have 1 unit group and save the caster into a variable with the custom value of each target and then loop through the whole group and check each unit

Yep :) as long as you put them seperatly.
If multiple groups are really needed, so not only needed as temporary group, then it's fully okay. :)
okay thanks ;)
 
Ok, i have a new problem :D
if i loop through the group and check for the units attached to the caster, i cannot do it this way:
JASS:
        loop
            set FoG = FirstOfGroup(g)
            exitwhen FoG == null
            call GroupRemoveUnit(g, FoG)
        endloop
because i dont want to remove units from the group that are not attached to the current caster. The loop would be infinite then. I thought about adding the "not fitting" units to a temp group and readd them to the main group after the loop, but that's probably not the best way :D
Is there another way to loop through a group?
 
A linked list might be more appropriate than a group for what you're trying to do (looping through without emptying it with acces to local variables). It would however be more work to code, unless you are using vJass.
 
You can also add those units to a separate group (typically referred to as a "swap" group) and swap the groups after the loop.

JASS:
        loop
            set FoG = FirstOfGroup(g)
            exitwhen FoG == null
            call GroupRemoveUnit(g, FoG)
            call GroupAddUnit(g2, FoG)
        endloop

        set gTemp = g
        set g = g2
        set g2 = gTemp
 
Status
Not open for further replies.
Back
Top