Unit Group leak problem

mapguy

New Member
Reaction score
46
Im having a problem, some people just told me that in GUI:
Code:
set g = units in playable map area
pick every units in g and do actions
clear all units from group g
Custom script: call DestroyGroup (udg_g)
causes leak when I destroy the group...

well
how can I solve my problem using only "GUI custom scripts" to create groups, destroy them, pick my units and so on?
 

Ayanami

칼리
Reaction score
288
You've really asked this many times. This uses FirstOfGroup, but whatever, at least it solves your leak issues. You need Recycle. Here's an example of how you use FirstOfGroup. You need NewGen.

Trigger:
  • Untitled Trigger
    • Events
    • Conditions
    • Actions
      • Custom script: local group g = Group.get()
      • Custom script: local real x = GetUnitX(GetTriggerUnit())
      • Custom script: local real y = GetUnitY(GetTriggerUnit())
      • Custom script: local unit u
      • Custom script: call GroupEnumUnitsInRange(g, x, y, 500.00, null)
      • Custom script: loop
      • Custom script: set u = FirstOfGroup(g)
      • Custom script: exitwhen u == null
      • -------- Do actions --------
      • Custom script: call GroupRemoveUnit(g, u)
      • Custom script: endloop
      • Custom script: call Group.release(g)
      • Custom script: set g = null
      • Custom script: set u = null


Basically, you set the condition in the "Do actions" part. x and y is basically the coordinates of the point that you want to take the circle's origin to be, in other words, the "location". But by using x, y we don't need to worry about leaks, unlike locations. GetUnitX(GetTriggerUnit()) and GetUnitY(GetTriggerUnit()) simply means to get the current x and y coordinates of the Triggering unit's position. So let's say I want to get only units that are alive. Then it'll be:

Trigger:
  • Untitled Trigger
    • Events
    • Conditions
    • Actions
      • Custom script: local group g = Group.get()
      • Custom script: local real x = GetUnitX(GetTriggerUnit())
      • Custom script: local real y = GetUnitY(GetTriggerUnit())
      • Custom script: local unit u
      • Custom script: call GroupEnumUnitsInRange(g, x, y, 500.00, null)
      • Custom script: loop
      • Custom script: set u = FirstOfGroup(g)
      • Custom script: exitwhen u == null
      • Custom script: if not IsUnitType(u, UNIT_TYPE_DEAD) then
      • -------- Do actions --------
      • Custom script: endif
      • Custom script: call GroupRemoveUnit(g, u)
      • Custom script: endloop
      • Custom script: call Group.release(g)
      • Custom script: set g = null
      • Custom script: set u = null


You don't use set g = CreateGroup() or DestroyGroup(g) anymore. You replace CreateGroup() with Group.get() and DestroyGroup() with Group.release(). Thus, you need Recycle, as I stated above.

But this really does look ridiculous. No sense of organization. Compare the above chunk of nonsense with this.

JASS:

local group g = Group.get()
local real x = GetUnitX(GetTriggerUnit())
local real y = GetUnitY(GetTriggerUnit())
local unit u
call GroupEnumUnitsInRange(g, x, y, 500.00, null)
loop
    set u = FirstOfGroup(g)
    exitwhen u == null
    if not IsUnitType(u, UNIT_TYPE_DEAD) then
        //Do actions
    endif
    call GroupRemoveUnit(g, u)
endloop
call Group.release(g)
set g = null
set u = null


Which one seems more comprehend-able, obviously the one in JASS tags. Thus, using v/JASS would be the best method...
 

hgkjfhfdsj

Active Member
Reaction score
55
not sure if this is the best method..
- make the group local
- set the local as a global
- use GroupEnumUnit....accordingly
- recycle the group
 

hgkjfhfdsj

Active Member
Reaction score
55
but using enum filter function is difficult to squeeze in in gui, which may end up having the filter function in a map header, which isnt that practical considering how many times he will use that.
 

mapguy

New Member
Reaction score
46
now the truth to me, please, which is easier and faster:

1 - Glenphyr solution

or

2 - cause dummy units to damage an area, then I block that damage and detect the source, then, I do my actions, example:
Code:
----lots of other actions are above this one----
If unit type of damage source equal to (fear) then do actions
If damage taken greater than 0.00 then do actions
if damaged_unit is facing Vampire then do actions
add damage_unit to Units_with_fear
//a timer runs when the spell is cast, and when the timer ends the trigger below runs
----lots of more actions are below this one----
Code:
fear timer ends

clear all units from Units_With_fear
My method for me is simple, Im not saying Glenphyr method is wrong, no, Im just saing that for me, Its easier to do my way.
MY WAS IS LEAK FREE?
 

Immolation

Member
Reaction score
20
I think it may be, not sure. However that solution crashes Mac users.

Also, in my opinion Glenph's solution is much better: Recycle is great if you do alot of work with groups, and JASS is much faster than GUI anyway.
 

mapguy

New Member
Reaction score
46
faster?
what do you mean by faster???
you mean less lag?
is it really faster or just like 25% ?
well.
the problem for MAC users is when I deal 0.00 damage in area or when I deal any damage in area?
 

Ayanami

칼리
Reaction score
288
faster?
what do you mean by faster???
you mean less lag?
is it really faster or just like 25% ?
well.
the problem for MAC users is when I deal 0.00 damage in area or when I deal any damage in area?

It's the function "Unit - Damage Area" that causes the problem for Mac users.
 

Immolation

Member
Reaction score
20
[ljass]call UnitDamagePointLoc[/ljass] crashes Mac users, their WC3 just shuts down, regardless of damage, radius, etc...

Also, I dunno how much faster, just faster. That's enough for me.
 

mapguy

New Member
Reaction score
46
lol.
Mac users can't do nothing to prevent this?
well.

lets make a guess.
do you think like 25% of the persons who plays my map uses mac?
or mac users are more like 10%?
Im asking for mac users that playes WC3, not general mac users.
Ill make a poll at game talk forums and ask for what people uses.
 

mapguy

New Member
Reaction score
46
You've really asked this many times. This uses FirstOfGroup, but whatever, at least it solves your leak issues. You need Recycle. Here's an example of how you use FirstOfGroup. You need NewGen.

Trigger:
  • Untitled Trigger
    • Events
    • Conditions
    • Actions
      • Custom script: local group g = Group.get()
      • Custom script: local real x = GetUnitX(GetTriggerUnit())
      • Custom script: local real y = GetUnitY(GetTriggerUnit())
      • Custom script: local unit u
      • Custom script: call GroupEnumUnitsInRange(g, x, y, 500.00, null)
      • Custom script: loop
      • Custom script: set u = FirstOfGroup(g)
      • Custom script: exitwhen u == null
      • -------- Do actions --------
      • Custom script: call GroupRemoveUnit(g, u)
      • Custom script: endloop
      • Custom script: call Group.release(g)
      • Custom script: set g = null
      • Custom script: set u = null


Basically, you set the condition in the "Do actions" part. x and y is basically the coordinates of the point that you want to take the circle's origin to be, in other words, the "location". But by using x, y we don't need to worry about leaks, unlike locations. GetUnitX(GetTriggerUnit()) and GetUnitY(GetTriggerUnit()) simply means to get the current x and y coordinates of the Triggering unit's position. So let's say I want to get only units that are alive. Then it'll be:

Trigger:
  • Untitled Trigger
    • Events
    • Conditions
    • Actions
      • Custom script: local group g = Group.get()
      • Custom script: local real x = GetUnitX(GetTriggerUnit())
      • Custom script: local real y = GetUnitY(GetTriggerUnit())
      • Custom script: local unit u
      • Custom script: call GroupEnumUnitsInRange(g, x, y, 500.00, null)
      • Custom script: loop
      • Custom script: set u = FirstOfGroup(g)
      • Custom script: exitwhen u == null
      • Custom script: if not IsUnitType(u, UNIT_TYPE_DEAD) then
      • -------- Do actions --------
      • Custom script: endif
      • Custom script: call GroupRemoveUnit(g, u)
      • Custom script: endloop
      • Custom script: call Group.release(g)
      • Custom script: set g = null
      • Custom script: set u = null


You don't use set g = CreateGroup() or DestroyGroup(g) anymore. You replace CreateGroup() with Group.get() and DestroyGroup() with Group.release(). Thus, you need Recycle, as I stated above.

But this really does look ridiculous. No sense of organization. Compare the above chunk of nonsense with this.

JASS:
local group g = Group.get()
local real x = GetUnitX(GetTriggerUnit())
local real y = GetUnitY(GetTriggerUnit())
local unit u
call GroupEnumUnitsInRange(g, x, y, 500.00, null)
loop
    set u = FirstOfGroup(g)
    exitwhen u == null
    if not IsUnitType(u, UNIT_TYPE_DEAD) then
        //Do actions
    endif
    call GroupRemoveUnit(g, u)
endloop
call Group.release(g)
set g = null
set u = null


Which one seems more comprehend-able, obviously the one in JASS tags. Thus, using v/JASS would be the best method...

sorry, I didnt understand very well, can U explain better how to use your way?

I just put my actions in the comment of actions?
like I was picking all unit in group and doing actions?
what is the "Custom script: local group g = Group.get()" ?

DANG! I just realized it was a double post!
 

hgkjfhfdsj

Active Member
Reaction score
55
Im asking for mac users that playes WC3, not general mac users.
you have my vote :)

[ljass]local group g = Group.get()[/ljass]
declares a local group. group.get() retrieves a group from a recycled stack
JASS:
     set u = FirstOfGroup(g)
    exitwhen u == null

change 'u' to a global so that you can use the unit in gui triggers/ outside of the custom script
changing u to global also allows you to declare the filters in gui(using the global)
 

mapguy

New Member
Reaction score
46
you are mac user?

hey, can you give me a practical use for glinphyrs trigger?
I still don't understant this shi... for me, looking to JASS is the same as looking to a text written in Latin (I know the letters, I know some works, but I dont understand the meaning).

is it like:

Code:
    * Custom script: local group g = Group.get()
    * Custom script: local real x = GetUnitX(GetTriggerUnit())
    * Custom script: local real y = GetUnitY(GetTriggerUnit())
    * Custom script: local unit u
    * Custom script: call GroupEnumUnitsInRange(g, x, y, 500.00, null)
    * Custom script: loop
    * Custom script: set u = FirstOfGroup(g)
    * Custom script: exitwhen u == null
    * Custom script: if not IsUnitType(u, UNIT_TYPE_DEAD) then

    * If unit type of u equal to footman then do actions:
                       *my actions

    * Custom script: endif
    * Custom script: call GroupRemoveUnit(g, u)
    * Custom script: endloop
    * Custom script: call Group.release(g)
    * Custom script: set g = null
    * Custom script: set u = null
this trigger she made is totally leak free?
I still have to recycle it or it recycles itself?

If I damage area with thunder clap(and not with triggers) dealing 0.00 damage it stills crash for mac users? no right? Is there a way to make units instantly cast some ability? like. cast in 0.00 second?
 

hgkjfhfdsj

Active Member
Reaction score
55
make units instantly cast some ability? like. cast in 0.00 second?
global dummy with 0 cast/animation time etc. use dummycaster, or otherwise just c&p the dummy in the system if you dont have newgen. ('recycle' also requires newgen, if you dont have, im pretty sure someone in this forum would kindly convert it to vanilla jass :))

Trigger:
  • Actions
    • Custom script: local group g = Group.get()
    • Custom script: call GroupEnumUnitsInRange(g, GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), 500., null )
    • Custom script: loop
    • Custom script: set udg_Filter_Unit = FirstOfGroup(g)
    • Custom script: exitwhen udg_Filter_Unit == null
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Filter_Unit is A structure) Equal to False
      • Then - Actions
        • Animation - Play Filter_Unit's stand animation
      • Else - Actions
        • Animation - Play Filter_Unit's attack animation
    • Custom script: call GroupRemoveUnit(g, udg_Filter_Unit)
    • Custom script: set udg_Filter_Unit = null // to be safe for the next loop
    • Custom script: endloop
    • Custom script: call Group.release(g)
    • Custom script: set g = null


as for the leaking issues, i know no more than what the previous posters said.
 

mapguy

New Member
Reaction score
46
ok, you are saying that this trigger has no leaks, but I have to recycle?

well, another thing.

PLEASE! ARE U SURE THIS CREEPY MAC BUG REALLY EXISTS!?
CAN U PLEASE CREATE A MAP AND TEST ON YOUR MAC TO SEE IF IT REALLY CRASHES? AND WHY MAC DEVELOPERS DIDNT FIX THIS BUG!?
WHY EVERYTHING CONSPIRES AGAINST ME!?
 

hgkjfhfdsj

Active Member
Reaction score
55
the group recycles, provided that you have the system imported.
the desync thing ive never experienced it, but i wouldnt say it doesnt exist.. i sometimes use parallels desktop to play wc3 instead :p) so i wouldnt really say im a mac user..
 

mapguy

New Member
Reaction score
46
could you try to see if the bug happend in your mac?

right now Im using Immollation to create unit groups based on damage detection.
but If the bug dont exist I can use "unit damages area"
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top