• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

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

Status
Not open for further replies.
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?
 
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
 
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.
 
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.
 
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.
Back
Top