About DestroyGroup()

Dois

New Member
Reaction score
1
I have this trigger and when after I call DestroyGroup(G), the functions "Spawn_Monsters_West_FunctionA" and "Spawn_Monsters_West_FunctionB" don't work... So the only thing that happens is "Spawn_Monsters_West_FunctionA" running once. Ever.
JASS:
function Spawn_Monsters_West_FunctionA takes nothing returns nothing
 local unit U = GetEnumUnit()
 local location L = GetUnitLoc(U) 
    call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl", L))
    call RemoveLocation(L)
    set L = GetRectCenter(gg_rct_West_1L)
    call IssuePointOrderLoc(U, "attack", L)
    call RemoveLocation(L)
 set U = null
 set L = null
endfunction

function Spawn_Monsters_West_FunctionB takes nothing returns nothing
 local unit U = GetEnumUnit()
 local location L = GetUnitLoc(U)
    call SetUnitUserData(U, 10)
    call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl", L))
    call RemoveLocation(L)
    set L = GetRectCenter(gg_rct_West_1R)
    call IssuePointOrderLoc(U, "attack", L)
    call RemoveLocation(L)
 set U = null
 set L = null    
endfunction

function Spawn_Monsters_West_Actions takes nothing returns nothing
 local location L
 local group G
 local integer a = 0
 local integer b
    loop
        set b = 1
        set a = a + 1 
        loop
            exitwhen b > 5
            call SetUnitAnimation(gg_unit_n001_0087, "stand work")
            call SetUnitAnimation(gg_unit_n001_0088, "stand work")
            call TriggerSleepAction(5.0)
            set L = GetUnitLoc(gg_unit_n001_0087)
            set G = CreateNUnitsAtLoc(4, udg_Monsters[a], Player(11), L, 270.0)
            call GroupAddGroup(G, udg_West_Side_Monster_Group)
            call ForGroup(G, function Spawn_Monsters_West_FunctionA)
     >>>>call DestroyGroup(G)<<<<
            call RemoveLocation(L)
            //Other Side
            set L = GetUnitLoc(gg_unit_n001_0088)
            set G = CreateNUnitsAtLoc(4, udg_Monsters[a], Player(11), L, 270.0)
            call GroupAddGroup(G, udg_West_Side_Monster_Group)
            call ForGroup(G, function Spawn_Monsters_West_FunctionB)
     >>>>call DestroyGroup(G)<<<<
            call RemoveLocation(L)
            call QueueUnitAnimation(gg_unit_n001_0087, "stand")
            call QueueUnitAnimation(gg_unit_n001_0088, "stand")
            call TriggerSleepAction(5.0)
            set b = b + 1
        endloop
        call TriggerSleepAction(20.0)
    endloop
endfunction

//===========================================================================
function InitTrig_Spawn_Monsters_West takes nothing returns nothing
    set gg_trg_Spawn_Monsters_West = CreateTrigger(  )
    call TriggerRegisterTimerEvent( gg_trg_Spawn_Monsters_West, 20.00, false )
    call TriggerAddAction( gg_trg_Spawn_Monsters_West, function Spawn_Monsters_West_Actions )
endfunction


However, when I remove the DestroyGroup(G), everything seems to work fine.

The thing is, with the DestroyGroup, even the GUI version(this one was initially GUI as well but I'm converting it to JASS) of this trigger (I have another one which spawns the monsters in the east side) doesn't work right... Its respective "Spawn_Monsters_West_FunctionA" and B doesn't seem to work as well. (The units dont attack-move to the region and no special effect is created)

Anyone knows why? I mean even the other trigger is affected!
 
Umm it works by looping CreateUnitAtLoc() right? So If I just make my own loop or something it should work? Well I'll try that...

Edit: by the way, does that mean I'll have to do
JASS:
 local group G = CreateGroup()
and then in the loop, add units to that group?

nvm yeah thanks for the help... So I'm actually like setting G = bj_lastCreatedGroup right

Edit agian: oh could I instead just do DestroyGroup(bj_lastCreatedGroup)
edit agaain again: oh wait... yeah thats whats im already doing and its causing the problem in all the triggers that use that... ok nvm i think i know what to do.. ill try just looping createUnitAtLoc()

thanks
 
Sorry, I've edited the last post so many times I was thinking maybe if I edited it again you wouldn't come back to see this...

I'm doing this now...
JASS:
...junk...            set L = GetUnitLoc(gg_unit_n001_0087)
            set c = 1
            loop
                exitwhen c > 4 
                call GroupAddUnit(G, CreateUnitAtLoc(Player(11), udg_Monsters[a], L, 270.0))
                set c = c + 1
            endloop
            call GroupAddGroup(G, udg_West_Side_Monster_Group)
            call ForGroup(G, function Spawn_Monsters_West_FunctionA)
            call DestroyGroup(G)
            call RemoveLocation(L)...junk...


This whole thing is in a loop so its gonna keep happening but if I DestroyGroup() then ill have to do something like set G = CreateGroup() again right?

The purpose of destroying the group is to also get rid of the group pointing to the units or something right?

Can I use GroupClear() and does it have the same effect?
 
> if I DestroyGroup() then ill have to do something like set G = CreateGroup() again right?

Yep.

> Can I use GroupClear() and does it have the same effect?

Clearing a group removes the units. The actual group remains and can be used just fine.



Actually, your original trigger... what problem were you seeing there with not destroying it?
 
Oh no there was no problem if I didn't destroy it... I just wanted to know why everything screwed up... Even another trigger. (The destroy was there because the trigger was initially made in GUI)

Anyway thanks for helping me understand... I assume its better to loop CreateUnitAtLoc() instead of the CreateNUnitsAtLoc() anyway since its calling one less function...
 
Thank you for clearing that up AceHeart, I had a similar quesiton. I didn't know if ClearGroup() would create a leak, or why people were telling me not to use DestroyGroup() on the bj_

I assume its better to loop CreateUnitAtLoc() instead of the CreateNUnitsAtLoc()
I think that's better, but I use CreateUnit because it takes points instead of a Loc.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      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