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

[General] Pick all units in group A that aren't in group B

Status
Not open for further replies.
Level 5
Joined
Oct 5, 2012
Messages
67
I need to write a trigger for a ability that ensnares every unit that enters an area ( it shouldn't stun one unit twice though). To achieve this I created 2 groups, one with all units that just entered (and haven't been ensnared yet) and one with all units that allready have been ensnared.
I didn't manage to find a trigger that picks every unit in a group that aren't in another group.
Here is the trigger:

  • Trigger Copy
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • Unit - Create 1 DummyUnit for (Owner of Owner) at (Position of Owner) facing Default building facing degrees
      • Set Ownerdummy = (Last created unit)
      • Set Ownerlevel = (Level of Flame Strike for Owner)
      • Unit - Set level of Ensnare for Ownerdummy to Ownerlevel
      • Unit Group - Add all units of (Units within 300.00 of Ownertarget matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is An Ancient) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an enemy of (Owner of Ku to group1
      • Unit Group - Pick every unit in group1 and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is in group2) Equal to False
            • Then - Actions
              • Set enemytarget = (Picked unit)
              • Unit - Order Ownerdummy to Orc Raider - Ensnare enemytarget
              • Unit Group - Add enemytarget to group2
              • Set enemytarget = No unit
            • Else - Actions
      • Unit - Kill dummy
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Instead of using unit groups, try this.If picked unit doesnt have ensnare buff, ensanre it.
 
Level 5
Joined
Oct 5, 2012
Messages
67
Instead of using unit groups, try this.If picked unit doesnt have ensnare buff, ensanre it.

This will not work. The units will stay ensnared for eternity (because everytime they loose the buff they will be ensnared again). That's not what I want!

I want the units to be ensnared ONCE when they enter the area, but they should be able to walk away after that. Every unit entering the area should be ensnared too...
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Ok then, do 2 checks before using ensnare,
1) Unit doesnt have ensnare buff
2) Unit is not in Ensnared units group
>> then ensnare unit and add unit to "Ensnared units" group

No need 2 seperate groups.
 
Level 18
Joined
Sep 14, 2012
Messages
3,413
There is such function ;)
JASS:
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

But not a native at all ^^
 
Status
Not open for further replies.
Top