• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Picking all enemy units in a single action?

Status
Not open for further replies.
Level 8
Joined
Sep 24, 2007
Messages
300
I have no idea, hot to pick all enemy units in a single action, like: Pick every unit owned by enemy of xxx player in rect and do actions.


Now, I use:

1. Pick player group (enemies of xxxx player)
........If/then/else
................Owned of picked unit equal to picked player
........................then
...............................pick every unit in unit group and do action


I dunno if this even works... Any more simple ways to do it (and wrorking..)?
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
  • Player Group - Pick every player in (All enemies of (Triggering player)) and do (Actions)
    • Loop - Actions
      • Set Abadon = (Units owned by (Picked player))
      • Unit Group - Pick every unit in Abadon and do (Actions)
        • Loop - Actions
          • Do Nothing
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
I think this is better, because spiwns solution leaks a player group:

  • Set Unitgroup = (Units in (Playable map area) matching (((Matching unit) belongs to an enemy of Player X (Colour)) Equal to True))
  • Unit Group - Pick every unit in Unitgroup and do (Actions)
    • Loop - Actions
      • -------- //Your Actions here, after the UnitGroup Loop, just destroy it to prefent it leaking =) --------
  • Custom script: call DestroyGroup(udg_Unitgroup)
  • Custom script: set udg_Unitgroup=null
 
Level 8
Joined
Sep 24, 2007
Messages
300
Ok, I tried a little different thingie, by removing all allied units from unit group, so I basicaly have only enemies.

Should this work?

trigger.jpg
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
That is correct, it leaks - easily fixable.
But it is faster.
P.s. You do not need the Custom script: set udg_Unitgroup=null
Unitgroup is a global variable, so you do not need to null it.
Edit:
Oh klemen that will not work.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
You lack experience in triggering, which I doubt you will earn very fast.
The trigger you posted will not do anything. If no one else post a working trigger, I will, but later.
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
Why do you GUI guys keep using DestroyGroup? I mean, the Blizzard dudes added the bj_wantDestroyGroup global JUST for this. So instead of destroying the group AFTER the enum, just do this right before the enum:
JASS:
set bj_wantDestroyGroup = true
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
:D
Here is a sample map. It does what the trigger you posted does(next time use trigger tags). I hope that is what you wanted it to do :D
P.s. Sample map so that you can see the variables or just copy it.
 

Attachments

  • spell.w3x
    9.4 KB · Views: 67
Status
Not open for further replies.
Top