• 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.

Removing a unit from a squad

Level 3
Joined
Apr 16, 2025
Messages
30
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 29
Joined
Sep 26, 2009
Messages
2,609
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 3
Joined
Apr 16, 2025
Messages
30
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 29
Joined
Sep 26, 2009
Messages
2,609
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
 
Top