• 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.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

[JASS] GroupEnumUnitsInRange doesn't work at start of map

Status
Not open for further replies.
Level 14
Joined
Aug 30, 2004
Messages
909
In a rather complicated missile trigger, I need to look around a given unit (u, located at point (x,y)) for potential enemies. When I use this line, all works fine:

  • Set tempDamageUnits = (Units within 125.00 of (Point(x, y)))
The trigger successfully detects my unit near "u" and puts that unit into the unit group "tempDamageUnits."

When I use this line of JASS as custom script instead, something odd happens:

  • Custom script: call GroupEnumUnitsInRange(udg_tempDamageUnits, udg_x, udg_y, 125, null)
When this line of code is used, my unit is no longer detected for the first 10 seconds of the game or so. After that, it appears to work.

I have a lot going on in the map, but I can't imagine why these two pieces of code should function differently at all. I usually use the "GroupEnumUnitsInRange" just so I can avoid having to remove the leaks. But apparently the command is different in some way than the GUI action. Does it have something to do with the "null" at the end? I don't know what that codes for.

Anyway, I've solved the problem by using the GUI action, but I would like to know for future reference what the difference between the JASS command the GUI command is.

Thank you.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Try creating the group itself before using the group variable:
  • Custom script: if (udg_tempDamageUnits==null) then
  • Custom script: set udg_tempDamageUnits=CreateGroup()
  • Custom script: endif
  • Custom script: call GroupEnumUnitsInRange(udg_tempDamageUnits, udg_x, udg_y, 125, null)
EDIT: Wait, I may be wrong, could you post the code?
 
Using "null" as filter does not leak anything. I think he means avoiding potential leak by not creating a new unit group with using the GroupEnum native instead of the GUI one.

Is the group maybe used & destroyed before in an other trigger? This way the group would not exist anymore, so you can't use it.
Chobibo has shown a good solution for this problem... you have to ensure that the group exists.

Else, we need to see the whole code. :)
 
Level 20
Joined
Jul 14, 2011
Messages
877
I was reffering to a tutorial from thehelper, which stated that using null leaks and recycling one global unit group is better (where you do everything in the filter). I'm pretty sure purgeandfire once linked it in the spells section. I remember that there was a system call 'Recycle', although I couldnt find neither it, nor the tutorial. I might also be remembering things wrong.

It also seems that thehelper is down :(
 
Level 14
Joined
Aug 30, 2004
Messages
909
I think you guys have solved it!

As I mentioned, the trigger doesn't work in the first few seconds of the game, but after a while it starts working. I didn't realize I needed to create the group first for that JASS command to work. I find it a little bit confusing, so I think I'll just stick with the GUI and the "destroyGroup" JASS custom script command to remove the leak.

For clarity's sake, the leak I was referring to was the unitGroup leak that results when you set a unit group equal to a group of units and then reuse that same unitGroup variable later without destroying it first.

Thanks everyone! +rep all around
 
Status
Not open for further replies.
Top