• 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.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Removing a unit from a squad

Level 4
Joined
Apr 16, 2025
Messages
57
I apologize right away, I'm a complete zero in creating squads.

Now to the point: how to add units to a squad and remove them from it after, say, 10 seconds? In the order in which this unit was added to the squad.

I tried writing the unit to a variable:
"action occurs"
"(C) = (C + 1)"
"Unit = Trigger unit [C]"
"Add unit [C] to the squad"
"Wait 10 game seconds"
"Remove unit C from the squad"
But the problem is that the unit with number C is removed, which will be the last one, and not the one recorded at the time of the event. I just don't have enough RAM in my brain to come up with a trick or method to avoid this.

Help, please!
 
Level 30
Joined
Sep 26, 2009
Messages
2,619
When implementing queue, you will need one variable to track the ending index of the queue (in your case "C") and another variable to track starting index of the queue, let's call it "X". The logic would be:
  • C = C + 1
  • Unit[C] = (Triggering unit)
  • Add Unit[C] to squad
  • Wait 10 seconds
  • X = X + 1
  • Remove Unit[X] from squad
 
Level 4
Joined
Apr 16, 2025
Messages
57
When implementing queue, you will need one variable to track the ending index of the queue (in your case "C") and another variable to track starting index of the queue, let's call it "X". The logic would be:
  • C = C + 1
  • Unit[C] = (Triggering unit)
  • Add Unit[C] to squad
  • Wait 10 seconds
  • X = X + 1
  • Remove Unit[X] from squad
And at what point does C go into X? I just don't understand X = X + 1
 
Level 30
Joined
Sep 26, 2009
Messages
2,619
You have empty queue. C = 0, X = 0.
You add a unit (Unit_A) into queue:
  • C = C + 1 = 1
  • Unit[C] = Unit[1] = Unit_A
  • Now starts the 10 second wait

2 seconds after adding Unit_A you add another unit into queue (Unit_B):
  • C = C + 1 = 2
  • Unit[C] = Unit[2] = Unit_B
  • Now starts the 10 second wait for Unit_B

8 seconds after adding Unit_B to queue Unit_A's time is up:
  • X = X + 1 = 1
  • Unit_to_remove = Unit[X] = Unit[1] = Unit_A

After another 2 seconds Unit_B's time is up:
  • X = X + 1 = 2
  • Unit_to_remove = Unit[X] = Unit[2] = Unit_B
 
Level 4
Joined
Apr 16, 2025
Messages
57
You have empty queue. C = 0, X = 0.
You add a unit (Unit_A) into queue:
  • C = C + 1 = 1
  • Unit[C] = Unit[1] = Unit_A
  • Now starts the 10 second wait

2 seconds after adding Unit_A you add another unit into queue (Unit_B):
  • C = C + 1 = 2
  • Unit[C] = Unit[2] = Unit_B
  • Now starts the 10 second wait for Unit_B

8 seconds after adding Unit_B to queue Unit_A's time is up:
  • X = X + 1 = 1
  • Unit_to_remove = Unit[X] = Unit[1] = Unit_A

After another 2 seconds Unit_B's time is up:
  • X = X + 1 = 2
  • Unit_to_remove = Unit[X] = Unit[2] = Unit_B
OMG, this is brilliant! Am I really that stupid that I couldn't figure this out? Thank you!
 
Top