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!
Make a real variable called GameTime.
Make a periodic trigger that runs every 0.03 and increase the GameTime variable by the amount it runs at.
Store the max number of those units in a hashtable based on the unit type id.
Store each unit into a hashtable based on their unit type and integer number of units for player.
Store each units GameTime in the hashtable.
Increase an integer that keeps track of how many units that players has of that unit type.
When a new unit is created check to see if the amount if units is more than max.
If it is more than max then load the units stored and check for the GameTime that they were created. After finding lowest GameTime value remove that unit. Then store the new unit in that position.
As units die you would need to remove them to clean the leaks. Then move the last units indexer (the integer value above) to the one that was removed.
So that the newest unit always stays as the last index and you do not have to loop through empty indexes when looking for units to remove.
Hello, well I'm not an expert, so I tried to do something simple.
Footman
Events
Unit - A unit enters (Playable map area)
Conditions
(Unit-type of (Entering unit)) Igual a Soldado raso
Actions
Set Footman_array = (Footman_array + 1)
Set Footman_id[Footman_array] = (Last created unit)
Unit - Remove Footman_id[(Footman_array - 3)] from the game
When a Footman enters in Playable Area this trigger gives it an "id". Then when a 4th Footman enters in the game this "system" will remove the older Footman.
There's only a problem, this won't work if there're more than 8000 Footman (I can't remember the exact number).
I attached an example for you (Write "foot" to create a footman). You must change the "-3" For the limit of unit of the type that you want.
I'm really Sorry for my English it's not very good.
EDIT: Use "Entering Unit" instead "Last Created Unit"
You can also set training limit, which will prevent training a unit, instead of killing it. This is not exactly what you're asking for, but it might be useful depending on your application.
Player - Limit training of Footman to 3 for Player 1 (Red)
@ inusenshi
Please post all the triggers. Also never use entering unit. Use triggering unit instead.
Entering unit is slower than just using triggering unit.
You can also set training limit, which will prevent training a unit, instead of killing it. This is not exactly what you're asking for, but it might be useful depending on your application.
Player - Limit training of Footman to 3 for Player 1 (Red)
Im not going to train them.... just i want is to make a limit on footman... ex. I cast thunder clap then after the effect 1 footman will create at front of me when i cast the skill 3 times the older footman will die....
Im not going to train them.... just i want is to make a limit on footman... ex. I cast thunder clap then after the effect 1 footman will create at front of me when i cast the skill 3 times the older footman will die....
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.