• 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.

[Solved] How can I convert PickEveryDestructible into Jass Script?

Status
Not open for further replies.
Level 10
Joined
May 12, 2018
Messages
147
1645822058944.png


I learned Location must leak, so I want to convert this trigger to Jass using x,y,range. How can I do this?
 
Level 30
Joined
Sep 26, 2009
Messages
2,617
Locations only leak if you do not destroy them.
  • Custom script: call RemoveLocation(udg_TempPoint)
The above removes location set to variable "TempPoint", preventing a memory leak.
Basically you will create location, do stuff with it and once you don't need it anymore, you remove it via the above custom script.

You can also check the following thread: Things That Leak
It contains list of types of objects that cause leak and how you can destroy the objects in order to prevent memory leaks
 
Level 10
Joined
May 12, 2018
Messages
147
Locations only leak if you do not destroy them.
  • Custom script: call RemoveLocation(udg_TempPoint)
The above removes location set to variable "TempPoint", preventing a memory leak.
Basically you will create location, do stuff with it and once you don't need it anymore, you remove it via the above custom script.

You can also check the following thread: Things That Leak
It contains list of types of objects that cause leak and how you can destroy the objects in order to prevent memory leaks
Some JassScripters taught me that RemoveLocation is not Destroy so it is not perfect to clear leaks.
So I was looking for a way to use only X, Y, and range without using Loc at all.
 

Uncle

Warcraft Moderator
Level 74
Joined
Aug 10, 2018
Messages
7,939
Some JassScripters taught me that RemoveLocation is not Destroy so it is not perfect to clear leaks.
So I was looking for a way to use only X, Y, and range without using Loc at all.
RemoveLocation() gets rid of the Location, there's nothing else that needs to be done.

Maybe they were talking about using local locations in Jass code? In which case you not only have to Remove the Location but also null it:
vJASS:
local location Loc = Location(0, 0)
call RemoveLocation(Loc)
set Loc = null

But for the sake of answering your question, here's some ways to enumerate over a group of destructables:
vJASS:
call EnumDestructablesInCircleBJ(radius, loc, actionFunc)
call EnumDestructablesInRect(r, filter, actionFunc)
call EnumDestructablesInRectAll(r, actionFunc)
This isn't really accessible in GUI.
 
Level 10
Joined
May 12, 2018
Messages
147
RemoveLocation() gets rid of the Location, there's nothing else that needs to be done.

Maybe they were talking about using local locations in Jass code? In which case you not only have to Remove the Location but also null it:
vJASS:
local location Loc = Location(0, 0)
call RemoveLocation(Loc)
set Loc = null

But for the sake of answering your question, here's some ways to enumerate over a group of destructables:
vJASS:
call EnumDestructablesInCircleBJ(radius, loc, actionFunc)
call EnumDestructablesInRect(r, filter, actionFunc)
call EnumDestructablesInRectAll(r, actionFunc)
This isn't really accessible in GUI.
Thanks for your detailed answer. I've already written RemoveLocation(udg_TempPoint) for that trigger. If the leak is completely cleaned by RemoveLocation, I don't have to write additional script, right?
 
Side suggestion, you may use "function IsDestructableTree takes destructable d returns boolean" to check for tree.
One line of custom script similar like you did on top with custom script could call the function and assign GUI boolean variable.
 
Status
Not open for further replies.
Top