Custom script: set bj_wantDestroyGroup = true

jig7c

Stop reading me...-statement
Reaction score
123
Custom script: set bj_wantDestroyGroup = true

what does it do? how does it work?

i seen people use this in GUI triggers and then the next action line would be creating a group
Unit Group - All units matching....

but then at the end, there is no group variable to destroy..

explain...
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
It is used by the GUI ForGroup() counterparts. Basically, when you use the BJ's and set it to true, it will [ljass]call DestroyGroup()[/ljass] after enumeration and ForGroup or whatever.

These are the functions that use it, however you are better off using natives if you use JASS, but I'll show you the functions that use it anyway:
JASS:
function IsUnitGroupDeadBJ takes group g returns boolean
function IsUnitGroupEmptyBJ takes group g returns boolean
function ForGroupBJ takes group whichGroup, code callback returns nothing
function GroupAddGroup takes group sourceGroup, group destGroup returns nothing
function GroupRemoveGroup takes group sourceGroup, group destGroup returns nothing
function GroupPickRandomUnit takes group whichGroup returns unit
function CountUnitsInGroup takes group g returns integer

JASS:
function IsUnitGroupDeadBJ takes group g returns boolean
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    set bj_isUnitGroupDeadResult = true
    call ForGroup(g, function IsUnitGroupDeadBJEnum)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(g)
    endif
    return bj_isUnitGroupDeadResult
endfunction
function IsUnitGroupEmptyBJ takes group g returns boolean
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    set bj_isUnitGroupEmptyResult = true
    call ForGroup(g, function IsUnitGroupEmptyBJEnum)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(g)
    endif
    return bj_isUnitGroupEmptyResult
endfunction
function ForGroupBJ takes group whichGroup, code callback returns nothing
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    call ForGroup(whichGroup, callback)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(whichGroup)
    endif
endfunction
function GroupAddGroup takes group sourceGroup, group destGroup returns nothing
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    set bj_groupAddGroupDest = destGroup
    call ForGroup(sourceGroup, function GroupAddGroupEnum)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(sourceGroup)
    endif
endfunction
function GroupRemoveGroup takes group sourceGroup, group destGroup returns nothing
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    set bj_groupRemoveGroupDest = destGroup
    call ForGroup(sourceGroup, function GroupRemoveGroupEnum)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(sourceGroup)
    endif
endfunction
function GroupPickRandomUnit takes group whichGroup returns unit
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    set bj_groupRandomConsidered = 0
    set bj_groupRandomCurrentPick = null
    call ForGroup(whichGroup, function GroupPickRandomUnitEnum)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(whichGroup)
    endif
    return bj_groupRandomCurrentPick
endfunction
function CountUnitsInGroup takes group g returns integer
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    set bj_groupCountUnits = 0
    call ForGroup(g, function CountUnitsInGroupEnum)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(g)
    endif
    return bj_groupCountUnits
endfunction
 

jig7c

Stop reading me...-statement
Reaction score
123
sorry to say this, but it doesn't make sense to me..

so instead of setting a group into a variable, you can use that BJ and you do'nt have to destroy the variable then? it automatically destroys it?
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Yes. Since all the group functions in GUI are BJ's, blizzard added the check to allow for easy group destroying. It checks if the bj_ is true, and if so, it will destroy the group after performing the actions it needs to. This way, the only real time you need to set a variable for groups is if you need to reference it later or you basically don't want to destroy it immediately.
 

jig7c

Stop reading me...-statement
Reaction score
123
ha-
i didn't know that
very interesting...
now you seem to an expert on this matter purge, so i'll ask you this..

which one is more efficient/quicker/better???
Trigger:
  • Sample I
    • Set UnitGroup = All units within 500 range of Point
    • Unit Group - Pick every unit in UnitGroup and do
      • Loop
        • Unit - Kill (Picked Unit)
    • Custom script: call DestroyGroup (udg_UnitGroup)

or

Trigger:
  • Sample II
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units within 500 range of Point)
      • Loop
        • Unit - Kill (Picked Unit)
 

shazada

New Member
Reaction score
0
PurgeandFire I saw your work at Photobucket. I must say dude it's awesome :D which platform you used ?
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
ha-
i didn't know that
very interesting...
now you seem to an expert on this matter purge, so i'll ask you this..

which one is more efficient/quicker/better???
Trigger:
  • Sample I
    • Set UnitGroup = All units within 500 range of Point
    • Unit Group - Pick every unit in UnitGroup and do
      • Loop
        • Unit - Kill (Picked Unit)
    • Custom script: call DestroyGroup (udg_UnitGroup)

or

Trigger:
  • Sample II
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Units within 500 range of Point)
      • Loop
        • Unit - Kill (Picked Unit)

Efficiency-wise there isn't really a difference. But in terms of implementation (the fact that a custom global variable is needed) makes the set bj_wantDestroyGroup "easier". :p Besides, one less global needed then. It is basically your choice, since they both require a variable setting and both call the same function ( DestroyGroup ).

PurgeandFire I saw your work at Photobucket. I must say dude it's awesome :D which platform you used ?

Hehe thanks, I used Photoshop CS2 for some and CS3 for the later ones. But I haven't done that in a while and I haven't bothered to install it D=
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Don't use it with "Enum units of type", because GUI fails, it will enum only units of Player(0) (red), and the group will be destroyed after this first enumeration.
And probably some other fancy stuff like leaking a group (didn't investigate this GUI code so much, a fail is a fail)
So i suggest to always use the custom script DestroyGroup instead.

Also if you really care about efficiency, learn jass.
GUI is all but not efficient.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top