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

Need help with a unit spawn system

Status
Not open for further replies.
Level 4
Joined
Jul 24, 2010
Messages
85
Event - Unit die
Condition - Triggering unit is in (Temp Group) == true
Action - Remove triggering unit from (Temp Group)
If (Number of units in (Temp Group)) == 0 then
Run Trigger (Your spawn trigger)

And then in your spawn trigger
- Add Last created unit group to (Temp Group)
 
Here's a more friendly version:

  • Unit Group Create
    • Events
    • Conditions
      • (Your Conditions)
    • Actions
      • Unit - blah blah
      • Unit Group - Add (Last Created Unit) to Spawned_Units\\ Do this for every unit created. If you create multiple units, use the (Last Created Unit Group) function. After all that, use this function:
      • Set Spawned_Units_Integer = (Number of units in (Spawned_Units))
Now to check if all the units are dead:
  • Check Dead
    • Events
      • Unit - A unit dies
    • Conditions
      • ((Dying Unit) is in (Spawned_Units)) Equal to True
    • Actions
      • Unit Group - Remove (Dying Unit) from Spawned_Units
      • Set Spawned_Units_Integer = ((Spawned_Units_Integer) - 1)
      • If (All Conditions are True) Then do (Then Actions) Else do (Else Actions)
        • If - Conditions
          • Spawned_Units_Integer Equal to 0
        • Then - Actions
          • Trigger - Run Unit Group Create <gen>\\ If you want to spawn the same units
        • Else - Actions
 
Level 15
Joined
Jul 9, 2008
Messages
1,552
if you creating more than one unit at a time of the same type by using somthing like this below will only add one to the unit group

  • Unit - Create 25 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
  • Unit Group - Add (Last created unit) to spawns
you will need to create the units in a loop to add them all to your unit group

  • For each (Integer A) from 1 to 25, do (Actions)
    • Loop - Actions
      • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
      • Unit Group - Add (Last created unit) to spawns
@indomitable1319
why don't you just use the condition
  • (Number of units in spawns) Equal to 0
instead of creating another variable
 
Status
Not open for further replies.
Top