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

[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 19
Joined
Jul 14, 2011
Messages
875
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