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

Unit Group Question

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
I am making a creep system. The actions:

  • Creep System
    • Events
      • Time - Every 6.00 seconds of game time
    • Conditions
    • Actions
      • Set CreepCounter = 1
      • Game - Display to (All players) for 5.00 seconds the text: (Creep Count: + (String(CreepCounter)))
      • Game - Display to (All players) for 5.00 seconds the text: (Number of Creeps: + (String((Number of units in CreepGroup[CreepCounter]))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in CreepGroup[CreepCounter]) Equal to 0
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 100) Less than or equal to 50
            • Then - Actions
              • Game - Display to (All players) for 5.00 seconds the text: Conditions Passed
              • Unit - Create 2 Forest Troll for Neutral Hostile at CreepSpawns[CreepCounter] facing Default building facing degrees
              • Unit Group - Add all units of (Last created unit group) to CreepGroup[CreepCounter]
              • Unit - Create 1 Forest Troll Berserker for Neutral Hostile at CreepSpawns[CreepCounter] facing Default building facing degrees
              • Unit Group - Add all units of (Last created unit group) to CreepGroup[CreepCounter]
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Random integer number between 1 and 100) Greater than or equal to 50
                • Then - Actions
                  • Game - Display to (All players) for 5.00 seconds the text: Conditions Passed
                  • Unit - Create 2 Razormane Scout for Neutral Hostile at CreepSpawns[CreepCounter] facing Default building facing degrees
                  • Unit Group - Add all units of (Last created unit group) to CreepGroup[CreepCounter]
                  • Unit - Create 1 Quillboar for Neutral Hostile at CreepSpawns[CreepCounter] facing Default building facing degrees
                  • Unit Group - Add all units of (Last created unit group) to CreepGroup[CreepCounter]
                  • Unit - Create 1 Razormane Brute for Neutral Hostile at CreepSpawns[CreepCounter] facing Default building facing degrees
                  • Unit Group - Add all units of (Last created unit group) to CreepGroup[CreepCounter]
                • Else - Actions
                  • Game - Display to (All players) for 5.00 seconds the text: Conditions Passed
                  • Unit - Create 2 Satyr for Neutral Hostile at CreepSpawns[CreepCounter] facing Default building facing degrees
                  • Unit Group - Add all units of (Last created unit group) to CreepGroup[CreepCounter]
                  • Unit - Create 1 Satyr Soulstealer for Neutral Hostile at CreepSpawns[CreepCounter] facing Default building facing degrees
                  • Unit Group - Add all units of (Last created unit group) to CreepGroup[CreepCounter]
        • Else - Actions
      • Wait 0.66 seconds
      • Set CreepCounter = (CreepCounter + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in CreepGroup[CreepCounter]) Equal to 0
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 100) Less than or equal to 50
            • Then - Actions
              • Unit - Create 2 Forest Troll for Neutral Hostile at CreepSpawns[CreepCounter] facing Default building facing degrees
              • Unit Group - Add all units of (Last created unit group) to CreepGroup[CreepCounter]
              • Unit - Create 1 Forest Troll Berserker for Neutral Hostile at CreepSpawns[CreepCounter] facing Default building facing degrees
              • Unit Group - Add all units of (Last created unit group) to CreepGroup[CreepCounter]
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Random integer number between 1 and 100) Greater than or equal to 50
                • Then - Actions
                  • Unit - Create 2 Razormane Scout for Neutral Hostile at CreepSpawns[CreepCounter] facing Default building facing degrees
                  • Unit Group - Add all units of (Last created unit group) to CreepGroup[CreepCounter]
                  • Unit - Create 1 Quillboar for Neutral Hostile at CreepSpawns[CreepCounter] facing Default building facing degrees
                  • Unit Group - Add all units of (Last created unit group) to CreepGroup[CreepCounter]
                  • Unit - Create 1 Razormane Brute for Neutral Hostile at CreepSpawns[CreepCounter] facing Default building facing degrees
                  • Unit Group - Add all units of (Last created unit group) to CreepGroup[CreepCounter]
                • Else - Actions
                  • Unit - Create 2 Satyr for Neutral Hostile at CreepSpawns[CreepCounter] facing Default building facing degrees
                  • Unit Group - Add all units of (Last created unit group) to CreepGroup[CreepCounter]
                  • Unit - Create 1 Satyr Soulstealer for Neutral Hostile at CreepSpawns[CreepCounter] facing Default building facing degrees
                  • Unit Group - Add all units of (Last created unit group) to CreepGroup[CreepCounter]
        • Else - Actions
The creeps are added and before new creeps are added, it checks if the old ones exist. The thing is, I dont have any kind of trigger to "remove unit from unit group". However, it seems after the bones decay, the Text message reports the unit group = 0, and therefore new units are created. 2 questions.

1.) Are the units in this unit group leaking?
2.) How can I make it so the unit is removed from the unit group after it dies (rather then after it's bones decay). I preferabely don't want to remove decay animations.
 
Level 12
Joined
Sep 11, 2011
Messages
1,176
1. as long as it's always used, then it isn't called leaks. just remember to remove the unit from the unit group after it dies.
2. i just tried this and it's working

  • Untitled Trigger 001
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (String((Number of units in tempGroup)))
      • Unit Group - Pick every unit in tempGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to False
            • Then - Actions
              • Unit Group - Remove (Picked unit) from tempGroup
            • Else - Actions
it remove the unit from the group after it dies, and before the decay animations.
this actions display the count of units in unit group every 0.03 seconds. so you could check if the unit is really removed after it dies.
  • Game - Display to (All players) the text: (String((Number of units in tempGroup)))
just change the tempGroup into your group.
 
Status
Not open for further replies.
Top