• 🏆 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!

How to create a unit group event

Status
Not open for further replies.
Level 4
Joined
Oct 9, 2013
Messages
84
Hello guys, so I'm having a bit of trouble here, I want to do a trigger where I kill 4 units (2 brigands, 1 assassin and 1 rogue) and certain action occurs, but I can't find a way to select a group to kill in order for an action to be activated

I can only select "kill 1 unit and certain action occurs"
I want to be able to "kill 4 units and certain action occurs"

I've tried to look for this answer everywhere but google search engine is absolutely useless, so I come here to ask for your help.
 
Level 16
Joined
Apr 20, 2014
Messages
522
You must create a group which has these 4 units.
If all units in the group are dead, then...

Is it what you wanted?
 
Level 12
Joined
May 22, 2015
Messages
1,051
Expanding on Tuwnew's comment, just check when 1 unit dies, but then check if all the units in the group are dead with each one, then do the action only when they are all dead.
 
Level 12
Joined
May 22, 2015
Messages
1,051
It's a variable type. Then there's an action to add a unit to a unit group and you can loop over the unit group. Basically, you need to add your 4 units into a unit group and then, whenever one of those units dies, you loop over the unit group and check if they are all dead. If they are all dead, then you do what you want to do.

Adding the units to the unit group should happen when you create the units. If they are already placed on the map at the start, just add them in a "map initialization" trigger.

Alternatively, you could have just a single integer variable. Start it at 0. Whenever one of those units dies, increase it by 1. When it is at 4, then you know all 4 died and can do your actions.
 
Level 4
Joined
Oct 9, 2013
Messages
84
sorry but I still don't quite understand, could you make an example of this trigger and show an image to me of the triggers please, it would help better
 
Level 39
Joined
Feb 27, 2007
Messages
4,994
If the units are preplaced on your map:
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Unit Group - Add Brigand 001 <gen> to DEATH_GROUP
    • Unit Group - Add Brigand 002 <gen> to DEATH_GROUP
    • Unit Group - Add Assassin 001 <gen> to DEATH_GROUP
    • Unit Group - Add Rogue 001 <gen> to DEATH_GROUP
If the units are created with a trigger instead:
  • -------- inside your creation trigger --------
  • Actions
    • Set SOME_POINT = (Center of SOME_REGION <gen>) //this is so we don't cause a memory leak, see below
    • Unit - Create 1 Brigand for (Neutral Hostile) at SOME_POINT facing Default building facing degrees
    • Unit Group - Add (Last created unit) to DEATH_GROUP
    • Unit - Create 1 Brigand for (Neutral Hostile) at SOME_POINT facing Default building facing degrees
    • Unit Group - Add (Last created unit) to DEATH_GROUP
    • Unit - Create 1 Assassin for (Neutral Hostile) at SOME_POINT facing Default building facing degrees
    • Unit Group - Add (Last created unit) to DEATH_GROUP
    • Unit - Create 1 Rogue for (Neutral Hostile) at SOME_POINT facing Default building facing degrees
    • Unit Group - Add (Last created unit) to DEATH_GROUP
    • -------- this next line cleans a point/location leak, there are many tutorials about this in the tutorials section ---------
    • Custom script: call RemoveLocation(udg_SOME_POINT) //change the name of the variable to match whatever you call your point variable, but keep the udg_ prefix
whenever one of those units dies, you loop over the unit group and check if they are all dead. If they are all dead, then you do what you want to do.
  • Events
    • Unit - A unit dies
  • Conditions
    • ((Triggering Unit) is in DEATH_GROUP) equal to true
  • Actions
    • Set AllDeadBoolean = True
    • Unit Group - Pick every unit in DEATH_GROUP and do (Actions)
      • Loop - Actions
        • If (All conditions are true) then do (Then actions) else do (Else actions)
          • If - Conditions
            • (Current life of (Picked Unit)) greater than 0.405 //units die at 0.405 hp
          • Then - Actions
            • Set AllDeadBoolean = False
          • Else - Actions
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • AllDeadBoolean equal to True
      • Then - Actions
        • -------- Do your actions here! --------
        • -------- Clean up the group and trigger too: --------
        • Custom script: call DestroyGroup(udg_DEATH_GROUP) //again change the name to match your variable but keep the udg_ prefix
        • Trigger - Turn off (This trigger)
      • Else - Actions
Alternatively, you could have just a single integer variable. Start it at 0. Whenever one of those units dies, increase it by 1. When it is at 4, then you know all 4 died and can do your actions.
  • Events
    • Unit - A unit dies
  • Conditions
    • ((Triggering Unit) is in DEATH_GROUP) equal to true
  • Actions
    • Set DeadCount = DeadCount + 1
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • DeadCount greater than or equal to 4
      • Then - Actions
        • -------- Do your actions here! --------
        • -------- Clean up the group and trigger too: --------
        • Custom script: call DestroyGroup(udg_DEATH_GROUP) //again change the name to match your variable but keep the udg_ prefix
        • Trigger - Turn off (This trigger)
      • Else - Actions
 
if the units won't respawn, are specific targets and you know the amount.
one can also do it that way:
  • Kill group
    • Events
      • Unit - Ritter 0006 <gen> Dies
      • Unit - Scharfschütze 0008 <gen> Dies
      • Unit - Scharfschütze 0007 <gen> Dies
      • Unit - Soldat 0005 <gen> Dies
    • Conditions
      • (Evaluation count of (This trigger)) Equal to 4
    • Actions
      • Game - Display to (All players) for 30.00 seconds the text: Group was defeated
 
Level 4
Joined
Oct 9, 2013
Messages
84
"(Current life of (Picked Unit)) greater than 0.405 //units die at 0.405 hp" this one I could not know how to do it
 
Status
Not open for further replies.
Top