• 🏆 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!

Unit Groups are making me angry.. @.@

Status
Not open for further replies.
Level 14
Joined
Aug 8, 2010
Messages
1,022
Hello, guys! I want to ask why this doesn't work...
  • Init Creeps
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set OgreCreepsRegions[1] = Creeps At Ronga <gen>
      • Set OgreCreepsRegions[2] = Creeps Ronga <gen>
      • Set OgreCreepsRegions[3] = Creeps At Ronga Gate <gen>
      • Set OgreCreepsRegions[4] = Creeps At Dagnis <gen>
      • Set OgreCreepsRegions[5] = Creeps At Human Tower <gen>
      • Set OgreCreepsRegions[6] = Creeps At Gramor Gate <gen>
      • Set OgreCreepsRegions[7] = Creeps Gramor <gen>
      • Set OgreCreepsRegions[8] = Creeps At Gramor <gen>
      • For each (Integer IntegerLoop) from 1 to 8, do (Actions)
        • Loop - Actions
          • Trigger - Add to Creeps Unit Groups <gen> the event (Unit - A unit enters OgreCreepsRegions[IntegerLoop])
  • Creeps Unit Groups
    • Events
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Entering unit)) Equal to Ogre Basher
          • (Unit-type of (Entering unit)) Equal to Ogre Warlock
    • Actions
      • For each (Integer IntegerLoop) from 1 to 7, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (OgreCreepsRegions[IntegerLoop] contains (Entering unit)) Equal to True
            • Then - Actions
              • Unit Group - Add (Entering unit) to OgreCreepsUnitGroups[IntegerLoop]
            • Else - Actions
              • Unit Group - Remove (Entering unit) from OgreCreepsUnitGroups[IntegerLoop]
  • Creeps Ronga
    • Events
      • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • Set CreepsSpawnPoint[1] = (Center of Creeps Ronga <gen>)
      • Unit - Create 1 Ogre Basher for Player 11 (Dark Green) at CreepsSpawnPoint[1] facing 0.00 degrees
      • Custom script: call RemoveLocation(udg_CreepsSpawnPoint[1])
  • Creeps Move
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer IntegerLoop) from 1 to 8, do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in OgreCreepsUnitGroups[IntegerLoop] and do (Actions)
            • Loop - Actions
              • Set Location = (Random point in OgreCreepsRegions[(IntegerLoop + 1)])
              • Unit - Order (Picked unit) to Move To Location
              • Custom script: call RemoveLocation(udg_Location)
The problem is that the created unit does not move.. i tested and made sure that the unit is in the right group, everything is OK, but the order is not given... it doesn't even kill the unit with the "Unit - Kill Unit" action.

I just wanna make a creep way. You know, i add the unit in a group, every second it checks if the units in unit group 1 have enemies within their acquisition range, if they have, then the trigger does nothing, else it orders the creeps to the second region, when the units enter the second region, they get added to unit group 2. And this process does this until the units reach the last region.
 
Level 14
Joined
Aug 8, 2010
Messages
1,022
Yes but... as i said, i tested and the unit is in the right unit group. The problem is not when the unit enters, it's when the unit is ordered (when all the units in the unit groups are picked).

EDIT : I tested again... i don't know if the unit is in the group. How to test and see?
 
Level 14
Joined
Aug 8, 2010
Messages
1,022
  • Creeps Unit Groups
    • Events
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Entering unit)) Equal to Ogre Basher
          • (Unit-type of (Entering unit)) Equal to Ogre Warlock
    • Actions
      • For each (Integer IntegerLoop) from 1 to 7, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Distance between (Position of (Entering unit)) and (Center of OgreCreepsRegions[IntegerLoop])) Less than or equal to 700.00
            • Then - Actions
              • Unit Group - Add (Entering unit) to OgreCreepsUnitGroups[IntegerLoop]
              • Game - Display to (All players) the text: aSd
            • Else - Actions
              • Unit Group - Remove (Entering unit) from OgreCreepsUnitGroups[IntegerLoop]
  • Test
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
    • Actions
      • For each (Integer IntegerLoop) from 1 to 8, do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in OgreCreepsUnitGroups[IntegerLoop] and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Triggering unit) is in OgreCreepsUnitGroups[IntegerLoop]) Equal to True
                • Then - Actions
                  • Game - Display to (All players) the text: Yes
                • Else - Actions
I see the aSd when i start the game, but i don't see Yes when i select the unit.. :sad:
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
No they are not supposed to be bugged.
It's more likely a lack of knowledge from yourself, before using a group it must be created, so since you use GUI array variable make sure you use the correct "size" in the variable editor.

Also, about the region event, it's way more tricky it depends from where the unit comes (north, south, east, west).
For half of them the unit is already inside, and for the other part it's still outside when the event fire.
I don't remember exactly how it works, but it's easy to test.
Also if i remember correctly the event works correctly when you move an unit by trigger, it's even instant.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Ok forget what i've said, frankly i didn't read well your trigger, my bad ...
I've also forgotten that you can't really use the "region" type in GUI.

What it's called a "region" in GUI is nothing more than a rect, and you use pre-defined rects, so yes it's probably because you overwrite the variable somewhere else or you go out of the range like Arhowk has suggested.
 
Last edited:
Level 14
Joined
Aug 8, 2010
Messages
1,022
@Troll-Brain, No, no, no, man. I have tested, i am 100% sure that unit groups are bugged. I have tested with a group with array 1 and group with array 100 (that big difference in the numbers can't be mistaken). And so the first group worked, but the second group didn't. Yes, the event was "A unit enters a region" but i made sure that the trigger gets the unit and fires correctly. Simply the unit wasn't added to the second group. And when i changed the variable with the 100-th array to another, array-less variable, it worked perfectly.

@Arhowk, i made that intentionally. There is no need for the 8-th group to run because there is no 9-th region to where they will go. Thus only the 7-th group must run to the 8-th region (the last one).
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
AFAIK, array size in the GUI variable manager doesn't actually do anything. They are either created with max size or "resize" dynamically as needed, because in all my maps I just tick "array", let it default to 1, and I can use an index I like.

Interesting thing, this unit group problem. I'll make a testmap and see if I can replicate.

My initial thoughts about being in a region or not were way off. This works:
  • enter regions
    • Events
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Footman
    • Actions
      • For each (Integer A) from 1 to 3, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (region[(Integer A)] contains (Triggering unit)) Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: (String((Integer A)))
              • Unit Group - Add (Triggering unit) to group[(Integer A)]
            • Else - Actions
Setup trigger and loop trigger:
  • sertup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set region[1] = Region 000 <gen>
      • Set region[2] = Region 001 <gen>
      • Set region[3] = Region 002 <gen>
      • For each (Integer A) from 1 to 3, do (Actions)
        • Loop - Actions
          • Trigger - Add to enter regions <gen> the event (Unit - A unit enters region[(Integer A)])
          • Floating Text - Create floating text that reads registered at (Center of region[(Integer A)]) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
  • crees pve
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 3, do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in group[(Integer A)] and do (Actions)
            • Loop - Actions
              • Unit - Order (Picked unit) to Attack-Move To (Center of region[((Integer A) + 1)])
So it is being successfully added to group 1, and in group 1 being ordered to region 2.

But the moment I try this:
  • enter regions
    • Events
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Footman
    • Actions
      • For each (Integer A) from 1 to 3, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (region[(Integer A)] contains (Triggering unit)) Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: (String((Integer A)))
              • For each (Integer B) from 1 to 3, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Triggering unit) is in group[(Integer B)]) Equal to True
                    • Then - Actions
                      • Game - Display to (All players) the text: remove
                      • Unit Group - Remove (Triggering unit) from group[(Integer B)]
                    • Else - Actions
              • Unit Group - Add (Triggering unit) to group[(Integer A)]
            • Else - Actions
It fails. Regardless of the order - as you can see I remove the unit from all groups it was in before adding it to the relevant group.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
AFAIK, array size in the GUI variable manager doesn't actually do anything. They are either created with max size or "resize" dynamically as needed, because in all my maps I just tick "array", let it default to 1, and I can use an index I like.

Whrong !!! Unit-Types (found the hard way) and a few others (read about it in some tutorial) need a pre set array. They don't expand their aray when used in triggers.

Maybe its time to attach a map so we can test ?
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
The array size X give X +1 values for your array index (from 0 to X).
Now it all depends how you use the array, all i can say is if you never set the index of an array variable and it is an handle variable (anything excepted boolean, integer, real, string) it will fail because the handle must be created first.

But it's not the case here since you set the index with pre-placed rects.
Anyway it's still more likely that there is a bug or more lying in your script, rather than "group arrays are bugged".

EDIT : If you use too much array sizes , like many ones with the size "100", or a big one with "8192", or whatever ... you can reach the limit op on the main function, which means that your triggers will never be created.

Ok, got the bug, it's in your "Creeps Unit Groups" trigger, yes it's a bug from wc3 but nothing to do with array group.
It's probably a coincidence when you did the tests, make better ones.
As said when the "enter region event" fire, sometimes the unit is still outside, it depends from where the unit is coming (north, south, east or west).
So instead of using this, use X triggers with only one event, this way you will obviously know which rect is concerned.
 
Status
Not open for further replies.
Top